summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2003-01-08 17:12:15 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2003-01-08 17:12:15 (GMT)
commit4d6dba4c37928026b577870e93128e55cd16a24f (patch)
treeaccd0180545ce70a9491bdf54bda9c0cdfe54e22
parent8b1d032b7beb96ba7931939bda46eb70a8434310 (diff)
downloadCMake-4d6dba4c37928026b577870e93128e55cd16a24f.zip
CMake-4d6dba4c37928026b577870e93128e55cd16a24f.tar.gz
CMake-4d6dba4c37928026b577870e93128e55cd16a24f.tar.bz2
ENH: only force the use of ansi flags in backwards mode
-rw-r--r--Modules/CMakeBackwardCompatibilityCXX.cmake4
-rw-r--r--Modules/CheckIncludeFileCXX.cmake1
-rw-r--r--Modules/TestForANSIForScope.cmake3
-rw-r--r--Modules/TestForSTDNamespace.cmake3
-rw-r--r--Source/cmTryCompileCommand.cxx21
5 files changed, 23 insertions, 9 deletions
diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake
index c11d56d..7c4554e 100644
--- a/Modules/CMakeBackwardCompatibilityCXX.cmake
+++ b/Modules/CMakeBackwardCompatibilityCXX.cmake
@@ -22,12 +22,14 @@ IF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
ENDIF(CMAKE_CXX_ACCEPTS_FLAGS)
ENDIF( CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+")
ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
-
+ SET(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIStreamHeaders.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIForScope.cmake)
CHECK_INCLUDE_FILE_CXX("sstream" CMAKE_HAS_ANSI_STRING_STREAM)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_SAVE}")
IF(NOT CMAKE_HAS_ANSI_STRING_STREAM)
SET( CMAKE_NO_ANSI_STRING_STREAM 1 CACHE INTERNAL
"Does the compiler support sstream or stringstream.")
diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake
index 75ab187..f8d7401 100644
--- a/Modules/CheckIncludeFileCXX.cmake
+++ b/Modules/CheckIncludeFileCXX.cmake
@@ -15,7 +15,6 @@ MACRO(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeTmp/CheckIncludeFile.cxx
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_ANSI_CXXFLAGS}
OUTPUT_VARIABLE OUTPUT)
IF(${VARIABLE})
MESSAGE(STATUS "Checking for CXX include file ${INCLUDE} -- found")
diff --git a/Modules/TestForANSIForScope.cmake b/Modules/TestForANSIForScope.cmake
index 0192062..12b770c 100644
--- a/Modules/TestForANSIForScope.cmake
+++ b/Modules/TestForANSIForScope.cmake
@@ -7,8 +7,7 @@
IF(NOT CMAKE_ANSI_FOR_SCOPE)
MESSAGE(STATUS "Check for ANSI scope")
TRY_COMPILE(CMAKE_ANSI_FOR_SCOPE ${CMAKE_BINARY_DIR}
- ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_ANSI_CXXFLAGS})
+ ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx)
IF (CMAKE_ANSI_FOR_SCOPE)
MESSAGE(STATUS "Check for ANSI scope - found")
SET (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL
diff --git a/Modules/TestForSTDNamespace.cmake b/Modules/TestForSTDNamespace.cmake
index 1bb8106..89e559e 100644
--- a/Modules/TestForSTDNamespace.cmake
+++ b/Modules/TestForSTDNamespace.cmake
@@ -7,8 +7,7 @@
IF(NOT CMAKE_STD_NAMESPACE)
MESSAGE(STATUS "Check for STD namespace")
TRY_COMPILE(CMAKE_STD_NAMESPACE ${CMAKE_BINARY_DIR}
- ${CMAKE_ROOT}/Modules/TestForSTDNamespace.cxx
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_ANSI_CXXFLAGS})
+ ${CMAKE_ROOT}/Modules/TestForSTDNamespace.cxx)
IF (CMAKE_STD_NAMESPACE)
MESSAGE(STATUS "Check for STD namespace - found")
SET (CMAKE_NO_STD_NAMESPACE 0 CACHE INTERNAL
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index d40996f..9a0a6ac 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -152,10 +152,25 @@ int cmTryCompileCommand::CoreTryCompileCode(
"; TRY_COMPILE only works for C and CXX files");
return -1;
}
-
+ const char* cflags = mf->GetDefinition("CMAKE_C_FLAGS");
fprintf(fout, "SET(CMAKE_VERBOSE_MAKEFILE 1)\n");
- fprintf(fout, "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} ${COMPILE_DEFINITIONS}\")\n");
- fprintf(fout, "SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${COMPILE_DEFINITIONS}\")\n");
+ fprintf(fout, "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}");
+ if(cflags)
+ {
+ fprintf(fout, " %s ", cflags);
+ }
+ fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n");
+ // CXX specific flags
+ if(format == cmSystemTools::CXX_FILE_FORMAT )
+ {
+ const char* cxxflags = mf->GetDefinition("CMAKE_CXX_FLAGS");
+ fprintf(fout, "SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ");
+ if(cxxflags)
+ {
+ fprintf(fout, " %s ", cxxflags);
+ }
+ fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n");
+ }
fprintf(fout, "INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})\n");
fprintf(fout, "LINK_DIRECTORIES(${LINK_DIRECTORIES})\n");
// handle any compile flags we need to pass on