patch [#28947] Patches for #28943 (Support for XDG Base Directory Specification)
[blender.git] / CMakeLists.txt
index 43ecdaa..0e06f39 100644 (file)
@@ -1,5 +1,4 @@
 # -*- mode: cmake; indent-tabs-mode: t; -*-
-# $Id$
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
 # This program is free software; you can redistribute it and/or
@@ -62,6 +61,13 @@ set(CMAKE_BUILD_TYPE_INIT "Release")
 # quiet output for Makefiles, 'make -s' helps too
 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
 
+# global compile definitions since add_definitions() adds for all.
+set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG           DEBUG _DEBUG)
+set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE         NDEBUG)
+set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL      NDEBUG)
+set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO  NDEBUG)
+
+
 #-----------------------------------------------------------------------------
 # Set policy
 
@@ -149,8 +155,10 @@ else()
 endif()
 
 if(UNIX AND NOT APPLE)
-       option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)"     ON)
+       option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)"   ON)
        option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
+       option(WITH_XDG_USER_DIRS    "Build with XDG Base Directory Specification (only config and documents for now)" OFF)
+       mark_as_advanced(WITH_XDG_USER_DIRS)
 else()
        # not an option for other OS's
        set(WITH_BUILTIN_GLEW ON)
@@ -189,7 +197,6 @@ option(WITH_OPENCOLLADA             "Enable OpenCollada Support (http://www.opencollada.org
 option(WITH_SDL           "Enable SDL for sound and joystick support" ON)
 option(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
 option(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
-option(WITH_SAMPLERATE    "Enable samplerate conversion" ON)
 
 # Compression
 option(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
@@ -214,6 +221,7 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC)
 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
 mark_as_advanced(WITH_ASSERT_ABORT)
 
+
 if(APPLE)
        if(NOT CMAKE_OSX_ARCHITECTURES)
                set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
@@ -273,7 +281,7 @@ if(WITH_PYTHON_MODULE)
        set(WITH_HEADLESS ON)
 endif()
 
-TEST_SSE_SUPPORT()
+TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
 
 # don't store paths to libs for portable distrobution
 if(WITH_INSTALL_PORTABLE)
@@ -287,7 +295,7 @@ endif()
 set(WITH_BINRELOC OFF)
 
 # MAXOSX only, set to avoid uninitialized
-set(EXETYPE)
+set(EXETYPE "")
 
 # C/C++ flags
 set(PLATFORM_CFLAGS)
@@ -296,15 +304,18 @@ set(PLATFORM_CFLAGS)
 set(C_WARNINGS)
 set(CXX_WARNINGS)
 
+# for gcc -Wno-blah-blah
+set(CC_REMOVE_STRICT_FLAGS)
+
 # 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 +447,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()
 
@@ -447,13 +458,6 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
-       if(WITH_SAMPLERATE)
-               find_package(Samplerate)
-               if(NOT SAMPLERATE_FOUND)
-                       set(WITH_SAMPLERATE OFF)
-               endif()
-       endif()
-
        if(WITH_OPENCOLLADA)
                find_package(OpenCOLLADA)
                if(OPENCOLLADA_FOUND)
@@ -511,8 +515,8 @@ if(UNIX AND NOT APPLE)
 
        set(PLATFORM_LINKFLAGS "-pthread")
 
-       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
-       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
+       # lfs on glibc, all compilers should use
+       add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
 
        # GNU Compiler
        if(CMAKE_COMPILER_IS_GNUCC)
@@ -565,13 +569,6 @@ elseif(WIN32)
                set(ICONV_LIBPATH ${ICONV}/lib)
        endif()
 
-       if(WITH_SAMPLERATE)
-               set(SAMPLERATE ${LIBDIR}/samplerate)
-               set(SAMPLERATE_INCLUDE_DIRS ${SAMPLERATE}/include)
-               set(SAMPLERATE_LIBRARIES libsamplerate)
-               set(SAMPLERATE_LIBPATH ${SAMPLERATE}/lib)
-       endif()
-
        set(PNG "${LIBDIR}/png")
        set(PNG_INCLUDE_DIR "${PNG}/include")
        set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
@@ -627,27 +624,27 @@ elseif(WIN32)
                set(CMAKE_C_FLAGS   "/nologo /J /W0 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013 /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
 
                if(CMAKE_CL_64)
-                       set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+                       set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
                else()
-                       set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
+                       set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
                endif()
-               set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
-               set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
-               set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
                if(CMAKE_CL_64)
-                       set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+                       set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
                else()
-                       set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
+                       set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
                endif()
-               set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
-               set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
-               set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+               set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
 
                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 +742,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
                        )
@@ -789,7 +786,7 @@ elseif(WIN32)
                set(PLATFORM_LINKFLAGS_DEBUG "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
 
        else()
-               # keep GCC spesific stuff here
+               # keep GCC specific stuff here
                if(CMAKE_COMPILER_IS_GNUCC)
                        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")
@@ -799,14 +796,11 @@ elseif(WIN32)
 
                add_definitions(-DFREE_WINDOWS)
 
-               set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
-               set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
-
                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 +950,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()
 
@@ -995,13 +989,6 @@ elseif(APPLE)
                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
        endif()
 
-       if(WITH_SAMPLERATE)
-               set(SAMPLERATE ${LIBDIR}/samplerate)
-               set(SAMPLERATE_INCLUDE_DIRS ${SAMPLERATE}/include)
-               set(SAMPLERATE_LIBRARIES samplerate)
-               set(SAMPLERATE_LIBPATH ${SAMPLERATE}/lib)
-       endif()
-
        find_library(SYSTEMSTUBS_LIBRARY
                NAMES
                SystemStubs
@@ -1105,11 +1092,11 @@ elseif(APPLE)
        set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
        set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
        if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
-               set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
-               set(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
+               set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
+               set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
        elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
-               set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
-               set(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
+               set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
+               set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
        else()
                set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
                set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
@@ -1128,31 +1115,17 @@ endif()
 # See TEST_SSE_SUPPORT() for how this is defined.
 
 if(WITH_RAYOPTIMIZATION)
-       if(CMAKE_COMPILER_IS_GNUCC)
-               set(_sse "-msse")
-               set(_sse2 "-msse2")
-       elseif(MSVC)
-               set(_sse "/arch:SSE")
-               set(_sse2 "/arch:SSE2")
-       else()
-               message(WARNING "SSE flags for this compiler not known")
-               set(_sse)
-               set(_sse2)
-       endif()
-
        if(SUPPORT_SSE_BUILD)
-               set(PLATFORM_CFLAGS " ${_sse} ${PLATFORM_CFLAGS}")
+               set(PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}")
                add_definitions(-D__SSE__ -D__MMX__)
        endif()
        if(SUPPORT_SSE2_BUILD)
-               set(PLATFORM_CFLAGS " ${_sse2} ${PLATFORM_CFLAGS}")
+               set(PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG} ${PLATFORM_CFLAGS}")
                add_definitions(-D__SSE2__)
                if(NOT SUPPORT_SSE_BUILD) # dont double up
                        add_definitions(-D__MMX__)
                endif()
        endif()
-       unset(_sse)
-       unset(_sse2)
 endif()
 
 
@@ -1253,21 +1226,6 @@ endif()
 #-----------------------------------------------------------------------------
 # Extra compile flags
 
-if((NOT WIN32) AND (NOT MSVC))
-       # used for internal debug checks
-       set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
-       set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
-
-       # assert() checks for this.
-       set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
-       set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
-       set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
-
-       set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
-       set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
-       set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
-endif()
-
 if(CMAKE_COMPILER_IS_GNUCC)
 
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
@@ -1297,6 +1255,11 @@ if(CMAKE_COMPILER_IS_GNUCC)
        # # this causes too many warnings, disable
        # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEFINED -Wundef)
 
+       # flags to undo strict flags
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER        -Wno-unused-parameter)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable)
+
 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
 
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
@@ -1307,6 +1270,10 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
        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)
 
+       # disable numbered, false positives
+       set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556")
+       set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556")
+
 endif()
 
 # MSVC2010 fails to links C++ libs right
@@ -1446,7 +1413,6 @@ if(FIRST_RUN)
        info_cfg_option(WITH_JACK)
        info_cfg_option(WITH_CODEC_FFMPEG)
        info_cfg_option(WITH_CODEC_SNDFILE)
-       info_cfg_option(WITH_SAMPLERATE)
 
        info_cfg_text("Compression:")
        info_cfg_option(WITH_LZMA)