3.2.1.1 : La création d'un projet
Voici le phoenix_base_project.cmake : Incluons la définition des versions :
1 |
include(create_version.cmake)
|
Fonction qui permet de définir simplement un projet (nom, version, description, url). Cela permet de simplifier la génération de paquets binaires :
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 |
# Define the base of a Phoenix project # programName : name of the program/library # programVersion : version of the program/library # programDescritpion : description of the program/library # programHomePage : home page of the program/library function(phoenix_base_project programName programVersion programDescritpion programHomePage) create_version("${programName}" "${programVersion}") if(NOT MODULE_MODE) set(PROGRAM_NAME "${programName}" CACHE STRING "name of the current project" FORCE) set(PROGRAM_VERSION "${programVersion}" CACHE STRING "version of the current project" FORCE) set(PROGRAM_DESCRIPTION_NO_QUOTE "${programDescritpion}" CACHE STRING "description of the current project" FORCE) set(PROGRAM_DESCRIPTION "\"${PROGRAM_DESCRIPTION_NO_QUOTE}\"" CACHE STRING "description with double quotes of the current project" FORCE) set(PROGRAM_HOMEPAGE "${programHomePage}" CACHE STRING "home page of the current project" FORCE) set(LIBRARY_DIRECTORY "lib" CACHE STRING "define the library directory (especially for Fedora with the wtf lib64)" FORCE) set(DOC_MODE no CACHE BOOL "Doc mode") set(SELF_TESTS_MODE yes CACHE BOOL "Self test mode") message(STATUS "SELF_TESTS_MODE = ${SELF_TESTS_MODE}") set(PHOENIX_FORCE_PULL_MODULE no CACHE BOOL "Say if the submodule have to be pulled every time or not") if(CMAKE_BUILD_TYPE STREQUAL "Coverage") message(STATUS "Build for tests COVERAGE") set(CTEST_COVERAGE_COMMAND "gcov") set(SELF_TESTS_MODE yes) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -Wall -Werror -g -O0 -fprofile-arcs -ftest-coverage" PARENT_SCOPE) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -Wall -Werror -g -O2" PARENT_SCOPE) endif() add_definitions(-D__PROGRAM_VERSION__="${PROGRAM_VERSION}") if(DOC_MODE) add_subdirectory(doc) endif() createLinuxPackages() endif() endfunction(phoenix_base_project) |
C'est un scandale que l'on soit encore en C++11 mais ça va bientôt changer. Le fichier phoenix_base_project.cmake complet :
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 |
include(create_version.cmake) # Define the base of a Phoenix project # programName : name of the program/library # programVersion : version of the program/library # programDescritpion : description of the program/library # programHomePage : home page of the program/library function(phoenix_base_project programName programVersion programDescritpion programHomePage) create_version("${programName}" "${programVersion}") if(NOT MODULE_MODE) set(PROGRAM_NAME "${programName}" CACHE STRING "name of the current project" FORCE) set(PROGRAM_VERSION "${programVersion}" CACHE STRING "version of the current project" FORCE) set(PROGRAM_DESCRIPTION_NO_QUOTE "${programDescritpion}" CACHE STRING "description of the current project" FORCE) set(PROGRAM_DESCRIPTION "\"${PROGRAM_DESCRIPTION_NO_QUOTE}\"" CACHE STRING "description with double quotes of the current project" FORCE) set(PROGRAM_HOMEPAGE "${programHomePage}" CACHE STRING "home page of the current project" FORCE) set(LIBRARY_DIRECTORY "lib" CACHE STRING "define the library directory (especially for Fedora with the wtf lib64)" FORCE) set(DOC_MODE no CACHE BOOL "Doc mode") set(SELF_TESTS_MODE yes CACHE BOOL "Self test mode") message(STATUS "SELF_TESTS_MODE = ${SELF_TESTS_MODE}") set(PHOENIX_FORCE_PULL_MODULE no CACHE BOOL "Say if the submodule have to be pulled every time or not") if(CMAKE_BUILD_TYPE STREQUAL "Coverage") message(STATUS "Build for tests COVERAGE") set(CTEST_COVERAGE_COMMAND "gcov") set(SELF_TESTS_MODE yes) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -Wall -Werror -g -O0 -fprofile-arcs -ftest-coverage" PARENT_SCOPE) else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -Wall -Werror -g -O2" PARENT_SCOPE) endif() add_definitions(-D__PROGRAM_VERSION__="${PROGRAM_VERSION}") if(DOC_MODE) add_subdirectory(doc) endif() createLinuxPackages() endif() endfunction(phoenix_base_project) |