diff options
author | Brad King <brad.king@kitware.com> | 2011-01-19 19:28:32 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2011-01-19 19:28:32 (GMT) |
commit | 3a1975c529ee254277b86cc3f16920ac61c5f54e (patch) | |
tree | 8029293cf80cab0675bd6281f42be5cba6f97adb | |
parent | 863c7dfd881148da8a8ef6b24a5fee23ae8b3b8b (diff) | |
parent | 052c2ae1aa9759e141a4331877f7e39ba5688ca5 (diff) | |
download | CMake-3a1975c529ee254277b86cc3f16920ac61c5f54e.zip CMake-3a1975c529ee254277b86cc3f16920ac61c5f54e.tar.gz CMake-3a1975c529ee254277b86cc3f16920ac61c5f54e.tar.bz2 |
Merge topic 'try_compile-Makefile-config'
052c2ae Document CMAKE_TRY_COMPILE_CONFIGURATION variable
56efc60 Honor CMAKE_TRY_COMPILE_CONFIGURATION in Makefile generators (#10809)
-rw-r--r-- | Source/cmDocumentVariables.cxx | 8 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 12 | ||||
-rw-r--r-- | Source/cmTryCompileCommand.h | 4 | ||||
-rw-r--r-- | Source/cmTryRunCommand.h | 5 |
4 files changed, 27 insertions, 2 deletions
diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 5dfa64e..e9b54d8 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1121,6 +1121,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "this variable for a target if they are set. " "Library targets are otherwise placed in this directory.",false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_TRY_COMPILE_CONFIGURATION", cmProperty::VARIABLE, + "Build configuration used for try_compile and try_run projects.", + "Projects built by try_compile and try_run are built " + "synchronously during the CMake configuration step. " + "Therefore a specific build configuration must be chosen even " + "if the generated build system supports multiple configurations.",false, + "Variables that Control the Build"); // Variables defined when the a language is enabled These variables will diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 41d36dc..e1cea22 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2718,6 +2718,18 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, cm.SetStartOutputDirectory(bindir); cm.SetCMakeCommand(cmakeCommand.c_str()); cm.LoadCache(); + if(!gg->IsMultiConfig()) + { + if(const char* config = + this->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION")) + { + // Tell the single-configuration generator which one to use. + // Add this before the user-provided CMake arguments in case + // one of the arguments is -DCMAKE_BUILD_TYPE=... + cm.AddCacheEntry("CMAKE_BUILD_TYPE", config, + "Build configuration", cmCacheManager::STRING); + } + } // if cmake args were provided then pass them in if (cmakeArgs) { diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 5b4ffca..0c67a8b 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -99,7 +99,9 @@ public: "Return the success or failure in " "RESULT_VAR. CMAKE_FLAGS can be used to pass -DVAR:TYPE=VALUE flags " "to the cmake that is run during the build. " - ""; + "Set variable CMAKE_TRY_COMPILE_CONFIGURATION to choose a build " + "configuration." + ; } cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile); diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index ca48e90..f86d863 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -93,7 +93,10 @@ public: "that when crosscompiling, the cache variables will have to be set " "manually to the output of the executable. You can also \"guard\" the " "calls to try_run with if(CMAKE_CROSSCOMPILING) and provide an " - "easy-to-preset alternative for this case.\n"; + "easy-to-preset alternative for this case.\n" + "Set variable CMAKE_TRY_COMPILE_CONFIGURATION to choose a build " + "configuration." + ; } cmTypeMacro(cmTryRunCommand, cmCoreTryCompile); |