cmake: add CPack support for creating binary archives

This commit is contained in:
Anonymous Maarten 2023-01-29 06:12:40 +01:00 committed by Anonymous Maarten
parent 64c97906c9
commit 53d434fd24
14 changed files with 350 additions and 172 deletions

View File

@ -16,7 +16,7 @@ jobs:
matrix:
platform:
- { name: Android.mk }
- { name: CMake, cmake: 1, android_abi: "arm64-v8a", android_platform: 23, arch: "aarch64" }
- { name: CMake, cmake: 1, android_abi: "arm64-v8a", android_platform: 23, arch: "aarch64", artifact: "SDL-android-arm64" }
steps:
- uses: actions/checkout@v3
@ -57,6 +57,10 @@ jobs:
cmake --install build --config Release
echo "SDL3_DIR=$(pwd)/prefix" >> $GITHUB_ENV
( cd prefix; find ) | LC_ALL=C sort -u
- name: Package (CPack)
if: ${{ matrix.platform.name == 'CMake' }}
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
if: ${{ matrix.platform.name == 'CMake' }}
run: |
@ -73,3 +77,9 @@ jobs:
export CC="${{ steps.setup_ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=${{ matrix.platform.arch }}-none-linux-androideabi${{ matrix.platform.android_platform }}"
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh
- uses: actions/upload-artifact@v3
if: ${{ matrix.platform.name == 'CMake' }}
with:
if-no-files-found: error
name: ${{ matrix.platform.artifact }}
path: build/dist/SDL3*

View File

@ -18,7 +18,7 @@ jobs:
run: |
sudo apt-get -y update
sudo apt-get install -y ninja-build
- name: Configure CMake
- name: Configure (CMake)
run: |
emcmake cmake -S . -B build \
-Wdeprecated -Wdev -Werror \
@ -28,7 +28,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=prefix \
-GNinja
- name: Build
- name: Build (CMake)
run: cmake --build build/ --verbose
- name: Run build-time tests
run: |
@ -36,10 +36,13 @@ jobs:
export SDL_TESTS_QUICK=1
# FIXME: enable Emscripten build time tests
# ctest -VV --test-dir build/
- name: Install
- name: Install (CMake)
run: |
echo "SDL3_DIR=$(pwd)/prefix" >> $GITHUB_ENV
cmake --install build/
- name: Package (CPack)
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
run: |
emcmake cmake -S cmake/test -B cmake_config_build \
@ -48,3 +51,8 @@ jobs:
-DTEST_SHARED=FALSE \
-DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }}
cmake --build cmake_config_build --verbose
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: SDL-emscripten
path: build/dist/SDL3*

View File

@ -18,23 +18,25 @@ jobs:
run: |
container-init & timeout 600 vmshell exit 0
- name: Setup Haiku dependencies
run: vmshell pkgman install -y cmd:cmake cmd:gcc cmd:ld cmd:ninja cmd:pkg_config haiku_devel devel:libgl devel:libglu
run: |
vmshell pkgman install -y cmd:cmake cmd:gcc cmd:ld cmd:ninja cmd:pkg_config haiku_devel devel:libgl devel:libglu
- uses: actions/checkout@v3
- name: Copy project to VM
run: |
vmshell mkdir ./src/
tar -cf - ./ | vmshell tar -xf - -C ./src/
- name: Configure (CMake)
run: vmshell cmake -S src -B build -GNinja \
-Wdeprecated -Wdev -Werror \
-DSDL_TESTS=ON \
-DSDL_WERROR=ON \
-DSDL_INSTALL_TESTS=ON \
-DSDL_VENDOR_INFO=Github_Workflow \
-DCMAKE_INSTALL_PREFIX=cmake_prefix \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
-DSDL_TESTS_TIMEOUT_MULTIPLIER=10
run: |
vmshell cmake -S src -B build -GNinja \
-Wdeprecated -Wdev -Werror \
-DSDL_TESTS=ON \
-DSDL_WERROR=ON \
-DSDL_INSTALL_TESTS=ON \
-DSDL_VENDOR_INFO=Github_Workflow \
-DCMAKE_INSTALL_PREFIX=cmake_prefix \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
-DSDL_TESTS_TIMEOUT_MULTIPLIER=10
- name: Build (CMake)
run: |
vmshell cmake --build ./build/ --config Release --verbose --parallel
@ -44,6 +46,9 @@ jobs:
- name: Install (CMake)
run: |
vmshell cmake --install ./build/ --config Release
- name: Package (CPack)
run: |
vmshell cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
run: |
vmshell cmake -S ./src/cmake/test -B cmake_config_build -G Ninja \
@ -53,3 +58,11 @@ jobs:
- name: Verify sdl3.pc
run: |
vmshell CC=c++ PKG_CONFIG_PATH=\$PWD/cmake_prefix/lib/pkgconfig src/cmake/test/test_pkgconfig.sh
- name: Copy package from VM
run: |
vmshell tar -cf - build/dist/ | tar -xf - -C ./
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: SDL-haiku
path: build/dist/SDL3*

View File

@ -19,15 +19,15 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows (mingw32), os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686, artifact: 'mingw32'}
- { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, artifact: 'mingw64' }
- { name: Windows (clang32), os: windows-latest, shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686, artifact: 'clang32' }
- { name: Windows (clang64), os: windows-latest, shell: 'msys2 {0}', msystem: clang64, msys-env: mingw-w64-clang-x86_64, artifact: 'clang64' }
- { name: Windows (ucrt64), os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64, msys-env: mingw-w64-ucrt-x86_64, artifact: 'ucrt64' }
- { name: Ubuntu 20.04, os: ubuntu-20.04, shell: sh, artifact: 'ubuntu20.04' }
- { name: Ubuntu 22.04, os: ubuntu-22.04, shell: sh, artifact: 'ubuntu22.04' }
- { name: MacOS (Framework), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DSDL_FRAMEWORK=ON', skip_test_pkgconfig: true, artifact: 'macos-framework' }
- { name: MacOS (GNU prefix), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64"', artifact: 'macos-gnu' }
- { name: Windows (mingw32), os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686, artifact: 'SDL-mingw32' }
- { name: Windows (mingw64), os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64, artifact: 'SDL-mingw64' }
- { name: Windows (clang32), os: windows-latest, shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686, artifact: 'SDL-msys2-clang32' }
- { name: Windows (clang64), os: windows-latest, shell: 'msys2 {0}', msystem: clang64, msys-env: mingw-w64-clang-x86_64, artifact: 'SDL-msys2-clang64' }
- { name: Windows (ucrt64), os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64, msys-env: mingw-w64-ucrt-x86_64, artifact: 'SDL-msys2-ucrt64' }
- { name: Ubuntu 20.04, os: ubuntu-20.04, shell: sh, artifact: 'SDL-ubuntu20.04' }
- { name: Ubuntu 22.04, os: ubuntu-22.04, shell: sh, artifact: 'SDL-ubuntu22.04' }
- { name: MacOS (Framework), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DSDL_FRAMEWORK=ON', skip_test_pkgconfig: true, artifact: 'SDL-macos-framework' }
- { name: MacOS (GNU prefix), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64"', artifact: 'SDL-macos-gnu' }
steps:
- name: Set up MSYS2
@ -95,6 +95,9 @@ jobs:
set -eu
cmake --install build/ --config Release
( cd cmake_prefix; find . ) | LC_ALL=C sort -u
- name: Package (CPack)
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
run: |
cmake -S cmake/test -B cmake_config_build -G Ninja \
@ -110,5 +113,6 @@ jobs:
cmake/test/test_pkgconfig.sh
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ matrix.platform.artifact }}
path: cmake_prefix/
path: build/dist/SDL3*

View File

@ -15,16 +15,16 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows (x64), flags: -A x64, project: VisualC/SDL.sln, projectflags: '/p:Platform=x64' }
- { name: Windows (x86), flags: -A Win32, project: VisualC/SDL.sln, projectflags: '/p:Platform=Win32' }
- { name: Windows static VCRT (x64), flags: -A x64 -DSDL_FORCE_STATIC_VCRT=ON }
- { name: Windows static VCRT (x86), flags: -A Win32 -DSDL_FORCE_STATIC_VCRT=ON }
- { name: Windows (clang-cl x64), flags: -T ClangCL -A x64 }
- { name: Windows (clang-cl x86), flags: -T ClangCL -A Win32 }
- { name: Windows (ARM), flags: -A ARM }
- { name: Windows (ARM64), flags: -A ARM64 }
- { name: Windows (x64), flags: -A x64, project: VisualC/SDL.sln, projectflags: '/p:Platform=x64', artifact: 'SDL-VC-x64' }
- { name: Windows (x86), flags: -A Win32, project: VisualC/SDL.sln, projectflags: '/p:Platform=Win32', artifact: 'SDL-VC-x86' }
- { name: Windows static VCRT (x64), flags: -A x64 -DSDL_FORCE_STATIC_VCRT=ON, artifact: 'SDL-VC-static-VCRT-x64' }
- { name: Windows static VCRT (x86), flags: -A Win32 -DSDL_FORCE_STATIC_VCRT=ON, artifact: 'SDL-VC-static-VCRT-x86' }
- { name: Windows (clang-cl x64), flags: -T ClangCL -A x64, artifact: 'SDL-clang-cl-x64' }
- { name: Windows (clang-cl x86), flags: -T ClangCL -A Win32, artifact: 'SDL-clang-cl-x86' }
- { name: Windows (ARM), flags: -A ARM, artifact: 'SDL-VC-arm32' }
- { name: Windows (ARM64), flags: -A ARM64, artifact: 'SDL-VC-arm64' }
- { name: UWP (x64), flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION="10.0" -DSDL_TESTS=OFF, nowerror: true,
project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0' }
project: VisualC-WinRT/SDL-UWP.sln, projectflags: '/p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.17763.0', artifact: 'SDL-VC-UWP' }
steps:
- uses: actions/checkout@v3
@ -50,6 +50,7 @@ jobs:
-DSDL_INSTALL_TESTS=ON `
-DSDL_VENDOR_INFO="Github Workflow" `
-DSDL_DISABLE_INSTALL=OFF `
-DSDL_DISABLE_INSTALL_CPACK=OFF `
${{ matrix.platform.flags }} `
-DCMAKE_INSTALL_PREFIX=prefix
- name: Build (CMake)
@ -63,6 +64,9 @@ jobs:
run: |
echo "SDL3_DIR=$Env:GITHUB_WORKSPACE/prefix" >> $Env:GITHUB_ENV
cmake --install build/
- name: Package (CPack)
run: |
cmake --build build/ --config Release --target PACKAGE
- name: Verify CMake configuration files
if: ${{ !contains(matrix.platform.name, 'UWP') }} # FIXME: cmake/test/CMakeLists.txt should support UWP
run: |
@ -77,3 +81,8 @@ jobs:
- name: Build msbuild
if: ${{ matrix.platform.project != '' }}
run: msbuild ${{ matrix.platform.project }} /m /p:BuildInParallel=true /p:Configuration=Release ${{ matrix.platform.projectflags }}
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ matrix.platform.artifact }}
path: build/dist/SDL3*

View File

@ -17,7 +17,7 @@ jobs:
run: |
apt update
apt install ninja-build
- name: Configure CMake
- name: Configure (CMake)
run: |
cmake -S . -B build -G Ninja \
-Wdeprecated -Wdev -Werror \
@ -28,13 +28,17 @@ jobs:
-DSDL_VENDOR_INFO="Github Workflow" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=prefix
- name: Build
run: cmake --build build --verbose
- name: Install CMake
- name: Build (CMake)
run: |
cmake --build build --verbose
- name: Install (CMake)
run: |
echo "SDL3_DIR=$(pwd)/prefix" >> $GITHUB_ENV
cmake --install build/
( cd prefix; find ) | LC_ALL=C sort -u
- name: Package (CPack)
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
run: |
cmake -S cmake/test -B cmake_config_build -G Ninja \
@ -54,3 +58,8 @@ jobs:
run: |
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: SDL-n3ds
path: build/dist/SDL3*

View File

@ -34,7 +34,7 @@ jobs:
-DSDL_TESTS=ON \
-DCMAKE_INSTALL_PREFIX=cmake_prefix \
-DCMAKE_BUILD_TYPE=Release
- name: Build
- name: Build (CMake)
run: cmake --build build --config Release --verbose --parallel
- name: Install (CMake)
run: |
@ -42,6 +42,9 @@ jobs:
cmake --install build/ --config Release
echo "SDL3_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
( cd cmake_prefix; find ) | LC_ALL=C sort -u
- name: Package (CPack)
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
run: |
@ -70,3 +73,8 @@ jobs:
name: tests-${{ steps.slug.outputs.sha8 }}
path: |
build/test
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: SDL-ps2
path: build/dist/SDL3*

View File

@ -16,7 +16,7 @@ jobs:
run: |
apk update
apk add cmake gmp mpc1 mpfr4 make pkgconf
- name: Configure CMake
- name: Configure (CMake)
run: |
cmake -S . -B build \
-Wdeprecated -Wdev -Werror \
@ -26,13 +26,16 @@ jobs:
-DSDL_INSTALL_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=prefix
- name: Build
- name: Build (CMake)
run: cmake --build build --config Release --verbose
- name: Install
- name: Install (CMake)
run: |
echo "SDL3_DIR=$(pwd)/prefix" >> $GITHUB_ENV
cmake --install build --config Release
( cd prefix; find ) | LC_ALL=C sort -u
- name: Package (CPack)
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
run: |
cmake -S cmake/test -B cmake_config_build \
@ -47,3 +50,8 @@ jobs:
export LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: SDL-psp
path: build/dist/SDL3*

View File

@ -44,6 +44,9 @@ jobs:
echo "SDL3_DIR=${{ github.workspace }}/prefix_cmake" >> $GITHUB_ENV
cmake --install build/
( cd ${{ github.workspace }}/prefix_cmake; find ) | LC_ALL=C sort -u
- name: Package (CPack)
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
run: |
cmake -S cmake/test -B cmake_config_build -G Ninja \
@ -52,3 +55,8 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
${{ matrix.platform.test_args }}
cmake --build cmake_config_build --verbose
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: SDL-riscos
path: build/dist/SDL3*

View File

@ -20,8 +20,8 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: GLES (pib), os: windows-latest, pib: true }
- { name: GLES (PVR_PSP2 + gl4es4vita), os: windows-latest, pvr: true }
- { name: Vita (GLES w/ pib), os: windows-latest, pib: true, artifact: SDL-vita-pib }
- { name: Vita (GLES w/ PVR_PSP2 + gles4vita), os: windows-latest, pvr: true, artifact: SDL-vita-pvr }
steps:
- uses: actions/checkout@v3
@ -65,7 +65,7 @@ jobs:
wget https://github.com/SonicMastr/gl4es4vita/releases/download/v$gl4es4vita_version-vita/vitasdk_stubs.zip -P/tmp
unzip /tmp/vitasdk_stubs.zip -d${VITASDK}/arm-vita-eabi/lib
- name: Configure CMake
- name: Configure (CMake)
run: |
cmake -S . -B build -G Ninja \
-Wdeprecated -Wdev -Werror \
@ -77,13 +77,16 @@ jobs:
-DSDL_INSTALL_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=prefix
- name: Build
- name: Build (CMake)
run: cmake --build build --verbose
- name: Install CMake
- name: Install (CMake)
run: |
echo "SDL3_DIR=$(pwd)/prefix" >> $GITHUB_ENV
cmake --install build/
( cd prefix; find ) | LC_ALL=C sort -u
- name: Package (CPack)
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
run: |
cmake -S cmake/test -B cmake_config_build -G Ninja \
@ -97,3 +100,8 @@ jobs:
export CC=arm-vita-eabi-gcc
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ matrix.platform.artifact }}
path: build/dist/SDL3*

View File

@ -50,6 +50,13 @@ jobs:
run: |
cmake -S . -B build -GNinja \
-Wdeprecated -Wdev -Werror \
-DCMAKE_BUILD_TYPE=Release \
-DSDL_CHECK_REQUIRED_INCLUDES="/usr/local/include" \
-DSDL_CHECK_REQUIRED_LINK_OPTIONS="-L/usr/local/lib"
cmake --build build --verbose -- -j`sysctl -n hw.ncpu`
cmake --build build/ --config Release --verbose -- -j`sysctl -n hw.ncpu`
cmake --build build/ --config Release --target package
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: SDL-freebsd
path: build/dist/SDL3*

View File

@ -104,6 +104,8 @@ set(SDL_DYLIB_COMPAT_VERSION "${SDL_DYLIB_COMPAT_VERSION_MAJOR}.${SDL_DYLIB_COMP
#message("SDL_SO_VERSION=${SDL_SO_VERSION} SDL_DYLIB_CURRENT_VERSION=${SDL_DYLIB_CURRENT_VERSION} SDL_DYLIB_COMPAT_VERSION=${SDL_DYLIB_COMPAT_VERSION}")
set(SDL_FRAMEWORK_VERSION "A")
SDL_DetectCPUArchitecture()
# Check for 64 or 32 bit
@ -357,6 +359,7 @@ endforeach()
# Allow some projects to be built conditionally.
set_option(SDL_DISABLE_INSTALL "Disable installation of SDL3" ${SDL3_SUBPROJECT})
cmake_dependent_option(SDL_DISABLE_INSTALL_CPACK "Create binary SDL3 archive using CPack" ${SDL3_SUBPROJECT} "NOT SDL_DISABLE_INSTALL" OFF)
set_option(SDL_DISABLE_UNINSTALL "Disable uninstallation of SDL3" OFF)
option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
@ -3149,7 +3152,7 @@ if(SDL_SHARED)
if(SDL_FRAMEWORK)
set_target_properties(SDL3 PROPERTIES
PUBLIC_HEADER "${SDL3_INCLUDE_FILES}"
FRAMEWORK_VERSION "A"
FRAMEWORK_VERSION "${SDL_FRAMEWORK_VERSION}"
MACOSX_FRAMEWORK_IDENTIFIER "org.libsdl.SDL3"
RESOURCE "${SDL_FRAMEWORK_RESOURCES}"
)
@ -3217,7 +3220,7 @@ if(SDL_STATIC)
)
if(SDL_FRAMEWORK)
set_target_properties(SDL3-static PROPERTIES
FRAMEWORK_VERSION "A"
FRAMEWORK_VERSION "${SDL_FRAMEWORK_VERSION}"
MACOSX_FRAMEWORK_IDENTIFIER "org.libsdl.SDL3-static"
RESOURCE "${SDL_FRAMEWORK_RESOURCES}"
)
@ -3263,7 +3266,7 @@ if(SDL_TEST)
)
if(SDL_FRAMEWORK)
set_target_properties(SDL3_test PROPERTIES
FRAMEWORK_VERSION "A"
FRAMEWORK_VERSION "${SDL_FRAMEWORK_VERSION}"
MACOSX_FRAMEWORK_IDENTIFIER "org.libsdl.SDL3_test"
RESOURCE "${SDL_FRAMEWORK_RESOURCES}"
)
@ -3297,50 +3300,46 @@ if(NOT SDL_DISABLE_INSTALL)
if(WINDOWS AND NOT MINGW)
set(SDL_INSTALL_CMAKEDIR "${SDL_INSTALL_CMAKEDIR_ROOT}")
set(LICENSES_PREFIX "licenses/SDL3")
set(RESOURCES_PREFIX ".")
set(PUBLIC_HEADER_PREFIX "${CMAKE_INSTALL_INCLUDEDIR}/SDL3")
set(SDL_INSTALL_LICENSEDIR "licenses/SDL3")
set(SDL_INSTALL_HEADERSDIR "${CMAKE_INSTALL_INCLUDEDIR}/SDL3")
elseif(SDL_FRAMEWORK)
set(SDL_INSTALL_CMAKEDIR "SDL3.framework/Resources/CMake")
set(LICENSES_PREFIX "Resources")
set(RESOURCES_PREFIX "Resources")
set(PUBLIC_HEADER_PREFIX "Headers")
set(SDL_INSTALL_CMAKEDIR "SDL3.framework/Versions/${SDL_FRAMEWORK_VERSION}/Resources/CMake")
set(SDL_INSTALL_LICENSEDIR "Resources")
set(SDL_INSTALL_HEADERSDIR "Headers")
else()
set(SDL_INSTALL_CMAKEDIR "${SDL_INSTALL_CMAKEDIR_ROOT}/SDL3")
set(LICENSES_PREFIX "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME}")
set(RESOURCES_PREFIX ".")
set(PUBLIC_HEADER_PREFIX "${CMAKE_INSTALL_INCLUDEDIR}/SDL3")
set(SDL_INSTALL_LICENSEDIR "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME}")
set(SDL_INSTALL_HEADERSDIR "${CMAKE_INSTALL_INCLUDEDIR}/SDL3")
endif()
##### Installation targets #####
if(SDL_FRAMEWORK)
set(SDL_SDL_INSTALL_RESOURCEDIR "SDL3.framework/Resources")
set(SDL_SDL_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_RESOURCEDIR}/CMake")
set(SDL_SDL_INSTALL_REAL_RESOURCEDIR "SDL3.framework/Versions/${SDL_FRAMEWORK_VERSION}/Resources")
set(SDL_SDL_INSTALL_REAL_CMAKEDIR "${SDL_SDL_INSTALL_REAL_RESOURCEDIR}/CMake")
install(TARGETS SDL3_Headers EXPORT SDL3headersTargets)
# - Install other SDL3*Config.cmake files in SDL3*.framework/Resources/CMake
# - The *_RELATIVE_CMAKEDIR variables are the symlinked folders visible from outside
set(SDL_SDLstatic_INSTALL_RESOURCEDIR "SDL3-static.framework/Resources")
set(SDL_SDLstatic_INSTALL_CMAKEDIR "${SDL_SDLstatic_INSTALL_RESOURCEDIR}/CMake")
set(SDL_SDLstatic_INSTALL_CMAKEFILENAME "SDL3-staticConfig.cmake")
if(SDL_SHARED)
install(TARGETS SDL3 EXPORT SDL3Targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
FRAMEWORK DESTINATION "."
PUBLIC_HEADER DESTINATION "${PUBLIC_HEADER_PREFIX}"
RESOURCE DESTINATION "${RESOURCES_PREFIX}"
)
endif()
set(SDL_SDLtest_INSTALL_RESOURCEDIR "SDL3_test.framework/Resources")
set(SDL_SDLtest_INSTALL_CMAKEDIR "${SDL_SDLtest_INSTALL_RESOURCEDIR}/CMake")
set(SDL_SDLtest_INSTALL_CMAKEFILENAME "SDL3_testConfig.cmake")
else()
set(SDL_SDL_INSTALL_RESOURCEDIR ".")
set(SDL_SDL_INSTALL_CMAKEDIR ${SDL_INSTALL_CMAKEDIR})
set(SDL_SDL_INSTALL_REAL_CMAKEDIR ${SDL_INSTALL_CMAKEDIR})
if(SDL_STATIC)
install(TARGETS SDL3-static EXPORT SDL3staticTargets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
FRAMEWORK DESTINATION "."
RESOURCE DESTINATION "${RESOURCES_PREFIX}"
)
endif()
# Install SDL3*Targets.cmake files in lib/cmake/SDL3
set(SDL_SDLstatic_INSTALL_RESOURCEDIR ".")
set(SDL_SDLstatic_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_CMAKEDIR}")
set(SDL_SDLstatic_INSTALL_CMAKEFILENAME "SDL3staticTargets.cmake")
if(SDL_TEST)
install(TARGETS SDL3_test EXPORT SDL3testTargets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
FRAMEWORK DESTINATION "."
RESOURCE DESTINATION "${RESOURCES_PREFIX}"
)
set(SDL_SDLtest_INSTALL_RESOURCEDIR ".")
set(SDL_SDLtest_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_CMAKEDIR}")
set(SDL_SDLtest_INSTALL_CMAKEFILENAME "SDL3_testTargets.cmake")
endif()
##### sdl3.pc #####
@ -3382,37 +3381,48 @@ if(NOT SDL_DISABLE_INSTALL)
install(FILES ${SDL3_BINARY_DIR}/sdl3.pc DESTINATION "${SDL_PKGCONFIG_INSTALLDIR}")
endif()
##### Installation targets #####()
install(TARGETS SDL3_Headers EXPORT SDL3headersTargets)
if(SDL_SHARED)
install(TARGETS SDL3 EXPORT SDL3Targets
PUBLIC_HEADER DESTINATION "${SDL_INSTALL_HEADERSDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
FRAMEWORK DESTINATION "."
RESOURCE DESTINATION "${SDL_SDL_INSTALL_RESOURCEDIR}"
)
endif()
if(SDL_STATIC)
install(TARGETS SDL3-static EXPORT SDL3staticTargets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
FRAMEWORK DESTINATION "."
RESOURCE DESTINATION "${SDL_SDLstatic_INSTALL_RESOURCEDIR}"
)
endif()
if(SDL_TEST)
install(TARGETS SDL3_test EXPORT SDL3testTargets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
FRAMEWORK DESTINATION "."
RESOURCE DESTINATION "${SDL_SDLtest_INSTALL_RESOURCEDIR}"
)
endif()
##### CMake Export files #####
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/SDL3Config.cmake.in SDL3Config.cmake
PATH_VARS CMAKE_INSTALL_PREFIX
INSTALL_DESTINATION "${SDL_INSTALL_CMAKEDIR}"
INSTALL_DESTINATION "${SDL_SDL_INSTALL_CMAKEDIR}"
)
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/SDL3ConfigVersion.cmake"
COMPATIBILITY AnyNewerVersion
)
if(SDL_FRAMEWORK)
set(SDL_SDL_INSTALL_CMAKEDIR "SDL3.framework/Resources/CMake")
# Install SDL3*Config.cmake files in SDL3*.framework/Resources/CMake
set(SDL_SDLstatic_INSTALL_CMAKEDIR "SDL3-static.framework/Resources/CMake")
set(SDL_SDLstatic_INSTALL_CMAKEFILE "SDL3-staticConfig.cmake")
set(SDL_SDLtest_INSTALL_CMAKEDIR "SDL3_test.framework/Resources/CMake")
set(SDL_SDLtest_INSTALL_CMAKEFILE "SDL3_testConfig.cmake")
else()
set(SDL_SDL_INSTALL_CMAKEDIR ${SDL_INSTALL_CMAKEDIR})
# Install SDL3*Targets.cmake files in lib/cmake/SDL3
set(SDL_SDLstatic_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_CMAKEDIR}")
set(SDL_SDLstatic_INSTALL_CMAKEFILE "SDL3staticTargets.cmake")
set(SDL_SDLtest_INSTALL_CMAKEDIR "${SDL_SDL_INSTALL_CMAKEDIR}")
set(SDL_SDLtest_INSTALL_CMAKEFILE "SDL3_testTargets.cmake")
endif()
install(EXPORT SDL3headersTargets
FILE "SDL3headersTargets.cmake"
NAMESPACE SDL3::
@ -3429,7 +3439,7 @@ if(NOT SDL_DISABLE_INSTALL)
if(SDL_STATIC)
install(EXPORT SDL3staticTargets
FILE "${SDL_SDLstatic_INSTALL_CMAKEFILE}"
FILE "${SDL_SDLstatic_INSTALL_CMAKEFILENAME}"
NAMESPACE SDL3::
DESTINATION "${SDL_SDLstatic_INSTALL_CMAKEDIR}"
)
@ -3437,35 +3447,46 @@ if(NOT SDL_DISABLE_INSTALL)
if(SDL_TEST)
install(EXPORT SDL3testTargets
FILE "${SDL_SDLtest_INSTALL_CMAKEFILE}"
FILE "${SDL_SDLtest_INSTALL_CMAKEFILENAME}"
NAMESPACE SDL3::
DESTINATION "${SDL_SDLtest_INSTALL_CMAKEDIR}"
)
endif()
install(
FILES
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/SDL3Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/SDL3ConfigVersion.cmake
${SDL3_SOURCE_DIR}/cmake/sdlfind.cmake
DESTINATION "${SDL_SDL_INSTALL_CMAKEDIR}"
COMPONENT Devel
DESTINATION "${SDL_SDL_INSTALL_REAL_CMAKEDIR}"
)
if(NOT SDL_FRAMEWORK)
install(
FILES
${SDL3_INCLUDE_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL3
install(FILES ${SDL3_INCLUDE_FILES}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SDL3"
)
if(SDL_TEST)
install(
FILES ${SDL3_TEST_INCLUDE_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL3
install(FILES ${SDL3_TEST_INCLUDE_FILES}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SDL3"
)
endif()
install(FILES "LICENSE.txt" DESTINATION "${LICENSES_PREFIX}")
install(FILES "LICENSE.txt" DESTINATION "${SDL_INSTALL_LICENSEDIR}")
endif()
if(NOT SDL_DISABLE_INSTALL_CPACK)
if(SDL_FRAMEWORK)
set(CPACK_GENERATOR "DragNDrop")
elseif(MSVC)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "TGZ")
endif()
configure_file(cmake/CPackProjectConfig.cmake.in CPackProjectConfig.cmake @ONLY)
set(CPACK_PROJECT_CONFIG_FILE "${SDL3_BINARY_DIR}/CPackProjectConfig.cmake")
# CPACK_SOURCE_PACKAGE_FILE_NAME must end with "-src" (so we can block creating a source archive)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "SDL${PROJECT_VERSION_MAJOR}-${PROJECT_VERSION}-src")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/dist")
include(CPack)
endif()
endif()

View File

@ -0,0 +1,36 @@
if(CPACK_PACKAGE_FILE_NAME MATCHES ".*-src$")
message(FATAL_ERROR "Creating source archives for SDL @PROJECT_VERSION@ is not supported.")
endif()
set(PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@")
set(SDL_CMAKE_PLATFORM "@SDL_CMAKE_PLATFORM@")
set(SDL_CPU_NAMES "@SDL_CPU_NAMES@")
list(SORT SDL_CPU_NAMES)
string(REPLACE ";" "-" SDL_CPU_NAMES_WITH_DASHES "${SDL_CPU_NAMES}")
if(SDL_CPU_NAMES_WITH_DASHES)
set(SDL_CPU_NAMES_WITH_DASHES "-${SDL_CPU_NAMES_WITH_DASHES}")
endif()
string(TOLOWER "${SDL_CMAKE_PLATFORM}" lower_sdl_cmake_platform)
string(TOLOWER "${SDL_CPU_NAMES}" lower_sdl_cpu_names)
if(lower_sdl_cmake_platform STREQUAL lower_sdl_cpu_names)
set(SDL_CPU_NAMES_WITH_DASHES)
endif()
set(MSVC @MSVC@)
set(MINGW @MINGW@)
if(MSVC)
set(SDL_CMAKE_PLATFORM "${SDL_CMAKE_PLATFORM}-VC")
elseif(MINGW)
set(SDL_CMAKE_PLATFORM "${SDL_CMAKE_PLATFORM}-mingw")
endif()
set(CPACK_PACKAGE_FILE_NAME "SDL@PROJECT_VERSION_MAJOR@-@PROJECT_VERSION@-${SDL_CMAKE_PLATFORM}${SDL_CPU_NAMES_WITH_DASHES}")
if(CPACK_GENERATOR STREQUAL "DragNDrop")
set(CPACK_DMG_VOLUME_NAME "SDL@PROJECT_VERSION_MAJOR@ @PROJECT_VERSION@")
# FIXME: use pre-built/create .DS_Store through AppleScript (CPACK_DMG_DS_STORE/CPACK_DMG_DS_STORE_SETUP_SCRIPT)
set(CPACK_DMG_DS_STORE "${PROJECT_SOURCE_DIR}/Xcode/SDL/pkg-support/resources/SDL_DS_Store")
endif()

View File

@ -2,75 +2,104 @@ macro(SDL_DetectCMakePlatform)
set(SDL_CMAKE_PLATFORM )
# Get the platform
if(WIN32)
set(SDL_CMAKE_PLATFORM WINDOWS)
elseif(UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(SDL_CMAKE_PLATFORM LINUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
set(SDL_CMAKE_PLATFORM FREEBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
set(SDL_CMAKE_PLATFORM NETBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(SDL_CMAKE_PLATFORM OPENBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
set(SDL_CMAKE_PLATFORM GNU)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(SDL_CMAKE_PLATFORM BSDI)
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(SDL_CMAKE_PLATFORM FREEBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
set(SDL_CMAKE_PLATFORM SYSV5)
elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*")
set(SDL_CMAKE_PLATFORM SOLARIS)
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
set(SDL_CMAKE_PLATFORM HPUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
set(SDL_CMAKE_PLATFORM AIX)
elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
set(SDL_CMAKE_PLATFORM MINIX)
endif()
set(SDL_CMAKE_PLATFORM Windows)
elseif(PSP)
set(SDL_CMAKE_PLATFORM psp)
elseif(APPLE)
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
set(SDL_CMAKE_PLATFORM DARWIN)
set(SDL_CMAKE_PLATFORM Darwin)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
set(SDL_CMAKE_PLATFORM MACOSX)
set(SDL_CMAKE_PLATFORM MacosX)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
set(SDL_CMAKE_PLATFORM TVOS)
set(SDL_CMAKE_PLATFORM tvOS)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*")
# !!! FIXME: remove the version check when we start requiring >= 3.14.0
if(CMAKE_VERSION VERSION_LESS 3.14)
set(SDL_CMAKE_PLATFORM IOS)
set(SDL_CMAKE_PLATFORM iOS)
endif()
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
set(SDL_CMAKE_PLATFORM Haiku)
elseif(NINTENDO_3DS)
set(SDL_CMAKE_PLATFORM n3ds)
elseif(PS2)
set(SDL_CMAKE_PLATFORM ps2)
elseif(VITA)
set(SDL_CMAKE_PLATFORM Vita)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
set(SDL_CMAKE_PLATFORM Linux)
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
set(SDL_CMAKE_PLATFORM FreeBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
set(SDL_CMAKE_PLATFORM NetBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
set(SDL_CMAKE_PLATFORM OpenBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
set(SDL_CMAKE_PLATFORM GNU)
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(SDL_CMAKE_PLATFORM BSDi)
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(SDL_CMAKE_PLATFORM FreeBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
set(SDL_CMAKE_PLATFORM SYSV5)
elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*")
set(SDL_CMAKE_PLATFORM Solaris)
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
set(SDL_CMAKE_PLATFORM HPUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
set(SDL_CMAKE_PLATFORM AIX)
elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
set(SDL_CMAKE_PLATFORM Minix)
elseif(CMAKE_SYSTEM_NAME MATCHES "Android.*")
set(SDL_CMAKE_PLATFORM Android)
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
message_error("BeOS support has been removed as of SDL 2.0.2.")
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
set(SDL_CMAKE_PLATFORM HAIKU)
elseif(NINTENDO_3DS)
set(SDL_CMAKE_PLATFORM N3DS)
endif()
if(SDL_CMAKE_PLATFORM)
set(${SDL_CMAKE_PLATFORM} TRUE)
string(TOUPPER "${SDL_CMAKE_PLATFORM}" _upper_platform)
set(${_upper_platform} TRUE)
else()
set(SDL_CMAKE_PLATFORM} "unknown")
endif()
endmacro()
function(SDL_DetectCPUArchitecture)
set(archs x86 x64 arm32 arm64 loongarch64)
set(found FALSE)
foreach(arch ${archs})
string(TOUPPER "${arch}" arch_upper)
set(var_name "SDL_CPU_${arch_upper}")
if(found)
set(${var_name} 0 PARENT_SCOPE)
set(sdl_cpu_names)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
if(osx_arch STREQUAL "x86_64")
list(APPEND sdl_cpu_names "x64")
elseif(osx_arch STREQUAL "arm64")
list(APPEND sdl_cpu_names "arm64")
endif()
endforeach()
endif()
set(sdl_known_archs x86 x64 arm32 arm64 loongarch64)
if(NOT sdl_cpu_names)
set(found FALSE)
foreach(sdl_known_arch ${sdl_known_archs})
if(NOT found)
string(TOUPPER "${sdl_known_arch}" sdl_known_arch_upper)
set(var_name "SDL_CPU_${sdl_known_arch_upper}")
check_cpu_architecture(${sdl_known_arch} ${var_name})
if(${var_name})
list(APPEND sdl_cpu_names ${sdl_known_arch})
set(found TRUE)
endif()
endif()
endforeach()
endif()
foreach(sdl_known_arch ${sdl_known_archs})
string(TOUPPER "${sdl_known_arch}" sdl_known_arch_upper)
set(var_name "SDL_CPU_${sdl_known_arch_upper}")
if(sdl_cpu_names MATCHES "(^|;)${sdl_known_arch}($|;)") # FIXME: use if(IN_LIST)
set(${var_name} 1 PARENT_SCOPE)
else()
check_cpu_architecture(${arch} ${var_name})
set(found ${${var_name}})
set(${var_name} ${${var_name}} PARENT_SCOPE)
set(SDL_CPU_NAME ${arch})
set(${var_name} 0 PARENT_SCOPE)
endif()
endforeach()
if(NOT found)
message(AUTHOR_WARNING "Unknown architecture (failed archs=${archs})")
set(SDL_CPU_NAME "(unknown)")
endif()
set(SDL_CPU_NAMES ${sdl_cpu_names} PARENT_SCOPE)
endfunction()