mirror of
https://github.com/wqking/eventpp.git
synced 2024-12-27 16:41:11 +08:00
Merge pull request #40 from rotolof/install_option
Enable or disable installation
This commit is contained in:
commit
a135c761b4
107
CMakeLists.txt
107
CMakeLists.txt
@ -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(
|
|
||||||
TARGETS eventpp
|
|
||||||
EXPORT eventppTargets
|
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install the headers
|
if (EVENTPP_INSTALL)
|
||||||
install(
|
# Install the library
|
||||||
DIRECTORY include/
|
install(
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
TARGETS eventpp
|
||||||
)
|
EXPORT eventppTargets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
)
|
||||||
|
|
||||||
# (Generate and) install the target import file
|
# Install the headers
|
||||||
install(
|
install(
|
||||||
EXPORT eventppTargets
|
DIRECTORY include/
|
||||||
NAMESPACE eventpp::
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# Generate the package version file
|
# (Generate and) install the target import file
|
||||||
include(CMakePackageConfigHelpers)
|
install(
|
||||||
write_basic_package_version_file(
|
EXPORT eventppTargets
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake
|
NAMESPACE eventpp::
|
||||||
VERSION ${PROJECT_VERSION}
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
||||||
COMPATIBILITY AnyNewerVersion
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# Generate the package configuration file, that allows other
|
# Generate the package version file
|
||||||
# CMake projects to find the library with find_package()
|
include(CMakePackageConfigHelpers)
|
||||||
configure_package_config_file(
|
write_basic_package_version_file(
|
||||||
cmake/eventppConfig.cmake.in
|
${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake
|
VERSION ${PROJECT_VERSION}
|
||||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
COMPATIBILITY AnyNewerVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install the package version and configuration files
|
# Generate the package configuration file, that allows other
|
||||||
install(
|
# CMake projects to find the library with find_package()
|
||||||
FILES
|
configure_package_config_file(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake
|
cmake/eventppConfig.cmake.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install readme and license
|
# Install the package version and configuration files
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
readme.md
|
${CMAKE_CURRENT_BINARY_DIR}/eventppConfig.cmake
|
||||||
license
|
${CMAKE_CURRENT_BINARY_DIR}/eventppConfigVersion.cmake
|
||||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/eventpp
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eventpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Install readme and license
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
readme.md
|
||||||
|
license
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/eventpp
|
||||||
|
)
|
||||||
|
endif()
|
Loading…
x
Reference in New Issue
Block a user