cmake:
authorCampbell Barton <ideasman42@gmail.com>
Sat, 1 Oct 2011 19:52:33 +0000 (19:52 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 1 Oct 2011 19:52:33 +0000 (19:52 +0000)
- fix for cmake's SSE detection which would fail because of strict warnings and also had redundant cache setting.
- was incorrectly initializing variables (own bad)
- python was searching for libs on every run, now only do this if there not cached.

CMakeLists.txt
build_files/cmake/Modules/FindPythonLibsUnix.cmake
build_files/cmake/macros.cmake
source/blender/blenfont/CMakeLists.txt

index 1b65c88..69d6bd5 100644 (file)
@@ -287,7 +287,7 @@ endif()
 set(WITH_BINRELOC OFF)
 
 # MAXOSX only, set to avoid uninitialized
-set(EXETYPE)
+set(EXETYPE "")
 
 # C/C++ flags
 set(PLATFORM_CFLAGS)
@@ -298,13 +298,13 @@ set(CXX_WARNINGS)
 
 # libraries to link the binary with passed to target_link_libraries()
 # known as LLIBS to scons
-set(PLATFORM_LINKLIBS)
+set(PLATFORM_LINKLIBS "")
 
 # Added to linker flags in setup_liblinks
 # - CMAKE_EXE_LINKER_FLAGS
 # - CMAKE_EXE_LINKER_FLAGS_DEBUG
-set(PLATFORM_LINKFLAGS)
-set(PLATFORM_LINKFLAGS_DEBUG)
+set(PLATFORM_LINKFLAGS "")
+set(PLATFORM_LINKFLAGS_DEBUG "")
 
 
 # disabled for now, not supported
@@ -436,7 +436,7 @@ if(UNIX AND NOT APPLE)
                )
 
                if(INTL_LIBRARY AND ICONV_LIBRARY)
-                       set(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
+                       set(GETTEXT_LIBRARIES ${INTL_LIBRARY} ${ICONV_LIBRARY})
                endif()
        endif()
 
@@ -645,9 +645,9 @@ elseif(WIN32)
 
                if(WITH_INTERNATIONAL)
                        set(GETTEXT ${LIBDIR}/gettext)
-                       set(GETTEXT_INC ${GETTEXT}/include)
+                       set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
                        set(GETTEXT_LIBPATH ${GETTEXT}/lib)
-                       set(GETTEXT_LIB gnu_gettext)
+                       set(GETTEXT_LIBRARIES gnu_gettext)
                endif()
 
                if(CMAKE_CL_64)
@@ -745,7 +745,7 @@ elseif(WIN32)
                        set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC})
                        set(OPENEXR_INCLUDE_DIRS
                                ${OPENEXR_INCUDE}
-                               ${OPENEXR_INCUDE}/IlmImf
+                               ${OPENEXR_INCUDE}/IlmImf
                                ${OPENEXR_INCUDE}/Iex
                                ${OPENEXR_INCUDE}/Imath
                        )
@@ -804,9 +804,9 @@ elseif(WIN32)
 
                if(WITH_INTERNATIONAL)
                        set(GETTEXT ${LIBDIR}/gcc/gettext)
-                       set(GETTEXT_INC ${GETTEXT}/include)
+                       set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
                        set(GETTEXT_LIBPATH ${GETTEXT}/lib)
-                       set(GETTEXT_LIB intl)
+                       set(GETTEXT_LIBRARIES intl)
                endif()
 
                set(JPEG_LIBRARIES libjpeg)
@@ -956,8 +956,8 @@ elseif(APPLE)
 
        if(WITH_INTERNATIONAL)
                set(GETTEXT ${LIBDIR}/gettext)
-               set(GETTEXT_INC "${GETTEXT}/include")
-               set(GETTEXT_LIB intl iconv)
+               set(GETTEXT_INCLUDE_DIRS "${GETTEXT}/include")
+               set(GETTEXT_LIBRARIES intl iconv)
                set(GETTEXT_LIBPATH ${GETTEXT}/lib)
        endif()
 
index 882f1e2..fd5d209 100644 (file)
@@ -34,67 +34,71 @@ IF(NOT PYTHON_ROOT_DIR AND NOT $ENV{PYTHON_ROOT_DIR} STREQUAL "")
   SET(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR})
 ENDIF()
 
-IF(DEFINED PYTHON_VERSION)
-  SET(PYTHON_VERSION "${PYTHON_VERSION}" CACHE STRING "")
-ELSE()
-  SET(PYTHON_VERSION 3.2 CACHE STRING "")
-ENDIF()
+SET(PYTHON_VERSION 3.2 CACHE STRING "Python Version (major and minor only)")
 MARK_AS_ADVANCED(PYTHON_VERSION)
 
-SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
+
+# See: http://docs.python.org/extending/embedding.html#linking-requirements
+#      for why this is needed
+SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic" CACHE STRING "Linker flags for python")
 MARK_AS_ADVANCED(PYTHON_LINKFLAGS)
 
-SET(_python_ABI_FLAGS
-  "m;mu;u; "  # release
-  "md;mud;ud;d" # debug
-)
-
-STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
-
-SET(_python_SEARCH_DIRS
-  ${PYTHON_ROOT_DIR}
-  "$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}"
-  "/opt/py${_PYTHON_VERSION_NO_DOTS}"
-)
-
-FOREACH(_CURRENT_ABI_FLAGS ${_python_ABI_FLAGS})
-  #IF(CMAKE_BUILD_TYPE STREQUAL Debug)
-  #  SET(_CURRENT_ABI_FLAGS "d${_CURRENT_ABI_FLAGS}")
-  #ENDIF()
-  STRING(REPLACE " " "" _CURRENT_ABI_FLAGS ${_CURRENT_ABI_FLAGS})
-
-  FIND_PATH(PYTHON_INCLUDE_DIR
-    NAMES
-      Python.h
-    HINTS
-      ${_python_SEARCH_DIRS}
-    PATH_SUFFIXES
-      include/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
-  )
 
-  FIND_LIBRARY(PYTHON_LIBRARY
-    NAMES
-      "python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}"
-    HINTS
-      ${_python_SEARCH_DIRS}
-    PATH_SUFFIXES
-      lib64 lib
+# only search for the dirs if we havn't already
+IF((NOT DEFINED PYTHON_INCLUDE_DIR) OR (NOT DEFINED PYTHON_LIBRARY))
+
+  SET(_python_ABI_FLAGS
+    "m;mu;u; "    # release
+    "md;mud;ud;d" # debug
   )
 
-  IF(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR)
-    break()
-  ELSE()
-    # ensure we dont find values from 2 different ABI versions
-    UNSET(PYTHON_INCLUDE_DIR CACHE)
-    UNSET(PYTHON_LIBRARY CACHE)
-  ENDIF()
-ENDFOREACH()
+  STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
 
-UNSET(_CURRENT_ABI_FLAGS)
-UNSET(_CURRENT_PATH)
+  SET(_python_SEARCH_DIRS
+    ${PYTHON_ROOT_DIR}
+    "$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}"
+    "/opt/py${_PYTHON_VERSION_NO_DOTS}"
+  )
 
-UNSET(_python_ABI_FLAGS)
-UNSET(_python_SEARCH_DIRS)
+  FOREACH(_CURRENT_ABI_FLAGS ${_python_ABI_FLAGS})
+    #IF(CMAKE_BUILD_TYPE STREQUAL Debug)
+    #  SET(_CURRENT_ABI_FLAGS "d${_CURRENT_ABI_FLAGS}")
+    #ENDIF()
+    STRING(REPLACE " " "" _CURRENT_ABI_FLAGS ${_CURRENT_ABI_FLAGS})
+
+    FIND_PATH(PYTHON_INCLUDE_DIR
+      NAMES
+        Python.h
+      HINTS
+        ${_python_SEARCH_DIRS}
+      PATH_SUFFIXES
+        include/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
+    )
+
+    FIND_LIBRARY(PYTHON_LIBRARY
+      NAMES
+        "python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}"
+      HINTS
+        ${_python_SEARCH_DIRS}
+      PATH_SUFFIXES
+        lib64 lib
+    )
+
+    IF(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR)
+      break()
+    ELSE()
+      # ensure we dont find values from 2 different ABI versions
+      UNSET(PYTHON_INCLUDE_DIR CACHE)
+      UNSET(PYTHON_LIBRARY CACHE)
+    ENDIF()
+  ENDFOREACH()
+
+  UNSET(_CURRENT_ABI_FLAGS)
+  UNSET(_CURRENT_PATH)
+
+  UNSET(_python_ABI_FLAGS)
+  UNSET(_python_SEARCH_DIRS)
+ENDIF()
 
 # handle the QUIETLY and REQUIRED arguments and SET PYTHONLIBSUNIX_FOUND to TRUE IF 
 # all listed variables are TRUE
index 52e48a0..64f46db 100644 (file)
@@ -235,7 +235,7 @@ macro(setup_liblinks
        endif()
 
        if(WITH_INTERNATIONAL)
-               target_link_libraries(${target} ${GETTEXT_LIB})
+               target_link_libraries(${target} ${GETTEXT_LIBRARIES})
 
                if(WIN32 AND NOT UNIX)
                        target_link_libraries(${target} ${ICONV_LIBRARIES})
@@ -343,18 +343,17 @@ macro(TEST_SSE_SUPPORT
                set(${_sse2_flags} "-xSSE2")            
        else()
                message(WARNING "SSE flags for this compiler: '${CMAKE_C_COMPILER_ID}' not known")
-               set(_sse_flags)
-               set(_sse2_flags)
+               set(${_sse_flags})
+               set(${_sse2_flags})
        endif()
 
-       if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
-               set(CMAKE_REQUIRED_FLAGS ${_sse_flags} ${_sse2_flags})
-       endif()
+       set(CMAKE_REQUIRED_FLAGS "${${_sse_flags}} ${${_sse2_flags}}")
 
-       if(NOT DEFINED ${SUPPORT_SSE_BUILD})
+       if(NOT DEFINED SUPPORT_SSE_BUILD)
+               # result cached
                check_c_source_runs("
                        #include <xmmintrin.h>
-                       int main() { __m128 v = _mm_setzero_ps(); return 0; }"
+                       int main(void) { __m128 v = _mm_setzero_ps(); return 0; }"
                SUPPORT_SSE_BUILD)
 
                if(SUPPORT_SSE_BUILD)
@@ -362,13 +361,13 @@ macro(TEST_SSE_SUPPORT
                else()
                        message(STATUS "SSE Support: missing.")
                endif()
-               set(${SUPPORT_SSE_BUILD} ${SUPPORT_SSE_BUILD} CACHE INTERNAL "SSE Test")
        endif()
 
-       if(NOT DEFINED ${SUPPORT_SSE2_BUILD})
+       if(NOT DEFINED SUPPORT_SSE2_BUILD)
+               # result cached
                check_c_source_runs("
                        #include <emmintrin.h>
-                       int main() { __m128d v = _mm_setzero_pd(); return 0; }"
+                       int main(void) { __m128d v = _mm_setzero_pd(); return 0; }"
                SUPPORT_SSE2_BUILD)
 
                if(SUPPORT_SSE2_BUILD)
@@ -376,9 +375,9 @@ macro(TEST_SSE_SUPPORT
                else()
                        message(STATUS "SSE2 Support: missing.")
                endif()
-               set(${SUPPORT_SSE2_BUILD} ${SUPPORT_SSE2_BUILD} CACHE INTERNAL "SSE2 Test")
        endif()
 
+       unset(CMAKE_REQUIRED_FLAGS)
 endmacro()
 
 # when we have warnings as errors applied globally this
index 838a36d..49323ec 100644 (file)
@@ -53,7 +53,7 @@ set(SRC
 
 if(WITH_INTERNATIONAL)
        list(APPEND INC_SYS
-               ${GETTEXT_INC}
+               ${GETTEXT_INCLUDE_DIRS}
        )
        add_definitions(-DWITH_INTERNATIONAL)
 endif()