diff options
author | martinRenou <martin.renou@gmail.com> | 2022-05-30 20:22:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-30 20:22:45 +0200 |
commit | 39e6e570d8ee589f8f692f348644e47ccef400cf (patch) | |
tree | 9a6457e07a7ee52eec6dd240299e608b00848036 | |
parent | 95064f9f083ac9520a17f2ba880e114643dcbeac (diff) | |
download | flac-39e6e570d8ee589f8f692f348644e47ccef400cf.tar.gz |
Export flac properly when use with add_subdirectory (#285)
This allows for flac to be used in a larger CMake project
with add_subdirectory. It also allows for Ogg to be
build elsewhere in the larger project.
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | flac-config.cmake.in | 4 |
2 files changed, 16 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 20b5db2c..5487f97a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,11 @@ if(WITH_OGG) set_target_properties(test_bitwise test_framing PROPERTIES FOLDER Tests) endif() else() - find_package(Ogg REQUIRED) + if(NOT TARGET Ogg::ogg) + find_package(Ogg REQUIRED) + else() + set(OGG_FOUND 1 CACHE INTERNAL "ogg has already been built") + endif() set(OGG_PACKAGE "ogg") endif() endif() @@ -228,12 +232,18 @@ if(INSTALL_CMAKE_CONFIG_MODULE) EXPORT targets DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake" NAMESPACE FLAC::) + export(EXPORT targets NAMESPACE FLAC:: FILE FLACTargets.cmake) configure_package_config_file( - flac-config.cmake.in flac-config.cmake + ${PROJECT_SOURCE_DIR}/flac-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake") write_basic_package_version_file( - flac-config-version.cmake COMPATIBILITY AnyNewerVersion) + ${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake COMPATIBILITY AnyNewerVersion) + + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake + DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake" + ) install( FILES diff --git a/flac-config.cmake.in b/flac-config.cmake.in index f44133c5..bcafc4c8 100644 --- a/flac-config.cmake.in +++ b/flac-config.cmake.in @@ -1,7 +1,9 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -find_dependency(Ogg) +if(NOT TARGET Ogg::ogg) + find_dependency(Ogg) +endif() include("${CMAKE_CURRENT_LIST_DIR}/targets.cmake") |