Skip to content

Commit

Permalink
Updates cmake setup for reducing sources of version info.
Browse files Browse the repository at this point in the history
Addresses #372: Multiple sources of project's version.
  • Loading branch information
louis-langholtz committed Nov 7, 2020
1 parent 9497f43 commit c499ea1
Show file tree
Hide file tree
Showing 11 changed files with 2,657 additions and 22 deletions.
6 changes: 4 additions & 2 deletions Build/xcode5/PlayRho.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@
4706451C25336237006E69AA /* LimitState.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LimitState.hpp; sourceTree = "<group>"; };
4706451E25336323006E69AA /* LimitState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LimitState.cpp; sourceTree = "<group>"; };
470ADAAB25546D2700EEE99D /* ArrayAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayAllocator.cpp; sourceTree = "<group>"; };
470ADAB82555E05100EEE99D /* Defines.hpp.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Defines.hpp.in; sourceTree = "<group>"; };
470ADAB92555F72B00EEE99D /* Real.hpp.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Real.hpp.in; sourceTree = "<group>"; };
470D533C1E82364F00E96896 /* SpinningCircle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SpinningCircle.hpp; sourceTree = "<group>"; };
470F94A51EC4C79B00AA3C82 /* BodyConf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BodyConf.hpp; sourceTree = "<group>"; };
470F94AB1EC4CAE600AA3C82 /* FixtureConf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FixtureConf.hpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -637,7 +639,6 @@
47B58F5F1F5B791500354C34 /* FlagGuard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlagGuard.cpp; sourceTree = "<group>"; };
47B58F621F64C19600354C34 /* RealConstants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RealConstants.hpp; sourceTree = "<group>"; };
47B58F651F64D2B500354C34 /* Real.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Real.hpp; sourceTree = "<group>"; };
47B58F671F64D2D200354C34 /* Real.hpp.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Real.hpp.in; sourceTree = "<group>"; };
47BE7FE125390E8F00CF0F22 /* BodyType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BodyType.cpp; sourceTree = "<group>"; };
47C85D091EFA251B00F70C56 /* WheelJoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WheelJoint.cpp; sourceTree = "<group>"; };
47C85D0B1EFA2C1C00F70C56 /* Version.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Version.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -943,6 +944,7 @@
children = (
80BB8923141C3E5900F1753A /* PlayRho.hpp */,
47327E7D1EA585790048FCD8 /* Defines.hpp */,
470ADAB82555E05100EEE99D /* Defines.hpp.in */,
80BB8926141C3E5900F1753A /* Collision */,
80BB893E141C3E5900F1753A /* Common */,
80BB894C141C3E5900F1753A /* Dynamics */,
Expand Down Expand Up @@ -1045,7 +1047,7 @@
4764085E2507FBFF0090F711 /* propagate_const.hpp */,
470F94E01ECBB3A100AA3C82 /* Range.hpp */,
47B58F651F64D2B500354C34 /* Real.hpp */,
47B58F671F64D2D200354C34 /* Real.hpp.in */,
470ADAB92555F72B00EEE99D /* Real.hpp.in */,
47B58F621F64C19600354C34 /* RealConstants.hpp */,
80BB8947141C3E5900F1753A /* Settings.hpp */,
4734B21E1DC1340500F15E29 /* Span.hpp */,
Expand Down
50 changes: 40 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
# This is a configuration file for CMake.
# Top level docs for 3.1.3 at: https://cmake.org/cmake/help/v3.1/
# Commands herein described at: https://cmake.org/cmake/help/v3.1/manual/cmake-commands.7.html
# Commands herein described at: https://cmake.org/cmake/help/latest/manual/cmake-commands.7.html

# Minimally require a CMake version that can handle what's necessary...
# According to the following link, support for cxx_std_17 first became available in CMake 3.8.
# https://github.com/Kitware/CMake/blob/07cfb18f9d29cfc0588ede928846a03ec5599c48/Help/release/3.8.rst
# It's not clear that CMake 3.8 is enough though. So 3.10 is picked in hopes that dust settled then.
cmake_minimum_required(VERSION 3.10)
# Availability of CMAKE_PROJECT_VERSION first appeared in CMake 3.12
cmake_minimum_required(VERSION 3.12)

foreach(p
CMP0048 # OK to clear PROJECT_VERSION on project()
CMP0054 # CMake 3.1
CMP0056 # export EXE_LINKER_FLAGS to try_run
CMP0057 # Support no if() IN_LIST operator
CMP0063 # Honor visibility properties for all targets
CMP0077 # Allow option() overrides in importing projects
)
if(POLICY ${p})
cmake_policy(SET ${p} NEW)
endif()
endforeach()

# Set name for entire project. This establishes the project name in <PROJECT_NAME>_* variables.
# Details at: https://cmake.org/cmake/help/latest/command/project.html#command:project
project(PlayRho VERSION 0.12.1)
# Now PlayRho_VERSION set to version above.
# PlayRho_VERSION_MAJOR set to first component.
# PlayRho_VERSION_MINOR set to second component.
# PlayRho_VERSION_PATCH set to third component.
set(PLAYRHO_VERSION PlayRho_VERSION)

# Make sure we can import our CMake functions
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Read the git tags to determine the project version
include(GetGitVersion)
get_git_version(GIT_VERSION)

# Tell the user what versions we are using
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION})
message(STATUS "Version: ${VERSION}")

# Require C++17...
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -22,10 +54,6 @@ endif()
# else will be ignored. PlayRho only supports Debug and Release
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;" CACHE STRING "Semicolon separated list of supported configuration types. PlayRho only supports Debug and Release configurations.")

# Set name for entire project.
# Details at: https://cmake.org/cmake/help/v3.1/command/project.html
project(PlayRho)

# Tell C++ compiler to optimize release builds for speed.
# In clang++, the optimize for speed flag is '-Ot'. This option isn't supported on g++
# however and it'd be nice to use an option that works for both compilers. So use '-O3'.
Expand All @@ -49,7 +77,6 @@ option(PLAYRHO_BUILD_BENCHMARK "Build PlayRho Benchmark console application." OF
option(PLAYRHO_BUILD_TESTBED "Build PlayRho Testbed GUI application." OFF)
option(PLAYRHO_ENABLE_COVERAGE "Enable code coverage generation." OFF)

set(PLAYRHO_VERSION 0.12.0)
set(LIB_INSTALL_DIR lib${LIB_SUFFIX})

# Tell Microsoft Visual C (MSVC) to enable unwind semantics since it doesn't by default.
Expand Down Expand Up @@ -94,5 +121,8 @@ if(PLAYRHO_BUILD_BENCHMARK)
endif(PLAYRHO_BUILD_BENCHMARK)

if(PLAYRHO_INSTALL_DOC)
install(DIRECTORY Documentation DESTINATION share/doc/PlayRho PATTERN ".svn" EXCLUDE)
find_package(Doxygen)
if (DOXYGEN_FOUND)
add_subdirectory(Documentation)
endif()
endif(PLAYRHO_INSTALL_DOC)
10 changes: 10 additions & 0 deletions Documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
configure_file(Doxyfile.in Doxyfile @ONLY)

add_custom_target(Documentation ALL "${DOXYGEN_EXECUTABLE}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Documentation"
COMMENT "Generating HTML documentation" VERBATIM)

install(
DIRECTORY "${CMAKE_BINARY_DIR}/Documentation/html"
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
)
2 changes: 1 addition & 1 deletion Documentation/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = PlayRho
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.12.0
PROJECT_NUMBER = $(PLAYRHO_VERSION)

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
Loading

0 comments on commit c499ea1

Please sign in to comment.