summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-21 15:07:20 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-21 16:14:08 (GMT)
commit8c5221fb1fad10518c8ef7901a686a9a816baf0e (patch)
tree591720b79c11e4e8f6e8c4493146713093ba01d5 /Source/cmCoreTryCompile.cxx
parent15ad8300621eaf9fe23cda30368f90b420505d43 (diff)
downloadCMake-8c5221fb1fad10518c8ef7901a686a9a816baf0e.zip
CMake-8c5221fb1fad10518c8ef7901a686a9a816baf0e.tar.gz
CMake-8c5221fb1fad10518c8ef7901a686a9a816baf0e.tar.bz2
try_compile: Preserve special characters in COMPILE_DEFINITIONS
When generating the `CMakeLists.txt` file, we pass the values given to our `COMPILE_DEFINITIONS` option in an `add_definitions` call. Pass them as bracket arguments to preserve special characters like `#`.
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 137b25f..ef250d7 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -599,7 +599,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n");
// handle any compile flags we need to pass on
if (!compileDefs.empty()) {
- fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str());
+ // Pass using bracket arguments to preserve content.
+ fprintf(fout, "add_definitions([==[%s]==])\n",
+ cmJoin(compileDefs, "]==] [==[").c_str());
}
/* Use a random file name to avoid rapid creation and deletion