buildbot: point python to a symbolic link. Helps when updating libs is happening.
[blender.git] / CMakeLists.txt
index cf083b87bc77a0f73cfcb7f7f276ae6474f1181f..2c0e069cf5b0080ee70f83226adb80187d8f6dee 100644 (file)
@@ -62,6 +62,22 @@ set(CMAKE_BUILD_TYPE_INIT "Release")
 # quiet output for Makefiles, 'make -s' helps too
 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
 
+#-----------------------------------------------------------------------------
+# Set policy
+
+# see "cmake --help-policy CMP0003"
+# So library linking is more sane
+cmake_policy(SET CMP0003 NEW)
+
+# So BUILDINFO and BLENDERPATH strings are automatically quoted
+cmake_policy(SET CMP0005 NEW)
+
+# So syntax problems are errors
+cmake_policy(SET CMP0010 NEW)
+
+# Input directories must have CMakeLists.txt
+cmake_policy(SET CMP0014 NEW)
+
 #-----------------------------------------------------------------------------
 # Load some macros.
 include(build_files/cmake/macros.cmake)
@@ -89,6 +105,7 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
 
 get_blender_version()
 
+
 # Blender internal features
 option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
 mark_as_advanced(WITH_BLENDER)
@@ -258,6 +275,11 @@ endif()
 
 TEST_SSE_SUPPORT()
 
+# don't store paths to libs for portable distrobution
+if(WITH_INSTALL_PORTABLE)
+       set(CMAKE_SKIP_BUILD_RPATH TRUE)
+endif()
+
 #-----------------------------------------------------------------------------
 # Initialize un-cached vars, avoid unused warning
 
@@ -429,21 +451,13 @@ if(UNIX AND NOT APPLE)
        endif()
 
        if(WITH_OPENCOLLADA)
-               set(OPENCOLLADA /usr/local/opencollada CACHE PATH "OpenCollada Directory")
-               mark_as_advanced(OPENCOLLADA)
-               set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
-               set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer xml2)
-               set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA})
-
-               set(PCRE /usr CACHE PATH "PCRE Directory")
-               mark_as_advanced(PCRE)
-               set(PCRE_LIBPATH ${PCRE}/lib)
-               set(PCRE_LIB pcre)
-
-               set(EXPAT /usr CACHE PATH "Expat Directory")
-               mark_as_advanced(EXPAT)
-               set(EXPAT_LIBPATH ${EXPAT}/lib)
-               set(EXPAT_LIB expat)
+               find_package(OpenCOLLADA)
+               if(OPENCOLLADA_FOUND)
+                       find_package(XML2)
+                       find_package(PCRE)
+               else()
+                       set(WITH_OPENCOLLADA OFF)
+               endif()
        endif()
 
        if(WITH_MEM_JEMALLOC)
@@ -499,6 +513,9 @@ if(UNIX AND NOT APPLE)
        # GNU Compiler
        if(CMAKE_COMPILER_IS_GNUCC)
                set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
+       # CLang is the same as GCC for now.
+       elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+               set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
        # Intel C++ Compiler
        elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
                # think these next two are broken
@@ -626,11 +643,7 @@ elseif(WIN32)
                        set(GETTEXT ${LIBDIR}/gettext)
                        set(GETTEXT_INC ${GETTEXT}/include)
                        set(GETTEXT_LIBPATH ${GETTEXT}/lib)
-                       if(CMAKE_CL_64)
-                               set(GETTEXT_LIB gettext)
-                       else()
-                               set(GETTEXT_LIB gnu_gettext)
-                       endif()
+                       set(GETTEXT_LIB gnu_gettext)
                endif()
 
                if(CMAKE_CL_64)
@@ -665,9 +678,15 @@ elseif(WIN32)
                endif()
 
                if(WITH_OPENCOLLADA)
-                       set(OPENCOLLADA_INCLUDE_DIR
-                               ${LIBDIR}/opencollada/include
+
+                       set(OPENCOLLADA_INCLUDE_DIRS
+                               ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
+                               ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
+                               ${LIBDIR}/opencollada/include/COLLADAFramework/include
+                               ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
+                               ${LIBDIR}/opencollada/include/GeneratedSaxParser/include                        
                        )
+
                        set(OPENCOLLADA_LIBRARIES
                                ${LIBDIR}/opencollada/lib/OpenCOLLADASaxFrameworkLoader.lib
                                ${LIBDIR}/opencollada/lib/OpenCOLLADAFramework.lib
@@ -680,7 +699,7 @@ elseif(WIN32)
                                ${LIBDIR}/opencollada/lib/ftoa.lib
                                ${LIBDIR}/opencollada/lib/UTF.lib
                        )
-                       set(PCRE_LIB
+                       set(PCRE_LIBRARIES
                                ${LIBDIR}/opencollada/lib/pcre.lib
                        )
                endif()
@@ -691,11 +710,11 @@ elseif(WIN32)
                                ${LIBDIR}/ffmpeg/include/msvc
                        )
                        set(FFMPEG_LIBRARIES
-                               ${LIBDIR}/ffmpeg/lib/avcodec-52.lib
-                               ${LIBDIR}/ffmpeg/lib/avformat-52.lib
-                               ${LIBDIR}/ffmpeg/lib/avdevice-52.lib
-                               ${LIBDIR}/ffmpeg/lib/avutil-50.lib
-                               ${LIBDIR}/ffmpeg/lib/swscale-0.lib
+                               ${LIBDIR}/ffmpeg/lib/avcodec-53.lib
+                               ${LIBDIR}/ffmpeg/lib/avformat-53.lib
+                               ${LIBDIR}/ffmpeg/lib/avdevice-53.lib
+                               ${LIBDIR}/ffmpeg/lib/avutil-51.lib
+                               ${LIBDIR}/ffmpeg/lib/swscale-2.lib
                        )
                endif()
 
@@ -768,7 +787,7 @@ elseif(WIN32)
        else()
                # keep GCC spesific stuff here
                if(CMAKE_COMPILER_IS_GNUCC)
-                       set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
+                       set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32")
                        set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
 
                        add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
@@ -813,16 +832,22 @@ elseif(WIN32)
 
                if(WITH_OPENCOLLADA)
                        set(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
-                       set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA}/include)
+                       set(OPENCOLLADA_INCLUDE_DIRS
+                               ${LIBDIR}/gcc/opencollada/include/COLLADAStreamWriter/include
+                               ${LIBDIR}/gcc/opencollada/include/COLLADABaseUtils/include
+                               ${LIBDIR}/gcc/opencollada/include/COLLADAFramework/include
+                               ${LIBDIR}/gcc/opencollada/include/COLLADASaxFrameworkLoader/include
+                               ${LIBDIR}/gcc/opencollada/include/GeneratedSaxParser/include                    
+                       )
                        set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
                        set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
-                       set(PCRE_LIB pcre)
+                       set(PCRE_LIBRARIES pcre)
                endif()
                
                if(WITH_CODEC_FFMPEG)
                        set(FFMPEG ${LIBDIR}/ffmpeg)
                        set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include ${FFMPEG}/include)
-                       set(FFMPEG_LIBRARIES avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
+                       set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
                        set(FFMPEG_LIBPATH ${FFMPEG}/lib)
                endif()
 
@@ -913,7 +938,7 @@ elseif(APPLE)
                # we use precompiled libraries for py 3.2 and up by default
 
                # normally cached but not since we include them with blender
-                set(PYTHON_VERSION 3.2)
+               set(PYTHON_VERSION 3.2)
                set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")
                # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
                set(PYTHON_LIBRARY python${PYTHON_VERSION})
@@ -1024,13 +1049,21 @@ elseif(APPLE)
 
        if(WITH_OPENCOLLADA)
                set(OPENCOLLADA ${LIBDIR}/opencollada)
-               set(OPENCOLLADA_INCLUDE_DIR ${OPENCOLLADA}/include)
+
+               set(OPENCOLLADA_INCLUDE_DIRS
+                       ${LIBDIR}/opencollada/include/COLLADAStreamWriter
+                       ${LIBDIR}/opencollada/include/COLLADABaseUtils
+                       ${LIBDIR}/opencollada/include/COLLADAFramework
+                       ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
+                       ${LIBDIR}/opencollada/include/GeneratedSaxParser
+               )
+
                set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
                set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
                #pcre is bundled with openCollada
                #set(PCRE ${LIBDIR}/pcre)
                #set(PCRE_LIBPATH ${PCRE}/lib)
-               set(PCRE_LIB pcre)
+               set(PCRE_LIBRARIES pcre)
                #libxml2 is used
                #set(EXPAT ${LIBDIR}/expat)
                #set(EXPAT_LIBPATH ${EXPAT}/lib)
@@ -1118,6 +1151,18 @@ if(WITH_RAYOPTIMIZATION)
        unset(_sse2)
 endif()
 
+
+# set the endian define
+include(TestBigEndian)
+test_big_endian(_SYSTEM_BIG_ENDIAN)
+if(_SYSTEM_BIG_ENDIAN)
+       add_definitions(-D__BIG_ENDIAN__)
+else()
+       add_definitions(-D__LITTLE_ENDIAN__)
+endif()
+unset(_SYSTEM_BIG_ENDIAN)
+
+
 if(WITH_IMAGE_OPENJPEG)
        if(UNIX AND NOT APPLE)
                # dealt with above
@@ -1224,6 +1269,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
        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_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEFINED -Wundef)
        # disable because it gives warnings for printf() & friends.
        # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
@@ -1231,6 +1277,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
        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)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEFINED -Wundef)
 
 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")