Skip to content

Commit

Permalink
Fix yaml-cpp build issues (#1907)
Browse files Browse the repository at this point in the history
Signed-off-by: Rémi Achard <remiachard@gmail.com>
Co-authored-by: Doug Walker <doug.walker@autodesk.com>
  • Loading branch information
remia and doug-walker committed Nov 22, 2023
1 parent 4f4f30e commit 41441bb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 27 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2023
install-ext-packages: MISSING
- build: 11
build-type: Release
build-shared: 'ON'
Expand All @@ -89,6 +90,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2023
install-ext-packages: ALL
- build: 10
build-type: Release
build-shared: 'OFF'
Expand All @@ -101,6 +103,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2023
install-ext-packages: ALL
# -------------------------------------------------------------------
# VFX CY2022 (Python 3.9)
# -------------------------------------------------------------------
Expand All @@ -116,6 +119,7 @@ jobs:
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2022
install-ext-packages: ALL
- build: 8
build-type: Release
build-shared: 'ON'
Expand All @@ -128,6 +132,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2022
install-ext-packages: MISSING
- build: 7
build-type: Release
build-shared: 'OFF'
Expand All @@ -140,6 +145,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2022
install-ext-packages: ALL
# -------------------------------------------------------------------
# VFX CY2021 (Python 3.7)
# -------------------------------------------------------------------
Expand All @@ -155,6 +161,7 @@ jobs:
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2021
install-ext-packages: MISSING
- build: 5
build-type: Release
build-shared: 'OFF'
Expand All @@ -167,6 +174,7 @@ jobs:
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2021
install-ext-packages: ALL
- build: 4
build-type: Debug
build-shared: 'ON'
Expand All @@ -179,6 +187,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2021
install-ext-packages: ALL
# -------------------------------------------------------------------
# VFX CY2020 (Python 3.7)
# -------------------------------------------------------------------
Expand All @@ -194,6 +203,7 @@ jobs:
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2020
install-ext-packages: MISSING
- build: 2
build-type: Debug
build-shared: 'OFF'
Expand All @@ -206,6 +216,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2020
install-ext-packages: ALL
- build: 1
build-type: Release
build-shared: 'ON'
Expand All @@ -218,6 +229,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2020
install-ext-packages: ALL
env:
CXX: ${{ matrix.cxx-compiler }}
CC: ${{ matrix.cc-compiler }}
Expand Down Expand Up @@ -245,7 +257,7 @@ jobs:
-DOCIO_BUILD_GPU_TESTS=OFF \
-DOCIO_USE_SIMD=${{ matrix.use-simd }} \
-DOCIO_USE_OIIO_FOR_APPS=${{ matrix.use-oiio }} \
-DOCIO_INSTALL_EXT_PACKAGES=ALL \
-DOCIO_INSTALL_EXT_PACKAGES=${{ matrix.install-ext-packages }} \
-DOCIO_WARNING_AS_ERROR=ON \
-DPython_EXECUTABLE=$(which python)
working-directory: _build
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/dependencies_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2022
use-oiio: 'ON'
- build: 2
build-docs: 'OFF'
build-openfx: 'OFF'
Expand All @@ -62,6 +63,7 @@ jobs:
cc-compiler: gcc
compiler-desc: GCC
vfx-cy: 2021
use-oiio: 'OFF'
# -------------------------------------------------------------------
# Clang
# -------------------------------------------------------------------
Expand All @@ -73,6 +75,7 @@ jobs:
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2022
use-oiio: 'OFF'
- build: 4
build-docs: 'ON'
build-openfx: 'ON'
Expand All @@ -81,6 +84,7 @@ jobs:
cc-compiler: clang
compiler-desc: Clang
vfx-cy: 2021
use-oiio: 'ON'
env:
CXX: ${{ matrix.cxx-compiler }}
CC: ${{ matrix.cc-compiler }}
Expand Down Expand Up @@ -132,7 +136,7 @@ jobs:
-DOCIO_INSTALL_EXT_PACKAGES=NONE \
-DOCIO_WARNING_AS_ERROR=OFF \
-DPython_EXECUTABLE=$(which python) \
-DOCIO_USE_OIIO_CMAKE_CONFIG=ON
-DOCIO_USE_OIIO_FOR_APPS=${{ matrix.use-oiio }}
working-directory: _build
- name: Build
run: |
Expand Down Expand Up @@ -176,11 +180,13 @@ jobs:
build-openfx: 'ON'
cxx-standard: 17
python-version: '3.11'
use-oiio: 'ON'
- build: 2
build-docs: 'ON'
build-openfx: 'ON'
cxx-standard: 14
python-version: '3.9'
use-oiio: 'OFF'
steps:
- name: Setup Python
uses: actions/setup-python@v4
Expand Down Expand Up @@ -235,7 +241,7 @@ jobs:
-DOCIO_INSTALL_EXT_PACKAGES=NONE \
-DOCIO_WARNING_AS_ERROR=OFF \
-DPython_EXECUTABLE=$(which python) \
-DOCIO_USE_OIIO_CMAKE_CONFIG=ON
-DOCIO_USE_OIIO_FOR_APPS=${{ matrix.use-oiio }}
working-directory: _build
- name: Build
run: |
Expand Down Expand Up @@ -279,11 +285,13 @@ jobs:
build-openfx: 'ON'
cxx-standard: 17
python-version: '3.11'
use-oiio: 'ON'
- build: 2
build-docs: 'ON'
build-openfx: 'ON'
cxx-standard: 14
python-version: '3.9'
use-oiio: 'OFF'
steps:
- name: Setup Python
uses: actions/setup-python@v4
Expand Down Expand Up @@ -362,7 +370,7 @@ jobs:
-DOCIO_WARNING_AS_ERROR=OFF \
-DPython_EXECUTABLE=$(which python) \
-DOCIO_BUILD_PYTHON=OFF \
-DOCIO_USE_OIIO_CMAKE_CONFIG=ON
-DOCIO_USE_OIIO_FOR_APPS=${{ matrix.use-oiio }}
shell: bash
working-directory: _build
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion share/cmake/macros/ocio_handle_dependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ macro (ocio_handle_dependency dep_name)
endif()
if(ocio_dep_REQUIRED)
if(NOT ${dep_name}_FOUND AND NOT ocio_dep_VERSION)
if(NOT ${dep_name}_FOUND)
message(SEND_ERROR "${ColorError}${dep_name} is required, will abort at the end.${ColorReset}")
endif()
endif()
Expand Down
16 changes: 9 additions & 7 deletions share/cmake/modules/Findyaml-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if(yaml-cpp_FIND_QUIETLY)
endif()

if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL)
set(_yaml-cpp_REQUIRED_VARS yaml-cpp_LIBRARY)

# Search for yaml-cpp-config.cmake
if(NOT DEFINED yaml-cpp_ROOT)
Expand All @@ -57,13 +58,15 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL)
add_library(yaml-cpp::yaml-cpp ALIAS yaml-cpp)
endif()

set(yaml-cpp_INCLUDE_DIR ${YAML_CPP_INCLUDE_DIR})
get_target_property(yaml-cpp_INCLUDE_DIR yaml-cpp::yaml-cpp INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(yaml-cpp_LIBRARY yaml-cpp::yaml-cpp LOCATION)
else()

# As yaml-cpp-config.cmake search fails, search an installed library
# using yaml-cpp.pc .

list(APPEND _yaml-cpp_REQUIRED_VARS yaml-cpp_INCLUDE_DIR yaml-cpp_VERSION)

# Search for yaml-cpp.pc
find_package(PkgConfig ${quiet})
pkg_check_modules(PC_yaml-cpp ${quiet} "yaml-cpp>=${yaml-cpp_FIND_VERSION}")
Expand Down Expand Up @@ -131,14 +134,10 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL)
set(yaml-cpp_FIND_REQUIRED FALSE)
endif()

set(YAML_CPP_INCLUDE_DIR "${yaml-cpp_INCLUDE_DIR}")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(yaml-cpp
REQUIRED_VARS
yaml-cpp_LIBRARY
yaml-cpp_INCLUDE_DIR
yaml-cpp_VERSION
${_yaml-cpp_REQUIRED_VARS}
VERSION_VAR
yaml-cpp_VERSION
)
Expand All @@ -149,7 +148,7 @@ endif()
###############################################################################
### Create target

if (NOT TARGET yaml-cpp::yaml-cpp)
if (yaml-cpp_FOUND AND NOT TARGET yaml-cpp::yaml-cpp)
add_library(yaml-cpp::yaml-cpp UNKNOWN IMPORTED GLOBAL)
set_target_properties(yaml-cpp::yaml-cpp PROPERTIES
IMPORTED_LOCATION ${yaml-cpp_LIBRARY}
Expand All @@ -163,8 +162,11 @@ if (NOT TARGET yaml-cpp::yaml-cpp)
if (NOT TARGET yaml-cpp)
add_library(yaml-cpp ALIAS yaml-cpp::yaml-cpp)
endif ()
endif ()

if (yaml-cpp_FOUND)
# TODO: Remove this variable and use the `yaml-cpp::yaml-cpp` target
# directly when the minimum version of yaml-cpp is updated to 0.8.
get_target_property(YAML_CPP_INCLUDE_DIR yaml-cpp::yaml-cpp INCLUDE_DIRECTORIES)
set(YAML_CPP_LIBRARIES yaml-cpp::yaml-cpp)
endif ()
20 changes: 5 additions & 15 deletions share/cmake/modules/install/Installyaml-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
###############################################################################
### Create target (if previous 'find_package' call hasn't) ###

if(NOT TARGET yaml-cpp)
add_library(yaml-cpp UNKNOWN IMPORTED GLOBAL)
if(NOT TARGET yaml-cpp::yaml-cpp)
add_library(yaml-cpp::yaml-cpp UNKNOWN IMPORTED GLOBAL)
set(_yaml-cpp_TARGET_CREATE TRUE)
endif()

Expand Down Expand Up @@ -138,7 +138,7 @@ if(NOT yaml-cpp_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PAC
--parallel
)

add_dependencies(yaml-cpp yaml-cpp_install)
add_dependencies(yaml-cpp::yaml-cpp yaml-cpp_install)
if(OCIO_VERBOSE)
message(STATUS "Installing yaml-cpp: ${yaml-cpp_LIBRARY} (version \"${yaml-cpp_VERSION}\")")
endif()
Expand All @@ -149,23 +149,13 @@ endif()
### Configure target ###

if(_yaml-cpp_TARGET_CREATE)
set_target_properties(yaml-cpp PROPERTIES
set_target_properties(yaml-cpp::yaml-cpp PROPERTIES
IMPORTED_LOCATION ${yaml-cpp_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${yaml-cpp_INCLUDE_DIR}
)

mark_as_advanced(yaml-cpp_INCLUDE_DIR yaml-cpp_LIBRARY yaml-cpp_VERSION)
endif()

###############################################################################
### Set variables for compatibility ###

if(TARGET yaml-cpp AND NOT TARGET yaml-cpp::yaml-cpp)
add_library(yaml-cpp::yaml-cpp ALIAS yaml-cpp)
endif()

if(yaml-cpp_INCLUDE_DIR)
set(YAML_CPP_INCLUDE_DIR "${yaml-cpp_INCLUDE_DIR}")
endif()

set(YAML_CPP_INCLUDE_DIR "${yaml-cpp_INCLUDE_DIR}")
set(YAML_CPP_LIBRARIES yaml-cpp::yaml-cpp)

0 comments on commit 41441bb

Please sign in to comment.