Convert all CMake subprojects' object libraries into static libraries

CMake object libraries keep building with position-independent code
enabled even when it's explicitly disabled! We do, in fact, have to
build with position-independent code disabled on some targets, such as
PlayStation Vita, since some targets support position-independent code.

CMake static libraries don't seem to forcibly enable
position-independent code, so I've converted all the object libraries
into static libraries and added the new static libraries as dependencies
in Meson.
This commit is contained in:
刘皓 2025-03-06 22:55:26 -05:00
parent 24a4ae5759
commit 516c706a66
No known key found for this signature in database
GPG key ID: 7901753DB465B711
3 changed files with 17 additions and 3 deletions

View file

@ -461,6 +461,7 @@ if is_libretro
cmake.subproject('libzip', options: libzip_options).dependency('zip'),
cmake.subproject('physfs', options: physfs_options).dependency('physfs-static'),
cmake.subproject('openal-soft', options: openal_options).dependency('OpenAL'),
cmake.subproject('openal-soft', options: openal_options).dependency('alsoft.fmt'),
cmake.subproject('fluidlite', options: fluidlite_options).dependency('fluidlite-static'),
cmake.subproject('ogg', options: ogg_options).dependency('ogg'),
cmake.subproject('vorbis', options: vorbis_options).dependency('vorbis'),
@ -468,6 +469,7 @@ if is_libretro
cmake.subproject('flac', options: flac_options).dependency('FLAC'),
cmake.subproject('opus', options: opus_options).dependency('opus'),
cmake.subproject('mpg123', options: mpg123_options).dependency('libmpg123'),
cmake.subproject('mpg123', options: mpg123_options).dependency('compat'),
cmake.subproject('libsndfile', options: libsndfile_options).dependency('sndfile'),
declare_dependency(
link_with: static_library(

View file

@ -3,13 +3,16 @@
--- a/ports/cmake/src/compat/CMakeLists.txt
+++ b/ports/cmake/src/compat/CMakeLists.txt
@@ -2,12 +2,6 @@ set(TARGET compat)
add_library(${TARGET} OBJECT
@@ -1,13 +1,7 @@
set(TARGET compat)
-add_library(${TARGET} OBJECT
+add_library(${TARGET} STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat.c"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_str.c")
-set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(${TARGET}_dl OBJECT
-add_library(${TARGET}_dl OBJECT
+add_library(${TARGET}_dl STATIC
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/compat/compat_dl.c")
-set_target_properties(${TARGET}_dl PROPERTIES POSITION_INDEPENDENT_CODE ON)
-

View file

@ -13,6 +13,15 @@
unset(HAS_ROUTER)
--- a/fmt-11.1.1/CMakeLists.txt
+++ b/fmt-11.1.1/CMakeLists.txt
@@ -58,7 +58,7 @@ add_headers(FMT_HEADERS args.h base.h chrono.h color.h compile.h core.h format.h
xchar.h)
set(FMT_SOURCES src/format.cc src/os.cc)
-add_library(alsoft.fmt OBJECT ${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md)
+add_library(alsoft.fmt STATIC ${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md)
add_library(alsoft::fmt ALIAS alsoft.fmt)
if (cxx_std_11 IN_LIST CMAKE_CXX_COMPILE_FEATURES)
@@ -73,7 +73,7 @@ target_include_directories(alsoft.fmt PUBLIC
set_target_properties(alsoft.fmt PROPERTIES ${ALSOFT_STD_VERSION_PROPS}
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}