-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
168 lines (136 loc) · 5.95 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
# This file is part of the StegX project.
# Copyright (C) 2018 StegX Team
#
# StegX is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Auteur : Pierre AYOUB
# ==============================================================================
# Vérifications ================================================================
# Version de CMake.
cmake_minimum_required (VERSION 3.6 FATAL_ERROR)
# Empêche de lancer une compilation in-source.
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message (FATAL_ERROR "In-source builds not allowed. Please make a new \
directory (called a build directory) and run CMake from there (cmake ..).")
endif()
# Projet =======================================================================
# Nom du projet et description.
project (StegX VERSION 1.1.0
DESCRIPTION "Projet de Stéganographie pour l'UVSQ"
LANGUAGES C
)
string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LC)
string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
# Texte de la license sous forme de chaîne de caractère en une ligne pour le C.
file (STRINGS ${CMAKE_SOURCE_DIR}/COPYING PROJECT_LICENSE_FULL_TEXT)
string (REPLACE "\\;" "TRUE_COMMA" PROJECT_LICENSE_FULL_TEXT "${PROJECT_LICENSE_FULL_TEXT}")
string (REPLACE ";" "\\n" PROJECT_LICENSE_FULL_TEXT "${PROJECT_LICENSE_FULL_TEXT}")
string (REPLACE "TRUE_COMMA" ";" PROJECT_LICENSE_FULL_TEXT "${PROJECT_LICENSE_FULL_TEXT}")
string (REPLACE "\"" "\\\"" PROJECT_LICENSE_FULL_TEXT "${PROJECT_LICENSE_FULL_TEXT}")
# Modes de compilation.
set (CMAKE_CONFIGURATION_TYPES Debug;Release)
set (CMAKE_BUILD_TYPE Release)
# Configuration ================================================================
# Configuration de CMake.
set (CONFIG_DIR config)
set (CONFIG_PATH ${CMAKE_SOURCE_DIR}/${CONFIG_DIR})
set (CMAKE_CONFIG_DIR cmake)
set (CMAKE_CONFIG_PATH ${CONFIG_PATH}/${CMAKE_CONFIG_DIR})
# Dossiers de recherche des modules de CMake.
set (CMAKE_MACRO_DIR macros)
set (CMAKE_MACRO_PATH ${CMAKE_CONFIG_PATH}/${CMAKE_MACRO_DIR})
set (CMAKE_TARGET_DIR targets)
set (CMAKE_TARGET_PATH ${CMAKE_CONFIG_PATH}/${CMAKE_TARGET_DIR})
set (CMAKE_TARGET_UNINSTALL_DIR uninstall)
set (CMAKE_TARGET_UNINSTALL_PATH ${CMAKE_TARGET_PATH}/${CMAKE_TARGET_UNINSTALL_DIR})
set (CMAKE_MODULE_PATH ${CMAKE_MACRO_PATH};${CMAKE_TARGET_PATH};
${CMAKE_TARGET_UNINSTALL_PATH})
# Configuration du raccourci (.desktop).
set (DESKTOP_DIR desktop)
set (DESKTOP_PATH ${CONFIG_PATH}/${DESKTOP_DIR})
# Macros =======================================================================
# Créer une liste des sous-répertoires.
include (subdirlist)
# Créer une liste de répertoires contenant des headers.
include (headers-directories)
# Sources ======================================================================
# Répertoires des sources du projet et des bibliothèques utilisées.
set (SRC_DIR src)
set (LIB_DIR lib)
# Extension des fichiers sources et des headers.
set (SRC_EXT .c)
set (INC_EXT .h)
# Répertoire des fichiers sources des tests unitaires.
set (TEST_DIR test)
# Répertoires des différentes cibles :
# Bibliothèque StegX.
set (SRC_LIB_DIR lib)
# Interface en ligne de commande.
set (SRC_CLI_DIR cli)
# Interface graphique.
set (SRC_GUI_DIR gui)
# Noms des différentes cibles :
# Bibliothèque StegX.
set (SRC_LIB_TARGET ${PROJECT_NAME_LC}-${SRC_LIB_DIR})
# Interface en ligne de commande.
set (SRC_CLI_TARGET ${PROJECT_NAME_LC}-${SRC_CLI_DIR})
# Interface graphique.
set (SRC_GUI_TARGET ${PROJECT_NAME_LC}-${SRC_GUI_DIR})
# Bibliothèque StegX :
# Headers publiques.
set (SRC_LIB_INC_DIR inc)
set (SRC_LIB_INC_PATH
${CMAKE_SOURCE_DIR}/${SRC_DIR}/${SRC_LIB_DIR}/${SRC_LIB_INC_DIR})
# Headers privés.
set (SRC_LIB_SRC_DIR src)
set (SRC_LIB_SRC_PATH
${CMAKE_SOURCE_DIR}/${SRC_DIR}/${SRC_LIB_DIR}/${SRC_LIB_SRC_DIR})
# Nom de la bibliothèque.
set (SRC_LIB_NAME ${PROJECT_NAME_LC})
# Variables communes.
set (SRC_ALL_DIR ${SRC_LIB_DIR} ${SRC_CLI_DIR} ${SRC_GUI_DIR})
set (SRC_ALL_TARGETS ${SRC_LIB_TARGET} ${SRC_CLI_TARGET} ${SRC_GUI_TARGET})
# Dossiers de sortie sur Windows.
if (WIN32)
set (SRC_RUNTIME_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${SRC_DIR})
set (TEST_OUTPUT_PATH ${CMAKE_BINARY_DIR}/${TEST_DIR})
endif()
# Flags de compilation généraux.
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3 -Wall -Wextra")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG -Wno-unused-result")
# Lecture des sources.
add_subdirectory (${SRC_DIR})
# Documentation ================================================================
# Lecture du répertoire de la configuration de la documentation.
set (DOC_DIR doc)
add_subdirectory (${DOC_DIR})
# Rapports =====================================================================
# Lecture du répertoire de la configuration des rapports.
set (REPORT_DIR report)
add_subdirectory (${REPORT_DIR})
# Tests unitaires ==============================================================
# Activation des tests unitaires, puis lecture du répertoire contenant la
# configuration des tests.
if (NOT MINGW AND NOT MSYS)
enable_testing ()
add_subdirectory (${TEST_DIR})
endif ()
# Divers =======================================================================
# Cible de réinitialisation de l'arborescence de build (à faire par exemple si
# on rajoute un fichier source).
add_custom_target (reinit
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean
COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR}
)
# Formatage des fichiers sources.
include (indent)