diff options
author | Felix Lelchuk <felix.lelchuk@gmx.de> | 2021-08-02 17:42:26 (GMT) |
---|---|---|
committer | Felix Lelchuk <felix.lelchuk@gmx.de> | 2021-08-02 17:42:26 (GMT) |
commit | 58d10cf6f13493db124af18e3cac127b2164ea59 (patch) | |
tree | 593dc156eae14ffe6584fa1a31e17f9a18d88a2f /Tests/CMakeLists.txt | |
parent | c15bb6f8b8c2eac691138e35d96570d537cc6d69 (diff) | |
download | CMake-58d10cf6f13493db124af18e3cac127b2164ea59.zip CMake-58d10cf6f13493db124af18e3cac127b2164ea59.tar.gz CMake-58d10cf6f13493db124af18e3cac127b2164ea59.tar.bz2 |
Alternative symlink-creating mode for file(INSTALL ...)
An new environment variable 'CMAKE_INSTALL_MODE' is introduced,
which can be used to ask CMake to create symbolic links
instead of copying files during a file(INSTALL ...).
The operation is at the file level only, directory trees are
still created using actual directories, not links.
Signed-off-by: Felix Lelchuk <felix.lelchuk@gmx.de>
Diffstat (limited to 'Tests/CMakeLists.txt')
-rw-r--r-- | Tests/CMakeLists.txt | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 388ff20..e59cdfb 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1641,6 +1641,54 @@ if(BUILD_TESTING) WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate DEPENDS ExternalProjectUpdateSetup ) + execute_process( + COMMAND ${CMAKE_CMAKE_COMMAND} + "-E" create_symlink + "${CMake_SOURCE_DIR}/Tests/CMakeLists.txt" # random source file that exists + "${CMake_BINARY_DIR}/Tests/try_to_create_symlink" # random target file in existing directory + RESULT_VARIABLE _failed + ) + if(_failed) + message("Failed to create a simple symlink on this machine. Skipping InstallMode tests.") + else() + function(add_installmode_test _mode) + set(ENV{CMAKE_INSTALL_MODE} _mode) + set(_maybe_InstallMode_CTEST_OPTIONS) + set(_maybe_BUILD_OPTIONS) + if(_isMultiConfig) + set(_maybe_CTEST_OPTIONS -C $<CONFIGURATION>) + else() + set(_maybe_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>") + endif() + add_test( + NAME "InstallMode-${_mode}" + COMMAND + ${CMAKE_CTEST_COMMAND} -V ${_maybe_CTEST_OPTIONS} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/InstallMode" + "${CMake_BINARY_DIR}/Tests/InstallMode-${_mode}" + ${build_generator_args} + --build-project superpro + --build-exe-dir "${CMake_BINARY_DIR}/Tests/InstallMode-${_mode}" + --force-new-ctest-process + --build-options + ${_maybe_BUILD_OPTIONS} + "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/InstallMode-${_mode}/install" + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InstallMode-${_mode}") + unset(ENV{CMAKE_INSTALL_MODE}) + endfunction() + + add_installmode_test(COPY) + add_installmode_test(REL_SYMLINK) + add_installmode_test(REL_SYMLINK_OR_COPY) + add_installmode_test(ABS_SYMLINK) + add_installmode_test(ABS_SYMLINK_OR_COPY) + add_installmode_test(SYMLINK) + add_installmode_test(SYMLINK_OR_COPY) + endif() + + # do each of the tutorial steps function(add_tutorial_test step_name use_mymath tutorial_arg pass_regex) set(tutorial_test_name Tutorial${step_name}) |