Skip to content

Commit

Permalink
Tentative fix yaml-cpp install
Browse files Browse the repository at this point in the history
Signed-off-by: Rémi Achard <[email protected]>
  • Loading branch information
remia committed Nov 14, 2023
1 parent f676942 commit f60745a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ string(REPLACE ";" ", " _EXT_OPTIONS_STR "${_EXT_OPTIONS}")

# Default option
set(_OCIO_INSTALL_EXT_PACKAGES "MISSING")
message(STATUS "Incoming OCIO_INSTALL_EXT_PACKAGES: ${OCIO_INSTALL_EXT_PACKAGES}")

if(DEFINED OCIO_INSTALL_EXT_PACKAGES)
# Case insensitive match
Expand All @@ -367,6 +368,7 @@ set(OCIO_INSTALL_EXT_PACKAGES "${_OCIO_INSTALL_EXT_PACKAGES}" CACHE STRING
"Set the condition for Installing external dependencies" FORCE)

set_property(CACHE OCIO_INSTALL_EXT_PACKAGES PROPERTY STRINGS ${_EXT_OPTIONS})
message(STATUS "Final OCIO_INSTALL_EXT_PACKAGES: ${OCIO_INSTALL_EXT_PACKAGES}")


###############################################################################
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def build_extension(self, ext):
subprocess.check_call(
["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp
)
print("Command line call args: ", cmake_args)
subprocess.check_call(
["cmake", "--build", "."] + build_args, cwd=self.build_temp
)
Expand Down
2 changes: 2 additions & 0 deletions share/cmake/macros/ocio_handle_dependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ macro (ocio_handle_dependency dep_name)
${ARGN})
set(ocio_dep_FORCE_INSTALLATION OFF)
message(STATUS "ocio_dep_ALLOW_INSTALL ${ocio_dep_ALLOW_INSTALL}")
message(STATUS "OCIO_INSTALL_EXT_PACKAGES ${OCIO_INSTALL_EXT_PACKAGES}")
if(ocio_dep_ALLOW_INSTALL AND OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL)
set(ocio_dep_FORCE_INSTALLATION ON)
endif()
Expand Down
2 changes: 1 addition & 1 deletion share/cmake/modules/Findyaml-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,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 Down
28 changes: 11 additions & 17 deletions share/cmake/modules/install/Installyaml-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
###############################################################################
### 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)
message(STATUS "Creating yaml-cpp::yaml-cpp target")
endif()

###############################################################################
Expand All @@ -44,6 +45,7 @@ if(NOT yaml-cpp_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PAC
set(yaml-cpp_VERSION ${yaml-cpp_FIND_VERSION})
endif()
set(yaml-cpp_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}")
message(STATUS "Set yaml-cpp_INCLUDE_DIR to ${yaml-cpp_INCLUDE_DIR}")

# Starting from 0.7.0, this is included on all platforms, we could also
# override CMAKE_DEBUG_POSTFIX to bypass it.
Expand Down Expand Up @@ -120,6 +122,7 @@ if(NOT yaml-cpp_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PAC

# Hack to let imported target be built from ExternalProject_Add
file(MAKE_DIRECTORY ${yaml-cpp_INCLUDE_DIR})
message(STATUS "Create directory ${yaml-cpp_INCLUDE_DIR}")

ExternalProject_Add(yaml-cpp_install
GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git"
Expand All @@ -138,34 +141,25 @@ if(NOT yaml-cpp_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PAC
--parallel
)

add_dependencies(yaml-cpp yaml-cpp_install)
if(OCIO_VERBOSE)
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()
# endif()
endif()
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}
)
message(STATUS "Set target include dir: ${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 f60745a

Please sign in to comment.