diff options
author | Brad King <brad.king@kitware.com> | 2024-01-31 14:03:10 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-01-31 14:03:21 (GMT) |
commit | 16b1f0c3e99023316b12fdabd1980a18b738d942 (patch) | |
tree | deb2853897370754c302aef05328f275a791ca57 /Tests/RunCMake | |
parent | 2a008138420b0a2cc867f5d3e47accc7d2fda5e0 (diff) | |
parent | 06af18b9db267926dfd8fd346328a64a41238aa3 (diff) | |
download | CMake-16b1f0c3e99023316b12fdabd1980a18b738d942.zip CMake-16b1f0c3e99023316b12fdabd1980a18b738d942.tar.gz CMake-16b1f0c3e99023316b12fdabd1980a18b738d942.tar.bz2 |
Merge topic 'env-cmake-install-prefix'
06af18b9db cmake: Allow CMAKE_INSTALL_PREFIX to be set by environment variable
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9200
Diffstat (limited to 'Tests/RunCMake')
7 files changed, 23 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/EnvInstallPrefix-stdout.txt b/Tests/RunCMake/CommandLine/EnvInstallPrefix-stdout.txt new file mode 100644 index 0000000..a0ca3d5 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvInstallPrefix-stdout.txt @@ -0,0 +1,3 @@ +-- ENV{CMAKE_INSTALL_PREFIX}='[^']*/Tests/RunCMake/CommandLine/install_prefix_set_via_env_var' +-- CMAKE_INSTALL_PREFIX='[^']*/Tests/RunCMake/CommandLine/install_prefix_set_via_env_var' +-- CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT='' diff --git a/Tests/RunCMake/CommandLine/EnvInstallPrefix.cmake b/Tests/RunCMake/CommandLine/EnvInstallPrefix.cmake new file mode 100644 index 0000000..24b1840 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvInstallPrefix.cmake @@ -0,0 +1,3 @@ +message(STATUS "ENV{CMAKE_INSTALL_PREFIX}='$ENV{CMAKE_INSTALL_PREFIX}'") +message(STATUS "CMAKE_INSTALL_PREFIX='${CMAKE_INSTALL_PREFIX}'") +message(STATUS "CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT='${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT}'") diff --git a/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithCmdLineOpt-stdout.txt b/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithCmdLineOpt-stdout.txt new file mode 100644 index 0000000..b95e277 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithCmdLineOpt-stdout.txt @@ -0,0 +1,3 @@ +-- ENV{CMAKE_INSTALL_PREFIX}='[^']*/Tests/RunCMake/CommandLine/install_prefix_set_via_env_var' +-- CMAKE_INSTALL_PREFIX='[^']*/Tests/RunCMake/CommandLine/install_prefix_set_cmd_line_opt' +-- CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT='' diff --git a/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithCmdLineOpt.cmake b/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithCmdLineOpt.cmake new file mode 100644 index 0000000..6de6be6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithCmdLineOpt.cmake @@ -0,0 +1 @@ +include(EnvInstallPrefix.cmake) diff --git a/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithVar-stdout.txt b/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithVar-stdout.txt new file mode 100644 index 0000000..3b7181d --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithVar-stdout.txt @@ -0,0 +1,3 @@ +-- ENV{CMAKE_INSTALL_PREFIX}='[^']*/Tests/RunCMake/CommandLine/install_prefix_set_via_env_var' +-- CMAKE_INSTALL_PREFIX='[^']*/Tests/RunCMake/CommandLine/install_prefix_set_via_var' +-- CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT='' diff --git a/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithVar.cmake b/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithVar.cmake new file mode 100644 index 0000000..6de6be6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/EnvInstallPrefixOverrideWithVar.cmake @@ -0,0 +1 @@ +include(EnvInstallPrefix.cmake) diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 03b9301..7b34773 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -459,6 +459,15 @@ elseif(RunCMake_GENERATOR MATCHES "Ninja Multi-Config|Visual Studio|Xcode") run_EnvironmentConfigTypes() endif() +function(run_EnvironmentInstallPrefix) + set(ENV{CMAKE_INSTALL_PREFIX} "${RunCMake_BINARY_DIR}/install_prefix_set_via_env_var") + run_cmake(EnvInstallPrefix) + run_cmake_with_options(EnvInstallPrefixOverrideWithVar -DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/install_prefix_set_via_var) + run_cmake_with_options(EnvInstallPrefixOverrideWithCmdLineOpt --install-prefix ${RunCMake_BINARY_DIR}/install_prefix_set_cmd_line_opt) + unset(ENV{CMAKE_INSTALL_PREFIX}) +endfunction() +run_EnvironmentInstallPrefix() + function(run_EnvironmentToolchain) set(ENV{CMAKE_TOOLCHAIN_FILE} "${RunCMake_SOURCE_DIR}/EnvToolchain-toolchain.cmake") run_cmake(EnvToolchainAbsolute) |