PengZheng commented on code in PR #476: URL: https://github.com/apache/celix/pull/476#discussion_r1098199548
########## libs/framework/CMakeLists.txt: ########## @@ -35,27 +35,31 @@ set(SOURCES src/celix_bundle_state.c src/celix_framework_utils.c src/celix_module_private.h) -add_library(framework SHARED ${SOURCES}) -set_target_properties(framework PROPERTIES OUTPUT_NAME "celix_framework") -target_include_directories(framework PUBLIC +add_library(framework_obj OBJECT ${SOURCES}) +target_include_directories(framework_obj PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> -) -target_compile_options(framework PRIVATE -DUSE_FILE32API) -target_compile_options(framework PRIVATE -Wno-deprecated-declarations) #note part of the api is deprecated, ignore this warning on own api -set_target_properties(framework PROPERTIES "SOVERSION" ${CELIX_MAJOR}) + ) +target_compile_options(framework_obj PRIVATE -DUSE_FILE32API) +target_compile_options(framework_obj PRIVATE -Wno-deprecated-declarations) #note part of the api is deprecated, ignore this warning on own api +target_link_libraries(framework_obj PUBLIC Celix::utils Celix::dfi ${CELIX_OPTIONAL_EXTRA_LIBS}) +target_link_libraries(framework_obj PUBLIC libuuid::libuuid CURL::libcurl ZLIB::ZLIB) +target_link_libraries(framework_obj PRIVATE ${CMAKE_DL_LIBS}) +celix_deprecated_utils_headers(framework_obj) -target_link_libraries(framework PUBLIC Celix::utils Celix::dfi ${CELIX_OPTIONAL_EXTRA_LIBS}) -target_link_libraries(framework PUBLIC libuuid::libuuid CURL::libcurl ZLIB::ZLIB) -target_link_libraries(framework PRIVATE ${CMAKE_DL_LIBS}) +add_library(framework SHARED) +target_link_libraries(framework PUBLIC framework_obj) +set_target_properties(framework PROPERTIES OUTPUT_NAME "celix_framework") +set_target_properties(framework PROPERTIES "SOVERSION" ${CELIX_MAJOR}) celix_deprecated_utils_headers(framework) -install(TARGETS framework EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework +install(TARGETS framework framework_obj EXPORT celix LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT framework Review Comment: By omitting `OBJECTS DESTINATION`, object files will NOT be installed. Instead, `Celix::framework_obj` will be turned into: ``` # Create imported target Celix::framework add_library(Celix::framework SHARED IMPORTED) set_target_properties(Celix::framework PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/celix" INTERFACE_LINK_LIBRARIES "Celix::framework_obj" ) # Create imported target Celix::framework_obj add_library(Celix::framework_obj INTERFACE IMPORTED) set_target_properties(Celix::framework_obj PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/celix" INTERFACE_LINK_LIBRARIES "Celix::utils;Celix::dfi;libuuid::libuuid;CURL::libcurl;ZLIB::ZLIB;\$<LINK_ONLY:dl>" ) ``` Then everything works like charm. It's explained by CMake developer Gregor Jasny nicely here: https://gitlab.kitware.com/cmake/cmake/-/issues/18935 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org