Remove SDL3_main from build systems, remove most of src/main/*

XCode is still missing, and src/main/winrt/SDL3-WinRTResource*
still need to find a new home
This commit is contained in:
Daniel Gibson 2022-12-12 23:27:42 +01:00 committed by Sam Lantinga
parent 63d3fb469d
commit c3bf253b09
19 changed files with 12 additions and 308 deletions

View File

@ -109,21 +109,4 @@ LOCAL_EXPORT_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid
include $(BUILD_STATIC_LIBRARY)
###########################
#
# SDL main static library
#
###########################
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_MODULE := SDL3_main
LOCAL_MODULE_FILENAME := libSDL3_main
include $(BUILD_STATIC_LIBRARY)
$(call import-module,android/cpufeatures)

View File

@ -382,7 +382,6 @@ foreach(_SUB ${SDL_SUBSYSTEMS})
endforeach()
# Allow some projects to be built conditionally.
set_option(SDL3_DISABLE_SDL3MAIN "Disable building/installation of SDL3_main" OFF)
set_option(SDL3_DISABLE_INSTALL "Disable installation of SDL3" ${SDL3_SUBPROJECT})
set_option(SDL3_DISABLE_UNINSTALL "Disable uninstallation of SDL3" OFF)
@ -1218,9 +1217,6 @@ if(ANDROID)
endif()
cmake_pop_check_state()
file(GLOB ANDROID_MAIN_SOURCES ${SDL3_SOURCE_DIR}/src/main/android/*.c)
list(APPEND SDLMAIN_SOURCES ${ANDROID_MAIN_SOURCES})
if(SDL_AUDIO)
set(SDL_AUDIO_DRIVER_ANDROID 1)
file(GLOB ANDROID_AUDIO_SOURCES ${SDL3_SOURCE_DIR}/src/audio/android/*.c)
@ -1990,12 +1986,7 @@ elseif(WINDOWS)
endif()
file(GLOB VERSION_SOURCES ${SDL3_SOURCE_DIR}/src/core/windows/*.rc)
file(GLOB SDLMAIN_SOURCES ${SDL3_SOURCE_DIR}/src/main/windows/*.c)
if(MINGW OR CYGWIN)
if(NOT SDL3_DISABLE_SDL3MAIN)
list(APPEND SDL_CFLAGS "-Dmain=SDL_main")
list(INSERT SDL_LIBS 0 "-lSDL3_main")
endif(NOT SDL3_DISABLE_SDL3MAIN)
list(INSERT SDL_LIBS 0 "-lmingw32" "-mwindows")
endif()
@ -2020,10 +2011,6 @@ elseif(APPLE)
set(HAVE_SDL_FILE TRUE)
endif()
if(IOS OR TVOS)
file(GLOB SDLMAIN_SOURCES ${SDL3_SOURCE_DIR}/src/main/uikit/*.c)
endif()
if(SDL_MISC)
if(IOS OR TVOS)
file(GLOB MISC_SOURCES ${SDL3_SOURCE_DIR}/src/misc/ios/*.m)
@ -2569,9 +2556,6 @@ elseif(VITA)
# CheckPTHREAD()
elseif(PSP)
file(GLOB PSP_MAIN_SOURCES ${SDL3_SOURCE_DIR}/src/main/psp/*.c)
list(APPEND SDLMAIN_SOURCES ${PSP_MAIN_SOURCES})
file(GLOB PSP_CORE_SOURCES ${SDL3_SOURCE_DIR}/src/core/psp/*.c)
list(APPEND SOURCE_FILES ${PSP_CORE_SOURCES})
@ -2632,16 +2616,10 @@ elseif(PSP)
pspctrl
psppower
)
if(NOT SDL3_DISABLE_SDL3MAIN)
list(INSERT SDL_LIBS 0 "-lSDL3_main")
endif(NOT SDL3_DISABLE_SDL3MAIN)
elseif(PS2)
list(APPEND EXTRA_CFLAGS "-DPS2" "-D__PS2__" "-I$ENV{PS2SDK}/ports/include" "-I$ENV{PS2DEV}/gsKit/include")
file(GLOB PS2_MAIN_SOURCES ${SDL3_SOURCE_DIR}/src/main/ps2/*.c)
set(SDLMAIN_SOURCES ${SDLMAIN_SOURCES} ${PS2_MAIN_SOURCES})
file(GLOB PS2_CORE_SOURCES ${SDL3_SOURCE_DIR}/src/core/ps2/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${PS2_CORE_SOURCES})
@ -2692,9 +2670,6 @@ elseif(PS2)
)
elseif(N3DS)
file(GLOB N3DS_MAIN_SOURCES ${SDL3_SOURCE_DIR}/src/main/n3ds/*.c)
set(SDLMAIN_SOURCES ${SDLMAIN_SOURCES} ${N3DS_MAIN_SOURCES})
file(GLOB N3DS_CORE_SOURCES ${SDL3_SOURCE_DIR}/src/core/n3ds/*.c)
list(APPEND SOURCE_FILES ${N3DS_CORE_SOURCES})
@ -2860,10 +2835,6 @@ if(NOT HAVE_SDL_TIMERS)
list(APPEND SOURCE_FILES ${TIMER_SOURCES})
endif()
if(NOT SDLMAIN_SOURCES)
file(GLOB SDLMAIN_SOURCES ${SDL3_SOURCE_DIR}/src/main/dummy/*.c)
endif()
# Append the -MMD -MT flags
# if(DEPENDENCY_TRACKING)
# if(COMPILER_IS_GNUCC)
@ -3150,31 +3121,6 @@ endif()
# Ensure that the extra cflags are used at compile time
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${EXTRA_CFLAGS_BUILD}")
if(NOT WINDOWS_STORE AND NOT SDL3_DISABLE_SDL3MAIN)
# Build SDL_main
add_library(SDL3_main STATIC ${SDLMAIN_SOURCES})
# alias target for in-tree builds
add_library(SDL3::SDL3_main ALIAS SDL3_main)
target_include_directories(SDL3_main
PRIVATE
"$<BUILD_INTERFACE:${SDL3_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>"
PUBLIC
"$<BUILD_INTERFACE:${SDL3_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${SDL3_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
if (WIN32)
target_link_libraries(SDL3_main PRIVATE shell32)
endif()
if(MINGW OR CYGWIN)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(SDL3_main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=_WinMain@16>")
else()
target_link_libraries(SDL3_main PUBLIC "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-Wl,--undefined=WinMain>")
endif()
endif()
endif()
if(ANDROID)
target_include_directories(sdl-build-options INTERFACE "${ANDROID_NDK}/sources/android/cpufeatures")
endif()
@ -3322,13 +3268,6 @@ if(NOT SDL3_DISABLE_INSTALL)
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
if(NOT WINDOWS_STORE AND NOT SDL3_DISABLE_SDL3MAIN)
install(TARGETS SDL3_main EXPORT SDL3mainTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
if(SDL_STATIC)
install(TARGETS SDL3-static EXPORT SDL3staticTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
@ -3375,18 +3314,6 @@ if(NOT SDL3_DISABLE_INSTALL)
endif()
endif()
if(NOT WINDOWS_STORE AND NOT SDL3_DISABLE_SDL3MAIN)
install(EXPORT SDL3mainTargets
FILE SDL3mainTargets.cmake
NAMESPACE SDL3::
DESTINATION "${SDL_INSTALL_CMAKEDIR}"
)
if(ANDROID AND NOT CMAKE_VERSION VERSION_LESS 3.7)
install(EXPORT_ANDROID_MK SDL3mainTargets
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/ndk-modules/SDL3_main")
endif()
endif()
if(SDL_STATIC)
install(EXPORT SDL3staticTargets
FILE SDL3staticTargets.cmake

View File

@ -21,10 +21,6 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3staticTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/SDL3staticTargets.cmake")
set(SDL3_SDL3-static_FOUND TRUE)
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3mainTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/SDL3mainTargets.cmake")
set(SDL3_SDL3_main_FOUND TRUE)
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3testTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/SDL3testTargets.cmake")
set(SDL3_SDL3_test_FOUND TRUE)
@ -65,11 +61,4 @@ set(SDL3_LIBRARIES SDL3::SDL3)
set(SDL3_STATIC_LIBRARIES SDL3::SDL3-static)
set(SDL3_STATIC_PRIVATE_LIBS)
set(SDL3MAIN_LIBRARY)
if(TARGET SDL3::SDL3_main)
set(SDL3MAIN_LIBRARY SDL3::SDL3_main)
list(INSERT SDL3_LIBRARIES 0 SDL3::SDL3_main)
list(INSERT SDL3_STATIC_LIBRARIES 0 SDL3::SDL3_main)
endif()
set(SDL3TEST_LIBRARY SDL3::SDL3_test)

View File

@ -48,8 +48,7 @@ set(SDL3_INCLUDE_DIRS "${SDL3_INCLUDE_DIR}")
set_and_check(SDL3_BINDIR "${SDL3_PREFIX}/lib/${_sdl_arch_subdir}")
set_and_check(SDL3_LIBDIR "${SDL3_PREFIX}/lib/${_sdl_arch_subdir}")
set(SDL3_LIBRARIES SDL3::SDL3_main SDL3::SDL3)
set(SDL3MAIN_LIBRARY SDL3::SDL3_main)
set(SDL3_LIBRARIES SDL3::SDL3)
set(SDL3TEST_LIBRARY SDL3::SDL3_test)
@ -77,21 +76,6 @@ endif()
unset(_sdl3_library)
unset(_sdl3_dll_library)
set(_sdl3main_library "${SDL3_LIBDIR}/SDL3_main.lib")
if(EXISTS "${_sdl3main_library}")
if(NOT TARGET SDL3::SDL3_main)
add_library(SDL3::SDL3_main STATIC IMPORTED)
set_target_properties(SDL3::SDL3_main
PROPERTIES
IMPORTED_LOCATION "${_sdl3main_library}"
)
endif()
set(SDL3_SDL3_main_FOUND TRUE)
else()
set(SDL3_SDL3_FOUND FALSE)
endif()
unset(_sdl3main_library)
set(_sdl3test_library "${SDL3_LIBDIR}/SDL3_test.lib")
if(EXISTS "${_sdl3test_library}")
if(NOT TARGET SDL3::SDL3_test)

View File

@ -61,9 +61,4 @@ if(NOT TARGET SDL3::SDL3)
endif()
set(SDL3_SDL3_FOUND TRUE)
if(NOT TARGET SDL3::SDL3_main)
add_library(SDL3::SDL3_main INTERFACE IMPORTED)
endif()
set(SDL3_SDL3_main_FOUND TRUE)
check_required_components(SDL3)

View File

@ -61,7 +61,6 @@ build_cmake_projects() {
-DSDL_STATIC=ON \
-DSDL_STATIC_PIC=ON \
-DSDL_TEST=ON \
-DSDL3_DISABLE_SDL3MAIN=OFF \
-DSDL3_DISABLE_INSTALL=OFF \
-DCMAKE_INSTALL_PREFIX="${build_root}/build_${android_abi}/prefix" \
-DCMAKE_INSTALL_INCLUDEDIR=include \
@ -252,35 +251,6 @@ EOF
done
}
create_sdlmain_module() {
echo "Creating SDL${sdl_major}main prefab module"
for android_abi in $android_abis; do
sdl_moduleworkdir="${modulesworkdir}/SDL${sdl_major}main"
mkdir -p "${sdl_moduleworkdir}"
abi_build_prefix="${build_root}/build_${android_abi}/prefix"
cat >"${sdl_moduleworkdir}/module.json" <<EOF
{
"export_libraries": [],
"library_name": "libSDL${sdl_major}main"
}
EOF
abi_sdllibdir="${sdl_moduleworkdir}/libs/android.${android_abi}"
mkdir -p "${abi_sdllibdir}"
cat >"${abi_sdllibdir}/abi.json" <<EOF
{
"abi": "${android_abi}",
"api": ${android_api},
"ndk": ${android_ndk},
"stl": "${android_stl}",
"static": true
}
EOF
cp "${abi_build_prefix}/lib/libSDL${sdl_major}main.a" "${abi_sdllibdir}"
done
}
create_sdltest_module() {
echo "Creating SDL${sdl_major}test prefab module"
for android_abi in $android_abis; do
@ -322,8 +292,6 @@ create_shared_sdl_module
create_static_sdl_module
create_sdlmain_module
create_sdltest_module
pushd "${aar_root}"

View File

@ -11,9 +11,6 @@
# NDK_LIBS_OUT=<dest> - specify alternate destination for installable
# modules.
#
# Note that SDL_main is not an installable module (.so) so libSDL_main.a
# can be found in $obj/local/<abi> along with the unstripped libSDL.so.
#
# Android.mk is in srcdir
@ -69,5 +66,5 @@ ndk-build \
APP_BUILD_SCRIPT=Android.mk \
APP_ABI="armeabi-v7a arm64-v8a x86 x86_64" \
APP_PLATFORM=android-16 \
APP_MODULES="SDL3 SDL3_main" \
APP_MODULES="SDL3" \
$ndk_args

View File

@ -29,13 +29,7 @@ add_feature_info("TEST_STATIC" TEST_STATIC "Test linking with static library")
if(TEST_SHARED)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3)
if(EMSCRIPTEN OR (WIN32 AND NOT WINDOWS_STORE))
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3_main)
endif()
add_executable(gui-shared WIN32 main_gui.c)
if(TARGET SDL3::SDL3_main)
target_link_libraries(gui-shared PRIVATE SDL3::SDL3_main)
endif()
target_link_libraries(gui-shared PRIVATE SDL3::SDL3)
if(WIN32)
add_custom_command(TARGET gui-shared POST_BUILD
@ -61,13 +55,9 @@ if(TEST_SHARED)
)
endif()
# SDL3_LIBRARIES does not support creating a cli SDL3 application
# (it is possible that SDL3_main is a stub, but we don't know for sure)
if(NOT TARGET SDL3::SDL3_main)
add_executable(cli-shared-vars main_cli.c)
target_link_libraries(cli-shared-vars PRIVATE ${SDL3_LIBRARIES})
target_include_directories(cli-shared-vars PRIVATE ${SDL3_INCLUDE_DIRS})
endif()
add_executable(cli-shared-vars main_cli.c)
target_link_libraries(cli-shared-vars PRIVATE ${SDL3_LIBRARIES})
target_include_directories(cli-shared-vars PRIVATE ${SDL3_INCLUDE_DIRS})
add_library(sharedlib-shared-vars SHARED main_lib.c)
target_link_libraries(sharedlib-shared-vars PRIVATE ${SDL3_LIBRARIES})
@ -79,13 +69,7 @@ endif()
if(TEST_STATIC)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-static)
if(EMSCRIPTEN OR (WIN32 AND NOT WINDOWS_STORE))
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3_main)
endif()
add_executable(gui-static WIN32 main_gui.c)
if(TARGET SDL3::SDL3_main)
target_link_libraries(gui-static PRIVATE SDL3::SDL3_main)
endif()
target_link_libraries(gui-static PRIVATE SDL3::SDL3-static)
option(SDL_STATIC_PIC "SDL static library has been built with PIC")
@ -98,19 +82,16 @@ if(TEST_STATIC)
endif()
add_executable(gui-static-vars WIN32 main_gui.c)
target_link_libraries(gui-static-vars PRIVATE ${SDL3MAIN_LIBRARY} ${SDL3_STATIC_LIBRARIES})
target_link_libraries(gui-static-vars PRIVATE ${SDL3_STATIC_LIBRARIES})
target_include_directories(gui-static-vars PRIVATE ${SDL3_INCLUDE_DIRS})
add_executable(cli-static main_cli.c)
target_link_libraries(cli-static PRIVATE SDL3::SDL3-static)
# SDL3_LIBRARIES does not support creating a cli SDL3 application (when SDL3::SDL3_main is available)
# (it is possible that SDL3_main is a stub, but we don't know for sure)
if(NOT TARGET SDL3::SDL3_main)
add_executable(cli-static-vars main_cli.c)
target_link_libraries(cli-static-vars PRIVATE ${SDL3_STATIC_LIBRARIES})
target_include_directories(cli-static-vars PRIVATE ${SDL3_INCLUDE_DIRS})
endif()
add_executable(cli-static-vars main_cli.c)
target_link_libraries(cli-static-vars PRIVATE ${SDL3_STATIC_LIBRARIES})
target_include_directories(cli-static-vars PRIVATE ${SDL3_INCLUDE_DIRS})
endif()
message(STATUS "SDL3_PREFIX: ${SDL3_PREFIX}")
@ -118,7 +99,6 @@ message(STATUS "SDL3_INCLUDE_DIR: ${SDL3_INCLUDE_DIR}")
message(STATUS "SDL3_INCLUDE_DIRS: ${SDL3_INCLUDE_DIRS}")
message(STATUS "SDL3_LIBRARIES: ${SDL3_LIBRARIES}")
message(STATUS "SDL3_STATIC_LIBRARIES: ${SDL3_STATIC_LIBRARIES}")
message(STATUS "SDL3MAIN_LIBRARY: ${SDL3MAIN_LIBRARY}")
message(STATUS "SDL3TEST_LIBRARY: ${SDL3TEST_LIBRARY}")
feature_summary(WHAT ALL)

View File

@ -7,5 +7,4 @@ LOCAL_SRC_FILES := ../main_gui.c
LOCAL_SHARED_LIBRARIES += SDL3
include $(BUILD_SHARED_LIBRARY)
$(call import-module,SDL3_main)
$(call import-module,SDL3)

View File

@ -1,7 +0,0 @@
/*
SDL_android_main.c, placed in the public domain by Sam Lantinga 3/13/14
As of SDL 2.0.6 this file is no longer necessary.
*/
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,21 +0,0 @@
/*
SDL_dummy_main.c, placed in the public domain by Sam Lantinga 3/13/14
*/
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h> /* until this SDL_main impl is converted to header-only.. */
#ifdef main
#undef main
int main(int argc, char *argv[])
{
return SDL_main(argc, argv);
}
#else
/* Nothing to do on this platform */
int SDL_main_stub_symbol(void)
{
return 0;
}
#endif
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,25 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Nothing to do here, the code moved into SDL_main_impl.h
TODO: remove this file
*/
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,25 +0,0 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Nothing to do here, the code moved into SDL_main_impl.h
TODO: remove this file
*/
/* vi: set sts=4 ts=4 sw=4 expandtab: */

View File

@ -1,8 +0,0 @@
/*
SDL_ngage_main.c, originally for SDL 1.2 by Hannu Viitala
empty, moved to SDL_main_impl.h and src/core/ngage/SDL_ngage_runapp.cpp
TODO: delete this file
*/
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,8 +0,0 @@
/*
SDL_ps2_main.c, fjtrujy@gmail.com
empty, moved to SDL_RunApp() in src/core/ps2/SDL_ps2.c
TODO: remove
*/
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,8 +0,0 @@
/*
SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14
empty, moved to SDL_RunApp() in src/core/psp/SDL_psp.c
TODO: remove
*/
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,8 +0,0 @@
/*
SDL_uikit_main.c, placed in the public domain by Sam Lantinga 3/18/2019
Nothing to do here, the code moved into SDL_main_impl.h
TODO: remove this file
*/
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -1,8 +0,0 @@
/*
SDL_windows_main.c, placed in the public domain by Sam Lantinga 4/13/98
Nothing to do here, the code moved into SDL_main_impl.h and SDL_windows.c (SDL_RunApp())
TODO: remove this file
*/
/* vi: set ts=4 sw=4 expandtab: */

View File

@ -31,7 +31,7 @@ else()
endif()
if(NOT TARGET SDL3::${sdl_name_component})
find_package(SDL3 3.0.0 REQUIRED COMPONENTS ${sdl_name_component} SDL3_main SDL3_test)
find_package(SDL3 3.0.0 REQUIRED COMPONENTS ${sdl_name_component} SDL3_test)
endif()
# CMake incorrectly detects opengl32.lib being present on MSVC ARM64
@ -61,7 +61,7 @@ macro(add_sdl_test_executable TARGET)
list(APPEND SOURCES ${RESOURCE_FILES})
endif()
add_executable(${TARGET} ${SOURCES})
target_link_libraries(${TARGET} PRIVATE SDL3::SDL3_main SDL3::SDL3_test SDL3::${sdl_name_component})
target_link_libraries(${TARGET} PRIVATE SDL3::SDL3_test SDL3::${sdl_name_component})
list(APPEND SDL_TEST_EXECUTABLES ${TARGET})
if(AST_NONINTERACTIVE)