Skip to content

Commit

Permalink
version.h is now auto-generated and the library is properly versioned
Browse files Browse the repository at this point in the history
  • Loading branch information
crankycyclops committed Feb 18, 2023
1 parent 7552f26 commit bded2f3
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 12 deletions.
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

# Change Log

## [0.91.2] - 2023-02-17

### Changed

- The include/trogdor/version.h header is now auto-generated by CMake
- The shared libraries are now properly versioned

## [0.91.1] - 2023-01-14

### Changed
Expand Down
42 changes: 41 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Current version of the library
set (TROGDOR_VERSION_MAJOR 0)
set (TROGDOR_VERSION_MINOR 91)
set (TROGDOR_VERSION_PATCH 2)

configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)

add_definitions(
-DTROGDOR_VERSION_MAJOR=${TROGDOR_VERSION_MAJOR}
-DTROGDOR_VERSION_MINOR=${TROGDOR_VERSION_MINOR}
-DTROGDOR_VERSION_PATCH=${TROGDOR_VERSION_PATCH}
)

cmake_minimum_required(VERSION 3.14)
enable_language(C CXX)

Expand All @@ -8,7 +21,7 @@ include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(LibtoolFile)

project(trogdor VERSION 0.80.0)
project(trogdor VERSION ${TROGDOR_VERSION_MAJOR}.${TROGDOR_VERSION_MINOR}.${TROGDOR_VERSION_PATCH})

# Enable conditional compilation in the case of a debug build
string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower)
Expand Down Expand Up @@ -51,10 +64,21 @@ add_definitions(-DGAME_XML_DEFAULT_PATH=\"${CMAKE_INSTALL_PREFIX}/share/trogdor/

###############################################################################

# Auto-generated version.h
add_custom_target(trogdor_version_h)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/version.h
DESTINATION include/trogdor
COMPONENT trogdor_version_h
)

###############################################################################

# C++ Include files necessary to develop for the library
add_custom_target(dev)

install(DIRECTORY include/trogdor DESTINATION include COMPONENT dev)
add_dependencies(dev trogdor_version_h)

###############################################################################

Expand Down Expand Up @@ -117,6 +141,10 @@ set(SERIAL_SOURCES
)

add_library(trogdor_serial SHARED ${SERIAL_SOURCES})
set_target_properties(trogdor_serial PROPERTIES
VERSION ${TROGDOR_VERSION_MAJOR}.${TROGDOR_VERSION_MINOR}.${TROGDOR_VERSION_PATCH}
SOVERSION ${TROGDOR_VERSION_MAJOR}
)
CREATE_LIBTOOL_FILE(trogdor_serial ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
target_include_directories(trogdor_serial ${CORE_INCLUDES})
add_dependencies(trogdor_serial trogdor_serial_pkgconfig)
Expand Down Expand Up @@ -149,6 +177,10 @@ if (ENABLE_SERIALIZE_JSON)
add_definitions(-DENABLE_SERIALIZE_JSON)

add_library(trogdor_serial_json SHARED ${JSON_SOURCES})
set_target_properties(trogdor_serial_json PROPERTIES
VERSION ${TROGDOR_VERSION_MAJOR}.${TROGDOR_VERSION_MINOR}.${TROGDOR_VERSION_PATCH}
SOVERSION ${TROGDOR_VERSION_MAJOR}
)
CREATE_LIBTOOL_FILE(trogdor_serial_json ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
target_link_libraries(trogdor_serial_json ${CORE_LIBRARIES})
target_include_directories(trogdor_serial_json ${CORE_INCLUDES})
Expand Down Expand Up @@ -191,6 +223,10 @@ if (ENABLE_SERIALIZE_SQLITE)
add_definitions(-DENABLE_SERIALIZE_SQLITE)

add_library(trogdor_serial_sqlite SHARED ${SQLITE_SOURCES})
set_target_properties(trogdor_serial_sqlite PROPERTIES
VERSION ${TROGDOR_VERSION_MAJOR}.${TROGDOR_VERSION_MINOR}.${TROGDOR_VERSION_PATCH}
SOVERSION ${TROGDOR_VERSION_MAJOR}
)
CREATE_LIBTOOL_FILE(trogdor_serial_sqlite ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
target_include_directories(trogdor_serial_sqlite ${CORE_INCLUDES})
target_link_libraries(trogdor_serial_sqlite ${SQLITE_LIBRARIES})
Expand Down Expand Up @@ -271,6 +307,10 @@ set(CORE_SOURCES
)

add_library(trogdor SHARED ${CORE_SOURCES})
set_target_properties(trogdor PROPERTIES
VERSION ${TROGDOR_VERSION_MAJOR}.${TROGDOR_VERSION_MINOR}.${TROGDOR_VERSION_PATCH}
SOVERSION ${TROGDOR_VERSION_MAJOR}
)
CREATE_LIBTOOL_FILE(trogdor ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})

target_include_directories(trogdor ${CORE_INCLUDES})
Expand Down
11 changes: 11 additions & 0 deletions src/core/cmake/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef TROGDOR_VERSION_H
#define TROGDOR_VERSION_H


// Current version of the core library
#define TROGDOR_VERSION_MAJOR @TROGDOR_VERSION_MAJOR@
#define TROGDOR_VERSION_MINOR @TROGDOR_VERSION_MINOR@
#define TROGDOR_VERSION_PATCH @TROGDOR_VERSION_PATCH@


#endif
11 changes: 0 additions & 11 deletions src/core/include/trogdor/version.h

This file was deleted.

0 comments on commit bded2f3

Please sign in to comment.