summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-03-23 18:48:09 (GMT)
committerBrad King <brad.king@kitware.com>2009-03-23 18:48:09 (GMT)
commit4085454658d9af9c2cfb58b67ff2434692887a30 (patch)
treed164217623a7d33569a807d9123565262e077f3a
parent10a91d8467d10fcf9cf9eaa2a05e9ea6fcc87614 (diff)
downloadCMake-4085454658d9af9c2cfb58b67ff2434692887a30.zip
CMake-4085454658d9af9c2cfb58b67ff2434692887a30.tar.gz
CMake-4085454658d9af9c2cfb58b67ff2434692887a30.tar.bz2
ENH: Support preprocessor def values in VS6
The add_definitions() command and COMPILE_DEFINITIONS dir/tgt/src properties support preprocessor definitions with values. Previously values were not supported in the VS6 generator even though the native tool supports them. It is only values with spaces that VS6 does not support. This enables support and instead complains only for values with spaces. See issue #8779.
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx6
-rw-r--r--Source/cmMakefile.cxx6
-rw-r--r--Source/cmSourceFile.cxx2
-rw-r--r--Source/cmTarget.cxx2
-rw-r--r--Tests/Preprocess/CMakeLists.txt63
-rw-r--r--Tests/Preprocess/preprocess.c2
-rw-r--r--Tests/Preprocess/preprocess.cxx2
7 files changed, 42 insertions, 41 deletions
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 3493719..8ecfa0d 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -1712,11 +1712,11 @@ cmLocalVisualStudio6Generator
}
// Now do the VS6-specific check.
- if(define.find_first_of("=") != define.npos)
+ if(define.find_first_of(" ") != define.npos)
{
cmOStringStream e;
- e << "WARNING: The VS6 IDE does not support preprocessor definitions "
- << "with values.\n"
+ e << "WARNING: The VS6 IDE does not support preprocessor definition "
+ << "values with spaces.\n"
<< "CMake is dropping a preprocessor definition: " << define << "\n"
<< "Consider defining the macro in a (configured) header file.\n";
cmSystemTools::Message(e.str().c_str());
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 69d58ba..a0b536b 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1216,10 +1216,10 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
return false;
}
- // VS6 IDE does not support definitions with values.
+ // VS6 IDE does not support definition values with spaces.
if((strcmp(this->LocalGenerator->GetGlobalGenerator()->GetName(),
"Visual Studio 6") == 0) &&
- (def.find("=") != def.npos))
+ (def.find(" ") != def.npos))
{
return false;
}
@@ -3475,7 +3475,7 @@ void cmMakefile::DefineProperties(cmake *cm)
"in the directory's parent.\n"
"CMake will automatically drop some definitions that "
"are not supported by the native build tool. "
- "The VS6 IDE does not support definitions with values "
+ "The VS6 IDE does not support definition values with spaces "
"(but NMake does).\n"
"Dislaimer: Most native build tools have poor support for escaping "
"certain values. CMake has work-arounds for many cases but some "
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 8603d98..cb7777c 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -405,7 +405,7 @@ void cmSourceFile::DefineProperties(cmake *cm)
"(ex. \"COMPILE_DEFINITIONS_DEBUG\").\n"
"CMake will automatically drop some definitions that "
"are not supported by the native build tool. "
- "The VS6 IDE does not support definitions with values "
+ "The VS6 IDE does not support definition values with spaces "
"(but NMake does). Xcode does not support per-configuration "
"definitions on source files.\n"
"Dislaimer: Most native build tools have poor support for escaping "
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 6b6635d..a640b0d 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -108,7 +108,7 @@ void cmTarget::DefineProperties(cmake *cm)
"(ex. \"COMPILE_DEFINITIONS_DEBUG\").\n"
"CMake will automatically drop some definitions that "
"are not supported by the native build tool. "
- "The VS6 IDE does not support definitions with values "
+ "The VS6 IDE does not support definition values with spaces "
"(but NMake does).\n"
"Dislaimer: Most native build tools have poor support for escaping "
"certain values. CMake has work-arounds for many cases but some "
diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt
index fa9a109..bb33907 100644
--- a/Tests/Preprocess/CMakeLists.txt
+++ b/Tests/Preprocess/CMakeLists.txt
@@ -65,14 +65,20 @@ if(NOT BORLAND AND NOT PP_VS70)
set(SEMICOLON "\;")
endif(NOT BORLAND AND NOT PP_VS70)
-if(NOT PP_BORLAND AND NOT PP_WATCOM)
- # Borland, WMake: multiple spaces
- # The make tool seems to remove extra whitespace from inside
- # quoted strings when passing to the compiler. It does not have
- # trouble passing to other tools, and the compiler may be directly
- # invoked from the command line.
- set(STRING_EXTRA "${STRING_EXTRA} ")
-endif(NOT PP_BORLAND AND NOT PP_WATCOM)
+if(NOT PP_VS6)
+ # VS 6 IDE: spaces
+ # The project parser unconditionally separates arguments at spaces.
+ set(STRING_EXTRA "${STRING_EXTRA} ")
+
+ if(NOT PP_BORLAND AND NOT PP_WATCOM)
+ # Borland, WMake: multiple spaces
+ # The make tool seems to remove extra whitespace from inside
+ # quoted strings when passing to the compiler. It does not have
+ # trouble passing to other tools, and the compiler may be directly
+ # invoked from the command line.
+ set(STRING_EXTRA "${STRING_EXTRA} ")
+ endif(NOT PP_BORLAND AND NOT PP_WATCOM)
+endif(NOT PP_VS6)
if(NOT PP_VS)
# VS: ,
@@ -152,7 +158,7 @@ endif(PP_NMAKE OR PP_UMAKE)
# support it and it is not an operator it is not worthwhile.
# Compose the final test string.
-set(STRING_VALUE "hello `~!@$*)(_+-=}{][:'.?/ ${STRING_EXTRA}world")
+set(STRING_VALUE "hello`~!@$*)(_+-=}{][:'.?/${STRING_EXTRA}world")
#-----------------------------------------------------------------------------
# Function-style macro command-line support:
@@ -194,11 +200,7 @@ endif(PP_VS6)
add_definitions(-DOLD_DEF -DOLD_EXPR=2)
# Make sure old-style definitions are converted to directory property.
-if(PREPROCESS_VS6)
- set(OLD_DEFS_EXPECTED "OLD_DEF")
-else(PREPROCESS_VS6)
- set(OLD_DEFS_EXPECTED "OLD_DEF;OLD_EXPR=2")
-endif(PREPROCESS_VS6)
+set(OLD_DEFS_EXPECTED "OLD_DEF;OLD_EXPR=2")
get_property(OLD_DEFS DIRECTORY PROPERTY COMPILE_DEFINITIONS)
if(NOT "${OLD_DEFS}" STREQUAL "${OLD_DEFS_EXPECTED}")
message(SEND_ERROR "add_definitions not converted to directory property!")
@@ -225,23 +227,26 @@ foreach(c "" "_DEBUG" "_RELEASE")
)
endforeach(c)
-# Add definitions with values. VS6 does not support this.
+# Add definitions with values.
if(NOT PREPROCESS_VS6)
- set_property(
- TARGET Preprocess
- APPEND PROPERTY COMPILE_DEFINITIONS
- "TARGET_STRING=\"${STRING_VALUE}${SEMICOLON}\""
- "TARGET_EXPR=${EXPR}"
- "TARGET_PATH=\"${TARGET_PATH}\""
- )
- set_property(
- SOURCE preprocess.c preprocess${VS6}.cxx
- APPEND PROPERTY COMPILE_DEFINITIONS
- "FILE_STRING=\"${STRING_VALUE}${SEMICOLON}\""
- "FILE_EXPR=${EXPR}"
- "FILE_PATH=\"${FILE_PATH}\""
- )
+ # The path might have spaces, which VS6 does not support.
+ set(DEF_TARGET_PATH "TARGET_PATH=\"${TARGET_PATH}\"")
+ set(DEF_FILE_PATH "FILE_PATH=\"${FILE_PATH}\"")
endif(NOT PREPROCESS_VS6)
+set_property(
+ TARGET Preprocess
+ APPEND PROPERTY COMPILE_DEFINITIONS
+ "TARGET_STRING=\"${STRING_VALUE}${SEMICOLON}\""
+ "TARGET_EXPR=${EXPR}"
+ ${DEF_TARGET_PATH}
+ )
+set_property(
+ SOURCE preprocess.c preprocess${VS6}.cxx
+ APPEND PROPERTY COMPILE_DEFINITIONS
+ "FILE_STRING=\"${STRING_VALUE}${SEMICOLON}\""
+ "FILE_EXPR=${EXPR}"
+ ${DEF_FILE_PATH}
+ )
# Helper target for running test manually in build tree.
add_custom_target(drive COMMAND Preprocess)
diff --git a/Tests/Preprocess/preprocess.c b/Tests/Preprocess/preprocess.c
index 5dd9003..16209ac 100644
--- a/Tests/Preprocess/preprocess.c
+++ b/Tests/Preprocess/preprocess.c
@@ -9,7 +9,6 @@
int check_defines_C(void)
{
int result = 1;
-#ifndef PREPROCESS_VS6
if(strcmp(FILE_STRING, STRING_VALUE) != 0)
{
fprintf(stderr,
@@ -38,7 +37,6 @@ int check_defines_C(void)
result = 0;
}
}
-#endif
#ifdef NDEBUG
# ifdef FILE_DEF_DEBUG
{
diff --git a/Tests/Preprocess/preprocess.cxx b/Tests/Preprocess/preprocess.cxx
index 628521f..27b6ac8 100644
--- a/Tests/Preprocess/preprocess.cxx
+++ b/Tests/Preprocess/preprocess.cxx
@@ -11,7 +11,6 @@ extern "C" int check_defines_C(void);
int check_defines_CXX()
{
int result = 1;
-#ifndef PREPROCESS_VS6
if(strcmp(FILE_STRING, STRING_VALUE) != 0)
{
fprintf(stderr,
@@ -40,7 +39,6 @@ int check_defines_CXX()
result = 0;
}
}
-#endif
#ifdef NDEBUG
# ifdef FILE_DEF_DEBUG
{