This repository was archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
149 lines (125 loc) · 5.57 KB
/
CMakeLists.txt
File metadata and controls
149 lines (125 loc) · 5.57 KB
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
# Copyright (c) 2022 askmeaboutloom
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.14)
project(drawdance
VERSION 0.3.0
DESCRIPTION "A Drawpile Client"
LANGUAGES C CXX)
option(USE_GENERATORS "Do code generation (turn off when cross-compiling)" ON)
option(USE_ADDRESS_SANITIZER "Build with address sanitizer enabled" ON)
option(USE_CLANG_TIDY "Run clang-tidy on build" ON)
option(USE_STRICT_ALIASING "Enable strict aliasing optimizations" OFF)
option(LINK_WITH_LIBM "Link with libm when using math" ON)
option(BUILD_TESTS "Build tests with CMocka" ON)
option(BUILD_APPS "Build applications (as opposed to only libraries)" ON)
set(THREAD_IMPL PTHREAD CACHE STRING
"Threading implementation (PTHREAD, QT, SDL)")
if(CMAKE_CROSSCOMPILING)
message(STATUS "Cross-compiling for platform '${CMAKE_SYSTEM_NAME}'")
endif()
if(CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using toolchain file '${CMAKE_TOOLCHAIN_FILE}'")
endif()
if(BUILD_TESTS)
enable_testing()
include("${CMAKE_CURRENT_LIST_DIR}/cmake/FetchCMocka.cmake")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/cmake/address_sanitizer.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/clang_format.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/clang_tidy.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/compile_flags.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/dpconfig.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/language_standards.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/export.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cmake/dependencies.cmake")
function(set_dp_target_properties target)
get_target_property(target_type "${target}" TYPE)
if(DRAWDANCE_EMSCRIPTEN)
if(NOT "${target_type}" STREQUAL "INTERFACE_LIBRARY")
target_compile_options("${target}" PRIVATE "-pthread")
target_link_options("${target}" PRIVATE
"-pthread" "SHELL:-s PROXY_TO_PTHREAD"
"SHELL:-s ALLOW_BLOCKING_ON_MAIN_THREAD=0"
"SHELL:-s ALLOW_MEMORY_GROWTH=1" "SHELL:-s FETCH=1"
"SHELL:-s MODULARIZE=1"
"SHELL:-s EXPORT_NAME=createModule"
"SHELL:-s DYNAMIC_EXECUTION=0")
endif()
if("${target_type}" STREQUAL "EXECUTABLE")
set_property(TARGET "${target}" PROPERTY SUFFIX ".js")
endif()
endif()
if(NOT "NO_EXPORT" IN_LIST ARGN)
add_dp_export_target("${target}")
endif()
if(NOT "${target_type}" STREQUAL "INTERFACE_LIBRARY")
set_language_standards("${target}")
add_address_sanitizer("${target}")
target_compile_definitions("${target}" PRIVATE "_XOPEN_SOURCE=600")
if("CXX" IN_LIST ARGN)
target_compile_options("${target}" PRIVATE "${dp_cxxflags}")
else()
target_compile_options("${target}" PRIVATE "${dp_cflags}")
endif()
if(NOT "NO_CLANG_TIDY" IN_LIST ARGN)
add_clang_tidy("${target}")
endif()
if(NOT "NO_WARNINGS" IN_LIST ARGN)
if("CXX" IN_LIST ARGN)
target_compile_options("${target}" PRIVATE "${dp_cxxwarnings}")
else()
target_compile_options("${target}" PRIVATE "${dp_cwarnings}")
endif()
endif()
if(NOT USE_STRICT_ALIASING)
target_compile_definitions(
"${target}" PRIVATE "DP_NO_STRICT_ALIASING")
endif()
string(LENGTH "${PROJECT_SOURCE_DIR}/" project_dir_length)
target_compile_definitions(
"${target}" PRIVATE "DP_PROJECT_DIR_LENGTH=${project_dir_length}")
endif()
endfunction()
function(add_dp_test_targets type tests)
foreach(test_file IN LISTS "${tests}")
get_filename_component(test_file_name "${test_file}" NAME_WE)
set(test_name "dp${type}_test_${test_file_name}")
add_executable("${test_name}" "${test_file}")
set_dp_target_properties("${test_name}" NO_EXPORT)
target_link_libraries("${test_name}" PUBLIC "dp${type}_test")
add_test(NAME "${test_name}" COMMAND "${test_name}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
endforeach()
endfunction()
add_subdirectory(3rdparty)
add_subdirectory(generators)
add_subdirectory(libcommon)
add_subdirectory(libmsg)
add_subdirectory(libclient)
add_subdirectory(libengine)
if(BUILD_APPS)
add_subdirectory(appconv)
add_subdirectory(appdrawdance)
endif()
define_clang_format_target()
report_address_sanitizer_targets()
report_clang_tidy_targets()
report_dp_export_targets()
export_dp_export_targets()