Mercurial > molko
annotate CMakeLists.txt @ 180:43aec6678cad
cmake: add options
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 27 Oct 2020 14:07:18 +0100 |
parents | 6a15145b331e |
children | a5436e15898d |
rev | line source |
---|---|
116
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
1 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
2 # CMakeLists.txt -- CMake build system for molko |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
3 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
4 # Copyright (c) 2020 David Demelier <markand@malikania.fr> |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
5 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
6 # Permission to use, copy, modify, and/or distribute this software for any |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
7 # purpose with or without fee is hereby granted, provided that the above |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
8 # copyright notice and this permission notice appear in all copies. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
9 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
17 # |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
18 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
19 cmake_minimum_required(VERSION 3.18) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
20 project(molko) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
21 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
22 set(CMAKE_C_STANDARD 11) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
23 set(CMAKE_C_STANDARD_REQUIRED On) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
24 set(CMAKE_C_EXTENSIONS Off) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
25 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
26 |
131 | 27 if (CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU") |
28 set(CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}") | |
29 endif () | |
30 | |
176
408e4823e378
cmake: add sone -fsanitize in Debug builds
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
31 if (CMAKE_C_COMPILER_ID MATCHES "Clang") |
177
6a15145b331e
cmake: shorter -fsanitize option list
David Demelier <markand@malikania.fr>
parents:
176
diff
changeset
|
32 set(options "-fsanitize=address,undefined,integer") |
176
408e4823e378
cmake: add sone -fsanitize in Debug builds
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
33 set(CMAKE_C_FLAGS_DEBUG "-fno-omit-frame-pointer ${options} ${CMAKE_C_FLAGS_DEBUG}") |
408e4823e378
cmake: add sone -fsanitize in Debug builds
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
34 set(CMAKE_EXE_LINKER_FLAGS "${options} ${CMAKE_EXE_LINKER_FLAGS}") |
408e4823e378
cmake: add sone -fsanitize in Debug builds
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
35 endif () |
408e4823e378
cmake: add sone -fsanitize in Debug builds
David Demelier <markand@malikania.fr>
parents:
148
diff
changeset
|
36 |
180 | 37 option(MOLKO_WITH_DOXYGEN "Enable Doxygen build" On) |
38 option(MOLKO_WITH_TESTS "Enable unit tests" On) | |
39 option(MOLKO_WITH_EXAMPLES "Enable build of examples" On) | |
40 | |
121
789b23e01f52
misc: reorganize hierarchy, closes #2490
David Demelier <markand@malikania.fr>
parents:
119
diff
changeset
|
41 set_property(GLOBAL PROPERTY USE_FOLDERS On) |
789b23e01f52
misc: reorganize hierarchy, closes #2490
David Demelier <markand@malikania.fr>
parents:
119
diff
changeset
|
42 |
119
43e04bf2c350
cmake: add tests, continue #2487 @1h
David Demelier <markand@malikania.fr>
parents:
118
diff
changeset
|
43 include(GNUInstallDirs) |
43e04bf2c350
cmake: add tests, continue #2487 @1h
David Demelier <markand@malikania.fr>
parents:
118
diff
changeset
|
44 |
43e04bf2c350
cmake: add tests, continue #2487 @1h
David Demelier <markand@malikania.fr>
parents:
118
diff
changeset
|
45 include(cmake/MolkoBuildAssets.cmake) |
121
789b23e01f52
misc: reorganize hierarchy, closes #2490
David Demelier <markand@malikania.fr>
parents:
119
diff
changeset
|
46 include(cmake/MolkoDefineExecutable.cmake) |
119
43e04bf2c350
cmake: add tests, continue #2487 @1h
David Demelier <markand@malikania.fr>
parents:
118
diff
changeset
|
47 include(cmake/MolkoDefineLibrary.cmake) |
122
d1ec1aa3fbe0
cmake: finalize, closes #2487
David Demelier <markand@malikania.fr>
parents:
121
diff
changeset
|
48 include(cmake/MolkoDefineTest.cmake) |
119
43e04bf2c350
cmake: add tests, continue #2487 @1h
David Demelier <markand@malikania.fr>
parents:
118
diff
changeset
|
49 |
116
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
50 find_package(Jansson REQUIRED) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
51 find_package(SDL2 REQUIRED COMPONENTS image mixer ttf) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
52 |
122
d1ec1aa3fbe0
cmake: finalize, closes #2487
David Demelier <markand@malikania.fr>
parents:
121
diff
changeset
|
53 add_subdirectory(cmake) |
d1ec1aa3fbe0
cmake: finalize, closes #2487
David Demelier <markand@malikania.fr>
parents:
121
diff
changeset
|
54 |
116
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
55 add_subdirectory(extern/libsqlite) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
56 add_subdirectory(extern/libgreatest) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
57 |
180 | 58 if (MOLKO_WITH_DOXYGEN) |
59 add_subdirectory(doxygen) | |
60 endif () | |
116
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
61 |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
62 add_subdirectory(tools/bcc) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
63 add_subdirectory(tools/map) |
0a6683615c73
cmake: change build system, continue #2487 @3h
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
64 |
121
789b23e01f52
misc: reorganize hierarchy, closes #2490
David Demelier <markand@malikania.fr>
parents:
119
diff
changeset
|
65 add_subdirectory(libcore) |
148
c577c15df07f
misc: split libraries, closes #2496
David Demelier <markand@malikania.fr>
parents:
131
diff
changeset
|
66 add_subdirectory(libui) |
c577c15df07f
misc: split libraries, closes #2496
David Demelier <markand@malikania.fr>
parents:
131
diff
changeset
|
67 add_subdirectory(librpg) |
121
789b23e01f52
misc: reorganize hierarchy, closes #2490
David Demelier <markand@malikania.fr>
parents:
119
diff
changeset
|
68 add_subdirectory(libadventure) |
789b23e01f52
misc: reorganize hierarchy, closes #2490
David Demelier <markand@malikania.fr>
parents:
119
diff
changeset
|
69 add_subdirectory(molko) |
119
43e04bf2c350
cmake: add tests, continue #2487 @1h
David Demelier <markand@malikania.fr>
parents:
118
diff
changeset
|
70 |
180 | 71 if (MOLKO_WITH_EXAMPLES) |
72 add_subdirectory(examples) | |
73 endif () | |
125
d59efa737fcc
cmake: add examples and fix
David Demelier <markand@malikania.fr>
parents:
122
diff
changeset
|
74 |
180 | 75 if (MOLKO_WITH_TESTS) |
76 enable_testing() | |
77 add_subdirectory(tests) | |
78 endif () |