From 6b2fb4ffd2e34093e54db0d5e2dac0fa17eacdf0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 11 May 2020 11:56:50 -0400 Subject: VS: Fix using PCH from source with COMPILE_OPTIONS If a source file gets per-source flags from both PCH and custom `COMPILE_OPTIONS`, combine them correctly. Fixes: #20694, #20456 --- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- Tests/RunCMake/PrecompileHeaders/PchInterface.cmake | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f220ea5..b33cb50 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2345,7 +2345,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( pchOptions = this->GeneratorTarget->GetPchUseCompileOptions(config, lang); } - customAndPchOptions += pchOptions; + customAndPchOptions = cmStrCat(customAndPchOptions, ';', pchOptions); } // if we have flags or defines for this config then diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake index a1e0792..aab20d8 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake @@ -9,6 +9,9 @@ target_precompile_headers(foo PUBLIC \"string.h\" ) +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + set_property(SOURCE foo.c APPEND PROPERTY COMPILE_OPTIONS "-WX-") +endif() add_library(bar INTERFACE) target_include_directories(bar INTERFACE include) -- cgit v0.12