diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a345f3..3eeb7ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,19 @@ # CMakeLists.txt cmake_minimum_required(VERSION 3.10) -project(coffee_crisis VERSION 1.00) + +# La versió de l'app es defineix una sola vegada a source/utils/defines.hpp +# (Defines::VERSION). El Makefile ja la grepeja per als noms de release; aqui +# l'extreiem perque project(... VERSION ...) i tots els consumidors interns +# de CMake (CPack, install, etc.) usin la mateixa font de veritat. +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/defines.hpp" _DEFINES_CONTENT) +string(REGEX MATCH "VERSION = \"([0-9]+\\.[0-9]+\\.[0-9]+)\"" _ "${_DEFINES_CONTENT}") +set(APP_VERSION "${CMAKE_MATCH_1}") +if(APP_VERSION STREQUAL "") + message(FATAL_ERROR "No s'ha pogut extreure VERSION de source/utils/defines.hpp") +endif() + +project(coffee_crisis VERSION ${APP_VERSION}) # Tipus de build per defecte (Debug) si no se n'ha especificat cap if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) diff --git a/source/utils/defines.hpp b/source/utils/defines.hpp index fffd22e..f51cbde 100644 --- a/source/utils/defines.hpp +++ b/source/utils/defines.hpp @@ -1,5 +1,5 @@ #pragma once namespace Texts { - constexpr const char* VERSION = "2.3.4"; // Versión del juego (también usada por el Makefile) + constexpr const char* VERSION = "2.4.0"; // Font de veritat: tambe la usen el Makefile (release names) i CMakeLists (project VERSION) } // namespace Texts