Skip to content

Commit

Permalink
CMake config file improvements to find dependencies automatically for…
Browse files Browse the repository at this point in the history
… consumers (#1640)
  • Loading branch information
foundry-markf authored Jul 21, 2023
1 parent 45c6cfd commit e8b6eac
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
OTIO_BUILD_CONFIG: Release
OTIO_BUILD_DIR: ${{ github.workspace }}/build
OTIO_INSTALL_DIR: ${{ github.workspace }}/install
OTIO_CONSUMER_TEST_BUILD_DIR: ${{ github.workspace }}/consumertest

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -81,6 +82,11 @@ jobs:
run: |
cd ${{ env.OTIO_BUILD_DIR }}
cmake --build . --target install --config ${{ env.OTIO_BUILD_CONFIG }}
- name: Consumer tests
run: |
cmake -E make_directory ${{ env.OTIO_CONSUMER_TEST_BUILD_DIR }}
cd ${{ env.OTIO_CONSUMER_TEST_BUILD_DIR }}
cmake ${{ github.workspace }}/tests/consumer -DCMAKE_PREFIX_PATH=${{ env.OTIO_INSTALL_DIR }}
py_build_test:
runs-on: ${{ matrix.os }}
Expand Down
21 changes: 19 additions & 2 deletions src/opentime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,31 @@ if(OTIO_CXX_INSTALL)
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/include/opentime")

install(TARGETS opentime
EXPORT OpenTimeConfig
EXPORT OpenTimeTargets
INCLUDES DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/include"
ARCHIVE DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}"
LIBRARY DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}"
RUNTIME DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}")

install(EXPORT OpenTimeConfig
install(EXPORT OpenTimeTargets
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentime"
NAMESPACE OTIO:: )

include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/OpenTimeConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/OpenTimeConfig.cmake
INSTALL_DESTINATION
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentime
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/OpenTimeConfig.cmake
DESTINATION
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentime
)
endif()

3 changes: 3 additions & 0 deletions src/opentime/OpenTimeConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/OpenTimeTargets.cmake")
21 changes: 19 additions & 2 deletions src/opentimelineio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,30 @@ if(OTIO_CXX_INSTALL)
endif()

install(TARGETS opentimelineio
EXPORT OpenTimelineIOConfig
EXPORT OpenTimelineIOTargets
INCLUDES DESTINATION "${OPENTIMELINEIO_INCLUDES}"
ARCHIVE DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}"
LIBRARY DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}"
RUNTIME DESTINATION "${OTIO_RESOLVED_CXX_DYLIB_INSTALL_DIR}")

install(EXPORT OpenTimelineIOConfig
install(EXPORT OpenTimelineIOTargets
DESTINATION "${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentimelineio"
NAMESPACE OTIO:: )

include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/OpenTimelineIOConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/OpenTimelineIOConfig.cmake
INSTALL_DESTINATION
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentimelineio
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/OpenTimelineIOConfig.cmake
DESTINATION
${OTIO_RESOLVED_CXX_INSTALL_DIR}/share/opentimelineio
)
endif()
6 changes: 6 additions & 0 deletions src/opentimelineio/OpenTimelineIOConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(OpenTime)

include("${CMAKE_CURRENT_LIST_DIR}/OpenTimelineIOTargets.cmake")
6 changes: 6 additions & 0 deletions tests/consumer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.18.2 FATAL_ERROR)

project(consumer_tests)

add_subdirectory(opentime)
add_subdirectory(opentimeline)
2 changes: 2 additions & 0 deletions tests/consumer/opentime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
find_package(OpenTime REQUIRED)
message(STATUS "Found OpenTime successfully at '${OpenTime_DIR}'")
2 changes: 2 additions & 0 deletions tests/consumer/opentimeline/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
find_package(OpenTimelineIO REQUIRED)
message(STATUS "Found OpenTimelineIO successfully at '${OpenTimelineIO_DIR}'")

0 comments on commit e8b6eac

Please sign in to comment.