-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable installation of the library via cmake.
See #8.
- Loading branch information
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project( | ||
tiny-optional | ||
VERSION 1.3.1 | ||
DESCRIPTION "Replacement for std::optional that does not waste memory unnecessarily." | ||
HOMEPAGE_URL "https://github.com/Sedeniono/tiny-optional" | ||
LANGUAGES CXX | ||
) | ||
|
||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
add_library(tiny-optional INTERFACE) | ||
add_library(tiny-optional::tiny-optional ALIAS tiny-optional) | ||
|
||
if (NOT PROJECT_IS_TOP_LEVEL) | ||
set(warning_guard SYSTEM) | ||
endif() | ||
|
||
target_include_directories( | ||
tiny-optional ${warning_guard} | ||
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" | ||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") | ||
|
||
target_compile_features(tiny-optional INTERFACE cxx_std_17) | ||
|
||
install( | ||
DIRECTORY include/ | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") | ||
|
||
install( | ||
TARGETS tiny-optional | ||
EXPORT tiny-optionalTargets | ||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") | ||
|
||
write_basic_package_version_file( | ||
"tiny-optionalConfigVersion.cmake" | ||
VERSION ${PROJECT_VERSION} | ||
# Different versions of tiny::optional cannot be mixed. It is | ||
# actively prevented by the use of inline namespaces. | ||
COMPATIBILITY ExactVersion) | ||
|
||
configure_package_config_file( | ||
"${PROJECT_SOURCE_DIR}/cmake/tiny-optionalConfig.cmake.in" | ||
"${PROJECT_BINARY_DIR}/tiny-optionalConfig.cmake" | ||
INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/tiny-optional") | ||
|
||
install( | ||
EXPORT tiny-optionalTargets | ||
FILE tiny-optionalTargets.cmake | ||
NAMESPACE tiny-optional:: | ||
DESTINATION "${CMAKE_INSTALL_DATADIR}/tiny-optional") | ||
|
||
install( | ||
FILES "${PROJECT_BINARY_DIR}/tiny-optionalConfig.cmake" | ||
"${PROJECT_BINARY_DIR}/tiny-optionalConfigVersion.cmake" | ||
DESTINATION "${CMAKE_INSTALL_DATADIR}/tiny-optional") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") | ||
check_required_components("@PROJECT_NAME@") |