fix for cmake flag detection, was not caching the resulting variable so the test...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 21 Dec 2010 03:32:51 +0000 (03:32 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 21 Dec 2010 03:32:51 +0000 (03:32 +0000)
also cache SSE, SSE2 checks.

CMakeLists.txt
build_files/cmake/macros.cmake

index 89ee0707280be0e02707ae19f660b92d16d4cc15..cc6715f8237f612695e1d80cba5a3a881d515e60 100644 (file)
@@ -962,6 +962,9 @@ if(WITH_OPENMP)
        else()
                set(WITH_OPENMP OFF)
        endif()
+
+       mark_as_advanced(OpenMP_C_FLAGS)
+       mark_as_advanced(OpenMP_CXX_FLAGS)
 endif() 
 
 #-----------------------------------------------------------------------------
@@ -984,32 +987,32 @@ endif()
 
 if(CMAKE_COMPILER_IS_GNUCC)
 
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wall)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wcast-align)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wdeclaration-after-statement)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Werror=declaration-after-statement)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Werror=implicit-function-declaration)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Werror=return-type)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Werror=strict-prototypes)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wno-char-subscripts)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wno-unknown-pragmas)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wpointer-arith)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wunused-parameter)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wwrite-strings)
-
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS -Wall)
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS -Wno-invalid-offsetof)
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS -Wno-sign-compare)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DECLARATION_AFTER_STATEMENT -Wdeclaration-after-statement)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_STRICT_PROTOTYPES -Werror=strict-prototypes)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
+
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
 
 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
 
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wall)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wpointer-arith)
-       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS -Wno-unknown-pragmas)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
 
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS -Wall)
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS -Wno-invalid-offsetof)
-       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS -Wno-sign-compare)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
 
 endif()
 
index ff8baa544b87c683f487a89706b3c828822c5718..00a64893e9fa60fa12320bedf12956a6178c7384 100644 (file)
@@ -212,27 +212,32 @@ macro(TEST_SSE_SUPPORT)
                set(CMAKE_REQUIRED_FLAGS "/arch:SSE2") # TODO, SSE 1 ?
        endif()
 
-       check_c_source_runs("
-               #include <xmmintrin.h>
-               int main() { __m128 v = _mm_setzero_ps(); return 0; }"
-       SUPPORT_SSE_BUILD)
-
-       check_c_source_runs("
-               #include <emmintrin.h>
-               int main() { __m128d v = _mm_setzero_pd(); return 0; }"
-       SUPPORT_SSE2_BUILD)
-       # message(STATUS "Detecting SSE support")
+       if(NOT DEFINED ${SUPPORT_SSE_BUILD})
+               check_c_source_runs("
+                       #include <xmmintrin.h>
+                       int main() { __m128 v = _mm_setzero_ps(); return 0; }"
+               SUPPORT_SSE_BUILD)
+               
+               if(SUPPORT_SSE_BUILD)
+                       message(STATUS "SSE Support: detected.")
+               else()
+                       message(STATUS "SSE Support: missing.")
+               endif()
+               set(${SUPPORT_SSE_BUILD} ${SUPPORT_SSE_BUILD} CACHE INTERNAL "SSE Test")
+       endif() 
 
-       if(SUPPORT_SSE_BUILD)
-               message(STATUS "SSE Support: detected.")
-       else()
-               message(STATUS "SSE Support: missing.")
-       endif()
+       if(NOT DEFINED ${SUPPORT_SSE2_BUILD})
+               check_c_source_runs("
+                       #include <emmintrin.h>
+                       int main() { __m128d v = _mm_setzero_pd(); return 0; }"
+               SUPPORT_SSE2_BUILD)
 
-       if(SUPPORT_SSE2_BUILD)
-               message(STATUS "SSE2 Support: detected.")
-       else()
-               message(STATUS "SSE2 Support: missing.")
+               if(SUPPORT_SSE2_BUILD)
+                       message(STATUS "SSE2 Support: detected.")
+               else()
+                       message(STATUS "SSE2 Support: missing.")
+               endif() 
+               set(${SUPPORT_SSE2_BUILD} ${SUPPORT_SSE2_BUILD} CACHE INTERNAL "SSE2 Test")
        endif()
 
 endmacro()
@@ -276,7 +281,7 @@ macro(remove_strict_flags)
 endmacro()
 
 
-# XXX, until cmake fix this bug! from CheckCCompilerFlag.cmakem reported 11615
+# XXX, until cmake 2.8.4 is released.
 INCLUDE(CheckCSourceCompiles)
 MACRO (CHECK_C_COMPILER_FLAG__INTERNAL _FLAG _RESULT)
    SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
@@ -295,14 +300,13 @@ ENDMACRO (CHECK_C_COMPILER_FLAG__INTERNAL)
 
 macro(ADD_CHECK_C_COMPILER_FLAG
        _CFLAGS
+       _CACHE_VAR
        _FLAG)
 
        # include(CheckCCompilerFlag)
 
-       # odd workaround
-       set(CFLAG_TEST "CFLAG_TEST")
-       CHECK_C_COMPILER_FLAG__INTERNAL("${_FLAG}" CFLAG_TEST)
-       if(CFLAG_TEST)
+       CHECK_C_COMPILER_FLAG__INTERNAL("${_FLAG}" "${_CACHE_VAR}")
+       if(${_CACHE_VAR})
                # message(STATUS "Using CFLAG: ${_FLAG}")
                set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}")
        else()
@@ -312,14 +316,13 @@ endmacro()
 
 macro(ADD_CHECK_CXX_COMPILER_FLAG
        _CXXFLAGS
+       _CACHE_VAR
        _FLAG)
 
        include(CheckCXXCompilerFlag)
 
-       # odd workaround
-       set(CFLAG_TEST "CXXFLAG_TEST")
-       CHECK_CXX_COMPILER_FLAG("${_FLAG}" CXXFLAG_TEST)
-       if(CXXFLAG_TEST)
+       CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
+       if(${_CACHE_VAR})
                # message(STATUS "Using CXXFLAG: ${_FLAG}")
                set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}")
        else()