From 3cd34eb279df8419dd849360cc3b2f1133d3f281 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 24 Feb 2023 15:00:32 -0500 Subject: Tests: Rename RunCMake.{ArtifactOutputDirs => TargetArtifacts} Generalize the name so we can add other kinds of artifact checks. --- .../ArtifactOutputDirs/ArtifactOutputDirs.cmake | 27 ---------------------- Tests/RunCMake/ArtifactOutputDirs/CMakeLists.txt | 3 --- .../RunCMake/ArtifactOutputDirs/RunCMakeTest.cmake | 19 --------------- Tests/RunCMake/ArtifactOutputDirs/check.cmake | 21 ----------------- Tests/RunCMake/ArtifactOutputDirs/lib.c | 4 ---- Tests/RunCMake/ArtifactOutputDirs/main.c | 4 ---- Tests/RunCMake/CMakeLists.txt | 3 +-- Tests/RunCMake/TargetArtifacts/CMakeLists.txt | 3 +++ Tests/RunCMake/TargetArtifacts/OutputDirs.cmake | 27 ++++++++++++++++++++++ Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake | 19 +++++++++++++++ Tests/RunCMake/TargetArtifacts/check.cmake | 21 +++++++++++++++++ Tests/RunCMake/TargetArtifacts/lib.c | 4 ++++ Tests/RunCMake/TargetArtifacts/main.c | 4 ++++ 13 files changed, 79 insertions(+), 80 deletions(-) delete mode 100644 Tests/RunCMake/ArtifactOutputDirs/ArtifactOutputDirs.cmake delete mode 100644 Tests/RunCMake/ArtifactOutputDirs/CMakeLists.txt delete mode 100644 Tests/RunCMake/ArtifactOutputDirs/RunCMakeTest.cmake delete mode 100644 Tests/RunCMake/ArtifactOutputDirs/check.cmake delete mode 100644 Tests/RunCMake/ArtifactOutputDirs/lib.c delete mode 100644 Tests/RunCMake/ArtifactOutputDirs/main.c create mode 100644 Tests/RunCMake/TargetArtifacts/CMakeLists.txt create mode 100644 Tests/RunCMake/TargetArtifacts/OutputDirs.cmake create mode 100644 Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/TargetArtifacts/check.cmake create mode 100644 Tests/RunCMake/TargetArtifacts/lib.c create mode 100644 Tests/RunCMake/TargetArtifacts/main.c diff --git a/Tests/RunCMake/ArtifactOutputDirs/ArtifactOutputDirs.cmake b/Tests/RunCMake/ArtifactOutputDirs/ArtifactOutputDirs.cmake deleted file mode 100644 index d0accd7..0000000 --- a/Tests/RunCMake/ArtifactOutputDirs/ArtifactOutputDirs.cmake +++ /dev/null @@ -1,27 +0,0 @@ -enable_language(C) - -if(CMAKE_IMPORT_LIBRARY_SUFFIX) - set(expect_dll 1) -else() - set(expect_dll 0) -endif() - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$/$,SHARED_LIBRARY>,rtlib,rtbin>") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$/$,SHARED_LIBRARY>,sharedlib,others>") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$/$,STATIC_LIBRARY>,staticlib,others>") - -add_executable(exe_tgt main.c) -add_library(shared_tgt SHARED lib.c) -add_library(static_tgt STATIC lib.c) - -add_custom_target(checkDirs ALL - COMMAND ${CMAKE_COMMAND} - -Dartifact_path=${CMAKE_CURRENT_BINARY_DIR}/$ - -Dexe_name=$ - -Dshared_name=$ - -Dstatic_name=$ - -Dexpect_dll=${expect_dll} - -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake - ) - -add_dependencies(checkDirs exe_tgt shared_tgt static_tgt) diff --git a/Tests/RunCMake/ArtifactOutputDirs/CMakeLists.txt b/Tests/RunCMake/ArtifactOutputDirs/CMakeLists.txt deleted file mode 100644 index ab1a20c..0000000 --- a/Tests/RunCMake/ArtifactOutputDirs/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 3.19) -project(${RunCMake_TEST} NONE) -include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ArtifactOutputDirs/RunCMakeTest.cmake b/Tests/RunCMake/ArtifactOutputDirs/RunCMakeTest.cmake deleted file mode 100644 index 1bf8438..0000000 --- a/Tests/RunCMake/ArtifactOutputDirs/RunCMakeTest.cmake +++ /dev/null @@ -1,19 +0,0 @@ -include(RunCMake) - -function(run_cmake_and_verify_after_build case) - set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${case}-build") - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR_IS_MULTI_CONFIG) - set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug) - else() - set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) - endif() - run_cmake(${case}) - run_cmake_command("${case}-build" ${CMAKE_COMMAND} --build .) - unset(RunCMake_TEST_NO_CLEAN) - unset(RunCMake_TEST_BINARY_DIR) -endfunction() - -run_cmake_and_verify_after_build(ArtifactOutputDirs) diff --git a/Tests/RunCMake/ArtifactOutputDirs/check.cmake b/Tests/RunCMake/ArtifactOutputDirs/check.cmake deleted file mode 100644 index ca37eba..0000000 --- a/Tests/RunCMake/ArtifactOutputDirs/check.cmake +++ /dev/null @@ -1,21 +0,0 @@ -set(expected ${artifact_path}/rtbin/${exe_name}) -if(NOT EXISTS "${expected}") - message(SEND_ERROR "executable artifact not created in the expected path:\n ${expected}") -endif() - -set(expected ${artifact_path}/staticlib/${static_name}) -if(NOT EXISTS "${expected}") - message(SEND_ERROR "static artifact not created in the expected path:\n ${expected}") -endif() - -if(expect_dll) - set(expected ${artifact_path}/rtlib/${shared_name}) - if(NOT EXISTS "${expected}") - message(SEND_ERROR "dll artifact not created in the expected path:\n ${expected}") - endif() -else() - set(expected ${artifact_path}/sharedlib/${shared_name}) - if(NOT EXISTS "${expected}") - message(SEND_ERROR "shared artifact not created in the expected path:\n ${expected}") - endif() -endif() diff --git a/Tests/RunCMake/ArtifactOutputDirs/lib.c b/Tests/RunCMake/ArtifactOutputDirs/lib.c deleted file mode 100644 index 22373f1..0000000 --- a/Tests/RunCMake/ArtifactOutputDirs/lib.c +++ /dev/null @@ -1,4 +0,0 @@ -int func(void) -{ - return 0; -} diff --git a/Tests/RunCMake/ArtifactOutputDirs/main.c b/Tests/RunCMake/ArtifactOutputDirs/main.c deleted file mode 100644 index 8488f4e..0000000 --- a/Tests/RunCMake/ArtifactOutputDirs/main.c +++ /dev/null @@ -1,4 +0,0 @@ -int main(void) -{ - return 0; -} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e372286..7ec9985 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -270,8 +270,6 @@ if(want_NoQt_test) add_RunCMake_test(AutogenNoQt TEST_DIR Autogen) endif() -add_RunCMake_test(ArtifactOutputDirs) - if(NOT DEFINED CMake_TEST_BuildDepends_GNU_AS AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "LCC") AND CMAKE_GENERATOR MATCHES "^Ninja" @@ -396,6 +394,7 @@ if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STRE endif() add_RunCMake_test(ScriptMode) add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) +add_RunCMake_test(TargetArtifacts) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetProperties) add_RunCMake_test(ToolchainFile) diff --git a/Tests/RunCMake/TargetArtifacts/CMakeLists.txt b/Tests/RunCMake/TargetArtifacts/CMakeLists.txt new file mode 100644 index 0000000..ab1a20c --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.19) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetArtifacts/OutputDirs.cmake b/Tests/RunCMake/TargetArtifacts/OutputDirs.cmake new file mode 100644 index 0000000..d0accd7 --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/OutputDirs.cmake @@ -0,0 +1,27 @@ +enable_language(C) + +if(CMAKE_IMPORT_LIBRARY_SUFFIX) + set(expect_dll 1) +else() + set(expect_dll 0) +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$/$,SHARED_LIBRARY>,rtlib,rtbin>") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$/$,SHARED_LIBRARY>,sharedlib,others>") +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$/$,STATIC_LIBRARY>,staticlib,others>") + +add_executable(exe_tgt main.c) +add_library(shared_tgt SHARED lib.c) +add_library(static_tgt STATIC lib.c) + +add_custom_target(checkDirs ALL + COMMAND ${CMAKE_COMMAND} + -Dartifact_path=${CMAKE_CURRENT_BINARY_DIR}/$ + -Dexe_name=$ + -Dshared_name=$ + -Dstatic_name=$ + -Dexpect_dll=${expect_dll} + -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake + ) + +add_dependencies(checkDirs exe_tgt shared_tgt static_tgt) diff --git a/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake b/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake new file mode 100644 index 0000000..54510b0 --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake @@ -0,0 +1,19 @@ +include(RunCMake) + +function(run_cmake_and_verify_after_build case) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${case}-build") + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + set(RunCMake_TEST_NO_CLEAN 1) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug) + else() + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + endif() + run_cmake(${case}) + run_cmake_command("${case}-build" ${CMAKE_COMMAND} --build .) + unset(RunCMake_TEST_NO_CLEAN) + unset(RunCMake_TEST_BINARY_DIR) +endfunction() + +run_cmake_and_verify_after_build(OutputDirs) diff --git a/Tests/RunCMake/TargetArtifacts/check.cmake b/Tests/RunCMake/TargetArtifacts/check.cmake new file mode 100644 index 0000000..ca37eba --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/check.cmake @@ -0,0 +1,21 @@ +set(expected ${artifact_path}/rtbin/${exe_name}) +if(NOT EXISTS "${expected}") + message(SEND_ERROR "executable artifact not created in the expected path:\n ${expected}") +endif() + +set(expected ${artifact_path}/staticlib/${static_name}) +if(NOT EXISTS "${expected}") + message(SEND_ERROR "static artifact not created in the expected path:\n ${expected}") +endif() + +if(expect_dll) + set(expected ${artifact_path}/rtlib/${shared_name}) + if(NOT EXISTS "${expected}") + message(SEND_ERROR "dll artifact not created in the expected path:\n ${expected}") + endif() +else() + set(expected ${artifact_path}/sharedlib/${shared_name}) + if(NOT EXISTS "${expected}") + message(SEND_ERROR "shared artifact not created in the expected path:\n ${expected}") + endif() +endif() diff --git a/Tests/RunCMake/TargetArtifacts/lib.c b/Tests/RunCMake/TargetArtifacts/lib.c new file mode 100644 index 0000000..22373f1 --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/lib.c @@ -0,0 +1,4 @@ +int func(void) +{ + return 0; +} diff --git a/Tests/RunCMake/TargetArtifacts/main.c b/Tests/RunCMake/TargetArtifacts/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} -- cgit v0.12 From 9694504adcdc44492a2e088343cd5be1fd28d270 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 24 Feb 2023 15:23:10 -0500 Subject: Tests: Simplify RunCMake.TargetArtifacts spec --- Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake b/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake index 54510b0..2b5c4b8 100644 --- a/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake @@ -2,18 +2,14 @@ include(RunCMake) function(run_cmake_and_verify_after_build case) set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${case}-build") - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - set(RunCMake_TEST_NO_CLEAN 1) if(RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_CONFIGURATION_TYPES=Debug) else() set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() run_cmake(${case}) + set(RunCMake_TEST_NO_CLEAN 1) run_cmake_command("${case}-build" ${CMAKE_COMMAND} --build .) - unset(RunCMake_TEST_NO_CLEAN) - unset(RunCMake_TEST_BINARY_DIR) endfunction() run_cmake_and_verify_after_build(OutputDirs) -- cgit v0.12 From a7f9c7da2618c795db534890124718fd0d9c73ce Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 24 Feb 2023 11:01:11 +0100 Subject: Add option to add SOVERSION to DLL names Add variable/target property `[CMAKE_]DLL_NAME_WITH_SOVERSION`. Fixes: #24251 Signed-off-by: Ralf Habacker --- Help/manual/cmake-properties.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/DLL_NAME_WITH_SOVERSION.rst | 17 +++++++++++++++++ Help/release/dev/dll-name-soversion.rst | 7 +++++++ Help/variable/CMAKE_DLL_NAME_WITH_SOVERSION.rst | 14 ++++++++++++++ Source/cmGeneratorTarget.cxx | 8 +++++++- Source/cmTarget.cxx | 6 ++++++ Tests/RunCMake/CMakeLists.txt | 2 +- .../TargetArtifacts/DLL-SOVERSION-build-stdout.txt | 2 ++ Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake | 18 ++++++++++++++++++ Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake | 4 ++++ Tests/RunCMake/TargetArtifacts/dll.c | 6 ++++++ 12 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 Help/prop_tgt/DLL_NAME_WITH_SOVERSION.rst create mode 100644 Help/release/dev/dll-name-soversion.rst create mode 100644 Help/variable/CMAKE_DLL_NAME_WITH_SOVERSION.rst create mode 100644 Tests/RunCMake/TargetArtifacts/DLL-SOVERSION-build-stdout.txt create mode 100644 Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake create mode 100644 Tests/RunCMake/TargetArtifacts/dll.c diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index fb84f5a..01c9ce8 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -202,6 +202,7 @@ Properties on Targets /prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY /prop_tgt/DEPRECATION /prop_tgt/DISABLE_PRECOMPILE_HEADERS + /prop_tgt/DLL_NAME_WITH_SOVERSION /prop_tgt/DOTNET_SDK /prop_tgt/DOTNET_TARGET_FRAMEWORK /prop_tgt/DOTNET_TARGET_FRAMEWORK_VERSION diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 0ba8363..373450d 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -427,6 +427,7 @@ Variables that Control the Build /variable/CMAKE_DEFAULT_CONFIGS /variable/CMAKE_DEPENDS_USE_COMPILER /variable/CMAKE_DISABLE_PRECOMPILE_HEADERS + /variable/CMAKE_DLL_NAME_WITH_SOVERSION /variable/CMAKE_ENABLE_EXPORTS /variable/CMAKE_EXE_LINKER_FLAGS /variable/CMAKE_EXE_LINKER_FLAGS_CONFIG diff --git a/Help/prop_tgt/DLL_NAME_WITH_SOVERSION.rst b/Help/prop_tgt/DLL_NAME_WITH_SOVERSION.rst new file mode 100644 index 0000000..59ef00f --- /dev/null +++ b/Help/prop_tgt/DLL_NAME_WITH_SOVERSION.rst @@ -0,0 +1,17 @@ +DLL_NAME_WITH_SOVERSION +----------------------- + +.. versionadded:: 3.27 + +This property control whether the :prop_tgt:`SOVERSION` target +property are added to the filename of generated DLL filenames +for the Windows platform, which is selected when the +:variable:`WIN32` variable is set. + +The value of the listed property is appended to the +basename of the runtime component of the shared library +target as ``-``. + +Please note that setting this property has no effect +if versioned filenames are globally disabled with the +:variable:`CMAKE_PLATFORM_NO_VERSIONED_SONAME` variable. diff --git a/Help/release/dev/dll-name-soversion.rst b/Help/release/dev/dll-name-soversion.rst new file mode 100644 index 0000000..56d0842 --- /dev/null +++ b/Help/release/dev/dll-name-soversion.rst @@ -0,0 +1,7 @@ +dll-name-soversion +------------------ + +* The :variable:`CMAKE_DLL_NAME_WITH_SOVERSION` variable and associated + :prop_tgt:`DLL_NAME_WITH_SOVERSION` target property were added to + optionally append the :prop_tgt:`SOVERSION` to the filename of the + ``.dll`` part of a shared library on Windows. diff --git a/Help/variable/CMAKE_DLL_NAME_WITH_SOVERSION.rst b/Help/variable/CMAKE_DLL_NAME_WITH_SOVERSION.rst new file mode 100644 index 0000000..5fa49de --- /dev/null +++ b/Help/variable/CMAKE_DLL_NAME_WITH_SOVERSION.rst @@ -0,0 +1,14 @@ +CMAKE_DLL_NAME_WITH_SOVERSION +----------------------------- + +.. versionadded:: 3.27 + +This variable is used to initialize the :prop_tgt:`DLL_NAME_WITH_SOVERSION` +property on shared library targets for the Windows platform, which is selected +when the :variable:`WIN32` variable is set. + +See this target property for additional information. + +Please note that setting this variable has no effect if versioned filenames +are globally disabled with the :variable:`CMAKE_PLATFORM_NO_VERSIONED_SONAME` +variable. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index be6456b..cfb2887 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5475,9 +5475,15 @@ cmGeneratorTarget::GetFullNameInternalComponents( // Name shared libraries with their version number on some platforms. if (cmValue soversion = this->GetProperty("SOVERSION")) { + cmValue dllProp; + if (this->IsDLLPlatform()) { + dllProp = this->GetProperty("DLL_NAME_WITH_SOVERSION"); + } if (this->GetType() == cmStateEnums::SHARED_LIBRARY && !isImportedLibraryArtifact && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) { + (dllProp.IsOn() || + (!dllProp.IsSet() && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")))) { outBase += "-"; outBase += *soversion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 91d5de6..2186cf0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -305,6 +305,8 @@ struct TargetProperty LinkableLibraryTarget, // Needs to be an executable. ExecutableTarget, + // Needs to be a shared library (`SHARED`). + SharedLibraryTarget, // Needs to be a target with meaningful symbol exports (`SHARED` or // `EXECUTABLE`). TargetWithSymbolExports, @@ -484,6 +486,7 @@ TargetProperty const StaticTargetProperties[] = { // ---- macOS { "FRAMEWORK_MULTI_CONFIG_POSTFIX_"_s, IC::LinkableLibraryTarget, R::PerConfig }, // ---- Windows + { "DLL_NAME_WITH_SOVERSION"_s, IC::SharedLibraryTarget }, { "GNUtoMS"_s, IC::CanCompileSources }, { "WIN32_EXECUTABLE"_s, IC::CanCompileSources }, { "WINDOWS_EXPORT_ALL_SYMBOLS"_s, IC::TargetWithSymbolExports }, @@ -1003,6 +1006,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, metConditions.insert( TargetProperty::InitCondition::LinkableLibraryTarget); } + if (this->impl->TargetType == cmStateEnums::SHARED_LIBRARY) { + metConditions.insert(TargetProperty::InitCondition::SharedLibraryTarget); + } } if (this->impl->TargetType == cmStateEnums::EXECUTABLE) { metConditions.insert(TargetProperty::InitCondition::ExecutableTarget); diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 7ec9985..72de742 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -394,7 +394,7 @@ if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STRE endif() add_RunCMake_test(ScriptMode) add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) -add_RunCMake_test(TargetArtifacts) +add_RunCMake_test(TargetArtifacts -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(TargetObjects) add_RunCMake_test(TargetProperties) add_RunCMake_test(ToolchainFile) diff --git a/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION-build-stdout.txt b/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION-build-stdout.txt new file mode 100644 index 0000000..b375da6 --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION-build-stdout.txt @@ -0,0 +1,2 @@ +.*exA_name="(libexA\.so\.2|libexA\.2\.dylib|(lib|cyg|msys-|)exA-2\.dll)" +.*exB_name="(libexB\.so\.2|libexB\.2\.dylib|(lib|cyg|msys-|)exB-2\.dll)" diff --git a/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake b/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake new file mode 100644 index 0000000..82eca0b --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/DLL-SOVERSION.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +add_library(exA SHARED dll.c) +set_target_properties(exA PROPERTIES + SOVERSION 2 + DLL_NAME_WITH_SOVERSION 1 + ) + +set(CMAKE_DLL_NAME_WITH_SOVERSION 1) +add_library(exB SHARED dll.c) +set_property(TARGET exB PROPERTY SOVERSION 2) + +add_custom_target(checkNames ALL + COMMAND ${CMAKE_COMMAND} -E echo exA_name="$" + COMMAND ${CMAKE_COMMAND} -E echo exB_name="$" + VERBATIM + ) +add_dependencies(checkNames exA exB) diff --git a/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake b/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake index 2b5c4b8..de69936 100644 --- a/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetArtifacts/RunCMakeTest.cmake @@ -9,7 +9,11 @@ function(run_cmake_and_verify_after_build case) endif() run_cmake(${case}) set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OUTPUT_MERGE 1) run_cmake_command("${case}-build" ${CMAKE_COMMAND} --build .) endfunction() +if(NOT CMAKE_SYSTEM_NAME STREQUAL "AIX") + run_cmake_and_verify_after_build(DLL-SOVERSION) +endif() run_cmake_and_verify_after_build(OutputDirs) diff --git a/Tests/RunCMake/TargetArtifacts/dll.c b/Tests/RunCMake/TargetArtifacts/dll.c new file mode 100644 index 0000000..31e1dbf --- /dev/null +++ b/Tests/RunCMake/TargetArtifacts/dll.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void dll(void) +{ +} -- cgit v0.12