Silence some annoying warnings when doing full build with strict flags
[blender.git] / build_files / cmake / macros.cmake
index 12b7e667fb14bcc7226c97af42eb70cab7f35e87..f26b22a9c5f13a1383e64129fdbcd267e9997c27 100644 (file)
@@ -141,22 +141,6 @@ function(target_link_libraries_debug
        endforeach()
 endfunction()
 
-function(target_link_libraries_decoupled
-       target
-       libraries_var
-       )
-
-       if(NOT MSVC)
-               target_link_libraries(${target} ${${libraries_var}})
-       else()
-               # For MSVC we link to different libraries depending whether
-               # release or debug target is being built.
-               file_list_suffix(_libraries_debug "${${libraries_var}}" "_d")
-               target_link_libraries_debug(${target} "${_libraries_debug}")
-               target_link_libraries_optimized(${target} "${${libraries_var}}")
-       endif()
-endfunction()
-
 # Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
 # use it instead of include_directories()
 function(blender_include_dirs
@@ -256,6 +240,9 @@ endfunction()
 
 function(SETUP_LIBDIRS)
 
+       # NOTE: For all new libraries, use absolute library paths.
+       # This should eventually be phased out.
+
        link_directories(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH})
 
        if(WITH_PYTHON)  #  AND NOT WITH_PYTHON_MODULE  # WIN32 needs
@@ -282,11 +269,8 @@ function(SETUP_LIBDIRS)
        if(WITH_OPENCOLORIO)
                link_directories(${OPENCOLORIO_LIBPATH})
        endif()
-       if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG)
-               link_directories(${OPENJPEG_LIBPATH})
-       endif()
-       if(WITH_CODEC_QUICKTIME)
-               link_directories(${QUICKTIME_LIBPATH})
+       if(WITH_OPENVDB)
+               link_directories(${OPENVDB_LIBPATH})
        endif()
        if(WITH_OPENAL)
                link_directories(${OPENAL_LIBPATH})
@@ -302,15 +286,13 @@ function(SETUP_LIBDIRS)
        endif()
        if(WITH_OPENCOLLADA)
                link_directories(${OPENCOLLADA_LIBPATH})
-               link_directories(${PCRE_LIBPATH})
-               link_directories(${EXPAT_LIBPATH})
+               ## Never set
+               # link_directories(${PCRE_LIBPATH})
+               # link_directories(${EXPAT_LIBPATH})
        endif()
        if(WITH_LLVM)
                link_directories(${LLVM_LIBPATH})
        endif()
-       if(WITH_MEM_JEMALLOC)
-               link_directories(${JEMALLOC_LIBPATH})
-       endif()
 
        if(WIN32 AND NOT UNIX)
                link_directories(${PTHREADS_LIBPATH})
@@ -400,6 +382,9 @@ function(setup_liblinks
                        target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES})
                endif()
        endif()
+       if(WITH_OPENVDB)
+               target_link_libraries(${target} ${OPENVDB_LIBRARIES} ${TBB_LIBRARIES})
+       endif()
        if(WITH_CYCLES_OSL)
                target_link_libraries(${target} ${OSL_LIBRARIES})
        endif()
@@ -411,14 +396,7 @@ function(setup_liblinks
        endif()
        target_link_libraries(${target} ${JPEG_LIBRARIES})
        if(WITH_IMAGE_OPENEXR)
-               if(WIN32 AND NOT UNIX AND NOT CMAKE_COMPILER_IS_GNUCC)
-                       file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")
-                       target_link_libraries_debug(${target} "${OPENEXR_LIBRARIES_DEBUG}")
-                       target_link_libraries_optimized(${target} "${OPENEXR_LIBRARIES}")
-                       unset(OPENEXR_LIBRARIES_DEBUG)
-               else()
-                       target_link_libraries(${target} ${OPENEXR_LIBRARIES})
-               endif()
+               target_link_libraries(${target} ${OPENEXR_LIBRARIES})
        endif()
        if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG)
                target_link_libraries(${target} ${OPENJPEG_LIBRARIES})
@@ -478,7 +456,11 @@ function(setup_liblinks
        # We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES dpeends on them..
        if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
                target_link_libraries(${target} "extern_clew")
-               target_link_libraries(${target} "extern_cuew")
+               if(WITH_CUDA_DYNLOAD)
+                       target_link_libraries(${target} "extern_cuew")
+               else()
+                       target_link_libraries(${target} ${CUDA_CUDA_LIBRARY})
+               endif()
        endif()
 
        #system libraries with no dependencies such as platform link libs or opengl should go last
@@ -596,6 +578,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
                ge_phys_bullet
                bf_intern_smoke
                extern_lzma
+               extern_curve_fit_nd
                ge_logic_ketsji
                extern_recastnavigation
                ge_logic
@@ -608,7 +591,6 @@ function(SETUP_BLENDER_SORTED_LIBS)
                ge_logic_loopbacknetwork
                bf_intern_moto
                extern_openjpeg
-               extern_redcode
                ge_videotex
                bf_dna
                bf_blenfont
@@ -623,13 +605,13 @@ function(SETUP_BLENDER_SORTED_LIBS)
                cycles_kernel
                cycles_util
                cycles_subd
-               bf_intern_raskter
                bf_intern_opencolorio
                bf_intern_eigen
                extern_rangetree
                extern_wcwidth
-               extern_libmv
+               bf_intern_libmv
                extern_glog
+               extern_gflags
                extern_sdlew
 
                bf_intern_glew_mx
@@ -709,6 +691,10 @@ function(SETUP_BLENDER_SORTED_LIBS)
                list(APPEND BLENDER_SORTED_LIBS bf_intern_opensubdiv)
        endif()
 
+       if(WITH_OPENVDB)
+               list(APPEND BLENDER_SORTED_LIBS bf_intern_openvdb)
+       endif()
+
        foreach(SORTLIB ${BLENDER_SORTED_LIBS})
                set(REMLIB ${SORTLIB})
                foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
@@ -795,15 +781,11 @@ macro(TEST_SSE_SUPPORT
        unset(CMAKE_REQUIRED_FLAGS)
 endmacro()
 
-macro(TEST_STDBOOL_SUPPORT)
-       include(CheckCSourceRuns)
-
-       # This program will compile correctly if and only if
-       # this C compiler supports C99 stdbool.
-       check_c_source_runs("
-               #include <stdbool.h>
-               int main(void) { return (int)false; }"
-       HAVE_STDBOOL_H)
+# Only print message if running CMake first time
+macro(message_first_run)
+       if(FIRST_RUN)
+               message(${ARGV})
+       endif()
 endmacro()
 
 macro(TEST_UNORDERED_MAP_SUPPORT)
@@ -812,11 +794,11 @@ macro(TEST_UNORDERED_MAP_SUPPORT)
        # and define the include path
        # This module defines
        #  HAVE_UNORDERED_MAP, whether unordered_map implementation was found
-       #  
+       #
        #  HAVE_STD_UNORDERED_MAP_HEADER, <unordered_map.h> was found
        #  HAVE_UNORDERED_MAP_IN_STD_NAMESPACE, unordered_map is in namespace std
        #  HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE, unordered_map is in namespace std::tr1
-       #  
+       #
        #  UNORDERED_MAP_INCLUDE_PREFIX, include path prefix for unordered_map, if found
        #  UNORDERED_MAP_NAMESPACE, namespace for unordered_map, if found
 
@@ -840,7 +822,7 @@ macro(TEST_UNORDERED_MAP_SUPPORT)
                                          }"
                                          HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
                if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
-                       message(STATUS "Found unordered_map/set in std namespace.")
+                       message_first_run(STATUS "Found unordered_map/set in std namespace.")
 
                        set(HAVE_UNORDERED_MAP "TRUE")
                        set(UNORDERED_MAP_INCLUDE_PREFIX "")
@@ -853,26 +835,26 @@ macro(TEST_UNORDERED_MAP_SUPPORT)
                                                  }"
                                                  HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
                        if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
-                               message(STATUS "Found unordered_map/set in std::tr1 namespace.")
+                               message_first_run(STATUS "Found unordered_map/set in std::tr1 namespace.")
 
                                set(HAVE_UNORDERED_MAP "TRUE")
                                set(UNORDERED_MAP_INCLUDE_PREFIX "")
                                set(UNORDERED_MAP_NAMESPACE "std::tr1")
                        else()
-                               message(STATUS "Found <unordered_map> but cannot find either std::unordered_map "
-                                       "or std::tr1::unordered_map.")
+                               message_first_run(STATUS "Found <unordered_map> but cannot find either std::unordered_map "
+                                                 "or std::tr1::unordered_map.")
                        endif()
                endif()
        else()
                CHECK_INCLUDE_FILE_CXX("tr1/unordered_map" HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
                if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
-                       message(STATUS "Found unordered_map/set in std::tr1 namespace.")
+                       message_first_run(STATUS "Found unordered_map/set in std::tr1 namespace.")
 
                        set(HAVE_UNORDERED_MAP "TRUE")
                        set(UNORDERED_MAP_INCLUDE_PREFIX "tr1")
                        set(UNORDERED_MAP_NAMESPACE "std::tr1")
                else()
-                       message(STATUS "Unable to find <unordered_map> or <tr1/unordered_map>. ")
+                       message_first_run(STATUS "Unable to find <unordered_map> or <tr1/unordered_map>. ")
                endif()
        endif()
 endmacro()
@@ -909,7 +891,7 @@ macro(TEST_SHARED_PTR_SUPPORT)
                                          HAVE_SHARED_PTR_IN_STD_NAMESPACE)
 
                if(HAVE_SHARED_PTR_IN_STD_NAMESPACE)
-                       message("-- Found shared_ptr in std namespace using <memory> header.")
+                       message_first_run("-- Found shared_ptr in std namespace using <memory> header.")
                        set(SHARED_PTR_FOUND TRUE)
                else()
                        CHECK_CXX_SOURCE_COMPILES("#include <memory>
@@ -919,7 +901,7 @@ macro(TEST_SHARED_PTR_SUPPORT)
                                                   }"
                                                  HAVE_SHARED_PTR_IN_TR1_NAMESPACE)
                        if(HAVE_SHARED_PTR_IN_TR1_NAMESPACE)
-                               message("-- Found shared_ptr in std::tr1 namespace using <memory> header.")
+                               message_first_run("-- Found shared_ptr in std::tr1 namespace using <memory> header.")
                                set(SHARED_PTR_TR1_NAMESPACE TRUE)
                                set(SHARED_PTR_FOUND TRUE)
                        endif()
@@ -940,7 +922,7 @@ macro(TEST_SHARED_PTR_SUPPORT)
                                                   }"
                                                   HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER)
                        if(HAVE_SHARED_PTR_IN_TR1_NAMESPACE_FROM_TR1_MEMORY_HEADER)
-                               message("-- Found shared_ptr in std::tr1 namespace using <tr1/memory> header.")
+                               message_first_run("-- Found shared_ptr in std::tr1 namespace using <tr1/memory> header.")
                                set(SHARED_PTR_TR1_MEMORY_HEADER TRUE)
                                set(SHARED_PTR_TR1_NAMESPACE TRUE)
                                set(SHARED_PTR_FOUND TRUE)
@@ -986,6 +968,7 @@ macro(remove_strict_flags)
                remove_cc_flag(
                        "-Wstrict-prototypes"
                        "-Wmissing-prototypes"
+                       "-Wmissing-declarations"
                        "-Wmissing-format-attribute"
                        "-Wunused-local-typedefs"
                        "-Wunused-macros"
@@ -1467,17 +1450,21 @@ function(find_python_package
                )
 
                 if(NOT EXISTS "${PYTHON_${_upper_package}_PATH}")
-                       message(WARNING "'${package}' path could not be found in:\n"
-                                       "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${package}', "
-                                       "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/${package}', "
-                                       "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/${package}', "
-                                       "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/${package}', "
-                                       "WITH_PYTHON_INSTALL_${_upper_package} option will be ignored when installing python")
+                       message(WARNING
+                               "Python package '${package}' path could not be found in:\n"
+                               "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/${package}', "
+                               "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/${package}', "
+                               "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/${package}', "
+                               "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/${package}', "
+                               "\n"
+                               "The 'WITH_PYTHON_INSTALL_${_upper_package}' option will be ignored when installing Python.\n"
+                               "The build will be usable, only add-ons that depend on this package won't be functional."
+                       )
                        set(WITH_PYTHON_INSTALL_${_upper_package} OFF PARENT_SCOPE)
                else()
                        message(STATUS "${package} found at '${PYTHON_${_upper_package}_PATH}'")
                endif()
-         endif()
+       endif()
 endfunction()
 
 # like Python's 'print(dir())'