From e2ecc315b4d5d045c31229e664f2e95ca8d50a1d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 14:44:47 +0100 Subject: [PATCH] cmake: attempt to fix dedicated build uhh building --- src/dedicated/CMakeLists.txt | 101 +++++++++++++++++++++++++++-------- 1 file changed, 79 insertions(+), 22 deletions(-) diff --git a/src/dedicated/CMakeLists.txt b/src/dedicated/CMakeLists.txt index 36f670251..84e36690f 100644 --- a/src/dedicated/CMakeLists.txt +++ b/src/dedicated/CMakeLists.txt @@ -1,21 +1,75 @@ # Declare dedicated interface sources -target_sourcefile(c) +set(SRB2_DEDICATED_SOURCES + i_system.c + i_main.c + i_video.c + i_sound.c + i_threads.c + dosstr.c + endtxt.c +) -target_sources(SRB2SDL2 PRIVATE) +set(SRB2_DEDICATED_HEADERS + endtxt.h +) + +source_group("Interface Code" FILES ${SRB2_DEDICATED_SOURCES} ${SRB2_DEDICATED_HEADERS}) + +set(SRB2_DEDICATED_TOTAL_SOURCES + ${SRB2_CORE_SOURCES} + ${SRB2_CORE_HEADERS} + ${SRB2_PNG_SOURCES} + ${SRB2_PNG_HEADERS} + ${SRB2_CORE_RENDER_SOURCES} + ${SRB2_CORE_GAME_SOURCES} + ${SRB2_LUA_SOURCES} + ${SRB2_LUA_HEADERS} + ${SRB2_BLUA_SOURCES} + ${SRB2_BLUA_HEADERS} + ${SRB2_DEDICATED_SOURCES} + ${SRB2_DEDICATED_HEADERS} +) + +source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS}) +source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES}) +source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES}) +source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) +source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) if(${CMAKE_SYSTEM} MATCHES Windows) - target_sources(SRB2SDL2 PRIVATE - ../win32/win_dbg.c - ../win32/Srb2win.rc) + set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES} + ${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c + ${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc + ) endif() +add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_DEDICATED_TOTAL_SOURCES}) + if(${CMAKE_SYSTEM} MATCHES Windows) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd) elseif(${CMAKE_SYSTEM} MATCHES Linux) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd) else() - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd) +endif() + +if(${CMAKE_SYSTEM} MATCHES Darwin) + find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation") + target_link_libraries(SRB2SDL2 PRIVATE + ${CORE_FOUNDATION_LIBRARY} + ) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") + + # Configure the app bundle icon and plist properties + target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns") + set_target_properties(SRB2SDL2 PROPERTIES + MACOSX_BUNDLE_ICON_FILE "Srb2mac" + MACOSX_BUNDLE_BUNDLE_NAME "Sonic Robo Blast 2" + MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION} + + RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns" + ) endif() if(${CMAKE_SYSTEM} MATCHES Darwin) @@ -24,25 +78,27 @@ if(${CMAKE_SYSTEM} MATCHES Darwin) ${CORE_LIB} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} + ${CURL_LIBRARIES} ) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") else() target_link_libraries(SRB2SDL2 PRIVATE ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} + ${CURL_LIBRARIES} ) - if(${CMAKE_SYSTEM} MATCHES Linux) target_link_libraries(SRB2SDL2 PRIVATE m rt + pthread ) endif() endif() -#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core) - -set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION}) +if(${SRB2_HAVE_LIBBACKTRACE}) + target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES}) +endif() if(${CMAKE_SYSTEM} MATCHES Windows) target_link_libraries(SRB2SDL2 PRIVATE @@ -60,19 +116,20 @@ target_include_directories(SRB2SDL2 PRIVATE target_compile_definitions(SRB2SDL2 PRIVATE -DDEDICATED + -DHAVE_THREADS ) ## strip debug symbols into separate file when using gcc -if(CMAKE_COMPILER_IS_GNUCC) - if(${CMAKE_BUILD_TYPE} MATCHES Debug) - message(STATUS "Will make separate debug symbols in *.debug") - add_custom_command(TARGET SRB2SDL2 POST_BUILD - COMMAND ${OBJCOPY} --only-keep-debug $ $.debug - COMMAND ${OBJCOPY} --strip-debug $ - COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ - ) - endif() -endif() +# if(CMAKE_COMPILER_IS_GNUCC) +# if(${CMAKE_BUILD_TYPE} MATCHES Debug) +# message(STATUS "Will make separate debug symbols in *.debug") +# add_custom_command(TARGET SRB2SDL2 POST_BUILD +# COMMAND ${OBJCOPY} --only-keep-debug $ $.debug +# COMMAND ${OBJCOPY} --strip-debug $ +# COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ +# ) +# endif() +# endif() #### Installation #### if(${CMAKE_SYSTEM} MATCHES Darwin)