build system: the version is read from cmake rather than written

This commit is contained in:
Michele Caini
2020-02-10 22:15:33 +01:00
parent 3ad2c559f1
commit 57d017ed8e
4 changed files with 15 additions and 17 deletions

View File

@@ -12,16 +12,26 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.")
endif()
#
# Read project version
#
set(ENTT_VERSION_REGEX "#define ENTT_VERSION_.*[ \t]+(.+)")
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/src/entt/config/version.h" ENTT_VERSION REGEX ${ENTT_VERSION_REGEX})
list(TRANSFORM ENTT_VERSION REPLACE ${ENTT_VERSION_REGEX} "\\1")
string(JOIN "." ENTT_VERSION ${ENTT_VERSION})
#
# Project configuration
#
project(
EnTT
VERSION 3.3.0
VERSION ${ENTT_VERSION}
DESCRIPTION "Gaming meets modern C++ - a fast and reliable entity-component system (ECS) and much more"
HOMEPAGE_URL "https://github.com/skypjack/entt"
LANGUAGES CXX)
LANGUAGES CXX
)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
@@ -68,8 +78,6 @@ include(GNUInstallDirs)
add_library(EnTT INTERFACE)
add_library(EnTT::EnTT ALIAS EnTT)
configure_file(${EnTT_SOURCE_DIR}/cmake/in/version.h.in ${EnTT_SOURCE_DIR}/src/entt/config/version.h @ONLY)
target_include_directories(
EnTT
INTERFACE

4
TODO
View File

@@ -17,7 +17,9 @@
* any-of rule for views/groups (eg entity has A and any of B/C/D)
- get -> all, exclude -> none
* review prepare after clone and the others have been removed
* build system: turn the version stuff on its head
* build system
- avoid showing gtest and the others in the ide
- use fetch content rather then external add
* WIP:
- deprecate clone, stamp, snapshot, loader, ...

View File

@@ -1,11 +0,0 @@
#ifndef ENTT_CONFIG_VERSION_H
#define ENTT_CONFIG_VERSION_H
#define ENTT_VERSION "@PROJECT_VERSION@"
#define ENTT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define ENTT_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define ENTT_VERSION_PATCH @PROJECT_VERSION_PATCH@
#endif

View File

@@ -2,7 +2,6 @@
#define ENTT_CONFIG_VERSION_H
#define ENTT_VERSION "3.3.0"
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 3
#define ENTT_VERSION_PATCH 0