build_environment: opencolorio 1.1.0
[blender.git] / build_files / build_environment / cmake / opencolorio.cmake
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ***** END GPL LICENSE BLOCK *****
18
19 set(OPENCOLORIO_EXTRA_ARGS
20         -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING}
21         -DBoost_USE_MULTITHREADED=ON
22         -DBoost_USE_STATIC_LIBS=ON
23         -DBoost_USE_STATIC_RUNTIME=ON
24         -DBOOST_ROOT=${LIBDIR}/boost
25         -DBOOST_INCLUDEDIR=${LIBDIR}/boost/include/boost_1_68/boost
26         -DBoost_NO_SYSTEM_PATHS=ON
27         -DBoost_DEBUG=ON
28         -DBoost_MAJOR_VERSION=1
29         -DBoost_MINOR_VERSION=60
30         -DOCIO_BUILD_APPS=OFF
31         -DOCIO_BUILD_PYGLUE=OFF
32         -DOCIO_BUILD_NUKE=OFF
33 )
34
35 if(WIN32)
36         set(OCIO_PATCH opencolorio_win.diff)
37         set(OPENCOLORIO_EXTRA_ARGS
38                 ${OPENCOLORIO_EXTRA_ARGS}
39                 -DOCIO_BUILD_SHARED=OFF
40                 -DOCIO_BUILD_STATIC=ON
41                 -DOCIO_BUILD_TRUELIGHT=OFF
42                 -DOCIO_BUILD_APPS=OFF
43                 -DOCIO_BUILD_NUKE=OFF
44                 -DOCIO_BUILD_DOCS=OFF
45                 -DOCIO_BUILD_TESTS=OFF
46                 -DOCIO_BUILD_PYGLUE=OFF
47                 -DOCIO_BUILD_JNIGLUE=OFF
48                 -DOCIO_STATIC_JNIGLUE=OFF
49                 -DOCIO_USE_SSE=ON
50                 -DOCIO_INLINES_HIDDEN=OFF
51                 -DOCIO_USE_BOOST_PTR=OFF
52                 -DOCIO_PYGLUE_LINK=OFF
53                 -DOCIO_PYGLUE_RESPECT_ABI=OFF
54                 -DOCIO_PYGLUE_SONAME=OFF
55                 -DOCIO_PYGLUE_LIB_PREFIX=OFF
56                 -DUSE_EXTERNAL_TINYXML=ON
57                 -DTINYXML_INCLUDE_DIR=${LIBDIR}/tinyxml/include
58                 -DTINYXML_LIBRARY=${LIBDIR}/tinyxml/lib/tinyxml${libext}
59                 -DUSE_EXTERNAL_YAML=ON
60                 -DYAML_CPP_FOUND=ON
61                 -DYAML_CPP_VERSION=${YAMLCPP_VERSION}
62                 -DUSE_EXTERNAL_LCMS=ON
63                 -DINC_1=${LIBDIR}/tinyxml/include
64                 -DINC_2=${LIBDIR}/yamlcpp/include
65         )
66 else()
67         set(OCIO_PATCH opencolorio.diff)
68         set(OPENCOLORIO_EXTRA_ARGS
69                 ${OPENCOLORIO_EXTRA_ARGS}
70                 -DOCIO_USE_BOOST_PTR=OFF
71                 -DOCIO_BUILD_STATIC=ON
72                 -DOCIO_BUILD_SHARED=OFF
73         )
74 endif()
75
76 ExternalProject_Add(external_opencolorio
77         URL ${OPENCOLORIO_URI}
78         DOWNLOAD_DIR ${DOWNLOAD_DIR}
79         URL_HASH MD5=${OPENCOLORIO_HASH}
80         PREFIX ${BUILD_DIR}/opencolorio
81         PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/opencolorio/src/external_opencolorio < ${PATCH_DIR}/${OCIO_PATCH}
82         CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/opencolorio ${DEFAULT_CMAKE_FLAGS} ${OPENCOLORIO_EXTRA_ARGS}
83         INSTALL_DIR ${LIBDIR}/opencolorio
84 )
85
86 if(NOT WIN32)
87         add_custom_command(
88                 OUTPUT ${LIBDIR}/opencolorio/lib/libtinyxml.a
89                 COMMAND cp ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/libtinyxml.a ${LIBDIR}/opencolorio/lib/libtinyxml.a
90                 COMMAND cp ${BUILD_DIR}/opencolorio/src/external_opencolorio-build/ext/dist/lib/libyaml-cpp.a ${LIBDIR}/opencolorio/lib/libyaml-cpp.a
91         )
92         add_custom_target(external_opencolorio_extra ALL DEPENDS external_opencolorio ${LIBDIR}/opencolorio/lib/libtinyxml.a)
93 endif()
94
95 add_dependencies(
96         external_opencolorio
97         external_boost
98 )
99
100 if(WIN32)
101         add_dependencies(
102                 external_opencolorio
103                 external_tinyxml
104                 external_yamlcpp
105         )
106         if(BUILD_MODE STREQUAL Release)
107                 ExternalProject_Add_Step(external_opencolorio after_install
108                         COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/include ${HARVEST_TARGET}/opencolorio/include
109                         COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/lib/static ${HARVEST_TARGET}/opencolorio/lib
110                         COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/yamlcpp/lib/libyaml-cppmt.lib ${HARVEST_TARGET}/opencolorio/lib/libyaml-cpp.lib
111                         COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/tinyxml/lib/tinyxml.lib ${HARVEST_TARGET}/opencolorio/lib/tinyxml.lib
112                         DEPENDEES install
113                 )
114         endif()
115         
116 endif()
117