-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
89 lines (68 loc) · 2.05 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
79
80
81
82
83
84
85
86
87
88
89
cmake_minimum_required(VERSION 3.5)
project(libsqrt VERSION 1.0.0 LANGUAGES CXX)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
add_subdirectory(module/libexponent)
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Exponent)
install(EXPORT exponent-targets
FILE
ExponentTargets.cmake
NAMESPACE
Exponent::
DESTINATION
${INSTALL_CONFIGDIR}
)
find_package(Exponent 1.0 REQUIRED)
add_library(sqrt
src/sqrt.cpp
)
add_library(Sqrt::sqrt ALIAS sqrt)
target_include_directories(sqrt
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/module/libexponent/include
)
target_compile_features(sqrt PRIVATE cxx_auto_type)
target_compile_options(sqrt PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall>)
target_link_libraries(sqrt
PRIVATE
Exponent
)
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Sqrt)
install(TARGETS sqrt
EXPORT sqrt-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
set_target_properties(sqrt PROPERTIES EXPORT_NAME Sqrt)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT sqrt-targets
FILE
SqrtTargets.cmake
NAMESPACE
Sqrt::
DESTINATION
${INSTALL_CONFIGDIR}
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/SqrtConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/SqrtConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SqrtConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/SqrtConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/SqrtConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
export(EXPORT sqrt-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/SqrtTargets.cmake NAMESPACE Sqrt::)
export(PACKAGE Sqrt)
# add_subdirectory(test)