Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b9d1cbc
- Refactoring how OCIO search for minizip-ng. The first step is to se…
cedrik-fuoco-adsk Nov 7, 2022
6f6a484
Update comments
cedrik-fuoco-adsk Nov 8, 2022
265d5f2
Improved find_package in Config mode (adding it back)
cedrik-fuoco-adsk Nov 15, 2022
2d8fc0e
Adding +x permissions for install_minizip_ng and zlib
cedrik-fuoco-adsk Nov 15, 2022
d0e7e7d
Changing target name to match the one used by minizip-ng library (+ u…
cedrik-fuoco-adsk Nov 21, 2022
d7ec9ca
First pass for the OpenColorIOConfig.cmake file with the required dep…
cedrik-fuoco-adsk Nov 28, 2022
21560fe
Adding a informative message when building static ocio instead of per…
cedrik-fuoco-adsk Nov 29, 2022
0d56923
Adding an extra step to test the consumer app with static OpenColorIO…
cedrik-fuoco-adsk Nov 29, 2022
0a00443
Re-using the same test instead of creating a new one by removing the …
cedrik-fuoco-adsk Dec 1, 2022
cf7eaff
Fixing spacing, typo and adding back the NOT in the condition. (it wa…
cedrik-fuoco-adsk Dec 1, 2022
97b89d1
Added general warninig when building static OCIO instead of per depen…
cedrik-fuoco-adsk Dec 6, 2022
f9cb1d0
Changing directory where we share OCIO custom find modules (now in <i…
cedrik-fuoco-adsk Dec 6, 2022
df34c3b
Adding missing backward slashes and saving the build path in an exist…
cedrik-fuoco-adsk Dec 7, 2022
009c8f2
Prevent the download of the dependencies in the scenario where static…
cedrik-fuoco-adsk Dec 7, 2022
76fd877
Changing path where OCIO install its own custom find module.
cedrik-fuoco-adsk Dec 8, 2022
acc80b7
Adding more details in comments
cedrik-fuoco-adsk Dec 9, 2022
857b956
Removing an extra "shell" property in CI workflow.
cedrik-fuoco-adsk Dec 9, 2022
42fe5a4
Fix issues discovered with the failing CI workflow:
cedrik-fuoco-adsk Dec 12, 2022
6a5a7a0
Removing pystring_STATIC_LIBRARY does not exists in CI workflow.
cedrik-fuoco-adsk Dec 13, 2022
705f419
Fix issues on Windows with expat and minizip-ng library naming when b…
cedrik-fuoco-adsk Dec 13, 2022
f84aef2
Added option for macOS CI job in order to get more info on a failed j…
cedrik-fuoco-adsk Dec 14, 2022
2531210
Fixing a issue on macOS.
cedrik-fuoco-adsk Dec 14, 2022
19f8a71
Proposing to remove Findminizip module since external minizip-ng buil…
cedrik-fuoco-adsk Dec 15, 2022
a960467
Removing findminizip.cmake from the install since it does not exist a…
cedrik-fuoco-adsk Dec 15, 2022
c4a2270
Merge branch 'main' into adsk_contrib/ocio-cmake-improvements
cedrik-fuoco-adsk Jan 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 92 additions & 3 deletions .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,12 @@ jobs:
--target install \
--config ${{ matrix.build-type }} \
-- -j$(nproc)
echo "ocio_build_path=$(pwd)" >> $GITHUB_ENV
working-directory: _build
- name: Test
run: ctest -V -C ${{ matrix.build-type }}
working-directory: _build
- name: Test CMake Consumer
- name: Test CMake Consumer with shared OCIO
if: matrix.build-shared == 'ON'
run: |
cmake . \
Expand All @@ -301,6 +302,34 @@ jobs:
--config ${{ matrix.build-type }}
./consumer
working-directory: _build/tests/cmake-consumer-dist
- name: Test CMake Consumer with static OCIO
if: matrix.build-shared == 'OFF'
# The yaml-cpp_VERSION is set below because Findyaml-cpp.cmake needs it but is unable to
# extract it from the headers, like the other modules.
#
# Prefer the static version of each dependencies by using <pkg>_STATIC_LIBRARY.
# Alternatively, this can be done by setting <pkg>_LIBRARY and <pkg>_INCLUDE_DIR to
# the static version of the package.
run: |
cmake . \
-DCMAKE_PREFIX_PATH=../../../_install \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-Dexpat_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dexpat_STATIC_LIBRARY=ON \
-DImath_ROOT=${{ env.ocio_build_path }}/ext/dist \
-DImath_STATIC_LIBRARY=ON \
-Dpystring_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dyaml-cpp_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dyaml-cpp_STATIC_LIBRARY=ON \
-Dyaml-cpp_VERSION=0.7.0 \
-DZLIB_ROOT=${{ env.ocio_build_path }}/ext/dist \
-DZLIB_STATIC_LIBRARY=ON \
-Dminizip-ng_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dminizip-ng_STATIC_LIBRARY=ON
cmake --build . \
--config ${{ matrix.build-type }}
./consumer
working-directory: _build/tests/cmake-consumer-dist

# ---------------------------------------------------------------------------
# macOS
Expand Down Expand Up @@ -424,11 +453,12 @@ jobs:
--target install \
--config ${{ matrix.build-type }} \
-- -j$(sysctl -n hw.ncpu)
echo "ocio_build_path=$(pwd)" >> $GITHUB_ENV
working-directory: _build
- name: Test
run: ctest -V -C ${{ matrix.build-type }}
working-directory: _build
- name: Test CMake Consumer
- name: Test CMake Consumer with shared OCIO
if: matrix.build-shared == 'ON'
run: |
cmake . \
Expand All @@ -438,6 +468,34 @@ jobs:
--config ${{ matrix.build-type }}
./consumer
working-directory: _build/tests/cmake-consumer-dist
- name: Test CMake Consumer with static OCIO
if: matrix.build-shared == 'OFF'
# The yaml-cpp_VERSION is set below because Findyaml-cpp.cmake needs it but is unable to
# extract it from the headers, like the other modules.
#
# Prefer the static version of each dependencies by using <pkg>_STATIC_LIBRARY.
# Alternatively, this can be done by setting <pkg>_LIBRARY and <pkg>_INCLUDE_DIR to
# the static version of the package.
run: |
cmake . \
-DCMAKE_PREFIX_PATH=../../../_install \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-Dexpat_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dexpat_STATIC_LIBRARY=ON \
-DImath_ROOT=${{ env.ocio_build_path }}/ext/dist \
-DImath_STATIC_LIBRARY=ON \
-Dpystring_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dyaml-cpp_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dyaml-cpp_STATIC_LIBRARY=ON \
-Dyaml-cpp_VERSION=0.7.0 \
-DZLIB_ROOT=${{ env.ocio_build_path }}/ext/dist \
-DZLIB_STATIC_LIBRARY=ON \
-Dminizip-ng_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dminizip-ng_STATIC_LIBRARY=ON
cmake --build . \
--config ${{ matrix.build-type }}
./consumer
working-directory: _build/tests/cmake-consumer-dist

# ---------------------------------------------------------------------------
# Windows
Expand Down Expand Up @@ -567,13 +625,14 @@ jobs:
cmake --build . \
--target install \
--config ${{ matrix.build-type }}
echo "ocio_build_path=$(pwd)" >> $GITHUB_ENV
shell: bash
working-directory: _build
- name: Test
run: ctest -V -C ${{ matrix.build-type }}
shell: bash
working-directory: _build
- name: Test CMake Consumer
- name: Test CMake Consumer with shared OCIO
if: matrix.build-shared == 'ON'
run: |
cmake . \
Expand All @@ -585,3 +644,33 @@ jobs:
./${{ matrix.build-type }}/consumer
shell: bash
working-directory: _build/tests/cmake-consumer-dist
- name: Test CMake Consumer with static OCIO
if: matrix.build-shared == 'OFF'
# The yaml-cpp_VERSION is set below because Findyaml-cpp.cmake needs it but is unable to
# extract it from the headers, like the other modules.
#
# Prefer the static version of each dependencies by using <pkg>_STATIC_LIBRARY.
# Alternatively, this can be done by setting <pkg>_LIBRARY and <pkg>_INCLUDE_DIR to
# the static version of the package.
run: |
cmake . \
-DCMAKE_PREFIX_PATH=../../../_install \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-Dexpat_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dexpat_STATIC_LIBRARY=ON \
-DImath_ROOT=${{ env.ocio_build_path }}/ext/dist \
-DImath_STATIC_LIBRARY=ON \
-Dpystring_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dyaml-cpp_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dyaml-cpp_STATIC_LIBRARY=ON \
-Dyaml-cpp_VERSION=0.7.0 \
-DZLIB_ROOT=${{ env.ocio_build_path }}/ext/dist \
-DZLIB_STATIC_LIBRARY=ON \
-Dminizip-ng_ROOT=${{ env.ocio_build_path }}/ext/dist \
-Dminizip-ng_STATIC_LIBRARY=ON
cmake --build . \
--config ${{ matrix.build-type }}
export PATH=../../../_install/bin:$PATH
./${{ matrix.build-type }}/consumer
shell: bash
working-directory: _build/tests/cmake-consumer-dist
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ if(OCIO_BUILD_STATIC)
endif()
endif()

if (NOT BUILD_SHARED_LIBS AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
message(STATUS "Note that building the static version of OpenColorIO does not embed the dependencies\
into the library file. The needed dependencies must be linked to the consumer
application or shared library that uses static OpenColorIO.

The following mandatory dependencies MUST be linked to the consumer application or shared library:
expat, yaml-cpp, Imath, pystring, minizip-ng and ZLIB")
endif()


###############################################################################
# Find or install external dependencies
Expand Down Expand Up @@ -299,6 +308,8 @@ set(OCIO_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets.cmake")
set(OCIO_VERSION_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(OCIO_PROJECT_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
set(OCIO_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(OCIO_CUSTOM_FIND_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/share/OpenColorIO/cmake/modules")
set(OCIO_CUSTOM_MACROS_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/share/OpenColorIO/cmake/macros")

# Version fetched from the top level project()
write_basic_package_version_file(
Expand All @@ -321,6 +332,24 @@ install(
FILE ${OCIO_TARGETS_EXPORT_NAME}
)

if (NOT BUILD_SHARED_LIBS)
# Install custom macros used in the find modules.
install(FILES
${CMAKE_CURRENT_LIST_DIR}/share/cmake/macros/VersionUtils.cmake
DESTINATION ${OCIO_CUSTOM_MACROS_MODULE_DIR}
)

# Install custom Find modules.
install(FILES
${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/Findexpat.cmake
${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/FindImath.cmake
${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/Findpystring.cmake
${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/Findminizip-ng.cmake
${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/Findyaml-cpp.cmake
DESTINATION ${OCIO_CUSTOM_FIND_MODULE_DIR}
)
endif()

install(
FILES "${OCIO_PROJECT_CONFIG}" "${OCIO_VERSION_CONFIG}"
DESTINATION "${OCIO_CONFIG_INSTALL_DIR}"
Expand Down
106 changes: 101 additions & 5 deletions share/cmake/modules/FindExtPackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY ON CACHE BOOL
set(CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY ON CACHE BOOL
"Disable CMake System Package Registry when finding packages")

if (APPLE)
# Store the previous value of CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE.
set(_PREVIOUS_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
set(_PREVIOUS_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})

# Prioritize other paths before Frameworks and Appbundle for find_path, find_library and
# find_package.
set(CMAKE_FIND_FRAMEWORK LAST)
set(CMAKE_FIND_APPBUNDLE LAST)
endif()

###############################################################################
### Packages and versions ###

Expand All @@ -41,14 +52,93 @@ find_package(pystring 1.1.3 REQUIRED)
set(_Imath_ExternalProject_VERSION "3.1.5")
find_package(Imath 3.0 REQUIRED)

# ZLIB
# https://github.com/madler/zlib
set(_zlib_ExternalProject_VERSION "1.2.12")
find_package(zlib REQUIRED)
###############################################################################
### ZLIB (https://github.com/madler/zlib)
###
### The following variables can be set:
### ZLIB_ROOT Location of ZLIB library file and includes folder.
### Alternatively, ZLIB_LIBRARY and ZLIB_INCLUDE_DIR can be used.
###
### ZLIB_LIBRARY Location of ZLIB library file.
### ZLIB_INCLUDE_DIR Location of ZLIB includes folder.
###
### ZLIB_VERSION ZLIB Version (CMake 3.26+)
### ZLIB_VERSION_STRING ZLIB Version (CMake < 3.26)
###
###############################################################################
# ZLIB 1.2.13 is used since it fixes a critical vulnerability.
# See https://nvd.nist.gov/vuln/detail/CVE-2022-37434
# See https://github.com/madler/zlib/releases/tag/v1.2.13
set(_ZLIB_FIND_VERSION "1.2.13")
set(_ZLIB_ExternalProject_VERSION ${_ZLIB_FIND_VERSION})

if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL)
# ZLIB_USE_STATIC_LIBS is supported only from CMake 3.24+.
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
if (ZLIB_STATIC_LIBRARY)
set(ZLIB_USE_STATIC_LIBS "${ZLIB_STATIC_LIBRARY}")
endif()
else() # For CMake < 3.24 since ZLIB_USE_STATIC_LIBS is not available.
if(NOT ZLIB_LIBRARY)
if(DEFINED CMAKE_FIND_LIBRARY_PREFIXES)
set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
else()
set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES)
endif()

if(DEFINED CMAKE_FIND_LIBRARY_SUFFIXES)
set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")
else()
set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
endif()

# Prefix/suffix for windows.
if(WIN32)
list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib")
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a")
endif()

# Check if static lib is preferred.
if(ZLIB_STATIC_LIBRARY OR ZLIB_USE_STATIC_LIBS)
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
endif()
endif()
endif()

set(_ZLIB_REQUIRED REQUIRED)
# Override REQUIRED if package can be installed
if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING)
set(_ZLIB_REQUIRED "")
endif()

find_package(ZLIB ${_ZLIB_FIND_VERSION} ${_ZLIB_REQUIRED})

# Restore the original find library ordering
if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}")
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES)
endif()

if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES)
set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}")
else()
set(CMAKE_FIND_LIBRARY_PREFIXES)
endif()
endif()

if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
include(InstallZLIB)
endif()
###############################################################################

# minizip-ng
# https://github.com/zlib-ng/minizip-ng
find_package(minizip-ng 3.0.6 REQUIRED)
find_package(minizip-ng 3.0.7 REQUIRED)

if(OCIO_BUILD_APPS)

Expand Down Expand Up @@ -157,3 +247,9 @@ if(OCIO_BUILD_TESTS)
message(WARNING "Could NOT find OpenImageIO. Skipping build of the OSL unit tests.")
endif()
endif()

if (APPLE)
# Restore CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE values.
set(CMAKE_FIND_FRAMEWORK ${_PREVIOUS_CMAKE_FIND_FRAMEWORK})
set(CMAKE_FIND_APPBUNDLE ${_PREVIOUS_CMAKE_FIND_APPBUNDLE})
endif()
11 changes: 10 additions & 1 deletion share/cmake/modules/FindImath.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
###############################################################################
### Try to find package ###

# BUILD_TYPE_DEBUG variable is currently set in one of the OCIO's CMake files.
# Now that some OCIO's find module are installed with the library itself (with static build),
# a consumer app don't have access to the variables set by an OCIO's CMake files. Therefore, some
# OCIO's find modules must detect the build type by itselves.
set(BUILD_TYPE_DEBUG OFF)
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
set(BUILD_TYPE_DEBUG ON)
endif()

if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL)
set(_Imath_REQUIRED_VARS Imath_LIBRARY)
set(_Imath_LIB_VER "${Imath_FIND_VERSION_MAJOR}_${Imath_FIND_VERSION_MINOR}")
Expand Down Expand Up @@ -131,7 +140,7 @@ endif()
###############################################################################
### Install package from source ###

if(NOT Imath_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
if(NOT Imath_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
include(ExternalProject)
include(GNUInstallDirs)

Expand Down
17 changes: 11 additions & 6 deletions share/cmake/modules/FindOpenEXR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL)
if(OpenEXR_FOUND)
get_target_property(OpenEXR_LIBRARY OpenEXR::OpenEXR LOCATION)
get_target_property(OpenEXR_INCLUDE_DIR OpenEXR::OpenEXR INTERFACE_INCLUDE_DIRECTORIES)

# IMPORTED_GLOBAL property must be set to TRUE since alisasing a non-global imported target
# is not possible until CMake 3.18+.
set_target_properties(OpenEXR::OpenEXR PROPERTIES IMPORTED_GLOBAL TRUE)
endif()

# Override REQUIRED if package can be installed
Expand Down Expand Up @@ -77,21 +81,22 @@ macro(set_target_location target_name)
endif()
endmacro()

if(NOT OpenEXR_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
if(NOT OpenEXR_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
include(ExternalProject)
include(GNUInstallDirs)

set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist")
set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build")

# Required dependency
# OCIO custom module to find ZLIB. (Findzlib)
find_package(zlib)
if(NOT ZLIB_FOUND)
message(STATUS "ZLib is required to build OpenEXR.")
return()
find_package(ZLIB)
if(NOT ZLIB_FOUND)
message(STATUS "ZLib is required to build OpenEXR.")
return()
endif()
endif()

find_package(Threads)
if(NOT Threads_FOUND)
message(STATUS "Threads is required to build OpenEXR.")
Expand Down
Loading