-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
78 lines (59 loc) · 2.12 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
cmake_minimum_required(VERSION 3.13)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/common/Modules/")
include(GitVersion)
git_version(PROJECT_VERSION)
project(floaxie
VERSION ${PROJECT_VERSION}
DESCRIPTION "Library for printing and parsing floating point values"
HOMEPAGE_URL "https://github.com/aclex/floaxie"
LANGUAGES CXX
)
include(GNUInstallDirs)
include(AddUninstallTarget)
add_library(floaxie INTERFACE)
target_include_directories(floaxie INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(floaxie INTERFACE cxx_std_14)
include(CMakePackageConfigHelpers)
set(CONFIG_PACKAGE_INSTALL_DIR lib/cmake/${PROJECT_NAME})
write_basic_package_version_file(
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(TARGETS floaxie
EXPORT floaxie-targets
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/config.cmake.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR}
PATH_VARS CMAKE_INSTALL_FULL_INCLUDEDIR
)
install(EXPORT ${PROJECT_NAME}-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR})
install(FILES
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR}
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/floaxie DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (BUILD_EXAMPLES)
add_subdirectory(example)
endif ()
if (CALC_COVERAGE AND (CMAKE_BUILD_TYPE STREQUAL "Debug") AND CMAKE_COMPILER_IS_GNUCXX)
set(COVERAGE_ENABLED TRUE)
endif()
if (BUILD_TESTS)
if (COVERAGE_ENABLED)
message("Will calculate code coverage.")
target_compile_options(floaxie INTERFACE --coverage)
target_link_options(floaxie INTERFACE --coverage)
endif()
enable_testing()
add_subdirectory(test)
endif (BUILD_TESTS)
if (BUILD_DOCUMENTATION)
add_subdirectory(doc)
endif (BUILD_DOCUMENTATION)