diff options
author | Brad King <brad.king@kitware.com> | 2022-11-23 12:09:01 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-11-23 12:09:09 (GMT) |
commit | 90907c8ff96ff07f0dafc1f4904d25b1e10f014b (patch) | |
tree | 2a83f7f51b031e917c71e377ac8e6d9891148ac6 | |
parent | 3bb47e43f0c3c7fc0240aa6ffdbc6748b01b05ea (diff) | |
parent | 80fc564dd7cbebc374a18fb57c71472dac5de6c1 (diff) | |
download | CMake-90907c8ff96ff07f0dafc1f4904d25b1e10f014b.zip CMake-90907c8ff96ff07f0dafc1f4904d25b1e10f014b.tar.gz CMake-90907c8ff96ff07f0dafc1f4904d25b1e10f014b.tar.bz2 |
Merge topic 'try_compile-copy-config' into release-3.25
80fc564dd7 try_compile: Restore COPY_FILE with CMAKE_TRY_COMPILE_CONFIGURATION
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: Robert Maynard <robertjmaynard@gmail.com>
Merge-request: !7948
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 15 | ||||
-rw-r--r-- | Tests/RunCMake/try_compile/CopyFileConfig.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake | 1 |
3 files changed, 20 insertions, 4 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 867f984..b44111d 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -206,6 +206,8 @@ auto const TryRunSourcesArgParser = auto const TryRunOldArgParser = makeTryRunParser(TryCompileOldArgParser); #undef BIND_LANG_PROPS + +std::string const TryCompileDefaultConfig = "DEBUG"; } Arguments cmCoreTryCompile::ParseArgs( @@ -706,9 +708,9 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments, CM_FALLTHROUGH; case cmPolicies::NEW: { // NEW behavior is to pass config-specific compiler flags. - static std::string const cfgDefault = "DEBUG"; - std::string const cfg = - !tcConfig.empty() ? cmSystemTools::UpperCase(tcConfig) : cfgDefault; + std::string const cfg = !tcConfig.empty() + ? cmSystemTools::UpperCase(tcConfig) + : TryCompileDefaultConfig; for (std::string const& li : testLangs) { std::string const langFlagsCfg = cmStrCat("CMAKE_", li, "_FLAGS_", cfg); @@ -1199,7 +1201,12 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName) tmpOutputFile += targetName; if (this->Makefile->GetGlobalGenerator()->IsMultiConfig()) { - tmpOutputFile += "_DEBUG"; + std::string const tcConfig = + this->Makefile->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); + std::string const cfg = !tcConfig.empty() + ? cmSystemTools::UpperCase(tcConfig) + : TryCompileDefaultConfig; + tmpOutputFile = cmStrCat(tmpOutputFile, '_', cfg); } tmpOutputFile += "_loc"; diff --git a/Tests/RunCMake/try_compile/CopyFileConfig.cmake b/Tests/RunCMake/try_compile/CopyFileConfig.cmake new file mode 100644 index 0000000..22d20b7 --- /dev/null +++ b/Tests/RunCMake/try_compile/CopyFileConfig.cmake @@ -0,0 +1,8 @@ +enable_language(C) +set(CMAKE_TRY_COMPILE_CONFIGURATION Release) + +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) +try_compile(RESULT + ${try_compile_bindir_or_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src.c + COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/out.bin" + ) diff --git a/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake b/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake index ac07ad3..3158e32 100644 --- a/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake +++ b/Tests/RunCMake/try_compile/old_and_new_signature_tests.cmake @@ -23,6 +23,7 @@ run_cmake(TryRunArgs) run_cmake(BuildType) run_cmake(BuildTypeAsFlag) run_cmake(OutputDirAsFlag) +run_cmake(CopyFileConfig) run_cmake(EnvConfig) |