From dcbb6b1e4d16803b77fc17dabf69c4bf50b417a1 Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Wed, 6 Apr 2016 09:33:13 +0200 Subject: [PATCH 1/2] make the install location for the generated cmake files configurable By default the cmake files are installed to "/lib/cmake/cppformat". This can now be customized using the `FMT_CMAKE_DIR` cache variable. Valid paths are documented in the cmake manual [1]. e.g., install the cmake files to "/share/cmake/cppformat" ``` cmake -DFMT_CMAKE_DIR=share/cmake/cppformat ``` Tip: Try `make package` to examine the result. [1] https://cmake.org/cmake/help/v3.0/command/find_package.html --- cppformat/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cppformat/CMakeLists.txt b/cppformat/CMakeLists.txt index cd580360..323bb338 100644 --- a/cppformat/CMakeLists.txt +++ b/cppformat/CMakeLists.txt @@ -45,7 +45,8 @@ endif () # Install targets. if (FMT_INSTALL) include(CMakePackageConfigHelpers) - set(config_install_dir lib/cmake/cppformat) + set(FMT_CMAKE_DIR lib/cmake/cppformat CACHE STRING + "Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.") set(version_config ${PROJECT_BINARY_DIR}/cppformat-config-version.cmake) set(project_config ${PROJECT_BINARY_DIR}/cppformat-config.cmake) set(targets_export_name cppformat-targets) @@ -66,14 +67,14 @@ if (FMT_INSTALL) configure_package_config_file( ${PROJECT_SOURCE_DIR}/support/cmake/cppformat-config.cmake.in ${project_config} - INSTALL_DESTINATION ${config_install_dir}) + INSTALL_DESTINATION ${FMT_CMAKE_DIR}) export(TARGETS ${INSTALL_TARGETS} FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake) # Install version, config and target files. install( FILES ${project_config} ${version_config} - DESTINATION ${config_install_dir}) - install(EXPORT ${targets_export_name} DESTINATION ${config_install_dir}) + DESTINATION ${FMT_CMAKE_DIR}) + install(EXPORT ${targets_export_name} DESTINATION ${FMT_CMAKE_DIR}) # Install the library and headers. install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name} DESTINATION ${FMT_LIB_DIR}) From 620f999e80560ecead7a70b016cec1d13b1aa0ee Mon Sep 17 00:00:00 2001 From: Mario Werner Date: Wed, 6 Apr 2016 09:49:34 +0200 Subject: [PATCH 2/2] ignore the current build directory when packaging This makes sure that the current build directory is not packaged with the regular source tree when `make package_source` is used. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 797be705..f326726c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,7 @@ if (MASTER_PROJECT AND EXISTS ${gitignore}) string(REPLACE "*" ".*" line "${line}") set(ignored_files ${ignored_files} "${line}$" "${line}/") endforeach () - set(ignored_files ${ignored_files} + set(ignored_files ${ignored_files} ${PROJECT_BINARY_DIR} /.git /breathe /format-benchmark sphinx/ .buildinfo .doctrees) set(CPACK_SOURCE_GENERATOR ZIP)