浏览代码

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

Michele Caini 6 年之前
父节点
当前提交
57d017ed8e
共有 4 个文件被更改,包括 15 次插入17 次删除
  1. 12 4
      CMakeLists.txt
  2. 3 1
      TODO
  3. 0 11
      cmake/in/version.h.in
  4. 0 1
      src/entt/config/version.h

+ 12 - 4
CMakeLists.txt

@@ -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

+ 3 - 1
TODO

@@ -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, ...

+ 0 - 11
cmake/in/version.h.in

@@ -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

+ 0 - 1
src/entt/config/version.h

@@ -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