CMake: Have CMake itself track versions

This commit is contained in:
Sam Edwards 2018-04-01 19:59:20 -06:00
parent 449195a33d
commit aed544bf5f
3 changed files with 9 additions and 26 deletions

View File

@ -1,15 +1,7 @@
# We require 2.8.12+ for three reasons:
# 1) CMake 3 is so common these days that it's really not a burden on the user
# to expect them to have it.
# 2) As of this writing, this is the oldest version included in a supported
# release of Ubuntu. Older versions are actually somewhat difficult to track
# down, so we don't test against them.
# 3) CMake's INTERFACE_INCLUDE_DIRECTORIES feature, which we rely on
# extensively, finally became stable in this release.
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.0.2)
set(CMAKE_DISABLE_SOURCE_CHANGES ON) # Must go before project() below
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) # Must go before project() below
project(Panda3D)
project(Panda3D VERSION 1.10.0)
enable_testing()
# Panda3D is now a C++11 project. Newer versions of CMake support this out of

View File

@ -2,9 +2,6 @@
# by the top CMakeLists.txt, which puts it in the global namespace for
# all CMake scripts for Panda.
set(PANDA_VERSION "1.9.0" CACHE STRING
"Use dots to separate the major, minor, and sequence numbers.")
option(PANDA_OFFICIAL_VERSION
"This variable will be defined to false in the CVS repository, but
scripts that generate source tarballs and/or binary releases for
@ -59,12 +56,6 @@ mark_as_advanced(PANDA_VERSION PANDA_OFFICIAL_VERSION
PANDA_PACKAGE_VERSION P3D_PLUGIN_VERSION P3D_COREAPI_VERSION
PANDA_DIST_USE_LICENSES)
# Separate the Panda3D version into its three components.
string(REPLACE "." ";" PANDA_VERSION_LIST "${PANDA_VERSION}")
list(GET PANDA_VERSION_LIST 0 PANDA_MAJOR_VERSION)
list(GET PANDA_VERSION_LIST 1 PANDA_MINOR_VERSION)
list(GET PANDA_VERSION_LIST 2 PANDA_SEQUENCE_VERSION)
# The version gets a "c" at the end if it's not an official one.
if(PANDA_OFFICIAL_VERSION)
set(VERSION_SUFFIX "")
@ -72,15 +63,15 @@ else()
set(VERSION_SUFFIX "c")
endif()
set(PANDA_VERSION_STR "${PANDA_VERSION}${VERSION_SUFFIX}")
set(PANDA_VERSION_STR "${PROJECT_VERSION}${VERSION_SUFFIX}")
# This symbol is used to enforce ABI incompatibility between
# major versions of Panda3D.
set(PANDA_VERSION_SYMBOL panda_version_${PANDA_MAJOR_VERSION}_${PANDA_MINOR_VERSION})
set(PANDA_VERSION_SYMBOL panda_version_${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR})
# The Panda version as a number, with three digits reserved
# for each component.
math(EXPR PANDA_NUMERIC_VERSION "${PANDA_MAJOR_VERSION}*1000000 + ${PANDA_MINOR_VERSION}*1000 + ${PANDA_SEQUENCE_VERSION}")
math(EXPR PANDA_NUMERIC_VERSION "${PROJECT_VERSION_MAJOR}*1000000 + ${PROJECT_VERSION_MINOR}*1000 + ${PROJECT_VERSION_PATCH}")
# Separate the plugin version into its three components.
string(REPLACE "." ";" P3D_PLUGIN_VERSION_LIST "${P3D_PLUGIN_VERSION}")

View File

@ -33,9 +33,9 @@
included in a .h file, then any other files which also include that
.h file will need to be rebuilt when the version number changes. */
#define PANDA_MAJOR_VERSION @PANDA_MAJOR_VERSION@
#define PANDA_MINOR_VERSION @PANDA_MINOR_VERSION@
#define PANDA_SEQUENCE_VERSION @PANDA_SEQUENCE_VERSION@
#define PANDA_MAJOR_VERSION @PROJECT_VERSION_MAJOR@
#define PANDA_MINOR_VERSION @PROJECT_VERSION_MINOR@
#define PANDA_SEQUENCE_VERSION @PROJECT_VERSION_PATCH@
/* Define if this is an "official" version, undefine otherwise. */
#cmakedefine PANDA_OFFICIAL_VERSION
@ -53,7 +53,7 @@
This usually means the major and minor version. It should be the
same for Panda3D versions that are supposed to be backward
ABI compatible with each other. */
#define PANDA_ABI_VERSION_STR "@PANDA_MAJOR_VERSION@.@PANDA_MINOR_VERSION@"
#define PANDA_ABI_VERSION_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@"
/* This is a string indicating who has provided this distribution. */
#define PANDA_DISTRIBUTOR "@PANDA_DISTRIBUTOR@"