Restructuration du fichier CMakeLists

This commit is contained in:
Mattéo Delabre 2017-02-16 21:23:23 +01:00
parent 05d433e9e7
commit a7e5ed1a8a
1 changed files with 138 additions and 84 deletions

222
CMakeLists.txt vendored
View File

@ -1,11 +1,68 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)
cmake_policy(SET CMP0048 NEW)
project(skizzle VERSION 0.1.0 LANGUAGES CXX)
#########################
# MÉTADONNÉES DU PROJET #
#########################
# Inclusion des fichiers d'en-tête et de source
# Nom et version du projet
project(skizzle VERSION 0.1.0 LANGUAGES CXX)
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
# Contact des mainteneurs·ses du projet
set(CPACK_PACKAGE_CONTACT "Maëlle Beuret <maelle.beuret@etu.umontpellier.fr>" "Rémi Cérès <remi.ceres@etu.umontpellier.fr>" "Mattéo Delabre <matteo.delabre@etu.umontpellier.fr>")
# Liste des exécutables du projet
set(CPACK_PACKAGE_EXECUTABLES "skizzle;Skizzle")
# Description du projet
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Jeu inspiré des jeux de \
plateformes, des jeux de réflexion et de coopération.")
# Icône du projet
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/${CMAKE_PROJECT_NAME}-128.png")
############################
# CHEMINS VERS LES SOURCES #
############################
# Liste des fichiers sources (cette liste doit être tenue à jour à chaque ajout
# ou suppression dun fichier source dans le dossier src/. Un fichier source
# non-présent dans cette liste ne serait pas lié à lexécutable final.)
set(SOURCES
"src/main.cpp"
"src/manager.cpp"
"src/resource_manager.cpp"
"src/utility.cpp"
"src/gui/action_toolbar.cpp"
"src/gui/icon_radio_button.cpp"
"src/gui/modal.cpp"
"src/gui/object_toolbar.cpp"
"src/objects/block.cpp"
"src/objects/collision.cpp"
"src/objects/finish_block.cpp"
"src/objects/gravity_block.cpp"
"src/objects/kill_block.cpp"
"src/objects/object.cpp"
"src/objects/player.cpp"
"src/objects/switch_block.cpp"
"src/states/editor.cpp"
"src/states/game.cpp"
"src/states/level.cpp"
"src/states/menu.cpp"
"src/states/rules.cpp"
"src/states/state.cpp"
)
# Chemin vers les fichiers d'en-tête
include_directories(include)
file(GLOB_RECURSE SOURCES "src/*.cpp")
################################
# CONFIGURATION DU COMPILATEUR #
################################
# Affichage de tous les avertisements
if(MSVC)
@ -14,100 +71,97 @@ elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wall -Wno-long-long -pedantic")
endif()
# Activation du standard C++11 sur le compilateur
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
# Activation du standard C++11
set(CMAKE_CXX_STANDARD 11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "Votre version de gcc ne supporte pas C++11. \
Le projet ne compilera probablement pas. Les versions de gcc \
compatibles sont 4.6 et supérieures.")
endif()
elseif(MSVC)
if(MSVC_VERSION LESS 1800)
message(STATUS "Votre version de Visual Studio ne supporte \
pas C++11. Le projet ne compilera probablement pas. Les versions \
de Visual Studio compatibles sont 2012 et supérieures.")
endif()
endif()
##############################
# GÉNÉRATION DE LEXÉCUTABLE #
##############################
# Recherche des librairies
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
add_executable(${CMAKE_PROJECT_NAME} ${SOURCES})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# Liaison avec la librairie SFML
find_package(SFML 2.3.2 REQUIRED system window graphics network audio)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} ${SFML_LIBRARIES})
# Liaison avec la librairie Boost System et Filesystem
find_package(Boost 1.58.0 COMPONENTS system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} ${Boost_LIBRARIES})
# Liaison statique avec la librairie SFGUI
set(SFGUI_STATIC_LIBRARIES YES)
find_package(SFGUI 0.2.3 REQUIRED)
include_directories(${SFML_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${SFGUI_INCLUDE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} ${SFML_LIBRARIES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${Boost_LIBRARIES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${SFGUI_LIBRARY} ${SFGUI_DEPENDENCIES})
# Informations pour la création des packages
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_CONTACT "Maëlle Beuret, Rémi Cérès, Mattéo Delabre")
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/${CMAKE_PROJECT_NAME}-128.png")
###########################
# CRÉATION DES PAQUETAGES #
###########################
set(CPACK_MONOLITHIC_INSTALL YES)
set(CPACK_PACKAGE_EXECUTABLES "skizzle;Skizzle")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Skizzle est un jeu inspiré des jeux de \
plateformes, des jeux de réflexion et de coopération.")
set(CPACK_STRIP_FILES YES)
# Création des packages en fonction du système actuel
# Configuration spécifique à Windows
if(WIN32)
set(CPACK_GENERATOR "NSIS")
#############################################
# TODO: ajout des instructions pour Windows #
#############################################
elseif(UNIX AND NOT APPLE)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsfml-system2.3v5 (>= 2.3.2), \
libsfml-window2.3v5 (>= 2.3.2), libsfml-graphics2.3v5 (>= 2.3.2), \
libsfml-audio2.3v5 (>= 2.3.2), libboost-system1.58.0 (>= 1.58.0), \
libboost-filesystem1.58.0 (>= 1.58.0)")
# Installation de l'exécutable
install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION games)
# Installation de la documentation et des ressources
install(FILES README.md DESTINATION share/${CMAKE_PROJECT_NAME})
install(DIRECTORY res docs DESTINATION share/${CMAKE_PROJECT_NAME})
# Installation des icônes
install(FILES cmake/${CMAKE_PROJECT_NAME}.svg DESTINATION share/pixmaps)
install(FILES ${CPACK_PACKAGE_ICON}
RENAME ${CMAKE_PROJECT_NAME}.png
DESTINATION share/pixmaps)
foreach(ICON_SIZE 16 32 48 64 128 256 512)
install(FILES cmake/${CMAKE_PROJECT_NAME}-${ICON_SIZE}.png
RENAME ${CMAKE_PROJECT_NAME}.png
DESTINATION share/icons/hicolor/${ICON_SIZE}x${ICON_SIZE}/apps)
endforeach(ICON_SIZE)
# Installation du fichier d'application
install(FILES cmake/${CMAKE_PROJECT_NAME}.desktop
DESTINATION share/applications)
else()
message(STATUS "Votre plateforme n'a pas été configurée pour produire \
des packages. La commande 'make package' ne fonctionnera pas, mais le \
projet peut compiler et vous serez en mesure de l'exécuter.")
set(CPACK_GENERATOR ${CPACK_GENERATOR} "NSIS")
# TODO: ajout des instructions pour Windows
endif()
# Configuration spécifique à Debian et dérivés
if(EXISTS /etc/debian_version)
set(CPACK_GENERATOR ${CPACK_GENERATOR} "DEB")
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)
set(BINARY_PATH games)
set(SHARE_PATH share/${CMAKE_PROJECT_NAME})
set(PIXMAPS_PATH share/pixmaps)
set(ICONS_PATH share/icons/hicolor)
set(APPS_PATH share/applications)
endif()
# Installation de l'exécutable
install(
TARGETS ${CMAKE_PROJECT_NAME}
DIRECTORY_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ
RUNTIME DESTINATION games
)
# Installation de la documentation et des ressources
install(FILES README.md DESTINATION ${SHARE_PATH})
install(DIRECTORY res docs DESTINATION ${SHARE_PATH})
# Installation des icônes
install(
FILES cmake/${CMAKE_PROJECT_NAME}.svg
RENAME ${CMAKE_PROJECT_NAME}.svg
DESTINATION ${PIXMAPS_PATH}
)
install(
FILES ${CPACK_PACKAGE_ICON}
RENAME ${CMAKE_PROJECT_NAME}.png
DESTINATION ${PIXMAPS_PATH}
)
foreach(ICON_SIZE 16 32 48 64 128 256 512)
install(
FILES cmake/${CMAKE_PROJECT_NAME}-${ICON_SIZE}.png
RENAME ${CMAKE_PROJECT_NAME}.png
DESTINATION ${ICONS_PATH}/${ICON_SIZE}x${ICON_SIZE}/apps
)
endforeach(ICON_SIZE)
# Installation du fichier d'application
install(
FILES cmake/${CMAKE_PROJECT_NAME}.desktop
DESTINATION ${APPS_PATH}
)
include(CPack)