diff options
Diffstat (limited to 'build_files')
-rw-r--r-- | build_files/cmake/macros.cmake | 242 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_apple.cmake | 10 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_unix.cmake | 5 | ||||
-rw-r--r-- | build_files/cmake/platform/platform_win32.cmake | 34 |
4 files changed, 88 insertions, 203 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 23ed5b6cbfb..2d13476f09a 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -251,8 +251,59 @@ function(blender_add_lib__impl add_library(${name} ${sources}) + # On Windows certain libraries have two sets of binaries: one for debug builds and one for + # release builds. The root of this requirement goes into ABI, I believe, but that's outside + # of a scope of this comment. + # + # CMake have a native way of dealing with this, which is specifying what build type the + # libraries are provided for: + # + # target_link_libraries(tagret optimized|debug|general <libraries>) + # + # The build type is to be provided as a separate argument to the function. + # + # CMake's variables for libraries will contain build type in such cases. For example: + # + # set(FOO_LIBRARIES optimized libfoo.lib debug libfoo_d.lib) + # + # Complications starts with a single argument for library_deps: all the elements are being + # put to a list: "${FOO_LIBRARIES}" will become "optimized;libfoo.lib;debug;libfoo_d.lib". + # This makes it impossible to pass it as-is to target_link_libraries sine it will treat + # this argument as a list of libraries to be linked against, causing missing libraries + # for optimized.lib. + # + # What this code does it traverses library_deps and extracts information about whether + # library is to provided as general, debug or optimized. This is a little state machine which + # keeps track of whiuch build type library is to provided for: + # + # - If "debug" or "optimized" word is found, the next element in the list is expected to be + # a library which will be passed to target_link_libraries() under corresponding build type. + # + # - If there is no "debug" or "optimized" used library is specified for all build types. + # + # NOTE: If separated libraries for debug and release ar eneeded every library is the list are + # to be prefixed explicitly. + # + # Use: "optimized libfoo optimized libbar debug libfoo_d debug libbar_d" + # NOT: "optimized libfoo libbar debug libfoo_d libbar_d" if(NOT "${library_deps}" STREQUAL "") - target_link_libraries(${name} INTERFACE "${library_deps}") + set(next_library_mode "") + foreach(library ${library_deps}) + string(TOLOWER "${library}" library_lower) + if(("${library_lower}" STREQUAL "optimized") OR + ("${library_lower}" STREQUAL "debug")) + set(next_library_mode "${library_lower}") + else() + if("${next_library_mode}" STREQUAL "optimized") + target_link_libraries(${name} optimized ${library}) + elseif("${next_library_mode}" STREQUAL "debug") + target_link_libraries(${name} debug ${library}) + else() + target_link_libraries(${name} ${library}) + endif() + set(next_library_mode "") + endif() + endforeach() endif() # works fine without having the includes @@ -404,6 +455,11 @@ function(setup_liblinks target ) + # NOTE: This might look like it affects global scope, accumulating linker flags on every call + # to setup_liblinks, but this isn't how CMake works. These flags will only affect current + # directory from where the function is called. + # This means that setup_liblinks() called for ffmpeg_test will not affect blender, and each + # of thsoe targets will have single set of linker flags. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}" PARENT_SCOPE) set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE) set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${PLATFORM_LINKFLAGS_RELEASE}" PARENT_SCOPE) @@ -416,201 +472,17 @@ function(setup_liblinks set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE) set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} ${PLATFORM_LINKFLAGS_RELEASE}" PARENT_SCOPE) - # Work around undefined reference errors when disabling certain libraries. - # Finding the right order for all combinations of options is too hard, so - # we use --start-group and --end-group so the linker does not discard symbols - # too early. This appears to have no significant performance impact. - if(UNIX AND NOT APPLE) - target_link_libraries( - ${target} - -Wl,--start-group - ) - endif() - # jemalloc must be early in the list, to be before pthread (see T57998) if(WITH_MEM_JEMALLOC) target_link_libraries(${target} ${JEMALLOC_LIBRARIES}) endif() - target_link_libraries( - ${target} - ${PNG_LIBRARIES} - ${FREETYPE_LIBRARY} - ) - - - if(WITH_PYTHON) - target_link_libraries(${target} ${PYTHON_LINKFLAGS}) - target_link_libraries(${target} ${PYTHON_LIBRARIES}) - endif() - - if(WITH_LZO AND WITH_SYSTEM_LZO) - target_link_libraries(${target} ${LZO_LIBRARIES}) - endif() - if(WITH_SYSTEM_GLEW) - target_link_libraries(${target} ${BLENDER_GLEW_LIBRARIES}) - endif() - if(WITH_BULLET AND WITH_SYSTEM_BULLET) - target_link_libraries(${target} ${BULLET_LIBRARIES}) - endif() - if(WITH_AUDASPACE AND WITH_SYSTEM_AUDASPACE) - target_link_libraries(${target} ${AUDASPACE_C_LIBRARIES} ${AUDASPACE_PY_LIBRARIES}) - endif() - if(WITH_OPENAL) - target_link_libraries(${target} ${OPENAL_LIBRARY}) - endif() - if(WITH_FFTW3) - target_link_libraries(${target} ${FFTW3_LIBRARIES}) - endif() - if(WITH_JACK AND NOT WITH_JACK_DYNLOAD) - target_link_libraries(${target} ${JACK_LIBRARIES}) - endif() - if(WITH_CODEC_SNDFILE) - target_link_libraries(${target} ${LIBSNDFILE_LIBRARIES}) - endif() - if(WITH_SDL AND NOT WITH_SDL_DYNLOAD) - target_link_libraries(${target} ${SDL_LIBRARY}) - endif() - if(WITH_CYCLES_OSL) - target_link_libraries(${target} ${OSL_LIBRARIES}) - endif() - if(WITH_OPENVDB) - target_link_libraries(${target} ${OPENVDB_LIBRARIES} ${BLOSC_LIBRARIES}) - endif() - if(WITH_USD) - # Source: https://github.com/PixarAnimationStudios/USD/blob/master/BUILDING.md#linking-whole-archives - if(WIN32) - target_link_libraries(${target} ${USD_LIBRARIES}) - set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG " /WHOLEARCHIVE:${USD_DEBUG_LIB}") - set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " /WHOLEARCHIVE:${USD_RELEASE_LIB}") - set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /WHOLEARCHIVE:${USD_RELEASE_LIB}") - set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_MINSIZEREL " /WHOLEARCHIVE:${USD_RELEASE_LIB}") - elseif(CMAKE_COMPILER_IS_GNUCXX) - target_link_libraries(${target} -Wl,--whole-archive ${USD_LIBRARIES} -Wl,--no-whole-archive) - elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - target_link_libraries(${target} -Wl,-force_load ${USD_LIBRARIES}) - else() - message(FATAL_ERROR "Unknown how to link USD with your compiler ${CMAKE_CXX_COMPILER_ID}") - endif() - endif() - if(WITH_OPENIMAGEIO) - target_link_libraries(${target} ${OPENIMAGEIO_LIBRARIES}) - endif() - if(WITH_OPENIMAGEDENOISE) - target_link_libraries(${target} ${OPENIMAGEDENOISE_LIBRARIES}) - endif() - if(WITH_TBB) - target_link_libraries(${target} ${TBB_LIBRARIES}) - endif() - if(WITH_OPENCOLORIO) - target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES}) - endif() - if(WITH_OPENSUBDIV) - target_link_libraries(${target} ${OPENSUBDIV_LIBRARIES}) - endif() - if(WITH_CYCLES_EMBREE) - target_link_libraries(${target} ${EMBREE_LIBRARIES}) - endif() - if(WITH_BOOST) - target_link_libraries(${target} ${BOOST_LIBRARIES}) - if(Boost_USE_STATIC_LIBS AND Boost_USE_ICU) - target_link_libraries(${target} ${ICU_LIBRARIES}) - endif() - endif() - target_link_libraries(${target} ${JPEG_LIBRARIES}) - if(WITH_ALEMBIC) - target_link_libraries(${target} ${ALEMBIC_LIBRARIES} ${HDF5_LIBRARIES}) - endif() - if(WITH_IMAGE_TIFF) - target_link_libraries(${target} ${TIFF_LIBRARY}) - endif() - if(WITH_IMAGE_OPENEXR) - target_link_libraries(${target} ${OPENEXR_LIBRARIES}) - endif() - if(WITH_IMAGE_OPENJPEG) - target_link_libraries(${target} ${OPENJPEG_LIBRARIES}) - endif() - if(WITH_CODEC_FFMPEG) - target_link_libraries(${target} ${FFMPEG_LIBRARIES}) - endif() - if(WITH_OPENCOLLADA) - if(WIN32 AND NOT UNIX) - file_list_suffix(OPENCOLLADA_LIBRARIES_DEBUG "${OPENCOLLADA_LIBRARIES}" "_d") - target_link_libraries_debug(${target} "${OPENCOLLADA_LIBRARIES_DEBUG}") - target_link_libraries_optimized(${target} "${OPENCOLLADA_LIBRARIES}") - unset(OPENCOLLADA_LIBRARIES_DEBUG) - - file_list_suffix(PCRE_LIBRARIES_DEBUG "${PCRE_LIBRARIES}" "_d") - target_link_libraries_debug(${target} "${PCRE_LIBRARIES_DEBUG}") - target_link_libraries_optimized(${target} "${PCRE_LIBRARIES}") - unset(PCRE_LIBRARIES_DEBUG) - - if(EXPAT_LIB) - file_list_suffix(EXPAT_LIB_DEBUG "${EXPAT_LIB}" "_d") - target_link_libraries_debug(${target} "${EXPAT_LIB_DEBUG}") - target_link_libraries_optimized(${target} "${EXPAT_LIB}") - unset(EXPAT_LIB_DEBUG) - endif() - else() - target_link_libraries( - ${target} - ${OPENCOLLADA_LIBRARIES} - ${PCRE_LIBRARIES} - ${XML2_LIBRARIES} - ${EXPAT_LIB} - ) - endif() - endif() - if(WITH_LLVM) - target_link_libraries(${target} ${LLVM_LIBRARY}) - endif() if(WIN32 AND NOT UNIX) target_link_libraries(${target} ${PTHREADS_LIBRARIES}) endif() - if(UNIX AND NOT APPLE) - if(WITH_OPENMP_STATIC) - target_link_libraries(${target} ${OpenMP_LIBRARIES}) - endif() - if(WITH_INPUT_NDOF) - target_link_libraries(${target} ${NDOF_LIBRARIES}) - endif() - endif() - if(WITH_SYSTEM_GLOG) - target_link_libraries(${target} ${GLOG_LIBRARIES}) - endif() - if(WITH_SYSTEM_GFLAGS) - target_link_libraries(${target} ${GFLAGS_LIBRARIES}) - endif() - - # We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES depends on them.. - if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV) - target_link_libraries(${target} "extern_clew") - if(WITH_CUDA_DYNLOAD) - target_link_libraries(${target} "extern_cuew") - else() - target_link_libraries(${target} ${CUDA_CUDA_LIBRARY}) - endif() - endif() - - target_link_libraries( - ${target} - ${ZLIB_LIBRARIES} - ) - - # System libraries with no dependencies such as platform link libs or opengl should go last. - target_link_libraries(${target} - ${BLENDER_GL_LIBRARIES}) # target_link_libraries(${target} ${PLATFORM_LINKLIBS} ${CMAKE_DL_LIBS}) target_link_libraries(${target} ${PLATFORM_LINKLIBS}) - - # See comments above regarding --start-group. - if(UNIX AND NOT APPLE) - target_link_libraries( - ${target} - -Wl,--end-group - ) - endif() endfunction() macro(TEST_SSE_SUPPORT diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index e60760e6cfd..a4de3876243 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -132,13 +132,13 @@ if(WITH_FFTW3) set(FFTW3_LIBPATH ${FFTW3}/lib) endif() -set(PNG_LIBRARIES png) -set(JPEG_LIBRARIES jpeg) - set(ZLIB /usr) set(ZLIB_INCLUDE_DIRS "${ZLIB}/include") set(ZLIB_LIBRARIES z bz2) +set(PNG_LIBRARIES png ${ZLIB_LIBRARIES}) +set(JPEG_LIBRARIES jpeg) + set(FREETYPE ${LIBDIR}/freetype) set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2) set(FREETYPE_LIBPATH ${FREETYPE}/lib) @@ -228,10 +228,6 @@ if(WITH_OPENCOLLADA) # set(PCRE ${LIBDIR}/pcre) # set(PCRE_LIBPATH ${PCRE}/lib) set(PCRE_LIBRARIES pcre) - # libxml2 is used - # set(EXPAT ${LIBDIR}/expat) - # set(EXPAT_LIBPATH ${EXPAT}/lib) - set(EXPAT_LIB) endif() if(WITH_SDL) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index d4a75e5e5c0..5d46ee751af 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -336,6 +336,11 @@ if(WITH_BOOST) set(BOOST_LIBRARIES ${Boost_LIBRARIES}) set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS}) set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB") + + if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU) + find_package(IcuLinux) + list(APPEND BOOST_LIBRARIES ${ICU_LIBRARIES}) + endif() endif() if(WITH_OPENIMAGEIO) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index f485490f300..b228930bfb1 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -225,7 +225,7 @@ windows_find_package(png) if(NOT PNG_FOUND) warn_hardcoded_paths(libpng) set(PNG_PNG_INCLUDE_DIR ${LIBDIR}/png/include) - set(PNG_LIBRARIES ${LIBDIR}/png/lib/libpng.lib) + set(PNG_LIBRARIES ${LIBDIR}/png/lib/libpng.lib ${ZLIB_LIBRARY}) set(PNG "${LIBDIR}/png") set(PNG_INCLUDE_DIRS "${PNG}/include") set(PNG_LIBPATH ${PNG}/lib) # not cmake defined @@ -269,21 +269,33 @@ if(WITH_OPENCOLLADA) ) set(OPENCOLLADA_LIBRARIES - ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib - ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework.lib - ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils.lib - ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter.lib - ${OPENCOLLADA}/lib/opencollada/MathMLSolver.lib - ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser.lib - ${OPENCOLLADA}/lib/opencollada/xml.lib - ${OPENCOLLADA}/lib/opencollada/buffer.lib - ${OPENCOLLADA}/lib/opencollada/ftoa.lib + optimized ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib + optimized ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework.lib + optimized ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils.lib + optimized ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter.lib + optimized ${OPENCOLLADA}/lib/opencollada/MathMLSolver.lib + optimized ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser.lib + optimized ${OPENCOLLADA}/lib/opencollada/xml.lib + optimized ${OPENCOLLADA}/lib/opencollada/buffer.lib + optimized ${OPENCOLLADA}/lib/opencollada/ftoa.lib + + debug ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader_d.lib + debug ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework_d.lib + debug ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils_d.lib + debug ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter_d.lib + debug ${OPENCOLLADA}/lib/opencollada/MathMLSolver_d.lib + debug ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser_d.lib + debug ${OPENCOLLADA}/lib/opencollada/xml_d.lib + debug ${OPENCOLLADA}/lib/opencollada/buffer_d.lib + debug ${OPENCOLLADA}/lib/opencollada/ftoa_d.lib ) list(APPEND OPENCOLLADA_LIBRARIES ${OPENCOLLADA}/lib/opencollada/UTF.lib) set(PCRE_LIBRARIES - ${OPENCOLLADA}/lib/opencollada/pcre.lib + optimized ${OPENCOLLADA}/lib/opencollada/pcre.lib + + debug ${OPENCOLLADA}/lib/opencollada/pcre_d.lib ) endif() |