summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-03-29 13:14:50 +0000
committerKitware Robot <kwrobot@kitware.com>2017-03-29 09:14:54 -0400
commit6dc7262bf77f551a7f3c36d7ca3023c63ef20af8 (patch)
tree456a43d8f048f74bfc8de345c0a984c58431d9b4
parent4a6a27ad85a4be666a3bb4260105a54ba1cea0eb (diff)
parentfff34934e70da77c359e47c53ffd04701bcd7611 (diff)
downloadcmake-6dc7262bf77f551a7f3c36d7ca3023c63ef20af8.tar.gz
Merge topic 'vs-rc-defines'
fff34934 MSVC: Restore _DEBUG preprocessor definition in RC debug builds 79a91538 RC: Add missing CMAKE_RC_FLAGS_<CONFIG> entries to cache c77194ec VS: Honor preprocessor definitions in RC flags 1449f6f6 cmVisualStudio10TargetGenerator: De-duplicate preprocessor defs 8a619e8c cmIDEOptions: Add GetDefines method Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !640
-rw-r--r--Modules/CMakeRCInformation.cmake17
-rw-r--r--Modules/Platform/Windows-MSVC.cmake3
-rw-r--r--Source/cmIDEOptions.cxx5
-rw-r--r--Source/cmIDEOptions.h2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx12
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx5
6 files changed, 37 insertions, 7 deletions
diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake
index 10f2cfbc4f..7ddd2978b2 100644
--- a/Modules/CMakeRCInformation.cmake
+++ b/Modules/CMakeRCInformation.cmake
@@ -17,11 +17,26 @@ set(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
-string(STRIP "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}" CMAKE_RC_FLAGS_INIT)
+set(CMAKE_RC_FLAGS_INIT "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}")
+
+foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
+ string(STRIP "${CMAKE_RC_FLAGS${c}_INIT}" CMAKE_RC_FLAGS${c}_INIT)
+endforeach()
set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS_INIT}" CACHE STRING
"Flags for Windows Resource Compiler.")
+if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
+ set (CMAKE_RC_FLAGS_DEBUG "${CMAKE_RC_FLAGS_DEBUG_INIT}" CACHE STRING
+ "Flags for Windows Resource Compiler during debug builds.")
+ set (CMAKE_RC_FLAGS_MINSIZEREL "${CMAKE_RC_FLAGS_MINSIZEREL_INIT}" CACHE STRING
+ "Flags for Windows Resource Compiler during release builds for minimum size.")
+ set (CMAKE_RC_FLAGS_RELEASE "${CMAKE_RC_FLAGS_RELEASE_INIT}" CACHE STRING
+ "Flags for Windows Resource Compiler during release builds.")
+ set (CMAKE_RC_FLAGS_RELWITHDEBINFO "${CMAKE_RC_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
+ "Flags for Windows Resource Compiler during release builds with debug info.")
+endif()
+
# These are the only types of flags that should be passed to the rc
# command, if COMPILE_FLAGS is used on a target this will be used
# to filter out any other flags
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index 31b26b5927..e4aca6eb2b 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -310,6 +310,9 @@ macro(__windows_compiler_msvc lang)
if(NOT CMAKE_RC_FLAGS_INIT)
string(APPEND CMAKE_RC_FLAGS_INIT " ${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_${lang}}")
endif()
+ if(NOT CMAKE_RC_FLAGS_DEBUG_INIT)
+ string(APPEND CMAKE_RC_FLAGS_DEBUG_INIT " /D_DEBUG")
+ endif()
enable_language(RC)
set(CMAKE_NINJA_CMCLDEPS_RC 1)
diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx
index 1c0a99e2c6..bda6b750fd 100644
--- a/Source/cmIDEOptions.cxx
+++ b/Source/cmIDEOptions.cxx
@@ -150,6 +150,11 @@ void cmIDEOptions::AddDefines(const std::vector<std::string>& defines)
this->Defines.insert(this->Defines.end(), defines.begin(), defines.end());
}
+std::vector<std::string> const& cmIDEOptions::GetDefines() const
+{
+ return this->Defines;
+}
+
void cmIDEOptions::AddFlag(const char* flag, const char* value)
{
this->FlagMap[flag] = value;
diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h
index 465cf2c58f..11f8aba446 100644
--- a/Source/cmIDEOptions.h
+++ b/Source/cmIDEOptions.h
@@ -24,6 +24,8 @@ public:
void AddDefine(const std::string& define);
void AddDefines(const char* defines);
void AddDefines(const std::vector<std::string>& defines);
+ std::vector<std::string> const& GetDefines() const;
+
void AddFlag(const char* flag, const char* value);
void AddFlag(const char* flag, std::vector<std::string> const& value);
void AppendFlag(std::string const& flag, std::string const& value);
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 84767a8b94..9c9296ee37 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2402,6 +2402,11 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
std::string(this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
rcOptions.Parse(flags.c_str());
+
+ // For historical reasons, add the C preprocessor defines to RC.
+ Options& clOptions = *(this->ClOptions[configName]);
+ rcOptions.AddDefines(clOptions.GetDefines());
+
this->RcOptions[configName] = pOptions.release();
return true;
}
@@ -2414,12 +2419,9 @@ void cmVisualStudio10TargetGenerator::WriteRCOptions(
}
this->WriteString("<ResourceCompile>\n", 2);
- // Preprocessor definitions and includes are shared with clOptions.
- Options& clOptions = *(this->ClOptions[configName]);
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", "RC");
-
Options& rcOptions = *(this->RcOptions[configName]);
+ rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
+ "\n", "RC");
rcOptions.AppendFlag("AdditionalIncludeDirectories", includes);
rcOptions.AppendFlag("AdditionalIncludeDirectories",
"%(AdditionalIncludeDirectories)");
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 1ca6b9cd10..abc4924107 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -1,5 +1,6 @@
#include "cmVisualStudioGeneratorOptions.h"
+#include "cmAlgorithms.h"
#include "cmLocalVisualStudioGenerator.h"
#include "cmOutputConverter.h"
#include "cmSystemTools.h"
@@ -403,8 +404,10 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
fout << prefix << tag << "=\"";
}
const char* sep = "";
+ std::vector<std::string>::const_iterator de =
+ cmRemoveDuplicates(this->Defines);
for (std::vector<std::string>::const_iterator di = this->Defines.begin();
- di != this->Defines.end(); ++di) {
+ di != de; ++di) {
// Escape the definition for the compiler.
std::string define;
if (this->Version < cmGlobalVisualStudioGenerator::VS10) {