-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
121 lines (94 loc) · 2.3 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(
cflags
LANGUAGES C CXX
DESCRIPTION "Command line flag parsing library in C/C++"
VERSION 3.0.3
)
###
### cflags
###
add_library(cflags INTERFACE)
add_library(cflags::cflags ALIAS cflags)
target_include_directories(
cflags INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
)
###
### cppflags
###
add_library(cppflags INTERFACE)
add_library(cflags::cppflags ALIAS cppflags)
target_include_directories(
cppflags INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include>
)
set_target_properties(
cppflags
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
###
### Install
###
install(
TARGETS cflags cppflags
EXPORT cflagsTargets
INCLUDES DESTINATION include
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cflagsConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(
EXPORT cflagsTargets
NAMESPACE cflags::
DESTINATION lib/cmake/cflags
)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/cflagsConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cflagsConfig.cmake
INSTALL_DESTINATION lib/cmake/cflags
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/cflagsConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/cflagsConfig.cmake
DESTINATION lib/cmake/cflags
)
include(FindPkgConfig)
if(PKG_CONFIG_FOUND)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/cflags.pc.in
${CMAKE_CURRENT_BINARY_DIR}/cflags.pc
@ONLY
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/cflags.pc
DESTINATION share/pkgconfig
)
endif()
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION include
)
###
### Test executables
###
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(example examples/example.c)
target_link_libraries(example cflags)
add_executable(example-cpp examples/example.cpp)
target_link_libraries(example-cpp cppflags)
set_target_properties(
example-cpp
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
endif()