diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-07-25 17:37:55 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-08-07 18:54:26 +0300 |
commit | 3c14f02eac36cccd280d9531cc3fd148526aedf9 (patch) | |
tree | a9180f4e5fd09d9b83f9f31b7f67bb3ab91bb01d /build_files/build_environment/cmake/options.cmake | |
parent | fc38276d74e1d451663c70f82e7f54293d24bbe4 (diff) |
Build: add scripts to build dependencies for Windows and macOS.
Note these are intended for platform maintainers, we do not intend to
support users making their own builds with these. For that precompiled
libraries from lib/ should be used.
Implemented by Martijn Berger, Ray Molenkamp and Brecht Van Lommel.
Differential Revision: https://developer.blender.org/D2753
Diffstat (limited to 'build_files/build_environment/cmake/options.cmake')
-rw-r--r-- | build_files/build_environment/cmake/options.cmake | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake new file mode 100644 index 00000000000..16d79d463f6 --- /dev/null +++ b/build_files/build_environment/cmake/options.cmake @@ -0,0 +1,202 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ***** END GPL LICENSE BLOCK ***** + +if(WIN32) + option(ENABLE_MINGW64 "Enable building of ffmpeg/iconv/libsndfile/lapack/fftw3 by installing mingw64" ON) +endif() +set(MAKE_THREADS 1 CACHE STRING "Number of threads to run make with") + +if(NOT BUILD_MODE) + set(BUILD_MODE "Release") + message(STATUS "Build type not specified: defaulting to a release build.") +endif() +Message("BuildMode = ${BUILD_MODE}") + +if(BUILD_MODE STREQUAL "Debug") + set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Debug) +ELSE(BUILD_MODE STREQUAL "Debug") + set(LIBDIR ${CMAKE_CURRENT_BINARY_DIR}/Release) +ENDIF(BUILD_MODE STREQUAL "Debug") + +set(DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/downloads) +set(PATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/patches) +set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/build) + +message("LIBDIR = ${LIBDIR}") +message("DOWNLOAD_DIR = ${DOWNLOAD_DIR}") +message("PATCH_DIR = ${PATCH_DIR}") +message("BUILD_DIR = ${BUILD_DIR}") + +if(WIN32) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw64/msys/1.0/bin/patch.exe) + else() + set(PATCH_CMD ${DOWNLOAD_DIR}/mingw/mingw32/msys/1.0/bin/patch.exe) + endif() + set(LIBEXT ".lib") + set(LIBPREFIX "") + + # For OIIO and OSL + set(COMMON_DEFINES /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS) + + # TODO FIXME highly MSVC specific + if(WITH_OPTIMIZED_DEBUG) + set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + else() + set(BLENDER_CMAKE_C_FLAGS_DEBUG "/MTd /Zi /Ob0 /Od /RTC1 /D_DEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + endif() + set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + set(BLENDER_CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /DNDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + + if(WITH_OPTIMIZED_DEBUG) + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /D PLATFORM_WINDOWS /MTd /Zi /Ob0 /Od /RTC1 /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + else() + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MTd /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + endif() + set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + set(BLENDER_CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /O2 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=1 /DOIIO_STATIC_BUILD /DTINYFORMAT_ALLOW_WCHAR_STRINGS") + + set(PLATFORM_FLAGS) + set(PLATFORM_CXX_FLAGS) + set(PLATFORM_CMAKE_FLAGS) + + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw64) + set(MINGW_SHELL ming64sh.cmd) + set(PERL_SHELL ${DOWNLOAD_DIR}/perl/portableshell.bat) + set(MINGW_HOST x86_64-w64-mingw32) + else() + set(MINGW_PATH ${DOWNLOAD_DIR}/mingw/mingw32) + set(MINGW_SHELL ming32sh.cmd) + set(PERL_SHELL ${DOWNLOAD_DIR}/perl32/portableshell.bat) + set(MINGW_HOST i686-w64-mingw32) + endif() + + set(CONFIGURE_ENV + cd ${MINGW_PATH} && + call ${MINGW_SHELL} && + call ${PERL_SHELL} && + set path && + set CFLAGS=-g && + set LDFLAGS=-Wl,--as-needed -static-libgcc + ) + + set(CONFIGURE_ENV_NO_PERL + cd ${MINGW_PATH} && + call ${MINGW_SHELL} && + set path && + set CFLAGS=-g && + set LDFLAGS=-Wl,--as-needed -static-libgcc + ) + + set(CONFIGURE_COMMAND sh ./configure) +else() + set(PATCH_CMD patch) + set(LIBEXT ".a") + set(LIBPREFIX "lib") + + if(APPLE) + set(OSX_ARCHITECTURES x86_64) + set(OSX_DEPLOYMENT_TARGET 10.9) + set(OSX_SDK_VERSION 10.12) + set(OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OSX_SDK_VERSION}.sdk) + + set(PLATFORM_CFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}") + set(PLATFORM_CXXFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET} -std=c++11 -stdlib=libc++") + set(PLATFORM_LDFLAGS "-isysroot ${OSX_SYSROOT} -mmacosx-version-min=${OSX_DEPLOYMENT_TARGET}") + set(PLATFORM_BUILD_TARGET --build=x86_64-apple-darwin13.0.0) # OS X 10.9 + set(PLATFORM_CMAKE_FLAGS + -DCMAKE_OSX_ARCHITECTURES:STRING=${OSX_ARCHITECTURES} + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_SYSROOT:PATH=${OSX_SYSROOT} + ) + else() + set(PLATFORM_CFLAGS "-fPIC") + set(PLATFORM_CXXFLAGS "-std=c++11 -fPIC") + set(PLATFORM_LDFLAGS) + set(PLATFORM_BUILD_TARGET) + set(PLATFORM_CMAKE_FLAGS) + endif() + + if(WITH_OPTIMIZED_DEBUG) + set(BLENDER_CMAKE_C_FLAGS_DEBUG "-O2 -DNDEBUG") + else() + set(BLENDER_CMAKE_C_FLAGS_DEBUG "-g") + endif() + set(BLENDER_CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") + set(BLENDER_CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") + set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") + + if(WITH_OPTIMIZED_DEBUG) + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "-O2 -DNDEBUG ${PLATFORM_CXXFLAGS}") + else() + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "-g ${PLATFORM_CXXFLAGS}") + endif() + + set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG ${PLATFORM_CXXFLAGS}") + set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${PLATFORM_CXXFLAGS}") + set(BLENDER_CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG ${PLATFORM_CXXFLAGS}") + + set(CONFIGURE_ENV + export MACOSX_DEPLOYMENT_TARGET=${OSX_DEPLOYMENT_TARGET} && + export CFLAGS=${PLATFORM_CFLAGS} && + export CXXFLAGS=${PLATFORM_CXXFLAGS} && + export LDFLAGS=${PLATFORM_LDFLAGS} + ) + set(CONFIGURE_ENV_NO_PERL ${CONFIGURE_ENV}) + set(CONFIGURE_COMMAND ./configure ${PLATFORM_BUILD_TARGET}) +endif() + +set(DEFAULT_CMAKE_FLAGS + -DCMAKE_BUILD_TYPE=${BUILD_MODE} + -DCMAKE_C_FLAGS_DEBUG=${BLENDER_CMAKE_C_FLAGS_DEBUG} + -DCMAKE_C_FLAGS_MINSIZEREL=${BLENDER_CMAKE_C_FLAGS_MINSIZEREL} + -DCMAKE_C_FLAGS_RELEASE=${BLENDER_CMAKE_C_FLAGS_RELEASE} + -DCMAKE_C_FLAGS_RELWITHDEBINFO=${BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO} + -DCMAKE_CXX_FLAGS_DEBUG=${BLENDER_CMAKE_CXX_FLAGS_DEBUG} + -DCMAKE_CXX_FLAGS_MINSIZEREL=${BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL} + -DCMAKE_CXX_FLAGS_RELEASE=${BLENDER_CMAKE_CXX_FLAGS_RELEASE} + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} + ${PLATFORM_CMAKE_FLAGS} +) + +if(WIN32) + #we need both flavors to build the thumbnail dlls + if(MSVC12) + set(GENERATOR_32 "Visual Studio 12 2013") + set(GENERATOR_64 "Visual Studio 12 2013 Win64") + elseif(MSVC14) + set(GENERATOR_32 "Visual Studio 14 2015") + set(GENERATOR_64 "Visual Studio 14 2015 Win64") + endif() +endif() + + +if(WIN32) + set(ZLIB_LIBRARY zlibstatic${LIBEXT}) +else() + set(ZLIB_LIBRARY libz${LIBEXT}) +endif() + +if(MSVC) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +endif() + +set(CMAKE_INSTALL_MESSAGE LAZY) |