ENH: only force the use of ansi flags in backwards mode

This commit is contained in:
Bill Hoffman 2003-01-08 12:12:15 -05:00
parent 8b1d032b7b
commit 4d6dba4c37
5 changed files with 23 additions and 9 deletions

View File

@ -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.")

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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