-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: support static OCIO self-builds (#4517)
* Add build recipes for certain dependencies needed for linking static OpenColorIO libs: expat, minizip-ng, pystring, and yaml-cpp * Add SOURCE_SUBDIR option to `build_dependency_with_cmake` that mimics the behavior of the FetchContent option of the same name * Tweak OpenColorIO build recipe to always build static libraries by default. --------- Signed-off-by: Zach Lewis <[email protected]>
- Loading branch information
Showing
7 changed files
with
260 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
||
###################################################################### | ||
# expat by hand! | ||
###################################################################### | ||
|
||
set_cache (expat_BUILD_VERSION 2.6.3 "expat version for local builds") | ||
set (expat_GIT_REPOSITORY "https://github.com/libexpat/libexpat") | ||
|
||
string(REPLACE "." ";" VERSION_LIST ${expat_BUILD_VERSION}) | ||
list(GET VERSION_LIST 0 expat_VERSION_MAJOR) | ||
list(GET VERSION_LIST 1 expat_VERSION_MINOR) | ||
list(GET VERSION_LIST 2 expat_VERSION_PATCH) | ||
|
||
set (expat_GIT_TAG "R_${expat_VERSION_MAJOR}_${expat_VERSION_MINOR}_${expat_VERSION_PATCH}") | ||
set_cache (expat_BUILD_SHARED_LIBS OFF #${LOCAL_BUILD_SHARED_LIBS_DEFAULT} | ||
DOC "Should execute a local expat build, if necessary, build shared libraries" ADVANCED) | ||
|
||
|
||
set (expat_LOCAL_SOURCE_DIR "${${PROJECT_NAME}_LOCAL_DEPS_ROOT}/expat/expat") | ||
|
||
build_dependency_with_cmake(expat | ||
VERSION ${expat_BUILD_VERSION} | ||
GIT_REPOSITORY ${expat_GIT_REPOSITORY} | ||
GIT_TAG ${expat_GIT_TAG} | ||
SOURCE_SUBDIR expat/ | ||
CMAKE_ARGS | ||
-D BUILD_SHARED_LIBS=${expat_BUILD_SHARED_LIBS} | ||
-D CMAKE_POSITION_INDEPENDENT_CODE=ON | ||
-D CMAKE_INSTALL_LIBDIR=lib | ||
-D CMAKE_C_FLAGS=${EXPAT_C_FLAGS} | ||
-D CMAKE_CXX_FLAGS=${EXPAT_CXX_FLAGS} | ||
-D EXPAT_BUILD_EXAMPLES=OFF | ||
-D EXPAT_BUILD_TESTS=OFF | ||
-D EXPAT_BUILD_TOOLS=OFF | ||
-D EXPAT_BUILD_DOCS=OFF | ||
-D EXPAT_SHARED_LIBS=${expat_BUILD_SHARED_LIBS} | ||
) | ||
|
||
# Set some things up that we'll need for a subsequent find_package to work | ||
set (expat_REFIND TRUE) | ||
set (expat_VERSION ${expat_BUILD_VERSION}) | ||
set (expat_DIR ${expat_ROOT}/lib/cmake/expat-${expat_VERSION}) | ||
|
||
if (WIN32) | ||
# Set the expat_LIBRARY variable to the full path to ${EXPAT_LIBRARIES}. | ||
# For some reason, find_package(expat) behaves differently on Windows | ||
find_package (EXPAT ${expat_BUILD_VERSION} EXACT REQUIRED) | ||
set_cache(expat_LIBRARY ${EXPAT_LIBRARIES} "Full path to the expat library") | ||
message(STATUS "expat_LIBRARY = ${expat_LIBRARY}") | ||
endif () | ||
|
||
if (expat_BUILD_SHARED_LIBS) | ||
install_local_dependency_libs (expat expat) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
||
###################################################################### | ||
# minizip-ng by hand! | ||
###################################################################### | ||
|
||
|
||
set_cache (minizip-ng_BUILD_VERSION 4.0.7 "minizip-ng version for local builds") | ||
set (minizip-ng_GIT_REPOSITORY "https://github.com/zlib-ng/minizip-ng") | ||
set (minizip-ng_GIT_TAG "${minizip-ng_BUILD_VERSION}") | ||
|
||
set_cache (minizip-ng_BUILD_SHARED_LIBS OFF | ||
DOC "Should a local minizip-ng build, if necessary, build shared libraries" ADVANCED) | ||
|
||
checked_find_package (ZLIB REQUIRED) | ||
|
||
|
||
build_dependency_with_cmake(minizip-ng | ||
VERSION ${minizip-ng_BUILD_VERSION} | ||
GIT_REPOSITORY ${minizip-ng_GIT_REPOSITORY} | ||
GIT_TAG ${minizip-ng_GIT_TAG} | ||
CMAKE_ARGS | ||
-D BUILD_SHARED_LIBS=${minizip-ng_BUILD_SHARED_LIBS} | ||
-D CMAKE_POSITION_INDEPENDENT_CODE=ON | ||
-D CMAKE_INSTALL_LIBDIR=lib | ||
# Since the other modules create a subfolder for the includes by default and since | ||
# minizip-ng does not, a suffix is added to CMAKE_INSTALL_INCLUDEDIR in order to | ||
# install the headers under a subdirectory named "minizip-ng". | ||
# Note that this does not affect external builds for minizip-ng. | ||
-D CMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng | ||
-D MZ_OPENSSL=OFF | ||
-D MZ_LIBBSD=OFF | ||
-D MZ_BUILD_TESTS=OFF | ||
-D MZ_COMPAT=OFF | ||
-D MZ_BZIP2=OFF | ||
-D MZ_LZMA=OFF | ||
-D MZ_LIBCOMP=OFF | ||
-D MZ_ZSTD=OFF | ||
-D MZ_PKCRYPT=OFF | ||
-D MZ_WZAES=OFF | ||
-D MZ_SIGNING=OFF | ||
-D MZ_ZLIB=ON | ||
-D MZ_ICONV=OFF | ||
-D MZ_FETCH_LIBS=OFF | ||
-D MZ_FORCE_FETCH_LIBS=OFF | ||
-D ZLIB_LIBRARY=${ZLIB_LIBRARIES} | ||
-D ZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} | ||
) | ||
|
||
|
||
set (minizip-ng_DIR ${minizip-ng_LOCAL_INSTALL_DIR}/lib/cmake/minizip-ng) | ||
set (minizip-ng_VERSION ${minizip-ng_BUILD_VERSION}) | ||
set (minizip-ng_REFIND TRUE) | ||
set (minizip-ng_REFIND_VERSION ${minizip-ng_BUILD_VERSION}) | ||
set (minizip-ng_REFIND_ARGS REQUIRED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
||
###################################################################### | ||
# pystring by hand! | ||
###################################################################### | ||
|
||
set_cache (pystring_BUILD_VERSION 1.1.4 "pystring version for local builds") | ||
set (pystring_GIT_REPOSITORY "https://github.com/imageworks/pystring") | ||
# See imageworks/pystring issue #43, git commit #c5ca4f5 | ||
# We require pystring commits made after the v1.1.4 tag to properly install headers! | ||
# TODO: Set this to "v${pystring_BUILD_VERSION}" once 1.1.5 is released | ||
set (pystring_GIT_TAG master) | ||
|
||
|
||
set_cache (pystring_BUILD_SHARED_LIBS OFF | ||
DOC "Should a local pystring build, if necessary, build shared libraries" ADVANCED) | ||
|
||
string (MAKE_C_IDENTIFIER ${pystring_BUILD_VERSION} pystring_VERSION_IDENT) | ||
|
||
build_dependency_with_cmake(pystring | ||
VERSION ${pystring_BUILD_VERSION} | ||
GIT_REPOSITORY ${pystring_GIT_REPOSITORY} | ||
GIT_TAG ${pystring_GIT_TAG} | ||
CMAKE_ARGS | ||
-D BUILD_SHARED_LIBS=${pystring_BUILD_SHARED_LIBS} | ||
-D CMAKE_POSITION_INDEPENDENT_CODE=ON | ||
-D CMAKE_INSTALL_LIBDIR=lib | ||
) | ||
|
||
set (pystring_VERSION ${pystring_BUILD_VERSION}) | ||
|
||
set (pystring_REFIND TRUE) | ||
set (pystring_REFIND_VERSION ${pystring_BUILD_VERSION}) | ||
|
||
|
||
if (pystring_BUILD_SHARED_LIBS) | ||
install_local_dependency_libs (pystring pystring) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
||
###################################################################### | ||
# yaml-cpp by hand! | ||
###################################################################### | ||
|
||
set_cache (yaml-cpp_BUILD_VERSION 0.8.0 "yaml-cpp version for local builds") | ||
set (yaml-cpp_GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp") | ||
set (yaml-cpp_GIT_TAG "${yaml-cpp_BUILD_VERSION}") # NB: versions earlier than 0.8.0 had a "yaml-cpp-" prefix | ||
|
||
set_cache (yaml-cpp_BUILD_SHARED_LIBS OFF | ||
DOC "Should a local yaml-cpp build, if necessary, build shared libraries" ADVANCED) | ||
|
||
string (MAKE_C_IDENTIFIER ${yaml-cpp_BUILD_VERSION} yaml-cpp_VERSION_IDENT) | ||
|
||
build_dependency_with_cmake(yaml-cpp | ||
VERSION ${yaml-cpp_BUILD_VERSION} | ||
GIT_REPOSITORY ${yaml-cpp_GIT_REPOSITORY} | ||
GIT_TAG ${yaml-cpp_GIT_TAG} | ||
CMAKE_ARGS | ||
-D YAML_CPP_BUILD_TESTS=OFF | ||
-D YAML_CPP_BUILD_TOOLS=OFF | ||
-D YAML_CPP_BUILD_CONTRIB=OFF | ||
-D YAML_BUILD_SHARED_LIBS=${yaml-cpp_BUILD_SHARED_LIBS} | ||
-D CMAKE_INSTALL_LIBDIR=lib | ||
) | ||
|
||
set (yaml-cpp_ROOT ${yaml-cpp_LOCAL_INSTALL_DIR}) | ||
set (yaml-cpp_DIR ${yaml-cpp_LOCAL_INSTALL_DIR}) | ||
set (yaml-cpp_VERSION ${yaml-cpp_BUILD_VERSION}) | ||
|
||
set (yaml-cpp_REFIND TRUE) | ||
set (yaml-cpp_REFIND_ARGS CONFIG) | ||
set (yaml-cpp_REFIND_VERSION ${yaml-cpp_BUILD_VERSION}) | ||
|
||
|
||
if (yaml-cpp_BUILD_SHARED_LIBS) | ||
install_local_dependency_libs (yaml-cpp yaml-cpp) | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright Contributors to the OpenImageIO project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# https://github.com/AcademySoftwareFoundation/OpenImageIO | ||
|
||
include (FindPackageHandleStandardArgs) | ||
|
||
# Find include directory | ||
find_path(pystring_INCLUDE_DIR | ||
NAMES | ||
pystring.h | ||
HINTS | ||
${pystring_ROOT} | ||
PATH_SUFFIXES | ||
include | ||
include/pystring | ||
pystring/include | ||
) | ||
|
||
# Find library | ||
find_library(pystring_LIBRARY | ||
NAMES | ||
pystring libpystring | ||
HINTS | ||
${pystring_ROOT} | ||
PATH_SUFFIXES | ||
pystring/lib | ||
lib64 | ||
lib | ||
) | ||
|
||
find_package_handle_standard_args(pystring | ||
REQUIRED_VARS | ||
pystring_INCLUDE_DIR | ||
pystring_LIBRARY | ||
VERSION_VAR pystring_VERSION | ||
) | ||
set(pystring_FOUND ${pystring_FOUND}) | ||
|
||
|
||
if(pystring_FOUND AND NOT TARGET pystring::pystring) | ||
add_library(pystring::pystring UNKNOWN IMPORTED GLOBAL) | ||
set(_pystring_TARGET_CREATE TRUE) | ||
endif() | ||
|
||
|
||
if(_pystring_TARGET_CREATE) | ||
set_target_properties(pystring::pystring PROPERTIES | ||
IMPORTED_LOCATION ${pystring_LIBRARY} | ||
INTERFACE_INCLUDE_DIRECTORIES ${pystring_INCLUDE_DIR} | ||
) | ||
|
||
mark_as_advanced(pystring_INCLUDE_DIR pystring_LIBRARY pystring_VERSION) | ||
endif() | ||
|