add checks for ansi flags and not hard code them
This commit is contained in:
parent
b8a1b1e9e7
commit
9a6c95fcea
|
@ -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/TestForANSIStreamHeaders.cmake)
|
||||||
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
|
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
|
||||||
INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)
|
INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -6,7 +6,6 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP "") # : or empty
|
||||||
IF(NOT CMAKE_COMPILER_IS_GNUCXX)
|
IF(NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||||
SET(CMAKE_CXX_CREATE_STATIC_LIBRARY
|
SET(CMAKE_CXX_CREATE_STATIC_LIBRARY
|
||||||
"<CMAKE_CXX_COMPILER> -ar -o <TARGET> <OBJECTS>")
|
"<CMAKE_CXX_COMPILER> -ar -o <TARGET> <OBJECTS>")
|
||||||
SET(CMAKE_ANSI_CXXFLAGS -LANG:std)
|
|
||||||
SET (CMAKE_CXX_FLAGS_INIT "")
|
SET (CMAKE_CXX_FLAGS_INIT "")
|
||||||
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
|
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
|
||||||
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O3")
|
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O3")
|
||||||
|
|
|
@ -21,6 +21,3 @@ IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
|
||||||
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":")
|
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":")
|
||||||
ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
|
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)
|
|
||||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue