mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Refactor CMake to allow source grouping and separation of interfaces.
Core and SDL2 are two separate targets now. Core is a static library that is linked into SRB2SDL2. The sources for both are separated. When using an IDE like Visual Studio or Xcode, the source code organized into groups that explain what that group of sources does. In the future, "Main" could be split into a few more groups based on file prefixes, but I think the way it is set up works for now. Makefile targets are not affected by source_groups and typing `make` will automatically compile both the "Core" library and SRB2SDL2 itself.
This commit is contained in:
parent
3d5d61ee87
commit
a713509493
4 changed files with 160 additions and 143 deletions
|
@ -26,7 +26,7 @@ endforeach()
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
if(CLANG)
|
if(CLANG)
|
||||||
get_target_property(outname ${SRB2_SDL2_EXE_NAME} OUTPUT_NAME)
|
get_target_property(outname SRB2SDL2 OUTPUT_NAME)
|
||||||
install(FILES ${SRB2_ASSET_ALL}
|
install(FILES ${SRB2_ASSET_ALL}
|
||||||
DESTINATION "${outname}.app/Contents/Resources"
|
DESTINATION "${outname}.app/Contents/Resources"
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,32 +34,6 @@ set(SRB2_CORE_SOURCES
|
||||||
m_random.c
|
m_random.c
|
||||||
md5.c
|
md5.c
|
||||||
mserv.c
|
mserv.c
|
||||||
p_ceilng.c
|
|
||||||
p_enemy.c
|
|
||||||
p_fab.c
|
|
||||||
p_floor.c
|
|
||||||
p_inter.c
|
|
||||||
p_lights.c
|
|
||||||
p_map.c
|
|
||||||
p_maputl.c
|
|
||||||
p_mobj.c
|
|
||||||
p_polyobj.c
|
|
||||||
p_saveg.c
|
|
||||||
p_setup.c
|
|
||||||
p_sight.c
|
|
||||||
p_spec.c
|
|
||||||
p_telept.c
|
|
||||||
p_tick.c
|
|
||||||
p_user.c
|
|
||||||
r_bsp.c
|
|
||||||
r_data.c
|
|
||||||
r_draw.c
|
|
||||||
r_main.c
|
|
||||||
r_plane.c
|
|
||||||
r_segs.c
|
|
||||||
r_sky.c
|
|
||||||
r_splats.c
|
|
||||||
r_things.c
|
|
||||||
s_sound.c
|
s_sound.c
|
||||||
screen.c
|
screen.c
|
||||||
sounds.c
|
sounds.c
|
||||||
|
@ -124,15 +98,31 @@ set(SRB2_CORE_HEADERS
|
||||||
md5.h
|
md5.h
|
||||||
mserv.h
|
mserv.h
|
||||||
p5prof.h
|
p5prof.h
|
||||||
p_local.h
|
s_sound.h
|
||||||
p_maputl.h
|
screen.h
|
||||||
p_mobj.h
|
sounds.h
|
||||||
p_polyobj.h
|
st_stuff.h
|
||||||
p_pspr.h
|
tables.h
|
||||||
p_saveg.h
|
v_video.h
|
||||||
p_setup.h
|
w_wad.h
|
||||||
p_spec.h
|
y_inter.h
|
||||||
p_tick.h
|
z_zone.h
|
||||||
|
|
||||||
|
config.h.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/config.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(SRB2_CORE_RENDER_SOURCES
|
||||||
|
r_bsp.c
|
||||||
|
r_data.c
|
||||||
|
r_draw.c
|
||||||
|
r_main.c
|
||||||
|
r_plane.c
|
||||||
|
r_segs.c
|
||||||
|
r_sky.c
|
||||||
|
r_splats.c
|
||||||
|
r_things.c
|
||||||
|
|
||||||
r_bsp.h
|
r_bsp.h
|
||||||
r_data.h
|
r_data.h
|
||||||
r_defs.h
|
r_defs.h
|
||||||
|
@ -145,57 +135,45 @@ set(SRB2_CORE_HEADERS
|
||||||
r_splats.h
|
r_splats.h
|
||||||
r_state.h
|
r_state.h
|
||||||
r_things.h
|
r_things.h
|
||||||
s_sound.h
|
|
||||||
screen.h
|
|
||||||
sounds.h
|
|
||||||
st_stuff.h
|
|
||||||
tables.h
|
|
||||||
v_video.h
|
|
||||||
w_wad.h
|
|
||||||
y_inter.h
|
|
||||||
z_zone.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
prepend_sources(SRB2_CORE_SOURCES)
|
set(SRB2_CORE_GAME_SOURCES
|
||||||
prepend_sources(SRB2_CORE_HEADERS)
|
p_ceilng.c
|
||||||
|
p_enemy.c
|
||||||
|
p_fab.c
|
||||||
|
p_floor.c
|
||||||
|
p_inter.c
|
||||||
|
p_lights.c
|
||||||
|
p_map.c
|
||||||
|
p_maputl.c
|
||||||
|
p_mobj.c
|
||||||
|
p_polyobj.c
|
||||||
|
p_saveg.c
|
||||||
|
p_setup.c
|
||||||
|
p_sight.c
|
||||||
|
p_spec.c
|
||||||
|
p_telept.c
|
||||||
|
p_tick.c
|
||||||
|
p_user.c
|
||||||
|
|
||||||
set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
p_local.h
|
||||||
|
p_maputl.h
|
||||||
set(SRB2_HWRENDER_SOURCES
|
p_mobj.h
|
||||||
hardware/hw_bsp.c
|
p_polyobj.h
|
||||||
hardware/hw_cache.c
|
p_pspr.h
|
||||||
hardware/hw_draw.c
|
p_saveg.h
|
||||||
hardware/hw_light.c
|
p_setup.h
|
||||||
hardware/hw_main.c
|
p_spec.h
|
||||||
hardware/hw_md2.c
|
p_tick.h
|
||||||
hardware/hw_trick.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SRB2_HWRENDER_HEADERS
|
if(NOT CLANG)
|
||||||
hardware/hw_data.h
|
set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c)
|
||||||
hardware/hw_defs.h
|
endif()
|
||||||
hardware/hw_dll.h
|
|
||||||
hardware/hw_drv.h
|
|
||||||
hardware/hw_glide.h
|
|
||||||
hardware/hw_glob.h
|
|
||||||
hardware/hw_light.h
|
|
||||||
hardware/hw_main.h
|
|
||||||
hardware/hw_md2.h
|
|
||||||
)
|
|
||||||
|
|
||||||
prepend_sources(SRB2_HWRENDER_SOURCES)
|
source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS})
|
||||||
prepend_sources(SRB2_HWRENDER_HEADERS)
|
source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES})
|
||||||
|
source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES})
|
||||||
set(SRB2_R_OPENGL_SOURCES
|
|
||||||
hardware/r_opengl/r_opengl.c
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SRB2_R_OPENGL_HEADERS
|
|
||||||
hardware/r_opengl/r_opengl.h
|
|
||||||
)
|
|
||||||
|
|
||||||
prepend_sources(SRB2_R_OPENGL_SOURCES)
|
|
||||||
prepend_sources(SRB2_R_OPENGL_HEADERS)
|
|
||||||
|
|
||||||
set(SRB2_ASM_SOURCES
|
set(SRB2_ASM_SOURCES
|
||||||
vid_copy.s
|
vid_copy.s
|
||||||
|
@ -219,8 +197,7 @@ if(MSVC)
|
||||||
list(APPEND SRB2_NASM_OBJECTS tmap_vc.obj)
|
list(APPEND SRB2_NASM_OBJECTS tmap_vc.obj)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
prepend_sources(SRB2_ASM_SOURCES)
|
source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES})
|
||||||
prepend_sources(SRB2_NASM_SOURCES)
|
|
||||||
|
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
@ -229,11 +206,11 @@ set(SRB2_CONFIG_HAVE_BLUA ON CACHE BOOL
|
||||||
set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
|
set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL
|
||||||
"Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.")
|
"Enable PNG support. Depends on zlib, so will be disabled if you don't enable that too.")
|
||||||
set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
|
set(SRB2_CONFIG_HAVE_ZLIB ON CACHE BOOL
|
||||||
"Enable zlib support")
|
"Enable zlib support.")
|
||||||
set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
|
set(SRB2_CONFIG_HAVE_GME ON CACHE BOOL
|
||||||
"Enable GME support")
|
"Enable GME support.")
|
||||||
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
|
set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
|
||||||
"Enable hardware rendering through OpenGL")
|
"Enable hardware rendering through OpenGL.")
|
||||||
set(SRB2_CONFIG_USEASM OFF CACHE BOOL
|
set(SRB2_CONFIG_USEASM OFF CACHE BOOL
|
||||||
"Enable NASM tmap implementation for software mode speedup.")
|
"Enable NASM tmap implementation for software mode speedup.")
|
||||||
set(SRB2_CONFIG_YASM OFF CACHE BOOL
|
set(SRB2_CONFIG_YASM OFF CACHE BOOL
|
||||||
|
@ -264,8 +241,7 @@ if(${SRB2_CONFIG_HAVE_BLUA})
|
||||||
lua_script.h
|
lua_script.h
|
||||||
)
|
)
|
||||||
|
|
||||||
prepend_sources(SRB2_LUA_SOURCES)
|
source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS})
|
||||||
prepend_sources(SRB2_LUA_HEADERS)
|
|
||||||
|
|
||||||
set(SRB2_BLUA_SOURCES
|
set(SRB2_BLUA_SOURCES
|
||||||
blua/lapi.c
|
blua/lapi.c
|
||||||
|
@ -318,8 +294,7 @@ if(${SRB2_CONFIG_HAVE_BLUA})
|
||||||
blua/lvm.h
|
blua/lvm.h
|
||||||
blua/lzio.h
|
blua/lzio.h
|
||||||
)
|
)
|
||||||
prepend_sources(SRB2_BLUA_SOURCES)
|
source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS})
|
||||||
prepend_sources(SRB2_BLUA_HEADERS)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${SRB2_CONFIG_HAVE_GME})
|
if(${SRB2_CONFIG_HAVE_GME})
|
||||||
|
@ -355,6 +330,36 @@ endif()
|
||||||
|
|
||||||
if(${SRB2_CONFIG_HWRENDER})
|
if(${SRB2_CONFIG_HWRENDER})
|
||||||
add_definitions(-DHWRENDER)
|
add_definitions(-DHWRENDER)
|
||||||
|
set(SRB2_HWRENDER_SOURCES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_trick.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set (SRB2_HWRENDER_HEADERS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glide.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(SRB2_R_OPENGL_SOURCES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.c
|
||||||
|
)
|
||||||
|
|
||||||
|
set(SRB2_R_OPENGL_HEADERS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h
|
||||||
|
)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
|
if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
|
||||||
|
@ -384,10 +389,6 @@ endif()
|
||||||
|
|
||||||
# Targets
|
# Targets
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
|
||||||
add_subdirectory(win32)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Compatibility flag with later versions of GCC
|
# Compatibility flag with later versions of GCC
|
||||||
# We should really fix our code to not need this
|
# We should really fix our code to not need this
|
||||||
if(NOT CLANG AND NOT MSVC)
|
if(NOT CLANG AND NOT MSVC)
|
||||||
|
@ -396,4 +397,23 @@ endif()
|
||||||
|
|
||||||
add_definitions(-DCMAKECONFIG)
|
add_definitions(-DCMAKECONFIG)
|
||||||
|
|
||||||
|
add_library(SRB2Core STATIC
|
||||||
|
${SRB2_CORE_SOURCES}
|
||||||
|
${SRB2_CORE_HEADERS}
|
||||||
|
${SRB2_CORE_RENDER_SOURCES}
|
||||||
|
${SRB2_CORE_GAME_SOURCES}
|
||||||
|
${SRB2_LUA_SOURCES}
|
||||||
|
${SRB2_LUA_HEADERS}
|
||||||
|
${SRB2_BLUA_SOURCES}
|
||||||
|
${SRB2_BLUA_HEADERS}
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(sdl)
|
add_subdirectory(sdl)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||||
|
add_subdirectory(win32)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE})
|
||||||
|
message(FATAL_ERROR "There are no targets available to build an SRB2 executable. :(")
|
||||||
|
endif()
|
|
@ -3,6 +3,12 @@
|
||||||
#ifndef __CONFIG_H__
|
#ifndef __CONFIG_H__
|
||||||
#define __CONFIG_H__
|
#define __CONFIG_H__
|
||||||
|
|
||||||
|
/* DO NOT MODIFY config.h DIRECTLY! It will be overwritten by cmake.
|
||||||
|
* If you want to change a configuration option here, modify it in
|
||||||
|
* your CMakeCache.txt. config.h.in is used as a template for CMake
|
||||||
|
* variables, so you can insert them here too.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef CMAKECONFIG
|
#ifdef CMAKECONFIG
|
||||||
|
|
||||||
#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}"
|
#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}"
|
||||||
|
|
|
@ -39,16 +39,13 @@ set(SRB2_SDL2_HEADERS
|
||||||
sdlmain.h
|
sdlmain.h
|
||||||
)
|
)
|
||||||
|
|
||||||
prepend_sources(SRB2_SDL2_SOURCES)
|
source_group("Interface Code" FILES ${SRB2_SDL2_SOURCES} ${SRB2_SDL2_HEADERS})
|
||||||
prepend_sources(SRB2_SDL2_HEADERS)
|
|
||||||
|
|
||||||
# Dependency
|
# Dependency
|
||||||
find_package(SDL2)
|
find_package(SDL2)
|
||||||
|
|
||||||
if(${SDL2_FOUND})
|
if(${SDL2_FOUND})
|
||||||
set(SRB2_SDL2_TOTAL_SOURCES
|
set(SRB2_SDL2_TOTAL_SOURCES
|
||||||
${SRB2_CORE_SOURCES}
|
|
||||||
${SRB2_CORE_HEADERS}
|
|
||||||
${SRB2_SDL2_SOURCES}
|
${SRB2_SDL2_SOURCES}
|
||||||
${SRB2_SDL2_HEADERS}
|
${SRB2_SDL2_HEADERS}
|
||||||
)
|
)
|
||||||
|
@ -60,15 +57,9 @@ if(${SDL2_FOUND})
|
||||||
${SRB2_R_OPENGL_SOURCES}
|
${SRB2_R_OPENGL_SOURCES}
|
||||||
${SRB2_R_OPENGL_HEADERS}
|
${SRB2_R_OPENGL_HEADERS}
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${SRB2_CONFIG_HAVE_BLUA})
|
source_group("Hardware" FILES ${SRB2_HWRENDER_SOURCES} ${SRB2_HWRENDER_HEADERS})
|
||||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
source_group("Hardware\\OpenGL Renderer" FILES ${SRB2_R_OPENGL_SOURCES} ${SRB2_R_OPENGL_HEADERS})
|
||||||
${SRB2_LUA_SOURCES}
|
|
||||||
${SRB2_LUA_HEADERS}
|
|
||||||
${SRB2_BLUA_SOURCES}
|
|
||||||
${SRB2_BLUA_HEADERS}
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${SRB2_USEASM})
|
if(${SRB2_USEASM})
|
||||||
|
@ -85,7 +76,6 @@ if(${SDL2_FOUND})
|
||||||
set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C)
|
set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C)
|
||||||
set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
|
set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||||
|
@ -94,39 +84,36 @@ if(${SDL2_FOUND})
|
||||||
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
|
${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(NOT CLANG)
|
|
||||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
|
||||||
${CMAKE_SOURCE_DIR}/src/string.c
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||||
set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns)
|
set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns)
|
||||||
set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
||||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
set(SRB2_SDL2_MAC_SOURCES
|
||||||
macosx/mac_alert.c
|
macosx/mac_alert.c
|
||||||
macosx/mac_alert.h
|
macosx/mac_alert.h
|
||||||
macosx/mac_resources.c
|
macosx/mac_resources.c
|
||||||
macosx/mac_resources.h
|
macosx/mac_resources.h
|
||||||
macosx/Srb2mac.icns
|
macosx/Srb2mac.icns
|
||||||
)
|
)
|
||||||
|
source_group("Interface Code\\OSX Compatibility" FILES ${SRB2_SDL2_MAC_SOURCES})
|
||||||
|
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} ${SRB2_SDL2_MAC_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_SDL2_TOTAL_SOURCES})
|
||||||
|
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${SRB2_SDL2_EXE_NAME})
|
||||||
|
|
||||||
if(CLANG)
|
if(CLANG)
|
||||||
add_executable(${SRB2_SDL2_EXE_NAME} MACOSX_BUNDLE ${SRB2_SDL2_TOTAL_SOURCES})
|
add_framework(CoreFoundation SRB2SDL2)
|
||||||
add_framework(CoreFoundation ${SRB2_SDL2_EXE_NAME})
|
add_framework(SDL2 SRB2SDL2)
|
||||||
add_framework(SDL2 ${SRB2_SDL2_EXE_NAME})
|
add_framework(SDL2_mixer SRB2SDL2)
|
||||||
add_framework(SDL2_mixer ${SRB2_SDL2_EXE_NAME})
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
)
|
)
|
||||||
set_target_properties(${SRB2_SDL2_EXE_NAME} PROPERTIES OUTPUT_NAME "Sonic Robo Blast 2")
|
set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "Sonic Robo Blast 2")
|
||||||
else()
|
else()
|
||||||
add_executable(${SRB2_SDL2_EXE_NAME} WIN32 ${SRB2_SDL2_TOTAL_SOURCES})
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
|
|
||||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
|
||||||
${SDL2_LIBRARIES}
|
${SDL2_LIBRARIES}
|
||||||
${SDL2_MIXER_LIBRARIES}
|
${SDL2_MIXER_LIBRARIES}
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
|
@ -135,14 +122,15 @@ if(${SDL2_FOUND})
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM} MATCHES Linux)
|
if(${CMAKE_SYSTEM} MATCHES Linux)
|
||||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
m
|
m
|
||||||
rt
|
rt
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(SRB2SDL2 PRIVATE SRB2Core)
|
||||||
|
|
||||||
if(${SRB2_USEASM})
|
if(${SRB2_USEASM})
|
||||||
if(${SRB2_CONFIG_YASM})
|
if(${SRB2_CONFIG_YASM})
|
||||||
set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_YASM_COMPILER})
|
set(ASM_ASSEMBLER_TEMP ${CMAKE_ASM_YASM_COMPILER})
|
||||||
|
@ -159,7 +147,7 @@ if(${SDL2_FOUND})
|
||||||
foreach(ASMFILE ${SRB2_NASM_SOURCES})
|
foreach(ASMFILE ${SRB2_NASM_SOURCES})
|
||||||
get_filename_component(ASMFILE_NAME ${ASMFILE} NAME_WE)
|
get_filename_component(ASMFILE_NAME ${ASMFILE} NAME_WE)
|
||||||
set(ASMFILE_NAME ${ASMFILE_NAME}.obj)
|
set(ASMFILE_NAME ${ASMFILE_NAME}.obj)
|
||||||
add_custom_command(TARGET ${SRB2_SDL2_EXE_NAME} PRE_LINK
|
add_custom_command(TARGET SRB2SDL2 PRE_LINK
|
||||||
COMMAND ${ASM_ASSEMBLER_TEMP} ARGS -f ${ASM_ASSEMBLER_OBJFORMAT} -o ${CMAKE_CURRENT_BINARY_DIR}/${ASMFILE_NAME} ${ASMFILE}
|
COMMAND ${ASM_ASSEMBLER_TEMP} ARGS -f ${ASM_ASSEMBLER_OBJFORMAT} -o ${CMAKE_CURRENT_BINARY_DIR}/${ASMFILE_NAME} ${ASMFILE}
|
||||||
COMMENT "assemble ${ASMFILE_NAME}."
|
COMMENT "assemble ${ASMFILE_NAME}."
|
||||||
)
|
)
|
||||||
|
@ -167,23 +155,23 @@ if(${SDL2_FOUND})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(${SRB2_SDL2_EXE_NAME} PROPERTIES VERSION ${SRB2_VERSION})
|
set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION})
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
ws2_32
|
ws2_32
|
||||||
)
|
)
|
||||||
target_compile_options(${SRB2_SDL2_EXE_NAME} PRIVATE
|
target_compile_options(SRB2SDL2 PRIVATE
|
||||||
-U_WINDOWS
|
-U_WINDOWS
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
find_package(SDL2_MAIN REQUIRED)
|
find_package(SDL2_MAIN REQUIRED)
|
||||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
target_link_libraries(SRB2SDL2 PRIVATE
|
||||||
${SDL2_MAIN_LIBRARIES}
|
${SDL2_MAIN_LIBRARIES}
|
||||||
)
|
)
|
||||||
target_compile_options(${SRB2_SDL2_EXE_NAME} PRIVATE
|
target_compile_options(SRB2SDL2 PRIVATE
|
||||||
/Umain
|
/Umain
|
||||||
/D_CRT_SECURE_NO_WARNINGS # something about string functions.
|
/D_CRT_SECURE_NO_WARNINGS # something about string functions.
|
||||||
/D_CRT_NONSTDC_NO_DEPRECATE
|
/D_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
@ -192,7 +180,7 @@ if(${SDL2_FOUND})
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(${SRB2_SDL2_EXE_NAME} PRIVATE
|
target_include_directories(SRB2SDL2 PRIVATE
|
||||||
${SDL2_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIRS}
|
||||||
${SDL2_MIXER_INCLUDE_DIRS}
|
${SDL2_MIXER_INCLUDE_DIRS}
|
||||||
${PNG_INCLUDE_DIRS}
|
${PNG_INCLUDE_DIRS}
|
||||||
|
@ -201,10 +189,10 @@ if(${SDL2_FOUND})
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${SRB2_HAVE_MIXER})
|
if(${SRB2_HAVE_MIXER})
|
||||||
target_compile_definitions(${SRB2_SDL2_EXE_NAME} PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
|
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(${SRB2_SDL2_EXE_NAME} PRIVATE
|
target_compile_definitions(SRB2SDL2 PRIVATE
|
||||||
-DHAVE_SDL
|
-DHAVE_SDL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -212,21 +200,21 @@ if(${SDL2_FOUND})
|
||||||
if(CMAKE_COMPILER_IS_GNUCC)
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
|
||||||
message(STATUS "Will make separate debug symbols in *.debug")
|
message(STATUS "Will make separate debug symbols in *.debug")
|
||||||
add_custom_command(TARGET ${SRB2_SDL2_EXE_NAME} POST_BUILD
|
add_custom_command(TARGET SRB2SDL2 POST_BUILD
|
||||||
COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:${SRB2_SDL2_EXE_NAME}> $<TARGET_FILE:${SRB2_SDL2_EXE_NAME}>.debug
|
COMMAND ${OBJCOPY} --only-keep-debug $<TARGET_FILE:SRB2SDL2> $<TARGET_FILE:SRB2SDL2>.debug
|
||||||
COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:${SRB2_SDL2_EXE_NAME}>
|
COMMAND ${OBJCOPY} --strip-debug $<TARGET_FILE:SRB2SDL2>
|
||||||
COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:${SRB2_SDL2_EXE_NAME}>.debug $<TARGET_FILE:${SRB2_SDL2_EXE_NAME}>
|
COMMAND ${OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE_NAME:SRB2SDL2>.debug $<TARGET_FILE:SRB2SDL2>
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#### Installation ####
|
#### Installation ####
|
||||||
if (CLANG)
|
if (CLANG)
|
||||||
install(TARGETS ${SRB2_SDL2_EXE_NAME}
|
install(TARGETS SRB2SDL2
|
||||||
BUNDLE DESTINATION .
|
BUNDLE DESTINATION .
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
install(TARGETS ${SRB2_SDL2_EXE_NAME} ${SRB2_SDL2_EXE_NAME}
|
install(TARGETS SRB2SDL2 SRB2SDL2
|
||||||
RUNTIME DESTINATION .
|
RUNTIME DESTINATION .
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@ -257,7 +245,7 @@ if(${SDL2_FOUND})
|
||||||
|
|
||||||
# We also want to copy those DLLs to build directories on MSVC.
|
# We also want to copy those DLLs to build directories on MSVC.
|
||||||
# So we'll add a post_build step.
|
# So we'll add a post_build step.
|
||||||
copy_files_to_build_dir(${SRB2_SDL2_EXE_NAME} win_extra_dll_list)
|
copy_files_to_build_dir(SRB2SDL2 win_extra_dll_list)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,6 +259,9 @@ if(${SDL2_FOUND})
|
||||||
)"
|
)"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(SRB2_SDL2_AVAILABLE YES PARENT_SCOPE)
|
||||||
else()
|
else()
|
||||||
message(WARNING "SDL2 wasn't found, so ${SRB2_SDL2_EXE_NAME} won't be available")
|
message(WARNING "SDL2 was not found, so the SDL2 target will not be available.")
|
||||||
|
set(SRB2_SDL2_AVAILABLE NO PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
Loading…
Reference in a new issue