forked from pantoniou/libfyaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
152 lines (132 loc) · 3.76 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) # Allow project(xxx VERSION a.b.c)
endif()
# version number below should be the currently under development version,
# so when doing a tag/release it is captured with the proper numbering.
project(fyaml LANGUAGES C VERSION 0.7.2)
cmake_minimum_required(VERSION 3.0)
# Must use GNUInstallDirs to install libraries into correct
# locations on all platforms.
include(GNUInstallDirs)
set(LIBHDRS
src/valgrind/fy-valgrind.h
src/xxhash/xxhash.h
src/lib/fy-accel.h
src/lib/fy-atom.h
src/lib/fy-composer.h
src/lib/fy-ctype.h
src/lib/fy-diag.h
src/lib/fy-doc.h
src/lib/fy-docbuilder.c
src/lib/fy-docstate.h
src/lib/fy-dump.h
src/lib/fy-emit-accum.h
src/lib/fy-emit.h
src/lib/fy-event.h
src/lib/fy-input.h
src/lib/fy-list.h
src/lib/fy-parse.h
src/lib/fy-path.h
src/lib/fy-token.h
src/lib/fy-typelist.h
src/lib/fy-types.h
src/lib/fy-utf8.h
src/lib/fy-utils.h
src/lib/fy-walk.h
)
set(LIBSRCS
src/lib/fy-accel.c
src/lib/fy-atom.c
src/lib/fy-composer.c
src/lib/fy-ctype.c
src/lib/fy-diag.c
src/lib/fy-doc.c
src/lib/fy-docstate.c
src/lib/fy-dump.c
src/lib/fy-emit.c
src/lib/fy-event.c
src/lib/fy-input.c
src/lib/fy-parse.c
src/lib/fy-path.c
src/lib/fy-token.c
src/lib/fy-types.c
src/lib/fy-utf8.c
src/lib/fy-utils.c
src/lib/fy-walk.c
src/xxhash/xxhash.c
)
set(LIBHDRSPUB
include/libfyaml.h
)
add_library(${PROJECT_NAME}
${LIBHDRS}
${LIBSRCS}
${LIBHDRSPUB}
)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Libraries")
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${${PROJECT_NAME}_SOURCE_DIR}/src/lib
${${PROJECT_NAME}_SOURCE_DIR}/src/lib/internal
${${PROJECT_NAME}_SOURCE_DIR}/src/xxhash
)
#target_link_libraries(${PROJECT_NAME} PUBLIC xx)
#target_compile_definitions(${PROJECT_NAME} PUBLIC xx)
target_compile_definitions(${PROJECT_NAME} PRIVATE
VERSION="0.5.7.34"
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
$<$<NOT:$<CONFIG:DEBUG>>:NDEBUG>
)
# Shared options between GCC and CLANG:
if (NOT MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
-Wall
-fPIC
-D_GNU_SOURCE
)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${PROJECT_NAME} PRIVATE
-O2
)
endif()
endif()
# ==== Install & export target ========
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
export(
TARGETS ${PROJECT_NAME}
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-targets.cmake"
NAMESPACE ${PROJECT_NAME}::
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)