cmake: pass VERSION to project() + don't use SDL_VERSION
parent
3aa456dead
commit
9cf34908a1
|
@ -1,9 +1,11 @@
|
|||
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the SDL source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there")
|
||||
endif()
|
||||
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
project(SDL3 C CXX)
|
||||
# See docs/release_checklist.md
|
||||
project(SDL3 LANGUAGES C CXX VERSION "3.0.0")
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||
set(SDL3_SUBPROJECT OFF)
|
||||
|
@ -75,36 +77,30 @@ if (LIBC_IS_GLIBC AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|||
target_compile_definitions(sdl-build-options INTERFACE "_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
|
||||
# See docs/release_checklist.md
|
||||
set(SDL_MAJOR_VERSION 3)
|
||||
set(SDL_MINOR_VERSION 0)
|
||||
set(SDL_MICRO_VERSION 0)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
|
||||
# Increment this if there is an incompatible change - but if that happens,
|
||||
# we should rename the library from SDL3 to SDL4, at which point this would
|
||||
# reset to 0 anyway.
|
||||
set(SDL_SO_VERSION_MAJOR "0")
|
||||
set(SDL_SO_VERSION_MINOR "${SDL_MINOR_VERSION}")
|
||||
set(SDL_SO_VERSION_MICRO "${SDL_MICRO_VERSION}")
|
||||
set(SDL_SO_VERSION "${SDL_SO_VERSION_MAJOR}.${SDL_SO_VERSION_MINOR}.${SDL_SO_VERSION_MICRO}")
|
||||
set(SDL_SO_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
||||
set(SDL_SO_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
||||
set(SDL_SO_VERSION "${SDL_SO_VERSION_MAJOR}.${SDL_SO_VERSION_MINOR}.${SDL_SO_VERSION_PATCH}")
|
||||
|
||||
if(SDL_MINOR_VERSION MATCHES "[02468]$")
|
||||
math(EXPR SDL_DYLIB_COMPAT_VERSION_MAJOR "100 * ${SDL_MINOR_VERSION} + 1")
|
||||
if(PROJECT_VERSION_MINOR MATCHES "[02468]$")
|
||||
math(EXPR SDL_DYLIB_COMPAT_VERSION_MAJOR "100 * ${PROJECT_VERSION_MINOR} + 1")
|
||||
set(SDL_DYLIB_COMPAT_VERSION_MINOR "0")
|
||||
math(EXPR SDL_DYLIB_CURRENT_VERSION_MAJOR "${SDL_DYLIB_COMPAT_VERSION_MAJOR}")
|
||||
set(SDL_DYLIB_CURRENT_VERSION_MINOR "${SDL_MICRO_VERSION}")
|
||||
set(SDL_DYLIB_CURRENT_VERSION_MINOR "${PROJECT_VERSION_PATCH}")
|
||||
else()
|
||||
math(EXPR SDL_DYLIB_COMPAT_VERSION_MAJOR "100 * ${SDL_MINOR_VERSION} + ${SDL_MICRO_VERSION} + 1")
|
||||
math(EXPR SDL_DYLIB_COMPAT_VERSION_MAJOR "100 * ${PROJECT_VERSION_MINOR} + ${PROJECT_VERSION_PATCH} + 1")
|
||||
set(SDL_DYLIB_COMPAT_VERSION_MINOR "0")
|
||||
math(EXPR SDL_DYLIB_CURRENT_VERSION_MAJOR "${SDL_DYLIB_COMPAT_VERSION_MAJOR}")
|
||||
set(SDL_DYLIB_CURRENT_VERSION_MINOR "0")
|
||||
endif()
|
||||
set(SDL_DYLIB_COMPAT_VERSION_MICRO "0")
|
||||
set(SDL_DYLIB_CURRENT_VERSION_MICRO "0")
|
||||
set(SDL_DYLIB_COMPAT_VERSION_PATCH "0")
|
||||
set(SDL_DYLIB_COMPAT_VERSION_PATCH "0")
|
||||
|
||||
set(SDL_DYLIB_CURRENT_VERSION "${SDL_DYLIB_CURRENT_VERSION_MAJOR}.${SDL_DYLIB_CURRENT_VERSION_MINOR}.${SDL_DYLIB_CURRENT_VERSION_MICRO}")
|
||||
set(SDL_DYLIB_COMPAT_VERSION "${SDL_DYLIB_COMPAT_VERSION_MAJOR}.${SDL_DYLIB_COMPAT_VERSION_MINOR}.${SDL_DYLIB_COMPAT_VERSION_MICRO}")
|
||||
set(SDL_DYLIB_CURRENT_VERSION "${SDL_DYLIB_CURRENT_VERSION_MAJOR}.${SDL_DYLIB_CURRENT_VERSION_MINOR}.${SDL_DYLIB_COMPAT_VERSION_PATCH}")
|
||||
set(SDL_DYLIB_COMPAT_VERSION "${SDL_DYLIB_COMPAT_VERSION_MAJOR}.${SDL_DYLIB_COMPAT_VERSION_MINOR}.${SDL_DYLIB_COMPAT_VERSION_PATCH}")
|
||||
|
||||
#message("SDL_SO_VERSION=${SDL_SO_VERSION} SDL_DYLIB_CURRENT_VERSION=${SDL_DYLIB_CURRENT_VERSION} SDL_DYLIB_COMPAT_VERSION=${SDL_DYLIB_COMPAT_VERSION}")
|
||||
|
||||
|
@ -2868,7 +2864,7 @@ else()
|
|||
# If VERSION does not exist, use git to calculate a version
|
||||
git_describe(SDL_REVISION_CENTER)
|
||||
if(NOT SDL_REVISION_CENTER)
|
||||
set(SDL_REVISION_CENTER "${SDL_VERSION}-no-vcs")
|
||||
set(SDL_REVISION_CENTER "${SDL3_VERSION}-no-vcs")
|
||||
endif()
|
||||
endif()
|
||||
set(SDL_REVISION "SDL-${SDL_REVISION_CENTER}${SDL_REVISION_SUFFIX}")
|
||||
|
@ -3197,9 +3193,9 @@ if(SDL_STATIC)
|
|||
endif()
|
||||
|
||||
target_compile_definitions(sdl-build-options INTERFACE
|
||||
"SDL_BUILD_MAJOR_VERSION=${SDL_MAJOR_VERSION}"
|
||||
"SDL_BUILD_MINOR_VERSION=${SDL_MINOR_VERSION}"
|
||||
"SDL_BUILD_MICRO_VERSION=${SDL_MICRO_VERSION}"
|
||||
"SDL_BUILD_MAJOR_VERSION=${PROJECT_VERSION_MAJOR}"
|
||||
"SDL_BUILD_MINOR_VERSION=${PROJECT_VERSION_MINOR}"
|
||||
"SDL_BUILD_MICRO_VERSION=${PROJECT_VERSION_PATCH}"
|
||||
)
|
||||
|
||||
##### Tests #####
|
||||
|
@ -3318,7 +3314,6 @@ if(NOT SDL3_DISABLE_INSTALL)
|
|||
INSTALL_DESTINATION "${SDL_INSTALL_CMAKEDIR}"
|
||||
)
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/SDL3ConfigVersion.cmake"
|
||||
VERSION ${SDL_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
|
|
|
@ -25,10 +25,7 @@ not_ok () {
|
|||
failed=1
|
||||
}
|
||||
|
||||
major=$(sed -ne 's/^set(SDL_MAJOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
|
||||
minor=$(sed -ne 's/^set(SDL_MINOR_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
|
||||
micro=$(sed -ne 's/^set(SDL_MICRO_VERSION \([0-9]*\))$/\1/p' CMakeLists.txt)
|
||||
version="${major}.${minor}.${micro}"
|
||||
version=$(sed -Ene 's/^project\(SDL[0-9]+ LANGUAGES C CXX VERSION "([0-9.]*)"\)$/\1/p' CMakeLists.txt)
|
||||
|
||||
if [ "$ref_version" = "$version" ]; then
|
||||
ok "CMakeLists.txt $version"
|
||||
|
|
|
@ -54,9 +54,7 @@ if [ "x$PATCH" != "x0" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
perl -w -pi -e 's/\A(set\(SDL_MAJOR_VERSION\s+)\d+/${1}'$MAJOR'/;' CMakeLists.txt
|
||||
perl -w -pi -e 's/\A(set\(SDL_MINOR_VERSION\s+)\d+/${1}'$MINOR'/;' CMakeLists.txt
|
||||
perl -w -pi -e 's/\A(set\(SDL_MICRO_VERSION\s+)\d+/${1}'$PATCH'/;' CMakeLists.txt
|
||||
perl -w -pi -e 's/\A(project\(SDL[0-9]+ LANGUAGES C CXX VERSION ")[0-9.]+/${1}'$NEWVERSION'/;' CMakeLists.txt
|
||||
|
||||
perl -w -pi -e 's/\A(.* SDL_MAJOR_VERSION = )\d+/${1}'$MAJOR'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
|
||||
perl -w -pi -e 's/\A(.* SDL_MINOR_VERSION = )\d+/${1}'$MINOR'/;' android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
|
||||
|
|
|
@ -7,7 +7,7 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
|||
|
||||
Name: sdl3
|
||||
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
|
||||
Version: @SDL_VERSION@
|
||||
Version: @PROJECT_VERSION@
|
||||
Requires.private: @SDL_PC_PRIVATE_REQUIRES@
|
||||
Conflicts:
|
||||
Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_PC_LIBS@ @PKGCONFIG_LIBS_PRIV@ @SDL_PC_STATIC_LIBS@
|
||||
|
|
|
@ -351,8 +351,8 @@ if(APPLE)
|
|||
foreach(CURRENT_TARGET ${SDL_TEST_EXECUTABLES})
|
||||
set_target_properties("${CURRENT_TARGET}" PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "org.libsdl.${CURRENT_TARGET}"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION "${SDL_VERSION}"
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING "${SDL_VERSION}"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION "${SDL3_VERSION}"
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING "${SDL3_VERSION}"
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue