Commit 3228a31d authored by Pierre Aubert's avatar Pierre Aubert
Browse files

Add version generator

parent 2951c5c9
# Create the version header of the given program
# projectName : name of the project
# projectVersion : version of the project
function(create_version projectName projectVersion)
message(STATUS "Program ${projectName} version ${projectVersion}")
string(REPLACE "." ";" VERSION_STR_LIST ${projectVersion})
set(VERSION_LIST ${VERSION_STR_LIST})
list(LENGTH VERSION_LIST listLength)
list(GET VERSION_LIST 0 MAJOR_PROG_VERSION)
list(GET VERSION_LIST 1 MINOR_PROG_VERSION)
list(GET VERSION_LIST 2 PATCH_PROG_VERSION)
string(TOUPPER ${projectName} PROGRAM_UPPER_NAME)
string(TOLOWER ${projectName} PROGRAM_LOWER_NAME)
set(OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROGRAM_LOWER_NAME}_version.h)
set(DEFINE_MACRO_HEADER "__${PROGRAM_UPPER_NAME}_VERSION_H__")
file(WRITE ${OUTPUT_FILE} "\n")
file(APPEND ${OUTPUT_FILE} "/***************************************\n")
file(APPEND ${OUTPUT_FILE} " Auteur : Pierre Aubert\n")
file(APPEND ${OUTPUT_FILE} " Mail : aubertp7@gmail.com\n")
file(APPEND ${OUTPUT_FILE} " Licence : CeCILL-C\n")
file(APPEND ${OUTPUT_FILE} "****************************************/\n")
file(APPEND ${OUTPUT_FILE} "\n")
file(APPEND ${OUTPUT_FILE} "#ifndef ${DEFINE_MACRO_HEADER}\n")
file(APPEND ${OUTPUT_FILE} "#define ${DEFINE_MACRO_HEADER}\n\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_VERSION_MAJOR ${MAJOR_PROG_VERSION}\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_VERSION_MINOR ${MINOR_PROG_VERSION}\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_VERSION_PATCH ${PATCH_PROG_VERSION}\n\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_MAKE_VERSION(major, minor, patch) ((major) *10000 + (minor) *100 + (patch))\n\n")
file(APPEND ${OUTPUT_FILE} "#define ${PROGRAM_UPPER_NAME}_VERSION ${PROGRAM_UPPER_NAME}_MAKE_VERSION (${PROGRAM_UPPER_NAME}_VERSION_MAJOR, ${PROGRAM_UPPER_NAME}_VERSION_MINOR, ${PROGRAM_UPPER_NAME}_VERSION_PATCH)\n\n")
file(APPEND ${OUTPUT_FILE} "#endif\n\n")
install(FILES ${OUTPUT_FILE} DESTINATION include/${projectName})
endfunction(create_version)
include(create_version.cmake)
# Define the base of a Phoenix project
# programName : name of the program/library
......@@ -6,6 +7,7 @@
# 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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment