diff options
author | Brad King <brad.king@kitware.com> | 2016-05-24 19:33:34 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-25 13:36:19 (GMT) |
commit | d256ba078a10001883487ed6af746af5b9cd9608 (patch) | |
tree | 094283876832165e43db22f3e5bff7205b01d761 /Source/cmCoreTryCompile.cxx | |
parent | fb4791b37ccea1f38b8625b31df952408ab942f3 (diff) | |
download | CMake-d256ba078a10001883487ed6af746af5b9cd9608.zip CMake-d256ba078a10001883487ed6af746af5b9cd9608.tar.gz CMake-d256ba078a10001883487ed6af746af5b9cd9608.tar.bz2 |
try_compile: Optionally forward custom platform variables to test project
Add a `CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable to specify a list
of custom variables to be forwarded to a `try_compile` test project.
This will be useful for platform information modules or toolchain files
to forward some platform-specific set of variables from the host project
(perhaps set in its cache) to the test project so that it can build the
same way.
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index bd9fd87..0149fdf 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -41,6 +41,8 @@ static std::string const kCMAKE_POSITION_INDEPENDENT_CODE = static std::string const kCMAKE_SYSROOT = "CMAKE_SYSROOT"; static std::string const kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES = "CMAKE_TRY_COMPILE_OSX_ARCHITECTURES"; +static std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES = + "CMAKE_TRY_COMPILE_PLATFORM_VARIABLES"; int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, bool isTryRun) @@ -421,6 +423,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, vars.insert(kCMAKE_POSITION_INDEPENDENT_CODE); vars.insert(kCMAKE_SYSROOT); + if (const char* varListStr = this->Makefile->GetDefinition( + kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) { + std::vector<std::string> varList; + cmSystemTools::ExpandListArgument(varListStr, varList); + vars.insert(varList.begin(), varList.end()); + } + /* for the TRY_COMPILEs we want to be able to specify the architecture. So the user can set CMAKE_OSX_ARCHITECTURES to i386;ppc and then set CMAKE_TRY_COMPILE_OSX_ARCHITECTURES first to i386 and then to ppc to |