-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
13 deletions.
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 |
---|---|---|
@@ -1,30 +1,52 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
project(NamedType CXX) | ||
project(NamedType VERSION 1.1.0 LANGUAGES CXX) | ||
|
||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13") | ||
cmake_policy(SET CMP0076 NEW) | ||
endif() | ||
|
||
set(MASTER_PROJECT OFF) | ||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) | ||
set(MASTER_PROJECT ON) | ||
endif () | ||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) | ||
set(MASTER_PROJECT ON) | ||
endif() | ||
|
||
add_library(${PROJECT_NAME} INTERFACE) | ||
target_include_directories(${PROJECT_NAME} INTERFACE "include/") | ||
|
||
target_sources(${PROJECT_NAME} INTERFACE | ||
"include/NamedType/crtp.hpp" | ||
"include/NamedType/named_type.hpp" | ||
"include/NamedType/named_type_impl.hpp" | ||
"include/NamedType/underlying_functionalities.hpp" | ||
"include/NamedType/version.hpp" | ||
) | ||
target_include_directories(${PROJECT_NAME} | ||
INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
|
||
set(ENABLE_TEST ON CACHE BOOL "Enable test") | ||
|
||
if (ENABLE_TEST AND ${MASTER_PROJECT}) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() | ||
|
||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
install(TARGETS NamedType | ||
EXPORT ${PROJECT_NAME}Targets) | ||
|
||
# Makes the project importable from the build directory | ||
export(EXPORT ${PROJECT_NAME}Targets | ||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake") | ||
|
||
install(DIRECTORY include/NamedType | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
INSTALL_DESTINATION lib/cmake/) | ||
|
||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
VERSION ${${PROJECT_NAME}_VERSION} | ||
COMPATIBILITY AnyNewerVersion) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake | ||
DESTINATION lib/cmake/) | ||
install(EXPORT ${PROJECT_NAME}Targets | ||
FILE ${PROJECT_NAME}Targets.cmake | ||
DESTINATION lib/cmake/) |
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,7 @@ | ||
|
||
@PACKAGE_INIT@ | ||
|
||
if(NOT TARGET @PROJECT_NAME@) | ||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
get_target_property(@PROJECT_NAME@_INCLUDE_DIRS @PROJECT_NAME@ INTERFACE_INCLUDE_DIRECTORIES) | ||
endif() |