forked from kirillochnev/mustache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
202 lines (178 loc) · 8.33 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
cmake_minimum_required(VERSION 3.7)
project(mustache
VERSION 0.2
LANGUAGES C CXX
HOMEPAGE_URL https://github.com/kirillochnev/mustache
)
message(VERBOSE "*")
message(VERBOSE "* ${PROJECT_NAME} v${PROJECT_VERSION} (${CMAKE_BUILD_TYPE})")
message(VERBOSE "* Copyright (c) 2020-2022 Kirill Ochnev <kirillochnev@gmail.com>")
message(VERBOSE "*")
set(MUSTACHE_VERSION ${PROJECT_VERSION})
find_package(Threads REQUIRED)
set(MUSTACHE_CXX_STD cxx_std_17 CACHE STRING "C++ standard revision to build mustache")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(MUSTACHE_USE_SANITIZER "Enable sanitizers by adding -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined flags if availbale." OFF)
option(MUSTACHE_WARNINGS_AS_ERROR "Enable -Werror and some of extra warnings" ON)
option(MUSTACHE_BUILD_SHARED "Build shared libraries?" ON)
if(MUSTACHE_USE_SANITIZER)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
endif()
include(GNUInstallDirs)
if (MUSTACHE_BUILD_SHARED)
if(MSVC)
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(MUSTACHE_LIB_TYPE SHARED)
if(WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()
else()
set(MUSTACHE_LIB_TYPE STATIC
src/mustache/utils/fast_private_impl.hpp
src/mustache/utils/unused.hpp)
endif ()
add_library(${PROJECT_NAME} ${MUSTACHE_LIB_TYPE}
${mustache_SOURCE_DIR}/src/mustache/utils/dll_export.h
${mustache_SOURCE_DIR}/src/mustache/utils/timer.cpp
${mustache_SOURCE_DIR}/src/mustache/utils/timer.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/logger.cpp
${mustache_SOURCE_DIR}/src/mustache/utils/logger.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/type_info.cpp
${mustache_SOURCE_DIR}/src/mustache/utils/type_info.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/benchmark.cpp
${mustache_SOURCE_DIR}/src/mustache/utils/benchmark.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/uncopiable.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/unused.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/memory_manager.cpp
${mustache_SOURCE_DIR}/src/mustache/utils/memory_manager.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/dispatch.cpp
${mustache_SOURCE_DIR}/src/mustache/utils/dispatch.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/index_like.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/fast_private_impl.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/array_wrapper.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/invoke.hpp
${mustache_SOURCE_DIR}/src/mustache/utils/crc32.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/entity.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/entity.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/archetype_operation_helper.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/archetype_operation_helper.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/temporal_storage.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/temporal_storage.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/entity_manager.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/entity_manager.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/base_job.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/base_job.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/job.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/non_template_job.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/non_template_job.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/system.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/system.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/system_manager.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/system_manager.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/archetype.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/archetype.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/job_arg_parcer.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_handler.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_mask.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_mask.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/world.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/world.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_info.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_info.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_events.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_factory.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_factory.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/entity_group.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/entity_group.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/world_filter.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/world_filter.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/base_component_data_storage.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/base_component_data_storage.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/default_component_data_storage.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/default_component_data_storage.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/new_component_data_storage.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/new_component_data_storage.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/event_manager.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/event_manager.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/entity_builder.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/entity_builder.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/world_storage.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/world_storage.hpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_version_storage.cpp
${mustache_SOURCE_DIR}/src/mustache/ecs/component_version_storage.hpp
${mustache_SOURCE_DIR}/src/mustache/c_api.cpp
${mustache_SOURCE_DIR}/src/mustache/c_api.h
)
if (MUSTACHE_WARNINGS_AS_ERROR)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
include(cmake/gcc_warnings.cmake)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
include(cmake/clang_warnings.cmake)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
include(cmake/msvc_warnings.cmake)
endif()
target_compile_options(${PROJECT_NAME} PRIVATE ${MUSTACHE_WARNINGS})
else()
message(WARNING "If you have disabled compiler warnings because your compiler throws errors, please let me know.")
endif()
add_subdirectory(third_party)
target_link_libraries(${PROJECT_NAME} mustache_profiler)
include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME})
if (MUSTACHE_BUILD_SHARED)
target_compile_definitions(${PROJECT_NAME} PRIVATE mustache_EXPORTS)
endif()
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${mustache_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
)
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
target_compile_features(${PROJECT_NAME} PUBLIC ${MUSTACHE_CXX_STD})
option(MUSTACHE_BUILD_TESTS "Build mustache Tests" OFF)
if (MUSTACHE_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
option(MUSTACHE_BUILD_EXAMPLES "Build mustache Examples" OFF)
if (MUSTACHE_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
set(mustache_libs -lmustache)
configure_file(
${mustache_SOURCE_DIR}/mustache.pc.in
${CMAKE_CURRENT_BINARY_DIR}/mustache.pc
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/mustache.pc
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)
install(
DIRECTORY src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
# TODO: add mustache_export.h to install files
#install(
# FILES ${PROJECT_BINARY_DIR}/mustache_export.h
# DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
#)
install(
DIRECTORY src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "bin"
)