--- CMakeLists.txt.orig 2024-05-09 19:42:48 UTC +++ CMakeLists.txt @@ -39,11 +39,6 @@ set(arduino_files "library.properties") # Compile options -get_setting(target_arch STRING "Target system architecture (fed to the compiler's -march=XXX).") -if(NOT target_arch AND NOT CMAKE_CROSSCOMPILING) - set(target_arch native) -endif() - get_setting(target_device STRING "Target device identifier (defines HYDRO_TARGET_DEVICE_XXX).") set(compile_options @@ -89,8 +84,9 @@ set(compile_options # Main library -add_library("${PROJECT_NAME}") +add_library("${PROJECT_NAME}" SHARED) add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}") +add_library("${PROJECT_NAME}_static" STATIC) target_sources("${PROJECT_NAME}" PRIVATE ${source_files}) @@ -100,11 +96,21 @@ target_compile_options("${PROJECT_NAME}" PRIVATE ${com target_compile_options("${PROJECT_NAME}" PRIVATE ${compile_options}) +target_sources("${PROJECT_NAME}_static" PRIVATE ${source_files}) + +target_include_directories("${PROJECT_NAME}_static" + PUBLIC $ + $) + +target_compile_options("${PROJECT_NAME}_static" PRIVATE ${compile_options}) + +set_target_properties("${PROJECT_NAME}_static" PROPERTIES OUTPUT_NAME "${PROJECT_NAME}") + # Installation set(targets_export_name "${PROJECT_NAME}-targets") -install(TARGETS "${PROJECT_NAME}" +install(TARGETS "${PROJECT_NAME}" "${PROJECT_NAME}_static" EXPORT "${targets_export_name}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")