summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Complex/Executable/CMakeLists.txt3
-rw-r--r--Tests/Complex/Executable/complex.cxx17
-rw-r--r--Tests/Complex/Executable/testcflags.c15
-rw-r--r--Tests/ComplexOneConfig/Executable/CMakeLists.txt3
-rw-r--r--Tests/ComplexOneConfig/Executable/complex.cxx17
-rw-r--r--Tests/ComplexOneConfig/Executable/testcflags.c15
-rw-r--r--Tests/ComplexRelativePaths/Executable/CMakeLists.txt3
-rw-r--r--Tests/ComplexRelativePaths/Executable/complex.cxx17
-rw-r--r--Tests/ComplexRelativePaths/Executable/testcflags.c15
9 files changed, 102 insertions, 3 deletions
diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt
index 6c1deb5..e36dc26 100644
--- a/Tests/Complex/Executable/CMakeLists.txt
+++ b/Tests/Complex/Executable/CMakeLists.txt
@@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.3)
# Create exe.
#
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS")
+SET(CMAKE_C_FLAGS "${CMAKE_C} -DTEST_C_FLAGS")
# Link to CMake lib
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source)
@@ -14,7 +15,7 @@ SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared
LINK_LIBRARIES(${COMPLEX_LIBS})
ADD_EXECUTABLE(A A.cxx)
-ADD_EXECUTABLE(complex complex)
+ADD_EXECUTABLE(complex complex testcflags.c)
ADD_EXECUTABLE(complex.file complex.file.cxx)
TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib)
IF (UNIX)
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index 7d0cb56..a8356f1 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -258,6 +258,8 @@ void TestCMGeneratedFileSTream()
cmSystemTools::RemoveFile(file2tmp.c_str());
cmSystemTools::RemoveFile(file3tmp.c_str());
}
+// defined in testcflags.c
+extern "C" int TestCFlags(char* m);
// ======================================================================
@@ -372,6 +374,21 @@ int main()
#else
cmPassed("CMake CMAKE_CXX_FLAGS is being passed to the compiler.");
#endif
+#ifdef TEST_C_FLAGS
+ cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
+#else
+ cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
+#endif
+ char msg[1024];
+ if(TestCFlags(msg))
+ {
+ cmPassed(
+ "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not.");
+ }
+ else
+ {
+ cmFailed(msg);
+ }
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
diff --git a/Tests/Complex/Executable/testcflags.c b/Tests/Complex/Executable/testcflags.c
new file mode 100644
index 0000000..96224d4
--- /dev/null
+++ b/Tests/Complex/Executable/testcflags.c
@@ -0,0 +1,15 @@
+#include <string.h>
+int TestCFlags(char* m)
+{
+ // TEST_CXX_FLAGS should not be defined in a c file
+#ifdef TEST_CXX_FLAGS
+ strcpy(m, "CMake CMAKE_CXX_FLAGS (TEST_CXX_FLAGS) found in c file.");
+ return 0;
+#endif
+ // TEST_C_FLAGS should be defined in a c file
+#ifndef TEST_C_FLAGS
+ strcpy(m, "CMake CMAKE_C_FLAGS (TEST_C_FLAGS) not found in c file.");
+ return 0;
+#endif
+ return 1;
+}
diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
index 6c1deb5..e36dc26 100644
--- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt
@@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.3)
# Create exe.
#
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS")
+SET(CMAKE_C_FLAGS "${CMAKE_C} -DTEST_C_FLAGS")
# Link to CMake lib
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source)
@@ -14,7 +15,7 @@ SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared
LINK_LIBRARIES(${COMPLEX_LIBS})
ADD_EXECUTABLE(A A.cxx)
-ADD_EXECUTABLE(complex complex)
+ADD_EXECUTABLE(complex complex testcflags.c)
ADD_EXECUTABLE(complex.file complex.file.cxx)
TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib)
IF (UNIX)
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index 7d0cb56..a8356f1 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -258,6 +258,8 @@ void TestCMGeneratedFileSTream()
cmSystemTools::RemoveFile(file2tmp.c_str());
cmSystemTools::RemoveFile(file3tmp.c_str());
}
+// defined in testcflags.c
+extern "C" int TestCFlags(char* m);
// ======================================================================
@@ -372,6 +374,21 @@ int main()
#else
cmPassed("CMake CMAKE_CXX_FLAGS is being passed to the compiler.");
#endif
+#ifdef TEST_C_FLAGS
+ cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
+#else
+ cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
+#endif
+ char msg[1024];
+ if(TestCFlags(msg))
+ {
+ cmPassed(
+ "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not.");
+ }
+ else
+ {
+ cmFailed(msg);
+ }
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
diff --git a/Tests/ComplexOneConfig/Executable/testcflags.c b/Tests/ComplexOneConfig/Executable/testcflags.c
new file mode 100644
index 0000000..96224d4
--- /dev/null
+++ b/Tests/ComplexOneConfig/Executable/testcflags.c
@@ -0,0 +1,15 @@
+#include <string.h>
+int TestCFlags(char* m)
+{
+ // TEST_CXX_FLAGS should not be defined in a c file
+#ifdef TEST_CXX_FLAGS
+ strcpy(m, "CMake CMAKE_CXX_FLAGS (TEST_CXX_FLAGS) found in c file.");
+ return 0;
+#endif
+ // TEST_C_FLAGS should be defined in a c file
+#ifndef TEST_C_FLAGS
+ strcpy(m, "CMake CMAKE_C_FLAGS (TEST_C_FLAGS) not found in c file.");
+ return 0;
+#endif
+ return 1;
+}
diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
index 6c1deb5..e36dc26 100644
--- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
+++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt
@@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 1.3)
# Create exe.
#
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS")
+SET(CMAKE_C_FLAGS "${CMAKE_C} -DTEST_C_FLAGS")
# Link to CMake lib
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source)
@@ -14,7 +15,7 @@ SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared
LINK_LIBRARIES(${COMPLEX_LIBS})
ADD_EXECUTABLE(A A.cxx)
-ADD_EXECUTABLE(complex complex)
+ADD_EXECUTABLE(complex complex testcflags.c)
ADD_EXECUTABLE(complex.file complex.file.cxx)
TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib)
IF (UNIX)
diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx
index 7d0cb56..a8356f1 100644
--- a/Tests/ComplexRelativePaths/Executable/complex.cxx
+++ b/Tests/ComplexRelativePaths/Executable/complex.cxx
@@ -258,6 +258,8 @@ void TestCMGeneratedFileSTream()
cmSystemTools::RemoveFile(file2tmp.c_str());
cmSystemTools::RemoveFile(file3tmp.c_str());
}
+// defined in testcflags.c
+extern "C" int TestCFlags(char* m);
// ======================================================================
@@ -372,6 +374,21 @@ int main()
#else
cmPassed("CMake CMAKE_CXX_FLAGS is being passed to the compiler.");
#endif
+#ifdef TEST_C_FLAGS
+ cmFailed("CMake CMAKE_C_FLAGS are being passed to c++ files the compiler!");
+#else
+ cmPassed("CMake CMAKE_C_FLAGS are not being passed to c++ files.");
+#endif
+ char msg[1024];
+ if(TestCFlags(msg))
+ {
+ cmPassed(
+ "CMake CMAKE_C_FLAGS are being passed to c files and CXX flags are not.");
+ }
+ else
+ {
+ cmFailed(msg);
+ }
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
diff --git a/Tests/ComplexRelativePaths/Executable/testcflags.c b/Tests/ComplexRelativePaths/Executable/testcflags.c
new file mode 100644
index 0000000..96224d4
--- /dev/null
+++ b/Tests/ComplexRelativePaths/Executable/testcflags.c
@@ -0,0 +1,15 @@
+#include <string.h>
+int TestCFlags(char* m)
+{
+ // TEST_CXX_FLAGS should not be defined in a c file
+#ifdef TEST_CXX_FLAGS
+ strcpy(m, "CMake CMAKE_CXX_FLAGS (TEST_CXX_FLAGS) found in c file.");
+ return 0;
+#endif
+ // TEST_C_FLAGS should be defined in a c file
+#ifndef TEST_C_FLAGS
+ strcpy(m, "CMake CMAKE_C_FLAGS (TEST_C_FLAGS) not found in c file.");
+ return 0;
+#endif
+ return 1;
+}