diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2002-11-21 17:52:54 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2002-11-21 17:52:54 (GMT) |
commit | 9a6c95fcea52bd1b5b4930fdac0a48088e55273b (patch) | |
tree | 25daf13b3701dcedcd1210e79dfcae42946a6043 /Modules | |
parent | b8a1b1e9e7adcc69d26d6fefaf6da059580afdba (diff) | |
download | CMake-9a6c95fcea52bd1b5b4930fdac0a48088e55273b.zip CMake-9a6c95fcea52bd1b5b4930fdac0a48088e55273b.tar.gz CMake-9a6c95fcea52bd1b5b4930fdac0a48088e55273b.tar.bz2 |
add checks for ansi flags and not hard code them
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeBackwardCompatibilityCXX.cmake | 23 | ||||
-rw-r--r-- | Modules/DummyCXXFile.cxx | 4 | ||||
-rw-r--r-- | Modules/Platform/IRIX64.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/OSF1.cmake | 3 | ||||
-rw-r--r-- | Modules/TestCXXAcceptsFlag.cmake | 20 |
5 files changed, 47 insertions, 4 deletions
diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index a8e4424..ccc2e33 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake @@ -1,4 +1,27 @@ # + +# check for some ANSI flags in the CXX compiler if it is not gnu +IF(NOT CMAKE_COMPILER_IS_GNUCXX) + INCLUDE(${CMAKE_ROOT}/Modules/TestCXXAcceptFlag.cmake) + SET(CMAKE_TRY_ANSI_CXX_FLAGS "") + IF(CMAKE_SYSTEM MATCHES "IRIX.*") + SET(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std") + ENDIF(CMAKE_SYSTEM MATCHES "IRIX.*") + IF(CMAKE_SYSTEM MATCHES "OSF.*") + SET(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname") + ENDIF(CMAKE_SYSTEM MATCHES "OSF.*") + # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see + # if the compiler accepts it + IF( CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+") + CHECK_CXX_ACCEPTS_FLAG(${CMAKE_TRY_ANSI_CXX_FLAGS} CMAKE_CXX_ACCEPTS_FLAGS) + # if the compiler liked the flag then set CMAKE_ANSI_CXXFLAGS + # to the flag + IF(CMAKE_CXX_ACCEPTS_FLAGS) + SET(CMAKE_ANSI_CXXFLAGS ${CMAKE_TRY_ANSI_CXX_FLAGS}) + ENDIF(CMAKE_CXX_ACCEPTS_FLAGS) + ENDIF( CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+") +ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) + INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIStreamHeaders.cmake) INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake) INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake) diff --git a/Modules/DummyCXXFile.cxx b/Modules/DummyCXXFile.cxx new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Modules/DummyCXXFile.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Modules/Platform/IRIX64.cmake b/Modules/Platform/IRIX64.cmake index 0caf9ab..8f78f02 100644 --- a/Modules/Platform/IRIX64.cmake +++ b/Modules/Platform/IRIX64.cmake @@ -6,7 +6,6 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP "") # : or empty IF(NOT CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -ar -o <TARGET> <OBJECTS>") - SET(CMAKE_ANSI_CXXFLAGS -LANG:std) SET (CMAKE_CXX_FLAGS_INIT "") SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g") SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O3") diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake index 188045e..08be310 100644 --- a/Modules/Platform/OSF1.cmake +++ b/Modules/Platform/OSF1.cmake @@ -21,6 +21,3 @@ IF(CMAKE_SYSTEM MATCHES "OSF1-V.*") SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") -IF(NOT CMAKE_COMPILER_IS_GNUCXX) - SET(CMAKE_ANSI_CXXFLAGS "-std strict_ansi -nopure_cname") -ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake new file mode 100644 index 0000000..1c6f351 --- /dev/null +++ b/Modules/TestCXXAcceptsFlag.cmake @@ -0,0 +1,20 @@ +# +# Check if the CXX compiler accepts a flag +# +# CHECK_FUNCTION_EXISTS - macro which checks if the function exists +# FLAG - the flags to try +# VARIABLE - variable to store the result +# + +MACRO(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE) + MESSAGE(STATUS "Checking to see if CXX compiler acepts flag ${FLAGS}") + TRY_COMPILE(${VARIABLE} + ${PROJECT_BINARY_DIR} + ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS} + OUTPUT_VARIABLE OUTPUT) + IF(NOT ${VARIABLE}) + WRITE_FILE(${PROJECT_BINARY_DIR}/CMakeError.log + "Determining if the CXX compiler accepts the flag ${FLAGS} failed with the following output:\n" "${OUTPUT}\n" APPEND) + ENDIF(NOT ${VARIABLE}) +ENDMACRO(CHECK_CXX_ACCEPTS_FLAG) |