Format CMake files, ignore generated files and don't copy header

This commit is contained in:
vitaut 2016-01-13 07:14:32 -08:00
parent 52ee516cf3
commit 22f61140d1
4 changed files with 32 additions and 37 deletions

2
.gitignore vendored
View File

@ -9,8 +9,8 @@ bin/
*.a
*.so*
*.zip
/*.cmake
cmake_install.cmake
CPack*Config.cmake
CTestTestfile.cmake
CMakeCache.txt
CMakeFiles

View File

@ -142,9 +142,10 @@ endif ()
set_target_properties(cppformat PROPERTIES
VERSION ${CPPFORMAT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR})
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.gitignore")
set(gitignore ${CMAKE_CURRENT_SOURCE_DIR}/.gitignore)
if (EXISTS ${gitignore})
# Get the list of ignored files from .gitignore.
file (STRINGS ".gitignore" lines)
file (STRINGS ${gitignore} lines)
LIST(REMOVE_ITEM lines /doc/html)
foreach (line ${lines})
string(REPLACE "." "[.]" line "${line}")
@ -156,8 +157,8 @@ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.gitignore")
set(CPACK_SOURCE_GENERATOR ZIP)
set(CPACK_SOURCE_IGNORE_FILES ${ignored_files})
set(CPACK_SOURCE_PACKAGE_FILE_NAME "cppformat-${CPPFORMAT_VERSION}")
set(CPACK_PACKAGE_NAME "cppformat")
set(CPACK_SOURCE_PACKAGE_FILE_NAME cppformat-${CPPFORMAT_VERSION})
set(CPACK_PACKAGE_NAME cppformat)
set(CPACK_RESOURCE_FILE_README ${FORMAT_SOURCE_DIR}/README.rst)
include(CPack)
endif ()
@ -165,44 +166,38 @@ endif ()
# Install targets.
if (FMT_INSTALL)
include(CMakePackageConfigHelpers)
set(config_install_dir "lib/cmake/cppformat")
set(version_config "${CMAKE_CURRENT_BINARY_DIR}/cppformatConfigVersion.cmake")
set(project_config "${CMAKE_CURRENT_BINARY_DIR}/cppformatConfig.cmake")
set(targets_export_name "cppformatTargets")
set(config_install_dir lib/cmake/cppformat)
set(version_config ${CMAKE_CURRENT_BINARY_DIR}/cppformat-config-version.cmake)
set(project_config ${CMAKE_CURRENT_BINARY_DIR}/cppformat-config.cmake)
set(targets_export_name cppformat-targets)
set(FMT_LIB_DIR "lib" CACHE STRING
set(FMT_LIB_DIR lib CACHE STRING
"Installation directory for libraries, relative to ${CMAKE_INSTALL_PREFIX}.")
# copy the header into the build directory to mimic the installed tree
configure_file("format.h" "cppformat/format.h" COPYONLY)
# add the include directories for both build and install tree
# Add the include directories for both build and install tree.
target_include_directories(
cppformat PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)
# generate the version, config and target files into the build directory
# Generate the version, config and target files into the build directory.
write_basic_package_version_file(
"${version_config}"
${version_config}
VERSION ${CPPFORMAT_VERSION}
COMPATIBILITY AnyNewerVersion
)
COMPATIBILITY AnyNewerVersion)
configure_package_config_file(
"support/cmake/cppformatConfig.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
export(TARGETS cppformat FILE "${targets_export_name}.cmake")
support/cmake/cppformat-config.cmake.in
${project_config}
INSTALL_DESTINATION ${config_install_dir})
export(TARGETS cppformat FILE ${targets_export_name}.cmake)
# install version, config and target files
# 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}")
FILES ${project_config} ${version_config}
DESTINATION ${config_install_dir})
install(EXPORT ${targets_export_name} DESTINATION ${config_install_dir})
# install the library and the include file
install(TARGETS cppformat EXPORT "${targets_export_name}" DESTINATION "${FMT_LIB_DIR}")
install(FILES format.h DESTINATION "include/cppformat")
# Install the library and the include file.
install(TARGETS cppformat EXPORT ${targets_export_name} DESTINATION ${FMT_LIB_DIR})
install(FILES format.h DESTINATION include/cppformat)
endif ()

View File

@ -0,0 +1,4 @@
@PACKAGE_INIT@
include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake)
check_required_components(cppformat)

View File

@ -1,4 +0,0 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
check_required_components("cppformat")