diff options
-rw-r--r-- | Help/prop_tgt/NO_SONAME.rst | 6 | ||||
-rw-r--r-- | Help/release/dev/modules-no-soname.rst | 7 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 3 | ||||
-rw-r--r-- | Tests/Plugin/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Tests/Plugin/PluginTest/CMakeLists.txt | 17 | ||||
-rw-r--r-- | Tests/Plugin/check_mod_soname.cmake | 17 |
6 files changed, 23 insertions, 36 deletions
diff --git a/Help/prop_tgt/NO_SONAME.rst b/Help/prop_tgt/NO_SONAME.rst index fc668b5..ee45ed8 100644 --- a/Help/prop_tgt/NO_SONAME.rst +++ b/Help/prop_tgt/NO_SONAME.rst @@ -1,11 +1,11 @@ NO_SONAME --------- -Whether to set "soname" when linking a shared library or module. +Whether to set "soname" when linking a shared library. -Enable this boolean property if a generated shared library or module +Enable this boolean property if a generated shared library should not have "soname" set. Default is to set "soname" on all -shared libraries and modules as long as the platform supports it. +shared libraries as long as the platform supports it. Generally, use this property only for leaf private libraries or plugins. If you use it on normal shared libraries which other targets link against, on some platforms a linker will insert a full path to diff --git a/Help/release/dev/modules-no-soname.rst b/Help/release/dev/modules-no-soname.rst new file mode 100644 index 0000000..8fe74f8 --- /dev/null +++ b/Help/release/dev/modules-no-soname.rst @@ -0,0 +1,7 @@ +modules-no-soname +----------------- + +* The ``SONAME`` field is no longer set for ``MODULE`` libraries + created with the :command:`add_library` command. ``MODULE`` + libraries are meant for explicit dynamic loading at runtime. + They cannot be linked so ``SONAME`` is not useful. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 299c112..89c1922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -761,8 +761,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && + return ((this->GetType() == cmTarget::SHARED_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index ecdece8..2b7bac1 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -52,13 +52,8 @@ target_link_libraries(example_mod_1 example_exe) if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND "${CMAKE_C_CREATE_SHARED_MODULE}" MATCHES "SONAME_FLAG") - # Add a second plugin that should not have any soname. - add_library(example_mod_2 MODULE src/example_mod_1.c) - target_link_libraries(example_mod_2 example_exe) - set_property(TARGET example_mod_2 PROPERTY NO_SONAME 1) - # Verify that targets export with proper IMPORTED SONAME properties. - export(TARGETS example_mod_1 example_mod_2 NAMESPACE exp_ + export(TARGETS example_mod_1 NAMESPACE exp_ FILE ${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) include(ExternalProject) @@ -68,7 +63,7 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND DOWNLOAD_COMMAND "" INSTALL_COMMAND "" ) - add_dependencies(PluginTest example_mod_1 example_mod_2) + add_dependencies(PluginTest example_mod_1) endif() # TODO: diff --git a/Tests/Plugin/PluginTest/CMakeLists.txt b/Tests/Plugin/PluginTest/CMakeLists.txt index 79ef8a9..5626dbc 100644 --- a/Tests/Plugin/PluginTest/CMakeLists.txt +++ b/Tests/Plugin/PluginTest/CMakeLists.txt @@ -6,17 +6,11 @@ include(${CMAKE_CURRENT_BINARY_DIR}/../mods.cmake) get_property(configs TARGET exp_example_mod_1 PROPERTY IMPORTED_CONFIGURATIONS) foreach(c ${configs}) string(TOUPPER "${c}" CONFIG) - get_property(soname1 TARGET exp_example_mod_1 PROPERTY IMPORTED_SONAME_${CONFIG}) - get_property(soname2 TARGET exp_example_mod_2 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) - if(soname1) - message(STATUS "exp_example_mod_1 has IMPORTED_SONAME_${CONFIG} as expected: ${soname1}") + get_property(soname TARGET exp_example_mod_1 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) + if(soname) + message(STATUS "exp_example_mod_1 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname}") else() - message(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_SONAME_${CONFIG} but should") - endif() - if(soname2) - message(STATUS "exp_example_mod_2 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname2}") - else() - message(SEND_ERROR "exp_example_mod_2 does not have IMPORTED_NO_SONAME_${CONFIG} but should") + message(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_NO_SONAME_${CONFIG} but should") endif() endforeach() @@ -26,8 +20,7 @@ if("${CMAKE_EXECUTABLE_FORMAT}" MATCHES "ELF") if(READELF_EXE) add_custom_target(check_mod_soname ALL COMMAND ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} - -Dmod1=$<TARGET_FILE:exp_example_mod_1> - -Dmod2=$<TARGET_FILE:exp_example_mod_2> + -Dmod=$<TARGET_FILE:exp_example_mod_1> -P ${CMAKE_CURRENT_SOURCE_DIR}/../check_mod_soname.cmake ) endif() diff --git a/Tests/Plugin/check_mod_soname.cmake b/Tests/Plugin/check_mod_soname.cmake index 3737b45..21a33b1 100644 --- a/Tests/Plugin/check_mod_soname.cmake +++ b/Tests/Plugin/check_mod_soname.cmake @@ -1,14 +1,7 @@ -execute_process(COMMAND ${readelf} -d ${mod1} OUTPUT_FILE ${mod1}.readelf.txt) -execute_process(COMMAND ${readelf} -d ${mod2} OUTPUT_FILE ${mod2}.readelf.txt) -file(STRINGS ${mod1}.readelf.txt soname1 REGEX "\\(SONAME\\)") -file(STRINGS ${mod2}.readelf.txt soname2 REGEX "\\(SONAME\\)") -if(soname1) - message(STATUS "${mod1} has soname as expected: ${soname1}") +execute_process(COMMAND ${readelf} -d ${mod} OUTPUT_FILE ${mod}.readelf.txt) +file(STRINGS ${mod}.readelf.txt soname REGEX "\\(SONAME\\)") +if(soname) + message(FATAL_ERROR "${mod} has soname but should not:\n ${soname}") else() - message(FATAL_ERROR "${mod1} has no soname but should:\n ${soname1}") -endif() -if(soname2) - message(FATAL_ERROR "${mod2} has soname but should not:\n ${soname2}") -else() - message(STATUS "${mod2} has no soname as expected") + message(STATUS "${mod} has no soname as expected") endif() |