From d47cef9bbd7e7ab0edbe00eb82905cde15ba7d41 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 17 Jul 2023 22:45:18 +0200
Subject: [PATCH] cmake: move examples in subfoler + relocatable sdl3-mixer.pc
---
.github/workflows/main.yml | 10 ++++-----
Android.mk | 2 +-
CMakeLists.txt | 21 +++++++++----------
VisualC/playmus/playmus.vcxproj | 2 +-
VisualC/playwave/playwave.vcxproj | 2 +-
.../test-versioning.sh | 4 +++-
cmake/sdl3-mixer.pc.in | 2 +-
playmus.c => examples/playmus.c | 0
playwave.c => examples/playwave.c | 0
SDL_mixer.sym => src/SDL_mixer.sym | 0
version.rc => src/version.rc | 0
11 files changed, 22 insertions(+), 21 deletions(-)
rename test-versioning.sh => build-scripts/test-versioning.sh (98%)
rename playmus.c => examples/playmus.c (100%)
rename playwave.c => examples/playwave.c (100%)
rename SDL_mixer.sym => src/SDL_mixer.sym (100%)
rename version.rc => src/version.rc (100%)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 1a527a29..0261f8e0 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -46,7 +46,7 @@ jobs:
${{ matrix.platform.msys-env }}-wavpack
${{ matrix.platform.msys-env }}-ninja
${{ matrix.platform.msys-env }}-pkg-config
- - name: Setup Ninja
+ - name: Set up Ninja
if: ${{ !contains(matrix.platform.shell, 'msys2') }}
uses: ashutoshvarma/setup-ninja@master
with:
@@ -59,7 +59,7 @@ jobs:
version: 3-head
sdl-test: true
shell: ${{ matrix.platform.shell }}
- - name: Setup Macos dependencies
+ - name: Set up Macos dependencies
if: runner.os == 'macOS'
run: |
brew install \
@@ -75,7 +75,7 @@ jobs:
opusfile \
wavpack \
${NULL+}
- - name: Setup Linux dependencies
+ - name: Set up Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
@@ -99,7 +99,7 @@ jobs:
- name: Check that versioning is consistent
# We only need to run this once: arbitrarily use the Linux build
if: "runner.os == 'Linux'"
- run: ./test-versioning.sh
+ run: ./build-scripts/test-versioning.sh
- name: Setup (CMake)
if: ${{ !matrix.platform.msystem && !matrix.platform.msvc }}
@@ -115,7 +115,7 @@ jobs:
-DSDL3MIXER_FLAC_LIBFLAC=ON \
-DSDL3MIXER_GME=ON \
-DSDL3MIXER_MOD_XMP=ON \
- -DSDL3MIXER_MP3_MPG133=ON \
+ -DSDL3MIXER_MP3_MPG123=ON \
-DSDL3MIXER_OPUS=ON \
-DSDL3MIXER_VORBIS=VORBISFILE \
-DSDL3MIXER_WERROR=ON \
diff --git a/Android.mk b/Android.mk
index 133a5481..7265d4ab 100644
--- a/Android.mk
+++ b/Android.mk
@@ -83,7 +83,7 @@ LOCAL_SRC_FILES := \
LOCAL_CFLAGS :=
LOCAL_LDLIBS :=
-LOCAL_LDFLAGS := -Wl,--no-undefined -Wl,--version-script=$(LOCAL_PATH)/SDL_mixer.sym
+LOCAL_LDFLAGS := -Wl,--no-undefined -Wl,--version-script=$(LOCAL_PATH)/src/SDL_mixer.sym
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES := SDL3
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cc1bb837..cbc21f44 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -268,7 +268,7 @@ endif()
sdl_add_warning_options(${sdl3_mixer_target_name} WARNING_AS_ERROR ${SDL3MIXER_WERROR})
if(WIN32 AND BUILD_SHARED_LIBS)
target_sources(${sdl3_mixer_target_name} PRIVATE
- version.rc
+ src/version.rc
)
endif()
set_target_properties(${sdl3_mixer_target_name} PROPERTIES
@@ -316,7 +316,7 @@ if(SDL3MIXER_BUILD_SHARED_LIBS)
sdl_target_link_options_no_undefined(${sdl3_mixer_target_name})
endif()
-sdl_target_link_option_version_file(${sdl3_mixer_target_name} "${CMAKE_CURRENT_SOURCE_DIR}/SDL_mixer.sym")
+sdl_target_link_option_version_file(${sdl3_mixer_target_name} "${CMAKE_CURRENT_SOURCE_DIR}/src/SDL_mixer.sym")
if(SDL3MIXER_BUILD_SHARED_LIBS)
# Make sure static library dependencies are built with -fPIC when building a shared SDL3_mixer
@@ -925,6 +925,7 @@ if(SDL3MIXER_INSTALL)
set(SDL3MIXER_INSTALL_CMAKEDIR_ROOT_DEFAULT "${CMAKE_INSTALL_LIBDIR}/cmake")
endif()
set(SDL3MIXER_INSTALL_CMAKEDIR_ROOT "${SDL3MIXER_INSTALL_CMAKEDIR_ROOT_DEFAULT}" CACHE STRING "Root folder where to install SDL3Config.cmake related files (SDL3 subfolder for non-MSVC projects)")
+ set(SDLMIXER_PKGCONFIG_INSTALLDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
if(WIN32 AND NOT MINGW)
set(SDL3MIXER_INSTALL_CMAKEDIR "${SDL3MIXER_INSTALL_CMAKEDIR_ROOT}")
@@ -967,19 +968,17 @@ if(SDL3MIXER_INSTALL)
COMPONENT devel
)
+ file(RELATIVE_PATH SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${CMAKE_INSTALL_PREFIX}/${SDLMIXER_PKGCONFIG_INSTALLDIR}" "${CMAKE_INSTALL_PREFIX}")
+ string(REGEX REPLACE "[/]+$" "" SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}")
+ set(SDL_PKGCONFIG_PREFIX "\${pcfiledir}/${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}")
+
string(JOIN " " PC_REQUIRES ${PC_REQUIRES})
string(JOIN " " PC_LIBS ${PC_LIBS})
configure_file(cmake/sdl3-mixer.pc.in sdl3-mixer.pc @ONLY)
- if(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
- # FreeBSD uses ${PREFIX}/libdata/pkgconfig
- set(PC_DESTDIR "libdata/pkgconfig")
- else()
- set(PC_DESTDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
- endif()
# Always install sdl3-mixer.pc file: libraries might be different between config modes
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sdl3-mixer.pc"
- DESTINATION "${PC_DESTDIR}" COMPONENT devel)
+ DESTINATION "${SDLMIXER_PKGCONFIG_INSTALLDIR}" COMPONENT devel)
install(FILES "LICENSE.txt"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME}"
@@ -998,8 +997,8 @@ if(SDL3MIXER_SAMPLES)
check_include_file("signal.h" HAVE_SIGNAL_H)
check_symbol_exists("setbuf" "stdio.h" HAVE_SETBUF)
- add_executable(playmus playmus.c)
- add_executable(playwave playwave.c)
+ add_executable(playmus examples/playmus.c)
+ add_executable(playwave examples/playwave.c)
foreach(prog playmus playwave)
sdl_add_warning_options(${prog} WARNING_AS_ERROR ${SDL3MIXER_WERROR})
diff --git a/VisualC/playmus/playmus.vcxproj b/VisualC/playmus/playmus.vcxproj
index e55dac94..47e30552 100644
--- a/VisualC/playmus/playmus.vcxproj
+++ b/VisualC/playmus/playmus.vcxproj
@@ -212,7 +212,7 @@
<Bscmake />
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\..\playmus.c">
+ <ClCompile Include="..\..\examples\playmus.c">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
diff --git a/VisualC/playwave/playwave.vcxproj b/VisualC/playwave/playwave.vcxproj
index 1256f87a..eee1c7ba 100644
--- a/VisualC/playwave/playwave.vcxproj
+++ b/VisualC/playwave/playwave.vcxproj
@@ -210,7 +210,7 @@
<Bscmake />
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\..\playwave.c">
+ <ClCompile Include="..\..\examples\playwave.c">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
diff --git a/test-versioning.sh b/build-scripts/test-versioning.sh
similarity index 98%
rename from test-versioning.sh
rename to build-scripts/test-versioning.sh
index f5f5caf8..952ed7f6 100755
--- a/test-versioning.sh
+++ b/build-scripts/test-versioning.sh
@@ -4,6 +4,8 @@
set -eu
+cd `dirname $0`/..
+
# Needed so sed doesn't report illegal byte sequences on macOS
export LC_CTYPE=C
@@ -39,7 +41,7 @@ else
not_ok "CMakeLists.txt $version disagrees with SDL_mixer.h $ref_version"
fi
-for rcfile in version.rc VisualC/Version.rc; do
+for rcfile in src/version.rc VisualC/Version.rc; do
tuple=$(sed -ne 's/^ *FILEVERSION *//p' "$rcfile" | tr -d '\r')
ref_tuple="${ref_major},${ref_minor},${ref_micro},0"
diff --git a/cmake/sdl3-mixer.pc.in b/cmake/sdl3-mixer.pc.in
index 99fc8541..7ed18e87 100644
--- a/cmake/sdl3-mixer.pc.in
+++ b/cmake/sdl3-mixer.pc.in
@@ -1,4 +1,4 @@
-prefix=@CMAKE_INSTALL_PREFIX@
+prefix=@SDL_PKGCONFIG_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
diff --git a/playmus.c b/examples/playmus.c
similarity index 100%
rename from playmus.c
rename to examples/playmus.c
diff --git a/playwave.c b/examples/playwave.c
similarity index 100%
rename from playwave.c
rename to examples/playwave.c
diff --git a/SDL_mixer.sym b/src/SDL_mixer.sym
similarity index 100%
rename from SDL_mixer.sym
rename to src/SDL_mixer.sym
diff --git a/version.rc b/src/version.rc
similarity index 100%
rename from version.rc
rename to src/version.rc