mirror of
https://github.com/wqking/eventpp.git
synced 2024-12-27 00:17:02 +08:00
Merge pull request #40 from rotolof/install_option
Enable or disable installation
This commit is contained in:
commit
a135c761b4
@ -12,59 +12,74 @@ target_include_directories(
|
|||||||
|
|
||||||
add_library(eventpp::eventpp ALIAS eventpp)
|
add_library(eventpp::eventpp ALIAS eventpp)
|
||||||
|
|
||||||
|
# Checks if eventpp is the main project or if it is
|
||||||
|
# being built as a subproject (using add_subdirectory/FetchContent).
|
||||||
|
set(MAIN_PROJECT OFF)
|
||||||
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
|
set(MAIN_PROJECT ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
# ------------
|
# ------------
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
if (POLICY CMP0077)
|
||||||
|
# Allow CMake 3.13+ to override options when using add_subdirectory/FetchContent.
|
||||||
|
cmake_policy(SET CMP0077 NEW)
|
||||||
|
endif (POLICY CMP0077)
|
||||||
|
|
||||||
# Install the library
|
option(EVENTPP_INSTALL "Enable installation" ${MAIN_PROJECT})
|
||||||
install(
|
|
||||||
|
if (EVENTPP_INSTALL)
|
||||||
|
# Install the library
|
||||||
|
install(
|
||||||
TARGETS eventpp
|
TARGETS eventpp
|
||||||
EXPORT eventppTargets
|
EXPORT eventppTargets
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install the headers
|
# Install the headers
|
||||||
install(
|
install(
|
||||||
DIRECTORY include/
|
DIRECTORY include/
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# (Generate and) install the target import file
|
# (Generate and) install the target import file
|
||||||
install(
|
install(
|
||||||
EXPORT eventppTargets
|
EXPORT eventppTargets
|
||||||
NAMESPACE eventpp::
|
NAMESPACE eventpp::
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generate the package version file
|
# Generate the package version file
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
COMPATIBILITY AnyNewerVersion
|
COMPATIBILITY AnyNewerVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
# Generate the package configuration file, that allows other
|
# Generate the package configuration file, that allows other
|
||||||
# CMake projects to find the library with find_package()
|
# CMake projects to find the library with find_package()
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
cmake/eventppConfig.cmake.in
|
cmake/eventppConfig.cmake.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake
|
||||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install the package version and configuration files
|
# Install the package version and configuration files
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install readme and license
|
# Install readme and license
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
readme.md
|
readme.md
|
||||||
license
|
license
|
||||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/eventpp
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/eventpp
|
||||||
)
|
)
|
||||||
|
endif()
|
Loading…
x
Reference in New Issue
Block a user