summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx10
-rw-r--r--Source/cmGlobalXCodeGenerator.h3
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx4
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx6
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx10
-rw-r--r--Tests/Complex/Executable/CMakeLists.txt2
-rw-r--r--Tests/Complex/Executable/complex.cxx20
-rw-r--r--Tests/Complex/Executable/testcflags.c11
-rw-r--r--Tests/ComplexOneConfig/Executable/CMakeLists.txt2
-rw-r--r--Tests/ComplexOneConfig/Executable/complex.cxx20
-rw-r--r--Tests/ComplexOneConfig/Executable/testcflags.c11
-rw-r--r--Tests/ComplexRelativePaths/Executable/CMakeLists.txt2
-rw-r--r--Tests/ComplexRelativePaths/Executable/complex.cxx20
-rw-r--r--Tests/ComplexRelativePaths/Executable/testcflags.c11
14 files changed, 114 insertions, 18 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 9a2af69..0879224 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -466,12 +466,16 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObjectReference(cmXCodeObject* ref)
//----------------------------------------------------------------------------
cmXCodeObject*
cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
- cmSourceFile* sf)
+ cmSourceFile* sf,
+ cmTarget& cmtarget)
{
std::string flags;
// Add flags from source file properties.
+ if(cmtarget.GetProperty("COMPILE_FLAGS"))
+ {
+ lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS"));
+ }
lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS"));
-
cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
cmXCodeObject* group = m_GroupMap[sf];
@@ -650,7 +654,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
i != classes.end(); ++i)
{
cmXCodeObject* xsf =
- this->CreateXCodeSourceFile(m_CurrentLocalGenerator, *i);
+ this->CreateXCodeSourceFile(m_CurrentLocalGenerator, *i, cmtarget);
cmXCodeObject* fr = xsf->GetObject("fileRef");
cmXCodeObject* filetype =
fr->GetObject()->GetObject("lastKnownFileType");
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 9cea343..aafacc6 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -124,7 +124,8 @@ private:
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
- cmSourceFile* sf);
+ cmSourceFile* sf,
+ cmTarget& cmtarget);
void CreateXCodeTargets(cmLocalGenerator* gen, std::vector<cmXCodeObject*>&);
void AddDependTarget(cmXCodeObject* target,
cmXCodeObject* dependTarget);
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 8d4c46b..5b15e96 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -617,6 +617,10 @@ cmLocalUnixMakefileGenerator3
// Write the build rule.
// Build the set of compiler flags.
std::string flags;
+ if(target.GetProperty("COMPILE_FLAGS"))
+ {
+ this->AppendFlags(flags, target.GetProperty("COMPILE_FLAGS"));
+ }
// Add flags from source file properties.
if (source.GetProperty("COMPILE_FLAGS"))
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 054a782..54f8324 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -405,6 +405,12 @@ void cmLocalVisualStudio6Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
{
compileFlags = cflags;
}
+ if(target.GetProperty("COMPILE_FLAGS"))
+ {
+ compileFlags += " ";
+ compileFlags += target.GetProperty("COMPILE_FLAGS");
+ }
+
const char* lang =
m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
if(lang && strcmp(lang, "CXX") == 0)
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 8578588..466154d 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1036,11 +1036,17 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
std::string additionalDeps;
// Check for extra compiler flags.
+ if(target.GetProperty("COMPILE_FLAGS"))
+ {
+ compileFlags += " ";
+ compileFlags += target.GetProperty("COMPILE_FLAGS");
+ }
const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
if(cflags)
{
- compileFlags = cflags;
- }
+ compileFlags += " ";
+ compileFlags += cflags;
+ }
const char* lang =
m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
if(lang && strcmp(lang, "CXX") == 0)
diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt
index 0f5add9..768e0fa 100644
--- a/Tests/Complex/Executable/CMakeLists.txt
+++ b/Tests/Complex/Executable/CMakeLists.txt
@@ -56,7 +56,7 @@ SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
)
-
+SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG")
ADD_CUSTOM_COMMAND(
TARGET complex
SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index 06af8ec..f7f8d53 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -272,6 +272,7 @@ void ForceStringUse()
// defined in testcflags.c
extern "C" int TestCFlags(char* m);
+extern "C" int TestTargetCompileFlags(char* m);
// ======================================================================
@@ -387,7 +388,12 @@ int main()
{
cmPassed("Call to file1 function returned 1.");
}
-
+#ifndef COMPLEX_TARGET_FLAG
+ cmFailed("COMPILE_FLAGS did not work with SET_TARGET_PROPERTIES");
+#else
+ cmPassed("COMPILE_FLAGS did work with SET_TARGET_PROPERTIES");
+#endif
+
if(file2() != 1)
{
cmFailed("Call to file2 function from library failed.");
@@ -403,6 +409,7 @@ int main()
#endif
std::string gen = CMAKE_GENERATOR;
// visual studio is currently broken for c flags
+ char msg[1024];
if(gen.find("Visual") == gen.npos)
{
#ifdef TEST_C_FLAGS
@@ -410,7 +417,6 @@ int main()
#else
cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
#endif
- char msg[1024];
if(TestCFlags(msg))
{
cmPassed(
@@ -421,7 +427,15 @@ int main()
cmFailed(msg);
}
}
-
+ if(TestTargetCompileFlags(msg))
+ {
+ cmPassed(msg);
+ }
+ else
+ {
+ cmFailed(msg);
+ }
+
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
diff --git a/Tests/Complex/Executable/testcflags.c b/Tests/Complex/Executable/testcflags.c
index 6c692f3..f4d5848 100644
--- a/Tests/Complex/Executable/testcflags.c
+++ b/Tests/Complex/Executable/testcflags.c
@@ -1,4 +1,15 @@
#include <string.h>
+
+int TestTargetCompileFlags(char* m)
+{
+#ifndef COMPLEX_TARGET_FLAG
+ strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS did not work");
+ return 0;
+#endif
+ strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS worked");
+ return 1;
+}
+
int TestCFlags(char* m)
{
/* TEST_CXX_FLAGS should not be defined in a c file */
diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
index 0f5add9..768e0fa 100644
--- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
@@ -56,7 +56,7 @@ SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
)
-
+SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG")
ADD_CUSTOM_COMMAND(
TARGET complex
SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index 06af8ec..f7f8d53 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -272,6 +272,7 @@ void ForceStringUse()
// defined in testcflags.c
extern "C" int TestCFlags(char* m);
+extern "C" int TestTargetCompileFlags(char* m);
// ======================================================================
@@ -387,7 +388,12 @@ int main()
{
cmPassed("Call to file1 function returned 1.");
}
-
+#ifndef COMPLEX_TARGET_FLAG
+ cmFailed("COMPILE_FLAGS did not work with SET_TARGET_PROPERTIES");
+#else
+ cmPassed("COMPILE_FLAGS did work with SET_TARGET_PROPERTIES");
+#endif
+
if(file2() != 1)
{
cmFailed("Call to file2 function from library failed.");
@@ -403,6 +409,7 @@ int main()
#endif
std::string gen = CMAKE_GENERATOR;
// visual studio is currently broken for c flags
+ char msg[1024];
if(gen.find("Visual") == gen.npos)
{
#ifdef TEST_C_FLAGS
@@ -410,7 +417,6 @@ int main()
#else
cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
#endif
- char msg[1024];
if(TestCFlags(msg))
{
cmPassed(
@@ -421,7 +427,15 @@ int main()
cmFailed(msg);
}
}
-
+ if(TestTargetCompileFlags(msg))
+ {
+ cmPassed(msg);
+ }
+ else
+ {
+ cmFailed(msg);
+ }
+
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
diff --git a/Tests/ComplexOneConfig/Executable/testcflags.c b/Tests/ComplexOneConfig/Executable/testcflags.c
index 6c692f3..f4d5848 100644
--- a/Tests/ComplexOneConfig/Executable/testcflags.c
+++ b/Tests/ComplexOneConfig/Executable/testcflags.c
@@ -1,4 +1,15 @@
#include <string.h>
+
+int TestTargetCompileFlags(char* m)
+{
+#ifndef COMPLEX_TARGET_FLAG
+ strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS did not work");
+ return 0;
+#endif
+ strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS worked");
+ return 1;
+}
+
int TestCFlags(char* m)
{
/* TEST_CXX_FLAGS should not be defined in a c file */
diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
index 0f5add9..768e0fa 100644
--- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
@@ -56,7 +56,7 @@ SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS"
OBJECT_DEPENDS ${Complex_BINARY_DIR}/cmTestGeneratedHeader.h
)
-
+SET_TARGET_PROPERTIES(complex PROPERTIES COMPILE_FLAGS "-DCOMPLEX_TARGET_FLAG")
ADD_CUSTOM_COMMAND(
TARGET complex
SOURCE ${Complex_SOURCE_DIR}/cmTestGeneratedHeader.h.in
diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx
index 06af8ec..f7f8d53 100644
--- a/Tests/ComplexRelativePaths/Executable/complex.cxx
+++ b/Tests/ComplexRelativePaths/Executable/complex.cxx
@@ -272,6 +272,7 @@ void ForceStringUse()
// defined in testcflags.c
extern "C" int TestCFlags(char* m);
+extern "C" int TestTargetCompileFlags(char* m);
// ======================================================================
@@ -387,7 +388,12 @@ int main()
{
cmPassed("Call to file1 function returned 1.");
}
-
+#ifndef COMPLEX_TARGET_FLAG
+ cmFailed("COMPILE_FLAGS did not work with SET_TARGET_PROPERTIES");
+#else
+ cmPassed("COMPILE_FLAGS did work with SET_TARGET_PROPERTIES");
+#endif
+
if(file2() != 1)
{
cmFailed("Call to file2 function from library failed.");
@@ -403,6 +409,7 @@ int main()
#endif
std::string gen = CMAKE_GENERATOR;
// visual studio is currently broken for c flags
+ char msg[1024];
if(gen.find("Visual") == gen.npos)
{
#ifdef TEST_C_FLAGS
@@ -410,7 +417,6 @@ int main()
#else
cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
#endif
- char msg[1024];
if(TestCFlags(msg))
{
cmPassed(
@@ -421,7 +427,15 @@ int main()
cmFailed(msg);
}
}
-
+ if(TestTargetCompileFlags(msg))
+ {
+ cmPassed(msg);
+ }
+ else
+ {
+ cmFailed(msg);
+ }
+
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
diff --git a/Tests/ComplexRelativePaths/Executable/testcflags.c b/Tests/ComplexRelativePaths/Executable/testcflags.c
index 6c692f3..f4d5848 100644
--- a/Tests/ComplexRelativePaths/Executable/testcflags.c
+++ b/Tests/ComplexRelativePaths/Executable/testcflags.c
@@ -1,4 +1,15 @@
#include <string.h>
+
+int TestTargetCompileFlags(char* m)
+{
+#ifndef COMPLEX_TARGET_FLAG
+ strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS did not work");
+ return 0;
+#endif
+ strcpy(m, "CMAKE SET_TARGET_PROPERTIES COMPILE_FLAGS worked");
+ return 1;
+}
+
int TestCFlags(char* m)
{
/* TEST_CXX_FLAGS should not be defined in a c file */