mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 12:16:40 +08:00
Tests: Add tests for new options
This commit is contained in:
@@ -478,6 +478,7 @@ if(BUILD_TESTING)
|
||||
ADD_TEST_MACRO(Preprocess Preprocess)
|
||||
set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
|
||||
-DCMake_TEST_CUDA:BOOL=${CMake_TEST_CUDA}
|
||||
-DCMake_INSTALL_NAME_TOOL_BUG:BOOL=${CMake_INSTALL_NAME_TOOL_BUG}
|
||||
)
|
||||
ADD_TEST_MACRO(ExportImport ExportImport)
|
||||
set_property(TEST ExportImport APPEND
|
||||
|
@@ -77,21 +77,29 @@ set_property(
|
||||
PROPERTY SYMBOLIC 1
|
||||
)
|
||||
|
||||
# Install the imported targets.
|
||||
add_custom_command(
|
||||
OUTPUT ${ExportImport_BINARY_DIR}/ImportInstall
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf ${ExportImport_BINARY_DIR}/Import/install
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
--install ${ExportImport_BINARY_DIR}/Import
|
||||
--prefix ${ExportImport_BINARY_DIR}/Import/install
|
||||
${NESTED_CONFIG_INSTALL_TYPE}
|
||||
)
|
||||
add_custom_target(ImportInstallTarget ALL DEPENDS ${ExportImport_BINARY_DIR}/ImportInstall)
|
||||
# Run the install tests.
|
||||
set(install_deps)
|
||||
set(rdep_tests)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Windows|Darwin)$" AND NOT CMake_INSTALL_NAME_TOOL_BUG)
|
||||
set(rdep_tests RUNTIME_DEPENDENCIES RUNTIME_DEPENDENCY_SET)
|
||||
endif()
|
||||
foreach(name IMPORTED_RUNTIME_ARTIFACTS ${rdep_tests})
|
||||
add_custom_command(
|
||||
OUTPUT ${ExportImport_BINARY_DIR}/ImportInstall-${name}
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf ${ExportImport_BINARY_DIR}/Import/install-${name}/install
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
--install ${ExportImport_BINARY_DIR}/Import/install-${name}
|
||||
--prefix ${ExportImport_BINARY_DIR}/Import/install-${name}/install
|
||||
${NESTED_CONFIG_INSTALL_TYPE}
|
||||
)
|
||||
list(APPEND install_deps ${ExportImport_BINARY_DIR}/ImportInstall-${name})
|
||||
set_property(
|
||||
SOURCE ${ExportImport_BINARY_DIR}/ImportInstall-${name}
|
||||
PROPERTY SYMBOLIC 1
|
||||
)
|
||||
endforeach()
|
||||
add_custom_target(ImportInstallTarget ALL DEPENDS ${install_deps})
|
||||
add_dependencies(ImportInstallTarget ImportTarget)
|
||||
set_property(
|
||||
SOURCE ${ExportImport_BINARY_DIR}/ImportInstall
|
||||
PROPERTY SYMBOLIC 1
|
||||
)
|
||||
|
||||
add_executable(ExportImport main.c)
|
||||
add_dependencies(ExportImport ImportTarget)
|
||||
|
@@ -690,3 +690,5 @@ if(NOT XCODE)
|
||||
install(TARGETS testLibFromGeneratedSource EXPORT testLibFromGeneratedSource_Export)
|
||||
install(EXPORT testLibFromGeneratedSource_Export DESTINATION lib)
|
||||
endif()
|
||||
|
||||
add_subdirectory(install-RUNTIME_DEPENDENCY_SET)
|
||||
|
@@ -0,0 +1,42 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
set(CMAKE_SKIP_RPATH OFF)
|
||||
|
||||
foreach(i 1 2 3 4 5 6 7 8 9 10 11 12)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dep${i}.c"
|
||||
"#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void dep${i}(void)
|
||||
{
|
||||
}
|
||||
")
|
||||
add_library(dep${i} SHARED "${CMAKE_CURRENT_BINARY_DIR}/dep${i}.c")
|
||||
endforeach()
|
||||
|
||||
set_target_properties(dep9 PROPERTIES
|
||||
FRAMEWORK TRUE
|
||||
)
|
||||
set_target_properties(dep2 PROPERTIES
|
||||
VERSION 1.2.3
|
||||
SOVERSION 1
|
||||
)
|
||||
|
||||
add_library(deplib SHARED deplib.c)
|
||||
target_link_libraries(deplib PRIVATE dep1)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set_target_properties(deplib PROPERTIES
|
||||
INSTALL_RPATH "@loader_path/"
|
||||
)
|
||||
endif()
|
||||
|
||||
install(TARGETS dep1 dep2 dep3 dep4 dep5 dep6 dep7 dep8 dep9 dep10 dep11 dep12 deplib EXPORT install-RUNTIME_DEPENDENCY_SET
|
||||
RUNTIME DESTINATION install-RUNTIME_DEPENDENCY_SET/bin
|
||||
LIBRARY DESTINATION install-RUNTIME_DEPENDENCY_SET/lib
|
||||
ARCHIVE DESTINATION install-RUNTIME_DEPENDENCY_SET/lib
|
||||
FRAMEWORK DESTINATION install-RUNTIME_DEPENDENCY_SET/frameworks
|
||||
)
|
||||
install(EXPORT install-RUNTIME_DEPENDENCY_SET
|
||||
FILE targets.cmake
|
||||
DESTINATION install-RUNTIME_DEPENDENCY_SET
|
||||
)
|
@@ -0,0 +1,12 @@
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern void dep1(void);
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void deplib(void)
|
||||
{
|
||||
dep1();
|
||||
}
|
@@ -29,3 +29,9 @@ add_subdirectory(version_range)
|
||||
|
||||
# Test install(IMPORTED_RUNTIME_ARTIFACTS)
|
||||
add_subdirectory(install-IMPORTED_RUNTIME_ARTIFACTS)
|
||||
|
||||
# Test install(RUNTIME_DEPENDENCIES) and install(RUNTIME_DEPENDENCY_SET)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Windows|Darwin)$")
|
||||
add_subdirectory(install-RUNTIME_DEPENDENCIES)
|
||||
add_subdirectory(install-RUNTIME_DEPENDENCY_SET)
|
||||
endif()
|
||||
|
20
Tests/ExportImport/Import/check_installed.cmake
Normal file
20
Tests/ExportImport/Import/check_installed.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
function(check_installed expect)
|
||||
file(GLOB_RECURSE actual
|
||||
LIST_DIRECTORIES TRUE
|
||||
RELATIVE ${CMAKE_INSTALL_PREFIX}
|
||||
${CMAKE_INSTALL_PREFIX}/*
|
||||
)
|
||||
if(actual)
|
||||
list(SORT actual)
|
||||
endif()
|
||||
if(NOT "${actual}" MATCHES "${expect}")
|
||||
message(FATAL_ERROR "Installed files:
|
||||
${actual}
|
||||
do not match what we expected:
|
||||
${expect}
|
||||
in directory:
|
||||
${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
endfunction()
|
@@ -1,23 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
function(check_installed expect)
|
||||
file(GLOB_RECURSE actual
|
||||
LIST_DIRECTORIES TRUE
|
||||
RELATIVE ${CMAKE_INSTALL_PREFIX}
|
||||
${CMAKE_INSTALL_PREFIX}/*
|
||||
)
|
||||
if(actual)
|
||||
list(SORT actual)
|
||||
endif()
|
||||
if(NOT "${actual}" MATCHES "${expect}")
|
||||
message(FATAL_ERROR "Installed files:
|
||||
${actual}
|
||||
do not match what we expected:
|
||||
${expect}
|
||||
in directory:
|
||||
${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
endfunction()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/../check_installed.cmake")
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(_dirs [[aaa;aaa/executables;aaa/executables/testExe1-4;aaa/executables/testExe3;aaa/libraries;aaa/libraries/libtestExe2lib\.so;aaa/libraries/libtestLib3lib(-d|-r)?\.so\.1\.2;aaa/libraries/libtestLib3lib(-d|-r)?\.so\.3;aaa/libraries/libtestLib4\.so;aaa/libraries/libtestMod1\.so;aaa/libraries/libtestMod2\.so]])
|
||||
|
@@ -0,0 +1,74 @@
|
||||
set(CMAKE_SKIP_RPATH OFF)
|
||||
|
||||
# Import targets from the install tree.
|
||||
include(${Import_BINARY_DIR}/../Root/install-RUNTIME_DEPENDENCY_SET/targets.cmake)
|
||||
|
||||
add_executable(exe1 main.c)
|
||||
add_executable(exe2 main.c)
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set_target_properties(exe1 exe2 PROPERTIES
|
||||
# Multiple MACOSX_BUNDLE executables are allowed on non-macOS platforms.
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(sublib1 SHARED sublib1.c)
|
||||
target_link_libraries(sublib1 PRIVATE dep6)
|
||||
|
||||
add_library(sublib2 SHARED sublib2.c)
|
||||
target_link_libraries(sublib2 PRIVATE dep7)
|
||||
|
||||
foreach(i exe1 exe2)
|
||||
target_link_libraries(${i} PRIVATE
|
||||
dep1
|
||||
dep2
|
||||
dep3
|
||||
dep4
|
||||
dep5
|
||||
dep10
|
||||
dep11
|
||||
dep12
|
||||
sublib1
|
||||
sublib2
|
||||
)
|
||||
endforeach()
|
||||
|
||||
add_library(lib SHARED lib.c)
|
||||
target_link_libraries(lib PRIVATE dep8)
|
||||
|
||||
add_library(mod MODULE mod.c)
|
||||
target_link_libraries(mod PRIVATE dep9)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set_target_properties(mod PROPERTIES
|
||||
SKIP_BUILD_RPATH TRUE
|
||||
)
|
||||
endif()
|
||||
|
||||
set(_framework_args)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(_framework_args FRAMEWORK DESTINATION subdir/frameworks)
|
||||
endif()
|
||||
install(TARGETS exe1 exe2 lib mod sublib1
|
||||
RUNTIME_DEPENDENCIES
|
||||
PRE_INCLUDE_REGEXES "$<1:dep([2-9]|1[012])>"
|
||||
PRE_EXCLUDE_REGEXES "$<1:.*>"
|
||||
POST_INCLUDE_REGEXES "$<1:(bin|lib)/(lib)?dep3>"
|
||||
POST_EXCLUDE_REGEXES "$<1:(bin|lib)/(lib)?dep[34]>"
|
||||
POST_INCLUDE_FILES "$<TARGET_FILE:dep10>" "$<TARGET_FILE:dep11>"
|
||||
POST_EXCLUDE_FILES "$<TARGET_FILE:dep11>" "$<TARGET_FILE:dep12>"
|
||||
DIRECTORIES "$<TARGET_FILE_DIR:dep9>"
|
||||
RUNTIME DESTINATION "$<1:subdir/bin>"
|
||||
LIBRARY DESTINATION "$<1:subdir/lib>"
|
||||
${_framework_args}
|
||||
)
|
||||
|
||||
install(TARGETS lib
|
||||
RUNTIME_DEPENDENCIES
|
||||
PRE_INCLUDE_REGEXES dep8
|
||||
PRE_EXCLUDE_REGEXES ".*"
|
||||
DIRECTORIES "$<TARGET_FILE_DIR:dep8>"
|
||||
${_framework_args}
|
||||
)
|
||||
|
||||
install(SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/check_installed.cmake")
|
@@ -0,0 +1,11 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/../check_installed.cmake")
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
|
||||
check_installed([[^lib;lib/libdep8\.so;lib/liblib\.so;subdir;subdir/bin;subdir/bin/exe1;subdir/bin/exe2;subdir/lib;subdir/lib/libdep10\.so;subdir/lib/libdep11\.so;subdir/lib/libdep2\.so\.1;subdir/lib/libdep2\.so\.1\.2\.3;subdir/lib/libdep3\.so;subdir/lib/libdep5\.so;subdir/lib/libdep6\.so;subdir/lib/libdep8\.so;subdir/lib/libdep9\.so;subdir/lib/liblib\.so;subdir/lib/libmod\.so;subdir/lib/libsublib1\.so$]])
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(_msvc_check [[bin;bin/dep8\.dll;bin/lib\.dll;lib;lib/lib\.lib;subdir;subdir/bin;subdir/bin/dep10\.dll;subdir/bin/dep11\.dll;subdir/bin/dep2\.dll;subdir/bin/dep3\.dll;subdir/bin/dep5\.dll;subdir/bin/dep6\.dll;subdir/bin/dep8\.dll;subdir/bin/dep9\.dll;subdir/bin/exe1\.exe;subdir/bin/exe2\.exe;subdir/bin/lib\.dll;subdir/bin/sublib1\.dll;subdir/lib;subdir/lib/mod\.dll]])
|
||||
set(_mingw_check [[bin;bin/libdep8\.dll;bin/liblib\.dll;lib;lib/liblib\.dll\.a;lib/liblib\.lib;subdir;subdir/bin;subdir/bin/exe1\.exe;subdir/bin/exe2\.exe;subdir/bin/libdep10\.dll;subdir/bin/libdep11\.dll;subdir/bin/libdep2\.dll;subdir/bin/libdep3\.dll;subdir/bin/libdep5\.dll;subdir/bin/libdep6\.dll;subdir/bin/libdep8\.dll;subdir/bin/libdep9\.dll;subdir/bin/liblib\.dll;subdir/bin/libsublib1\.dll;subdir/lib;subdir/lib/libmod\.dll]])
|
||||
check_installed("^(${_msvc_check}|${_mingw_check})$")
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
|
||||
check_installed([[^lib;lib/libdep8\.dylib;lib/liblib\.dylib;subdir;subdir/bin;subdir/bin/exe1;subdir/bin/exe2;subdir/frameworks;subdir/frameworks/dep9\.framework;subdir/frameworks/dep9\.framework/Resources;subdir/frameworks/dep9\.framework/Versions;subdir/frameworks/dep9\.framework/Versions/A;subdir/frameworks/dep9\.framework/Versions/A/Resources;subdir/frameworks/dep9\.framework/Versions/A/Resources/Info\.plist(;subdir/frameworks/dep9.framework/Versions/A/_CodeSignature;subdir/frameworks/dep9.framework/Versions/A/_CodeSignature/CodeResources)?;subdir/frameworks/dep9\.framework/Versions/A/dep9;subdir/frameworks/dep9\.framework/Versions/Current;subdir/frameworks/dep9\.framework/dep9;subdir/lib;subdir/lib/libdep10\.dylib;subdir/lib/libdep11\.dylib;subdir/lib/libdep2\.1\.2\.3\.dylib;subdir/lib/libdep2\.1\.dylib;subdir/lib/libdep3\.dylib;subdir/lib/libdep5\.dylib;subdir/lib/libdep6\.dylib;subdir/lib/libdep8\.dylib;subdir/lib/liblib\.dylib;subdir/lib/libmod\.so;subdir/lib/libsublib1\.dylib$]])
|
||||
endif()
|
12
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/lib.c
Normal file
12
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/lib.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern void dep8(void);
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void lib(void)
|
||||
{
|
||||
dep8();
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
#ifdef _WIN32
|
||||
# define DLLIMPORT __declspec(dllimport)
|
||||
#else
|
||||
# define DLLIMPORT
|
||||
#endif
|
||||
|
||||
DLLIMPORT extern void dep1(void);
|
||||
DLLIMPORT extern void dep2(void);
|
||||
DLLIMPORT extern void dep3(void);
|
||||
DLLIMPORT extern void dep4(void);
|
||||
DLLIMPORT extern void dep5(void);
|
||||
DLLIMPORT extern void dep10(void);
|
||||
DLLIMPORT extern void dep11(void);
|
||||
DLLIMPORT extern void dep12(void);
|
||||
DLLIMPORT extern void sublib1(void);
|
||||
DLLIMPORT extern void sublib2(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
dep1();
|
||||
dep2();
|
||||
dep3();
|
||||
dep4();
|
||||
dep5();
|
||||
dep10();
|
||||
dep11();
|
||||
dep12();
|
||||
sublib1();
|
||||
sublib2();
|
||||
return 0;
|
||||
}
|
12
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/mod.c
Normal file
12
Tests/ExportImport/Import/install-RUNTIME_DEPENDENCIES/mod.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern void dep9(void);
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void mod(void)
|
||||
{
|
||||
dep9();
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern void dep6(void);
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void sublib1(void)
|
||||
{
|
||||
dep6();
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern void dep7(void);
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
void sublib2(void)
|
||||
{
|
||||
dep7();
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
set(CMAKE_SKIP_RPATH OFF)
|
||||
|
||||
# Import targets from the install tree.
|
||||
include(${Import_BINARY_DIR}/../Root/install-RUNTIME_DEPENDENCY_SET/targets.cmake)
|
||||
|
||||
add_executable(exe main.c)
|
||||
target_link_libraries(exe PRIVATE dep3 dep4)
|
||||
|
||||
install(TARGETS exe RUNTIME_DEPENDENCY_SET myset)
|
||||
install(IMPORTED_RUNTIME_ARTIFACTS deplib RUNTIME_DEPENDENCY_SET myset)
|
||||
|
||||
install(RUNTIME_DEPENDENCY_SET myset
|
||||
PRE_INCLUDE_REGEXES "dep[134]"
|
||||
PRE_EXCLUDE_REGEXES ".*"
|
||||
POST_INCLUDE_REGEXES "dep[13]"
|
||||
POST_EXCLUDE_REGEXES "dep[34]"
|
||||
DIRECTORIES "$<TARGET_FILE_DIR:dep1>"
|
||||
)
|
||||
install(RUNTIME_DEPENDENCY_SET myset
|
||||
PRE_INCLUDE_REGEXES "dep[134]"
|
||||
PRE_EXCLUDE_REGEXES ".*"
|
||||
DIRECTORIES "$<TARGET_FILE_DIR:dep1>"
|
||||
RUNTIME DESTINATION yyy/bin
|
||||
LIBRARY DESTINATION yyy/lib
|
||||
)
|
||||
install(RUNTIME_DEPENDENCY_SET myset
|
||||
PRE_INCLUDE_REGEXES "dep[134]"
|
||||
PRE_EXCLUDE_REGEXES ".*"
|
||||
DIRECTORIES "$<TARGET_FILE_DIR:dep1>"
|
||||
DESTINATION zzz
|
||||
)
|
||||
|
||||
install(SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/check_installed.cmake")
|
@@ -0,0 +1,11 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/../check_installed.cmake")
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
|
||||
check_installed([[^bin;bin/exe;lib;lib/libdep1\.so;lib/libdep3\.so;lib/libdeplib\.so;yyy;yyy/lib;yyy/lib/libdep1\.so;yyy/lib/libdep3\.so;yyy/lib/libdep4\.so;zzz;zzz/libdep1\.so;zzz/libdep3\.so;zzz/libdep4\.so$]])
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(_msvc_check [[bin;bin/dep1\.dll;bin/dep3\.dll;bin/deplib\.dll;bin/exe\.exe;yyy;yyy/bin;yyy/bin/dep1\.dll;yyy/bin/dep3\.dll;yyy/bin/dep4\.dll;zzz;zzz/dep1\.dll;zzz/dep3\.dll;zzz/dep4\.dll]])
|
||||
set(_mingw_check [[bin;bin/exe\.exe;bin/libdep1\.dll;bin/libdep3\.dll;bin/libdeplib\.dll;yyy;yyy/bin;yyy/bin/libdep1\.dll;yyy/bin/libdep3\.dll;yyy/bin/libdep4\.dll;zzz;zzz/libdep1\.dll;zzz/libdep3\.dll;zzz/libdep4\.dll]])
|
||||
check_installed("^(${_msvc_check}|${_mingw_check})$")
|
||||
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
|
||||
check_installed([[^bin;bin/exe;lib;lib/libdep1\.dylib;lib/libdep3\.dylib;lib/libdeplib\.dylib;yyy;yyy/lib;yyy/lib/libdep1\.dylib;yyy/lib/libdep3\.dylib;yyy/lib/libdep4\.dylib;zzz;zzz/libdep1\.dylib;zzz/libdep3\.dylib;zzz/libdep4\.dylib$]])
|
||||
endif()
|
@@ -0,0 +1,15 @@
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern void dep3(void);
|
||||
#ifdef _WIN32
|
||||
__declspec(dllimport)
|
||||
#endif
|
||||
extern void dep4(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
dep3();
|
||||
dep4();
|
||||
return 0;
|
||||
}
|
@@ -186,6 +186,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$")
|
||||
run_cmake(TARGETS-RUNTIME_DEPENDENCIES-cross)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
run_cmake(TARGETS-RUNTIME_DEPENDENCY_SET-RUNTIME_DEPENDENCIES-conflict)
|
||||
run_cmake(RuntimeDependencies-COMPONENTS)
|
||||
else()
|
||||
run_cmake(TARGETS-RUNTIME_DEPENDENCIES-unsupported)
|
||||
run_cmake(TARGETS-RUNTIME_DEPENDENCY_SET-unsupported)
|
||||
|
39
Tests/RunCMake/install/RuntimeDependencies-COMPONENTS.cmake
Normal file
39
Tests/RunCMake/install/RuntimeDependencies-COMPONENTS.cmake
Normal file
@@ -0,0 +1,39 @@
|
||||
enable_language(C)
|
||||
|
||||
function(check_components value)
|
||||
get_cmake_property(comp COMPONENTS)
|
||||
if(NOT comp STREQUAL value)
|
||||
message(FATAL_ERROR "Expected value of COMPONENTS:\n ${value}\nActual value of COMPONENTS:\n ${comp}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
add_library(tgt MODULE obj1.c)
|
||||
else()
|
||||
add_executable(tgt main.c)
|
||||
endif()
|
||||
|
||||
install(TARGETS tgt
|
||||
RUNTIME_DEPENDENCIES
|
||||
RUNTIME DESTINATION bin COMPONENT bin1
|
||||
LIBRARY DESTINATION lib COMPONENT lib1
|
||||
FRAMEWORK DESTINATION fw COMPONENT fw1
|
||||
)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
check_components("bin1;fw1;lib1")
|
||||
else()
|
||||
check_components("bin1;lib1")
|
||||
endif()
|
||||
|
||||
install(RUNTIME_DEPENDENCY_SET deps
|
||||
RUNTIME DESTINATION bin COMPONENT bin2
|
||||
LIBRARY DESTINATION lib COMPONENT lib2
|
||||
FRAMEWORK DESTINATION fw COMPONENT fw2
|
||||
)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
check_components("bin1;fw1;fw2;lib1;lib2")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
check_components("bin1;bin2;lib1")
|
||||
elseif()
|
||||
check_components("bin1;lib1;lib2")
|
||||
endif()
|
Reference in New Issue
Block a user