diff --git a/CMakeLists.txt b/CMakeLists.txt index 560bb403..8c26b0b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,9 +13,13 @@ project(FLAC VERSION 1.3.3) # HOMEPAGE_URL "https://www.xiph.org/flac/") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") option(BUILD_CXXLIBS "Build libFLAC++" ON) +option(BUILD_PROGRAMS "Build and install programs" ON) option(BUILD_EXAMPLES "Build and install examples" ON) option(BUILD_DOCS "Build and install doxygen documents" ON) option(WITH_STACK_PROTECTOR "Enable GNU GCC stack smash protection" ON) +option(INSTALL_MANPAGES "Install MAN pages" ON) +option(INSTALL_PKGCONFIG_MODULES "Install PkgConfig modules" ON) +option(INSTALL_CMAKE_CONFIG_MODULE "Install CMake package-config module" ON) option(WITH_OGG "ogg support (default: test for libogg)" ON) if(WITH_OGG) @@ -120,26 +124,30 @@ endif() configure_file(config.cmake.h.in config.h) -install( - EXPORT targets - DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake" - NAMESPACE FLAC::) +if(INSTALL_CMAKE_CONFIG_MODULE) + install( + EXPORT targets + DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake" + NAMESPACE FLAC::) -configure_package_config_file( - flac-config.cmake.in flac-config.cmake - INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake") -write_basic_package_version_file( - flac-config-version.cmake COMPATIBILITY AnyNewerVersion) + configure_package_config_file( + flac-config.cmake.in flac-config.cmake + INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake") + write_basic_package_version_file( + flac-config-version.cmake COMPATIBILITY AnyNewerVersion) -install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake" - "cmake/FindOGG.cmake" - DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake") + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/flac-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/flac-config-version.cmake" + "cmake/FindOGG.cmake" + DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake") +endif() file(GLOB FLAC_HEADERS "include/FLAC/*.h") file(GLOB FLAC++_HEADERS "include/FLAC++/*.h") install(FILES ${FLAC_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FLAC") install(FILES ${FLAC++_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/FLAC++") -install(FILES "man/flac.1" "man/metaflac.1" DESTINATION "${CMAKE_INSTALL_MANDIR}") +if(INSTALL_MANPAGES) + install(FILES "man/flac.1" "man/metaflac.1" DESTINATION "${CMAKE_INSTALL_MANDIR}") +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e8a5de4..5579fa88 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,8 +8,10 @@ if(BUILD_CXXLIBS) add_subdirectory("libFLAC++") endif() add_subdirectory("share") -add_subdirectory("flac") -add_subdirectory("metaflac") +if(BUILD_PROGRAMS) + add_subdirectory("flac") + add_subdirectory("metaflac") +endif() add_subdirectory("utils") if(WITH_XMMS) diff --git a/src/libFLAC++/CMakeLists.txt b/src/libFLAC++/CMakeLists.txt index 04b721f3..a4849d74 100644 --- a/src/libFLAC++/CMakeLists.txt +++ b/src/libFLAC++/CMakeLists.txt @@ -1,9 +1,3 @@ -set(prefix "${CMAKE_INSTALL_PREFIX}") -set(exec_prefix "${CMAKE_INSTALL_PREFIX}") -set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") -set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") -configure_file(flac++.pc.in flac++.pc @ONLY) - check_cxx_source_compiles(" #ifdef __STDC_NO_VLA__ syntax error; @@ -45,5 +39,13 @@ install(TARGETS FLAC++ EXPORT targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac++.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +if(INSTALL_PKGCONFIG_MODULES) + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(exec_prefix "${CMAKE_INSTALL_PREFIX}") + set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") + set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") + configure_file(flac++.pc.in flac++.pc @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac++.pc" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig") +endif() diff --git a/src/libFLAC/CMakeLists.txt b/src/libFLAC/CMakeLists.txt index 53a8a200..aac7f941 100644 --- a/src/libFLAC/CMakeLists.txt +++ b/src/libFLAC/CMakeLists.txt @@ -45,13 +45,6 @@ if(IA32) endif() endif() - -set(prefix "${CMAKE_INSTALL_PREFIX}") -set(exec_prefix "${CMAKE_INSTALL_PREFIX}") -set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") -set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") -configure_file(flac.pc.in flac.pc @ONLY) - include_directories("include") add_library(FLAC @@ -120,5 +113,13 @@ install(TARGETS FLAC EXPORT targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +if(INSTALL_PKGCONFIG_MODULES) + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(exec_prefix "${CMAKE_INSTALL_PREFIX}") + set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") + set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") + configure_file(flac.pc.in flac.pc @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac.pc" + DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig") +endif()