-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
110 lines (87 loc) · 3.59 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
cmake_minimum_required(VERSION 3.8)
project(root)
option(TARGET "Architecture cible" pc)
option(COLOR "Sortie en couleur de la compilation" ON)
option(DEBUG "Compilation avec les symboles de debug et sans optimisations" OFF)
option(COVERAGE "Compilation avec '--coverage' pour l'utilisation de 'lcov'" OFF)
set(BITS "64" CACHE . "Build en 32 ou 64 bits")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -std=gnu++17")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_ENABLE_EXPORTS ON)
if(RASPI)
set(INFO_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build_arm")
else()
set(INFO_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build")
endif()
execute_process(
COMMAND mkdir -p ${INFO_OUTPUT_DIRECTORY}
)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${INFO_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${INFO_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${INFO_OUTPUT_DIRECTORY})
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/")
# Mise à jour des submodules Git.
execute_process(
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${root_SOURCE_DIR}
)
add_custom_target(InfoSubmodules
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${root_SOURCE_DIR}
)
if(DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -flto")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto")
endif()
if(COVERAGE)
message(STATUS "Building project with coverage information")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 --coverage")
endif()
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "^(Apple)?Clang$")
if (COLOR)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics")
else ()
set(CMAKE_COLOR_MAKEFILE OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-color-diagnostics")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-color-diagnostics")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-stack-address")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-local-addr")
endif()
if(${BITS} EQUAL 32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Waddress -Wbuiltin-macro-redefined -Werror=return-type -Winit-self -Wnon-virtual-dtor -Wno-sign-compare -Wold-style-cast -Woverloaded-virtual -Wsuggest-attribute=noreturn -Wswitch -Wuninitialized -Wunreachable-code -Wunused-parameter -Wunused-value")
function(compile_petri TARGET_NAME PATH_TO_DOC OUTPUT)
add_custom_target(${TARGET_NAME}
COMMAND petrilab --update --arch ${BITS} ${CMAKE_CURRENT_SOURCE_DIR}/${PATH_TO_DOC}
)
endfunction()
if(RASPI)
add_definitions(-DRASPI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
else()
link_directories(/usr/local/lib/)
endif()
# Il y a du code pour les ombres, apparamment. Ca a pas l'air de marcher.
# debug/CGTK semble désactivé depuis un moment également.
#add_definitions(-DGTKWIN_DISABLE)
include_directories(src/commun /usr/local/include/)
add_subdirectory(third_parties)
add_subdirectory(src)
# Target pour les tests unitaires
enable_testing()
add_subdirectory(test)