mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 07:12:03 +00:00
Add Xcode target support
It is really messy at the moment. There is no support for copying the necessary frameworks and dylibs out to the bundle for distribution, and it is a frankenstein of manual find_library and find_package which can sometimes pick up Homebrew dylibs.
This commit is contained in:
parent
05f5ec664a
commit
479ebc3f94
3 changed files with 63 additions and 9 deletions
|
@ -15,6 +15,24 @@ function(prepend_sources SOURCE_FILES)
|
|||
set(${SOURCE_FILES} ${MODIFIED} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Macro to add OSX framework
|
||||
macro(add_framework fwname appname)
|
||||
find_library(FRAMEWORK_${fwname}
|
||||
NAMES ${fwname}
|
||||
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
|
||||
${CMAKE_OSX_SYSROOT}/Library
|
||||
/System/Library
|
||||
/Library
|
||||
PATH_SUFFIXES Frameworks
|
||||
NO_DEFAULT_PATH)
|
||||
if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
|
||||
MESSAGE(ERROR ": Framework ${fwname} not found")
|
||||
else()
|
||||
TARGET_LINK_LIBRARIES(${appname} PRIVATE "${FRAMEWORK_${fwname}}/${fwname}")
|
||||
MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# 64-bit check
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
message(STATUS "Target is 64-bit")
|
||||
|
@ -32,12 +50,21 @@ endif()
|
|||
if (UNIX)
|
||||
add_definitions(-DUNIXCOMMON)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES "Linux")
|
||||
add_definitions(-DLINUX)
|
||||
if(${SRB2_SYSTEM_BITS} EQUAL 64)
|
||||
add_definitions(-DLINUX64)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES "Darwin")
|
||||
add_definitions(-DMACOSX)
|
||||
if(${CMAKE_C_COMPILER_ID} MATCHES "Clang")
|
||||
set(CLANG ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# TODO support MacOSX builds
|
||||
|
||||
add_subdirectory(src/)
|
||||
|
|
|
@ -64,7 +64,7 @@ set(SRB2_CORE_SOURCES
|
|||
screen.c
|
||||
sounds.c
|
||||
st_stuff.c
|
||||
string.c
|
||||
#string.c
|
||||
tables.c
|
||||
v_video.c
|
||||
w_wad.c
|
||||
|
@ -342,6 +342,8 @@ endif()
|
|||
|
||||
# Compatibility flag with later versions of GCC
|
||||
# We should really fix our code to not need this
|
||||
add_compile_options(-mno-ms-bitfields)
|
||||
if(NOT CLANG)
|
||||
add_compile_options(-mno-ms-bitfields)
|
||||
endif()
|
||||
|
||||
add_subdirectory(sdl)
|
||||
|
|
|
@ -40,6 +40,9 @@ set(SRB2_SDL2_EXE_NAME srb2sdl2)
|
|||
if(${CMAKE_SYSTEM} MATCHES "Windows")
|
||||
set(SRB2_SDL2_EXE_NAME srb2win)
|
||||
endif()
|
||||
if(CLANG)
|
||||
set(SRB2_SDL2_EXE_NAME SRB2)
|
||||
endif()
|
||||
|
||||
# Dependency
|
||||
find_package(SDL2)
|
||||
|
@ -76,14 +79,36 @@ if(${SDL2_FOUND})
|
|||
)
|
||||
endif()
|
||||
|
||||
add_executable(${SRB2_SDL2_EXE_NAME} WIN32 ${SRB2_SDL2_TOTAL_SOURCES})
|
||||
if(${CMAKE_SYSTEM} MATCHES Darwin)
|
||||
set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns)
|
||||
set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
||||
set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES}
|
||||
macosx/mac_alert.c
|
||||
macosx/mac_alert.h
|
||||
macosx/Srb2mac.icns
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
||||
${SDL2_LIBRARIES}
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
)
|
||||
if(CLANG)
|
||||
add_executable(${SRB2_SDL2_EXE_NAME} MACOSX_BUNDLE ${SRB2_SDL2_TOTAL_SOURCES})
|
||||
add_framework(CoreFoundation ${SRB2_SDL2_EXE_NAME})
|
||||
add_framework(SDL2 ${SRB2_SDL2_EXE_NAME})
|
||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
)
|
||||
else()
|
||||
add_executable(${SRB2_SDL2_EXE_NAME} WIN32 ${SRB2_SDL2_TOTAL_SOURCES})
|
||||
|
||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
||||
${SDL2_LIBRARIES}
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM} MATCHES Windows)
|
||||
target_link_libraries(${SRB2_SDL2_EXE_NAME} PRIVATE
|
||||
|
|
Loading…
Reference in a new issue