Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Aug 21, 2024
1 parent 787c085 commit 87c72ca
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 20 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,20 @@ add_subdirectory(lib/toucan)
add_subdirectory(plugins)
add_subdirectory(bin)
add_subdirectory(tests)

install(
FILES cmake/FindOpenFX.cmake
DESTINATION lib/cmake/toucan)
install(
FILES cmake/FindOTIO.cmake
DESTINATION lib/cmake/toucan)
include(CMakePackageConfigHelpers)
set(INCLUDE_INSTALL_DIR include/toucan)
configure_package_config_file(
toucanConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/toucanConfig.cmake
INSTALL_DESTINATION lib/cmake/toucan
PATH_VARS INCLUDE_INSTALL_DIR)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/toucanConfig.cmake
DESTINATION lib/cmake/toucan)
11 changes: 4 additions & 7 deletions cmake/FindOTIO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
# * OTIO

find_path(OTIO_INCLUDE_DIR NAMES opentimelineio/version.h)
if(OTIO_INCLUDE_DIR)
set(OTIO_DEPS_INCLUDE_DIRS ${OTIO_INCLUDE_DIR}/opentimelineio/deps)
endif()
set(OTIO_INCLUDE_DIRS ${OTIO_INCLUDE_DIR} ${OTIO_DEPS_INCLUDE_DIRS})
set(OTIO_INCLUDE_DIRS ${OTIO_INCLUDE_DIR})

if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
find_library(
Expand All @@ -44,8 +41,8 @@ set(OTIO_LIBRARIES ${opentimelineio_LIBRARY} ${opentime_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
OTIO
REQUIRED_VARS OTIO_INCLUDE_DIR OTIO_DEPS_INCLUDE_DIRS opentimelineio_LIBRARY opentime_LIBRARY)
mark_as_advanced(OTIO_INCLUDE_DIR OTIO_DEPS_INCLUDE_DIRS opentimelineio_LIBRARY opentime_LIBRARY)
REQUIRED_VARS OTIO_INCLUDE_DIR opentimelineio_LIBRARY opentime_LIBRARY)
mark_as_advanced(OTIO_INCLUDE_DIR opentimelineio_LIBRARY opentime_LIBRARY)

if(OTIO_FOUND AND NOT TARGET OTIO::opentime)
add_library(OTIO::opentime UNKNOWN IMPORTED)
Expand All @@ -59,7 +56,7 @@ if(OTIO_FOUND AND NOT TARGET OTIO::opentimelineio)
set_target_properties(OTIO::opentimelineio PROPERTIES
IMPORTED_LOCATION "${opentimelineio_LIBRARY}"
INTERFACE_COMPILE_DEFINITIONS opentimelineio_FOUND
INTERFACE_INCLUDE_DIRECTORIES "${OTIO_INCLUDE_DIR};${OTIO_DEPS_INCLUDE_DIRS}")
INTERFACE_INCLUDE_DIRECTORIES "${OTIO_INCLUDE_DIR}")
endif()
if(OTIO_FOUND AND NOT TARGET OTIO)
add_library(OTIO INTERFACE)
Expand Down
13 changes: 10 additions & 3 deletions lib/toucan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ else()
endif()

add_library(toucan ${HEADERS} ${HEADERS_PRIVATE} ${SOURCE})
target_link_libraries(toucan PUBLIC OTIO OpenImageIO::OpenImageIO MINIZIP::minizip)
target_link_libraries(toucan PUBLIC OTIO::opentimelineio OTIO::opentime OpenImageIO::OpenImageIO MINIZIP::minizip)
set_target_properties(toucan PROPERTIES FOLDER lib)
set_target_properties(toucan PROPERTIES PUBLIC_HEADER "${HEADERS}")

install(TARGETS toucan
install(
TARGETS toucan
EXPORT toucanTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include)
PUBLIC_HEADER DESTINATION include/toucan)
install(
EXPORT toucanTargets
FILE toucanTargets.cmake
DESTINATION "lib/cmake/toucan"
NAMESPACE toucan::)
25 changes: 16 additions & 9 deletions lib/toucan/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@ namespace toucan
int depth,
int maxDepth)
{
for (auto const& entry : std::filesystem::directory_iterator(path))
try
{
const auto& entryPath = entry.path();
if (entry.is_regular_file() &&
(entryPath.extension() == ".dll" || entryPath.extension() == ".so"))
for (auto const& entry : std::filesystem::directory_iterator(path))
{
out.push_back(entryPath);
}
else if (entry.is_directory() && depth < maxDepth)
{
_findPlugins(entryPath, out, depth + 1, maxDepth);
const auto& entryPath = entry.path();
if (entry.is_regular_file() &&
(entryPath.extension() == ".dll" || entryPath.extension() == ".so"))
{
out.push_back(entryPath);
}
else if (entry.is_directory() && depth < maxDepth)
{
_findPlugins(entryPath, out, depth + 1, maxDepth);
}
}
}
catch (const std::exception&)
{
//! \bug How should this be handled?
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ foreach(PLUGIN ColorSpace Draw Filter Generator Transform Transition)

install(TARGETS toucan${PLUGIN}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
LIBRARY DESTINATION bin
RUNTIME DESTINATION bin)
endforeach()
26 changes: 26 additions & 0 deletions toucanConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@PACKAGE_INIT@

# \todo Is this the correct way to locate the custom Find*.cmake files?
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})

include(CMakeFindDependencyMacro)
find_dependency(Imath)
find_dependency(Freetype)
find_dependency(ZLIB)
find_dependency(PNG)
find_dependency(JPEG)
find_dependency(TIFF)
find_dependency(OpenEXR)
find_dependency(minizip)
find_dependency(OpenColorIO)
find_dependency(OpenImageIO)
find_dependency(OTIO)
find_dependency(OpenFX)

include("${CMAKE_CURRENT_LIST_DIR}/toucanTargets.cmake")

# \todo Is this the correct way to add the include directory?
include_directories("@PACKAGE_INCLUDE_INSTALL_DIR@")
include_directories("@PACKAGE_INCLUDE_INSTALL_DIR@/../Imath")

check_required_components(toucan)

0 comments on commit 87c72ca

Please sign in to comment.