From 8c5221fb1fad10518c8ef7901a686a9a816baf0e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 21 Jan 2019 10:07:20 -0500 Subject: 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 `#`. --- Source/cmCoreTryCompile.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 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 -- cgit v0.12