mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 07:12:03 +00:00
0909fce2e3
silently fixing a bad malloc here too shhhhhhhhh
100 lines
2.8 KiB
CMake
100 lines
2.8 KiB
CMake
cmake_minimum_required(VERSION 3.0)
|
|
project(SRB2
|
|
VERSION 2.1.14
|
|
LANGUAGES C)
|
|
|
|
# Set up CMAKE path
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
|
|
|
### Useful functions
|
|
|
|
# Prepend sources with current source directory
|
|
function(prepend_sources SOURCE_FILES)
|
|
foreach(SOURCE_FILE ${${SOURCE_FILES}})
|
|
set(MODIFIED ${MODIFIED} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE})
|
|
endforeach()
|
|
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")
|
|
set(SRB2_SYSTEM_BITS 64)
|
|
else()
|
|
set(SRB2_SYSTEM_BITS 32)
|
|
endif()
|
|
|
|
if(MSVC)
|
|
message(WARNING "!! MSVC BUILDS OF SRB2 CANNOT PLAY MULTIPLAYER !! You're more than welcome to try and fix this!")
|
|
endif()
|
|
|
|
# OS macros
|
|
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()
|
|
|
|
# Set EXE names so the assets CMakeLists can refer to its target
|
|
set(SRB2_SDL2_EXE_NAME srb2)
|
|
set(SRB2_WIN_EXE_NAME srb2dd)
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
|
|
|
|
add_subdirectory(src)
|
|
add_subdirectory(assets)
|
|
|
|
|
|
## config.h generation
|
|
set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary")
|
|
include(GitUtilities)
|
|
git_describe(SRB2_COMP_REVISION "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
|
|
|
|
|
|
|
|
##### PACKAGE CONFIGURATION #####
|
|
|
|
if(${CMAKE_SYSTEM} MATCHES "Windows")
|
|
set(CPACK_GENERATOR "ZIP")
|
|
endif()
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2")
|
|
set(CPACK_PACKAGE_VENDOR "Sonic Team Jr.")
|
|
#set(CPACK_PACKAGE_DESCRIPTION_FILE )
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR})
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR})
|
|
set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH})
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}")
|
|
include(CPack)
|