Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions share/cmake/modules/install/Installpystring.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ if(NOT pystring_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PAC
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
-DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
-DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX}
-DPYSTRING_PC_VERSION=${pystring_VERSION}
)

if(CMAKE_TOOLCHAIN_FILE)
Expand Down
18 changes: 18 additions & 0 deletions share/cmake/projects/Buildpystring.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@ install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pystring
)

# pystring has no pkg-config file upstream, unlike its OCIO_INSTALL_EXT_PACKAGES
# siblings (expat, yaml-cpp, Imath, minizip-ng, zlib); write a minimal one so
# OpenColorIO.pc's Requires.private can reference it like the others.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pystring.pc"
"prefix=${CMAKE_INSTALL_PREFIX}
exec_prefix=\${prefix}
libdir=\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}
includedir=\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}/pystring

Name: pystring
Description: A C++ port of some of Python's string functions
Version: ${PYSTRING_PC_VERSION}
Libs: -L\${libdir} -lpystring
Cflags: -I\${includedir}
")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pystring.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
45 changes: 45 additions & 0 deletions src/OpenColorIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,51 @@ else()
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()

# Adds a static dependency's info to OpenColorIO.pc: to OCIO_PC_REQUIRES_PRIVATE
# if it has its own pkg-config file (built via OCIO_INSTALL_EXT_PACKAGES, only
# resolvable from the build tree), or to OCIO_PC_LIBS_PRIVATE otherwise (e.g. a
# system-provided copy, referenced directly since it may have no .pc file).
macro(ocio_add_static_pc_dependency dep_target pc_name)
if(TARGET ${dep_target})
get_target_property(_ocio_dep_loc ${dep_target} IMPORTED_LOCATION)
if(NOT _ocio_dep_loc)
get_target_property(_ocio_dep_configs ${dep_target} IMPORTED_CONFIGURATIONS)
if(_ocio_dep_configs)
list(GET _ocio_dep_configs 0 _ocio_dep_config)
get_target_property(_ocio_dep_loc ${dep_target} IMPORTED_LOCATION_${_ocio_dep_config})
endif()
endif()
if(_ocio_dep_loc)
string(FIND "${_ocio_dep_loc}" "${_ocio_ext_dist_root}/" _ocio_dep_is_ext_dist)
if(_ocio_dep_is_ext_dist EQUAL 0)
string(APPEND OCIO_PC_REQUIRES_PRIVATE " ${pc_name}")
else()
get_filename_component(_ocio_dep_dir "${_ocio_dep_loc}" DIRECTORY)
get_filename_component(_ocio_dep_name "${_ocio_dep_loc}" NAME_WE)
string(REGEX REPLACE "^lib" "" _ocio_dep_name "${_ocio_dep_name}")
string(APPEND OCIO_PC_LIBS_PRIVATE " -L${_ocio_dep_dir} -l${_ocio_dep_name}")
endif()
endif()
endif()
endmacro()

set(OCIO_PC_REQUIRES_PRIVATE "")
set(OCIO_PC_LIBS_PRIVATE "")
if(NOT BUILD_SHARED_LIBS)
# A static libOpenColorIO doesn't embed its own dependencies, so pkg-config
# needs to know about them too (pystring has no upstream .pc file, so
# Buildpystring.cmake now generates one).
set(_ocio_ext_dist_root "${PROJECT_BINARY_DIR}/ext/dist")
ocio_add_static_pc_dependency(expat::expat expat)
ocio_add_static_pc_dependency(Imath::Imath Imath)
ocio_add_static_pc_dependency(pystring::pystring pystring)
ocio_add_static_pc_dependency(yaml-cpp::yaml-cpp yaml-cpp)
ocio_add_static_pc_dependency(MINIZIP::minizip-ng minizip-ng)
ocio_add_static_pc_dependency(ZLIB::ZLIB zlib)
string(STRIP "${OCIO_PC_REQUIRES_PRIVATE}" OCIO_PC_REQUIRES_PRIVATE)
string(STRIP "${OCIO_PC_LIBS_PRIVATE}" OCIO_PC_LIBS_PRIVATE)
endif()

configure_file(res/OpenColorIO.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

Expand Down
2 changes: 2 additions & 0 deletions src/OpenColorIO/res/OpenColorIO.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ Name: @PROJECT_NAME@
Version: @PROJECT_VERSION@
Description: @PROJECT_DESCRIPTION@
URL: @PROJECT_HOMEPAGE_URL@
Requires.private: @OCIO_PC_REQUIRES_PRIVATE@
Libs: -L${libdir} -l@PROJECT_NAME@
Libs.private: @OCIO_PC_LIBS_PRIVATE@
Cflags: -I${includedir}