From a322d18e63326b7444b374f2a03da2751b49f08d Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Wed, 19 Jan 2022 22:46:10 -0700 Subject: [PATCH] Use built-in CMake project version functionality --- CMakeLists.txt | 28 ++++++++++++---------------- cmake/Macros.cmake | 18 +++++++++--------- cmake/SFMLConfig.cmake.in | 2 +- doc/doxyfile.in | 2 +- doc/header.html.in | 2 +- tools/pkg-config/sfml-all.pc.in | 2 +- tools/pkg-config/sfml-audio.pc.in | 2 +- tools/pkg-config/sfml-graphics.pc.in | 2 +- tools/pkg-config/sfml-network.pc.in | 2 +- tools/pkg-config/sfml-system.pc.in | 2 +- tools/pkg-config/sfml-window.pc.in | 2 +- tools/windows/resource.rc.in | 8 ++++---- 12 files changed, 34 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa9b9c57d..fd528daaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,9 @@ if(NOT CMAKE_OSX_SYSROOT) endif() # project name -project(SFML) +project(SFML VERSION 3.0.0) + +set(VERSION_IS_RELEASE OFF) # include the configuration file include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake) @@ -45,12 +47,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake) # https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html include(GNUInstallDirs) -# setup version numbers -set(VERSION_MAJOR 3) -set(VERSION_MINOR 0) -set(VERSION_PATCH 0) -set(VERSION_IS_RELEASE OFF) - # add an option for choosing the build type (shared or static) if(NOT (SFML_OS_IOS OR SFML_OS_ANDROID)) sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries") @@ -347,10 +343,10 @@ else() # edit target properties set_target_properties(SFML PROPERTIES FRAMEWORK TRUE - FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + FRAMEWORK_VERSION ${PROJECT_VERSION} MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.SFML - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} - MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} PUBLIC_HEADER "${SFML_HEADERS}") # add the non-optional SFML headers @@ -523,17 +519,17 @@ sfml_export_targets() set(CPACK_PACKAGE_NAME_SUMMARY "Simple and Fast Multimedia Library") set(CPACK_PACKAGE_VENDOR "SFML Team") -set(CPACK_PACKAGE_FILE_NAME "SFML-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}-${CMAKE_BUILD_TYPE}") +set(CPACK_PACKAGE_FILE_NAME "SFML-${PROJECT_VERSION}-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}-${CMAKE_BUILD_TYPE}") set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.md") -set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") -set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}") -set(CPACK_PACKAGE_INSTALL_DIRECTORY "SFML ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") +set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "SFML ${PROJECT_VERSION}") set(CPACK_MONOLITHIC_INSTALL ON) # NSIS configurations -set(CPACK_NSIS_DISPLAY_NAME "SFML ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})") +set(CPACK_NSIS_DISPLAY_NAME "SFML ${PROJECT_VERSION} (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})") set(CPACK_NSIS_CONTACT "team@sfml-dev.org") set(NSIS_IMAGE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/nsis/") string(REGEX REPLACE "/" "\\\\\\\\" NSIS_IMAGE_PATH ${NSIS_IMAGE_PATH}) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 6ea49f353..d1e440bd1 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -44,7 +44,7 @@ function(sfml_set_common_ios_properties target) MACOSX_BUNDLE TRUE # Bare executables are not usable on iOS, only bundle applications MACOSX_BUNDLE_GUI_IDENTIFIER "org.sfml-dev.${target}" # If missing, trying to launch an example in simulator will make Xcode < 9.3 crash MACOSX_BUNDLE_BUNDLE_NAME "${target}" - MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" + MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}" ) endif() endfunction() @@ -88,7 +88,7 @@ macro(sfml_add_library module) if(SFML_OS_WINDOWS) # include the major version number in Windows shared library names (but not import library names) set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d) - set_target_properties(${target} PROPERTIES SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}") + set_target_properties(${target} PROPERTIES SUFFIX "-${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}") # fill out all variables we use to generate the .rc file string(TIMESTAMP RC_CURRENT_YEAR "%Y") @@ -99,7 +99,7 @@ macro(sfml_add_library module) set(RC_VERSION_SUFFIX "") # Add something like the git revision short SHA-1 in the future set(RC_PRERELEASE "0") # Set to 1 to mark the DLL as a pre-release DLL set(RC_TARGET_NAME "${target}") - set(RC_TARGET_FILE_NAME_SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(RC_TARGET_FILE_NAME_SUFFIX "-${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}") # generate the .rc file configure_file( @@ -128,8 +128,8 @@ macro(sfml_add_library module) # set the version and soversion of the target (for compatible systems -- mostly Linuxes) # except for Android which strips soversion suffixes if(NOT SFML_OS_ANDROID) - set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}) - set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) + set_target_properties(${target} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) + set_target_properties(${target} PROPERTIES VERSION ${PROJECT_VERSION}) endif() # set the target's folder (for IDEs that support it, e.g. Visual Studio) @@ -172,10 +172,10 @@ macro(sfml_add_library module) # adapt target to build frameworks instead of dylibs set_target_properties(${target} PROPERTIES FRAMEWORK TRUE - FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + FRAMEWORK_VERSION ${PROJECT_VERSION} MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target} - MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} - MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}) endif() # adapt install directory to allow distributing dylibs/frameworks in user's frameworks/application bundle @@ -426,7 +426,7 @@ function(sfml_export_targets) include(CMakePackageConfigHelpers) write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/SFMLConfigVersion.cmake" - VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} + VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) if (BUILD_SHARED_LIBS) diff --git a/cmake/SFMLConfig.cmake.in b/cmake/SFMLConfig.cmake.in index 96a794794..cb4fdc82c 100644 --- a/cmake/SFMLConfig.cmake.in +++ b/cmake/SFMLConfig.cmake.in @@ -155,5 +155,5 @@ if (NOT SFML_FOUND) endif() if (SFML_FOUND AND NOT SFML_FIND_QUIETLY) - message(STATUS "Found SFML @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ in ${CMAKE_CURRENT_LIST_DIR}") + message(STATUS "Found SFML @PROJECT_VERSION@ in ${CMAKE_CURRENT_LIST_DIR}") endif() diff --git a/doc/doxyfile.in b/doc/doxyfile.in index 6d3106fb5..faeb0b316 100644 --- a/doc/doxyfile.in +++ b/doc/doxyfile.in @@ -38,7 +38,7 @@ PROJECT_NAME = SFML # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +PROJECT_NUMBER = @PROJECT_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 diff --git a/doc/header.html.in b/doc/header.html.in index cc42ea28d..5bf174589 100644 --- a/doc/header.html.in +++ b/doc/header.html.in @@ -12,7 +12,7 @@
diff --git a/tools/pkg-config/sfml-all.pc.in b/tools/pkg-config/sfml-all.pc.in index 3dba4f7c8..280ee4ecd 100644 --- a/tools/pkg-config/sfml-all.pc.in +++ b/tools/pkg-config/sfml-all.pc.in @@ -6,5 +6,5 @@ includedir=${prefix}/include Name: SFML-all Description: The Simple and Fast Multimedia Library, all modules. URL: http://www.sfml-dev.org -Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +Version: @PROJECT_VERSION@ Requires: sfml-system, sfml-window, sfml-graphics, sfml-audio, sfml-network diff --git a/tools/pkg-config/sfml-audio.pc.in b/tools/pkg-config/sfml-audio.pc.in index ad7fad727..0015dc47d 100644 --- a/tools/pkg-config/sfml-audio.pc.in +++ b/tools/pkg-config/sfml-audio.pc.in @@ -6,7 +6,7 @@ includedir=${prefix}/include Name: SFML-audio Description: The Simple and Fast Multimedia Library, audio module. URL: http://www.sfml-dev.org -Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +Version: @PROJECT_VERSION@ Requires: sfml-system Requires.private: openal, vorbisenc, vorbisfile, vorbis, ogg, flac Libs: -L${libdir} -lsfml-audio diff --git a/tools/pkg-config/sfml-graphics.pc.in b/tools/pkg-config/sfml-graphics.pc.in index 46f53874c..383ecb983 100644 --- a/tools/pkg-config/sfml-graphics.pc.in +++ b/tools/pkg-config/sfml-graphics.pc.in @@ -6,7 +6,7 @@ includedir=${prefix}/include Name: SFML-graphics Description: The Simple and Fast Multimedia Library, graphics module. URL: http://www.sfml-dev.org -Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +Version: @PROJECT_VERSION@ Requires: sfml-window Requires.private: sfml-system, freetype2 Libs: -L${libdir} -lsfml-graphics diff --git a/tools/pkg-config/sfml-network.pc.in b/tools/pkg-config/sfml-network.pc.in index c0199350c..d90e24b21 100644 --- a/tools/pkg-config/sfml-network.pc.in +++ b/tools/pkg-config/sfml-network.pc.in @@ -6,7 +6,7 @@ includedir=${prefix}/include Name: SFML-network Description: The Simple and Fast Multimedia Library, network module. URL: http://www.sfml-dev.org -Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +Version: @PROJECT_VERSION@ Requires: sfml-system Libs: -L${libdir} -lsfml-network Cflags: -I${includedir} diff --git a/tools/pkg-config/sfml-system.pc.in b/tools/pkg-config/sfml-system.pc.in index 285852d7b..a353844f5 100644 --- a/tools/pkg-config/sfml-system.pc.in +++ b/tools/pkg-config/sfml-system.pc.in @@ -6,6 +6,6 @@ includedir=${prefix}/include Name: SFML-system Description: The Simple and Fast Multimedia Library, system module. URL: http://www.sfml-dev.org -Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +Version: @PROJECT_VERSION@ Libs: -L${libdir} -lsfml-system Cflags: -I${includedir} diff --git a/tools/pkg-config/sfml-window.pc.in b/tools/pkg-config/sfml-window.pc.in index e216473ca..d4e5b4206 100644 --- a/tools/pkg-config/sfml-window.pc.in +++ b/tools/pkg-config/sfml-window.pc.in @@ -6,7 +6,7 @@ includedir=${prefix}/include Name: SFML-window Description: The Simple and Fast Multimedia Library, window module. URL: http://www.sfml-dev.org -Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +Version: @PROJECT_VERSION@ Requires: sfml-system Libs: -L${libdir} -lsfml-window # gl may not be in pkg-config diff --git a/tools/windows/resource.rc.in b/tools/windows/resource.rc.in index 944fcc930..a583ab8c6 100644 --- a/tools/windows/resource.rc.in +++ b/tools/windows/resource.rc.in @@ -5,11 +5,11 @@ #define VER_FILEDESCRIPTION_STR "SFML @RC_MODULE_NAME@ Module\0" #define VER_PRODUCTNAME_STR "Simple and Fast Multimedia Library\0" -#define VER_FILEVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0 -#define VER_FILEVERSION_STR "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@@RC_VERSION_SUFFIX@\0" +#define VER_FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0 +#define VER_FILEVERSION_STR "@PROJECT_VERSION@@RC_VERSION_SUFFIX@\0" -#define VER_PRODUCTVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0 -#define VER_PRODUCTVERSION_STR "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@@RC_VERSION_SUFFIX@\0" +#define VER_PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0 +#define VER_PRODUCTVERSION_STR "@PROJECT_VERSION@@RC_VERSION_SUFFIX@\0" #ifndef DEBUG #define VER_INTERNALNAME_STR "@RC_TARGET_NAME@@RC_TARGET_FILE_NAME_SUFFIX@\0"