2024-03-07 03:31:25 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2023-06-20 12:34:24 +00:00
|
|
|
|
|
|
|
# Find CCache
|
2024-03-07 03:16:30 +00:00
|
|
|
find_program(CCACHE_PATH ccache)
|
|
|
|
if(CCACHE_PATH)
|
|
|
|
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PATH}")
|
|
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PATH}")
|
|
|
|
message(STATUS "Using CCache")
|
|
|
|
else()
|
|
|
|
message(STATUS "Not using CCache")
|
|
|
|
endif()
|
|
|
|
|
2024-03-07 03:31:25 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
project(starbound)
|
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../cmake)
|
|
|
|
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES Debug RelWithAsserts RelWithDebInfo Release)
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_RELWITHASSERTS "" CACHE STRING "" FORCE)
|
2023-06-20 04:33:09 +00:00
|
|
|
# Update the docstring on CMAKE_BUILD_TYPE to show what options we actually
|
2024-03-07 03:31:25 +00:00
|
|
|
# allow
|
|
|
|
# SET (CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Choose the type of build, options are: Debug RelWithAsserts RelWithDebInfo Release" FORCE)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Discover all the relevant environment / system information and place the
|
|
|
|
# result in STAR_* cmake variables.
|
|
|
|
|
|
|
|
# STAR_SOURCE_IDENTIFIER may be set to any string value
|
2024-03-07 03:16:30 +00:00
|
|
|
if(NOT DEFINED STAR_SOURCE_IDENTIFIER)
|
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
get_git_head_revision(STAR_GIT_REFSPEC STAR_GIT_HASHVAR)
|
|
|
|
set(STAR_SOURCE_IDENTIFIER "${STAR_GIT_HASHVAR}")
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Architecture identifier, like i386, x86_64 or ppc
|
2024-03-07 03:16:30 +00:00
|
|
|
if(NOT DEFINED STAR_ARCHITECTURE)
|
|
|
|
include(TargetArch)
|
|
|
|
target_architecture(STAR_ARCHITECTURE)
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Either TRUE or FALSE
|
2024-03-07 03:16:30 +00:00
|
|
|
if(NOT DEFINED STAR_LITTLE_ENDIAN)
|
|
|
|
include(TestBigEndian)
|
|
|
|
test_big_endian(BIGENDIAN)
|
|
|
|
if(NOT BIGENDIAN)
|
|
|
|
set(STAR_LITTLE_ENDIAN TRUE)
|
|
|
|
else()
|
|
|
|
set(STAR_LITTLE_ENDIAN FALSE)
|
|
|
|
endif()
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# System name, like windows, macos, linux, freebsd, or (generic) unix
|
2024-03-07 03:16:30 +00:00
|
|
|
if(NOT DEFINED STAR_SYSTEM)
|
|
|
|
if(WIN32)
|
|
|
|
set(STAR_SYSTEM "windows")
|
|
|
|
elseif(APPLE AND ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
|
|
|
set(STAR_SYSTEM "macos")
|
|
|
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
|
|
|
set(STAR_SYSTEM "linux")
|
|
|
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
|
|
|
set(STAR_SYSTEM "freebsd")
|
|
|
|
elseif(UNIX)
|
|
|
|
set(STAR_SYSTEM "unix")
|
|
|
|
else()
|
|
|
|
set(STAR_SYSTEM "unknown")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED STAR_SYSTEM_FAMILY)
|
|
|
|
if(WIN32)
|
|
|
|
set(STAR_SYSTEM_FAMILY "windows")
|
|
|
|
elseif(UNIX)
|
|
|
|
set(STAR_SYSTEM_FAMILY "unix")
|
|
|
|
else()
|
|
|
|
set(STAR_SYSTEM_FAMILY "unknown")
|
|
|
|
endif()
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# C/C++ compiler ID, like clang, gnu, or msvc
|
2024-03-07 03:16:30 +00:00
|
|
|
if(NOT DEFINED STAR_COMPILER)
|
|
|
|
if(NOT CMAKE_C_COMPILER_ID STREQUAL CMAKE_CXX_COMPILER_ID)
|
2024-03-07 03:31:25 +00:00
|
|
|
message(FATAL_ERROR "C and C++ compiler id do not match, unsupported build configuration")
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
|
|
set(STAR_COMPILER "clang")
|
|
|
|
elseif(CMAKE_COMPILER_IS_GNUC)
|
|
|
|
set(STAR_COMPILER "gnu")
|
|
|
|
elseif(MSVC)
|
|
|
|
set(STAR_COMPILER "msvc")
|
|
|
|
else()
|
|
|
|
string(TOLOWER "${CMAKE_C_COMPILER_ID}" STAR_COMPILER)
|
|
|
|
endif()
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Enable OPTIONs based on the discovered system / environment...
|
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_COMPILER STREQUAL "gnu")
|
2024-03-07 03:31:25 +00:00
|
|
|
option(STAR_ENABLE_STATIC_LIBGCC_LIBSTDCXX "Statically link libgcc and libstdc++" OFF)
|
|
|
|
option(STAR_ENABLE_GCC_PROFILING "Enable gcc/g++ profiling via the -pg flag" OFF)
|
2024-03-07 03:16:30 +00:00
|
|
|
option(STAR_ENABLE_GLIBCXX_DEBUG "Enable _GLIBCXX_DEBUG for g++" OFF)
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_COMPILER STREQUAL "msvc")
|
|
|
|
option(STAR_ENABLE_STATIC_MSVC_RUNTIME "Statically link with the CRT" OFF)
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
option(STAR_BUILD_GUI "Build GUI utilities and Client" ON)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_BUILD_GUI)
|
|
|
|
option(STAR_BUILD_QT_TOOLS "Build GUI utilities that require Qt" OFF)
|
|
|
|
option(STAR_ENABLE_STEAM_INTEGRATION "Use Steam platform services" OFF)
|
|
|
|
option(STAR_ENABLE_DISCORD_INTEGRATION "Use Discord platform services" OFF)
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
option(STAR_LUA_APICHECK "Use lua api checks" OFF)
|
|
|
|
option(STAR_USE_JEMALLOC "Use jemalloc allocators" OFF)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Report all the discovered system / environment settings and all options.
|
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
message(STATUS "Source ID: ${STAR_SOURCE_IDENTIFIER}")
|
|
|
|
message(STATUS "Architecture: ${STAR_ARCHITECTURE}")
|
|
|
|
message(STATUS "Little Endian: ${STAR_LITTLE_ENDIAN}")
|
|
|
|
message(STATUS "System: ${STAR_SYSTEM}")
|
|
|
|
message(STATUS "System family: ${STAR_SYSTEM_FAMILY}")
|
|
|
|
message(STATUS "C/C++ compiler: ${STAR_COMPILER}")
|
|
|
|
|
|
|
|
if(DEFINED STAR_ENABLE_STATIC_LIBGCC_LIBSTDCXX)
|
2024-03-07 03:31:25 +00:00
|
|
|
message(STATUS "Statically linking to libgcc / libstdc++: ${STAR_ENABLE_STATIC_LIBGCC_LIBSTDCXX}")
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(DEFINED STAR_ENABLE_STATIC_MSVC_RUNTIME)
|
2024-03-07 03:31:25 +00:00
|
|
|
message(STATUS "Statically linking to CRT: ${STAR_ENABLE_STATIC_MSVC_RUNTIME}")
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(DEFINED STAR_ENABLE_GLIBCXX_DEBUG)
|
|
|
|
message(STATUS "Enabling _GLIBCXX_DEBUG: ${STAR_ENABLE_GLIBCXX_DEBUG}")
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
message(STATUS "Building GUI: ${STAR_BUILD_GUI}")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(DEFINED STAR_BUILD_QT_TOOLS)
|
|
|
|
message(STATUS "Building Qt tools: ${STAR_BUILD_QT_TOOLS}")
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(DEFINED STAR_ENABLE_STEAM_INTEGRATION)
|
2024-03-07 03:31:25 +00:00
|
|
|
message(STATUS "Using Steam platform services: ${STAR_ENABLE_STEAM_INTEGRATION}")
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(DEFINED STAR_ENABLE_DISCORD_INTEGRATION)
|
2024-03-07 03:31:25 +00:00
|
|
|
message(STATUS "Using Discord platform services: ${STAR_ENABLE_DISCORD_INTEGRATION}")
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
message(STATUS "Using Lua API checks: ${STAR_LUA_APICHECK}")
|
|
|
|
message(STATUS "Using jemalloc: ${STAR_USE_JEMALLOC}")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Set C defines and cmake variables based on the build settings we have now
|
|
|
|
# determined...
|
|
|
|
|
|
|
|
# Set a cmake variable to true and define a corresponding C/C++ definition
|
2024-03-07 03:16:30 +00:00
|
|
|
function(SET_FLAG flagValue)
|
2024-03-07 03:31:25 +00:00
|
|
|
set(${flagValue} TRUE PARENT_SCOPE)
|
2024-03-07 03:16:30 +00:00
|
|
|
add_definitions(-D${flagValue})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if(STAR_LITTLE_ENDIAN)
|
|
|
|
set_flag(STAR_LITTLE_ENDIAN)
|
|
|
|
elseif()
|
|
|
|
set_flag(STAR_BIG_ENDIAN)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_ARCHITECTURE STREQUAL "i386")
|
|
|
|
set_flag(STAR_ARCHITECTURE_I386)
|
|
|
|
elseif(STAR_ARCHITECTURE STREQUAL "x86_64")
|
|
|
|
set_flag(STAR_ARCHITECTURE_X86_64)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_SYSTEM STREQUAL "windows")
|
|
|
|
set_flag(STAR_SYSTEM_WINDOWS)
|
|
|
|
elseif(STAR_SYSTEM STREQUAL "macos")
|
|
|
|
set_flag(STAR_SYSTEM_MACOS)
|
|
|
|
elseif(STAR_SYSTEM STREQUAL "linux")
|
|
|
|
set_flag(STAR_SYSTEM_LINUX)
|
|
|
|
elseif(STAR_SYSTEM STREQUAL "freebsd")
|
|
|
|
set_flag(STAR_SYSTEM_FREEBSD)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_SYSTEM_FAMILY STREQUAL "windows")
|
|
|
|
set_flag(STAR_SYSTEM_FAMILY_WINDOWS)
|
|
|
|
elseif(STAR_SYSTEM_FAMILY STREQUAL "unix")
|
|
|
|
set_flag(STAR_SYSTEM_FAMILY_UNIX)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_COMPILER STREQUAL "gnu")
|
|
|
|
set_flag(STAR_COMPILER_GNU)
|
|
|
|
elseif(STAR_COMPILER STREQUAL "clang")
|
|
|
|
set_flag(STAR_COMPILER_CLANG)
|
|
|
|
elseif(STAR_COMPILER STREQUAL "msvc")
|
|
|
|
set_flag(STAR_COMPILER_MSVC)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_LUA_APICHECK)
|
|
|
|
add_definitions(-DLUA_USE_APICHECK)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_SYSTEM_WINDOWS)
|
2023-06-20 04:33:09 +00:00
|
|
|
# LUA_USE_WINDOWS is automatically defined in luaconf if _WIN32 is defined
|
2024-03-07 03:16:30 +00:00
|
|
|
elseif(STAR_SYSTEM_MACOS)
|
|
|
|
add_definitions(-DLUA_USE_MACOSX)
|
|
|
|
elseif(STAR_SYSTEM_LINUX)
|
|
|
|
add_definitions(-DLUA_USE_LINUX)
|
|
|
|
elseif(STAR_SYSTEM_FAMILY_UNIX)
|
|
|
|
add_definitions(-DLUA_USE_POSIX)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_ENABLE_STEAM_INTEGRATION)
|
|
|
|
add_definitions(-DSTAR_ENABLE_STEAM_INTEGRATION)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_ENABLE_DISCORD_INTEGRATION)
|
|
|
|
add_definitions(-DSTAR_ENABLE_DISCORD_INTEGRATION)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_USE_JEMALLOC)
|
|
|
|
add_definitions(-DSTAR_USE_JEMALLOC)
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Set C/C++ compiler flags based on build environment...
|
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_COMPILER_GNU)
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic -Wall -Wextra -Wno-unused -Wno-implicit-fallthrough -no-pie")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -rdynamic -Wall -Wextra -Wno-unused -Wno-implicit-fallthrough -no-pie")
|
2024-03-07 03:16:30 +00:00
|
|
|
|
|
|
|
if(STAR_SYSTEM_FAMILY_WINDOWS)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthreads")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads")
|
|
|
|
else()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -D_REENTRANT")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -D_REENTRANT")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_ENABLE_STATIC_LIBGCC_LIBSTDCXX)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_ENABLE_GCC_PROFILING)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -Og")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -Og")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHASSERTS "-g -Ofast")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHASSERTS "-g -Ofast")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -Ofast")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -Ofast")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -Ofast")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Ofast")
|
|
|
|
|
|
|
|
elseif(STAR_COMPILER_CLANG)
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wuninitialized -Wno-parentheses-equality -Wno-deprecated-declarations")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Wuninitialized -Wno-parentheses-equality -Wno-deprecated-declarations")
|
2024-03-07 03:16:30 +00:00
|
|
|
|
|
|
|
if(STAR_SYSTEM_MACOS)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export_dynamic")
|
2024-03-07 03:16:30 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-export_dynamic")
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17")
|
|
|
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
|
|
|
elseif()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -D_REENTRANT")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -D_REENTRANT")
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export_dynamic")
|
2024-03-07 03:16:30 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export_dynamic")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHASSERTS "-g -Ofast")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHASSERTS "-g -Ofast")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -Ofast")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -Ofast")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -Ofast")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Ofast")
|
|
|
|
|
|
|
|
elseif(STAR_COMPILER_MSVC)
|
2024-03-07 03:31:25 +00:00
|
|
|
# /MP - Multi-processor building
|
|
|
|
# /EHsc - Enable normal C++ exception handling
|
|
|
|
# /bigobj - More sections in .obj files (Cannot build in Debug without it)
|
|
|
|
# /MT - Use multi-threaded statically linked C runtime library
|
|
|
|
# /GA - Optimize for windows application
|
|
|
|
# /Ox - Full optimization
|
|
|
|
# /fp:fast - Equivalent to -ffast-math
|
|
|
|
# /GS- - Disable buffers security check
|
|
|
|
# /Zi - Generates debugging information without Edit and Continue
|
|
|
|
# /Gy - Use function-level linking
|
|
|
|
# /wd4996 - Disable warnings about unsafe C functions
|
|
|
|
# /wd4351 - Disable warnings about new behavior of default initialization of
|
|
|
|
# arrays (which is the correct behavior anyway)
|
2023-06-20 04:33:09 +00:00
|
|
|
# /wd4800 - Disable warnings about using non-bool as true or false (useless
|
2024-03-07 03:31:25 +00:00
|
|
|
# performance warning)
|
|
|
|
# /wd4244 - Disable warnings about type conversion loss of data, it's a nice
|
|
|
|
# warning, but it triggers on lots and lots of harmless things that no
|
|
|
|
# other compiler warns about, like passing an int as a float parameter
|
|
|
|
# /wd4305 - Disable warnings about truncation from double to float
|
|
|
|
# /wd4267 - Disable warnings about 64 - 32 bit truncation
|
|
|
|
# /wd4456 - Disable warnings about hiding previous local declaration
|
|
|
|
# /wd4503 - Silence warnings about MSVC generating a name so long it has to
|
|
|
|
# truncate it
|
|
|
|
# /wd4250 - Silence "XX inherits YY via dominance"
|
|
|
|
# /wd4624 - Silence implicitly deleted destructor warnings that show up when
|
|
|
|
# using unions in interesting ways.
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /EHsc /bigobj /wd4996 /wd4351 /wd4800 /wd4244 /wd4305 /wd4267 /wd4456 /wd4503 /wd4250 /wd4624")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /MP /EHsc /bigobj /wd4996 /wd4351 /wd4800 /wd4244 /wd4305 /wd4267 /wd4456 /wd4503 /wd4250 /wd4624")
|
2024-03-07 03:16:30 +00:00
|
|
|
|
|
|
|
if(STAR_ENABLE_STATIC_MSVC_RUNTIME)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "/Zi /Od")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "/Zi /Od")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHASSERTS "/Ox /fp:fast /GA /GS- /Zi /Gy")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHASSERTS "/Ox /fp:fast /GA /GS- /Zi /Gy")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Ox /fp:fast /GA /GS- /Zi /Gy /DNDEBUG")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Ox /fp:fast /GA /GS- /Zi /Gy /DNDEBUG")
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "/Ox /fp:fast /GA /GS- /Gy /DNDEBUG")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "/Ox /fp:fast /GA /GS- /Gy /DNDEBUG")
|
|
|
|
|
|
|
|
if(STAR_ARCHITECTURE_I386)
|
2023-06-20 04:33:09 +00:00
|
|
|
# Assume all 32 bit target cpus support MMX, SSE, and SSE2
|
|
|
|
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELWITHASSERTS "${CMAKE_C_FLAGS_RELWITHASSERTS} /arch:SSE2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHASSERTS "${CMAKE_CXX_FLAGS_RELWITHASSERTS} /arch:SSE2")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /arch:SSE2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /arch:SSE2")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /arch:SSE2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:SSE2")
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
add_definitions(/DUNICODE)
|
|
|
|
add_definitions(/D_UNICODE)
|
|
|
|
add_definitions(/DNOMINMAX)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pthread -D_REENTRANT")
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -pthread -D_REENTRANT")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELWITHASSERTS "-g -O2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHASSERTS "-g -O2")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-DNDEBUG -g -O2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-DNDEBUG -g -O2")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELEASE "$-DNDEBUG -O2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Set other global build settings based on environment...
|
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_SYSTEM_MACOS)
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "-flat_namespace -undefined suppress")
|
|
|
|
elseif(STAR_SYSTEM_WINDOWS)
|
|
|
|
set(CMAKE_RC_COMPILER_INIT windres)
|
|
|
|
|
|
|
|
enable_language(RC)
|
|
|
|
if(STAR_COMPILER STREQUAL "msvc")
|
|
|
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> /fo <OBJECT> <SOURCE>")
|
|
|
|
else()
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(STAR_COMPILER STREQUAL "msvc")
|
2024-03-07 03:31:25 +00:00
|
|
|
# /largeaddressaware - Make 32 bit build able to use 3GB addresses
|
|
|
|
# /OPT:REF - Eliminates functions and data that are never referenced
|
|
|
|
# /OPT:ICF - Performs identical COMDAT folding
|
|
|
|
# /PDBCompress - Hint to windows that it should compress the resulting PDB files
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /largeaddressaware /OPT:REF /OPT:ICF /PDBCompress")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Make sure RelWithAsserts has debugging enabled
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_RELWITHASSERTS "${CMAKE_EXE_LINKER_FLAGS_RELWITHASSERTS} /DEBUG")
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_SYSTEM_WINDOWS)
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} ws2_32.lib iphlpapi.lib shlwapi.lib dbghelp.lib")
|
|
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} ws2_32.lib iphlpapi.lib shlwapi.lib dbghelp.lib")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
elseif(STAR_SYSTEM_LINUX)
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lpthread -ldl -lrt")
|
|
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lpthread -ldl -lrt")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
elseif(STAR_SYSTEM_FREEBSD)
|
|
|
|
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lpthread -lrt")
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lpthread -lrt")
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Find all required external libraries, based on build settings...
|
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_USE_JEMALLOC)
|
2023-06-20 04:33:09 +00:00
|
|
|
# Assumes jemalloc was configured with a "je_" function prefix
|
2024-03-07 03:16:30 +00:00
|
|
|
find_package(JeMalloc REQUIRED)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIR})
|
|
|
|
set(STAR_EXT_LIBS ${JEMALLOC_LIBRARY})
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
find_package(PNG REQUIRED)
|
|
|
|
find_package(Freetype REQUIRED)
|
|
|
|
find_package(OggVorbis REQUIRED)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:31:25 +00:00
|
|
|
include_directories(SYSTEM
|
|
|
|
${FREETYPE_INCLUDE_DIRS}
|
|
|
|
${OGGVORBIS_INCLUDE_DIR}
|
|
|
|
)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(TARGET freetype AND NOT TARGET Freetype::Freetype)
|
2024-02-20 06:39:16 +00:00
|
|
|
add_library(Freetype::Freetype ALIAS freetype)
|
2024-03-07 03:16:30 +00:00
|
|
|
message(STATUS "Freetype target name is freetype")
|
|
|
|
elseif(TARGET Freetype::Freetype AND NOT TARGET freetype)
|
2024-02-20 06:39:16 +00:00
|
|
|
add_library(freetype ALIAS Freetype::Freetype)
|
2024-03-07 03:16:30 +00:00
|
|
|
message(STATUS "Freetype target name is Freetype::Freetype")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Could not find Freetype")
|
|
|
|
endif()
|
2024-02-20 06:39:16 +00:00
|
|
|
|
2024-03-07 03:31:25 +00:00
|
|
|
set(STAR_EXT_LIBS ${STAR_EXT_LIBS}
|
2024-02-20 05:59:47 +00:00
|
|
|
ZLIB::ZLIB
|
|
|
|
PNG::PNG
|
|
|
|
Freetype::Freetype
|
2024-02-22 05:46:45 +00:00
|
|
|
${VORBISFILE_LIBRARY}
|
|
|
|
${VORBIS_LIBRARY}
|
|
|
|
${OGG_LIBRARY}
|
2024-02-20 05:59:47 +00:00
|
|
|
opus # Currently a submodule from extern
|
2024-03-07 03:16:30 +00:00
|
|
|
)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_BUILD_GUI)
|
|
|
|
find_package(SDL2 REQUIRED)
|
|
|
|
include_directories(SYSTEM ${SDL2_INCLUDE_DIR})
|
|
|
|
set(STAR_EXT_GUI_LIBS ${SDL2_LIBRARY})
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
find_package(GLEW REQUIRED)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
include_directories(SYSTEM ${GLEW_INCLUDE_DIR} ${SDL2_INCLUDE_DIR})
|
|
|
|
set(STAR_EXT_GUI_LIBS ${STAR_EXT_GUI_LIBS} ${OPENGL_LIBRARY} ${GLEW_LIBRARY})
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_ENABLE_STEAM_INTEGRATION)
|
|
|
|
find_package(SteamApi REQUIRED)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
include_directories(SYSTEM ${STEAM_API_INCLUDE_DIR})
|
|
|
|
set(STAR_EXT_GUI_LIBS ${STAR_EXT_GUI_LIBS} ${STEAM_API_LIBRARY})
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_ENABLE_DISCORD_INTEGRATION)
|
|
|
|
find_package(DiscordApi REQUIRED)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
include_directories(SYSTEM ${DISCORD_API_INCLUDE_DIR})
|
|
|
|
set(STAR_EXT_GUI_LIBS ${STAR_EXT_GUI_LIBS} ${DISCORD_API_LIBRARY})
|
|
|
|
endif()
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Set basic build flags, include all the relevant source directories, based on
|
|
|
|
# build settings...
|
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
set(BUILD_SHARED_LIBS false)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# First set output dir for the generic no-config case (e.g. macos / linux)
|
2024-03-07 03:16:30 +00:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../dist)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Second, set output dir for multi-config builds (e.g. msvc)
|
2024-03-07 03:16:30 +00:00
|
|
|
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
|
|
|
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
|
2024-03-07 03:31:25 +00:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/../dist)
|
2024-03-07 03:16:30 +00:00
|
|
|
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# External code included with starbound source, which core depends on
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_EXTERN_INCLUDES ${PROJECT_SOURCE_DIR}/extern)
|
|
|
|
add_subdirectory(extern)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Core support code, not specific to starbound.
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_CORE_INCLUDES ${PROJECT_SOURCE_DIR}/core)
|
|
|
|
add_subdirectory(core)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Less general purpose code than core that is available to both the game and
|
|
|
|
# application modules.
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_BASE_INCLUDES ${PROJECT_SOURCE_DIR}/base)
|
|
|
|
add_subdirectory(base)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Platform APIs that are implemented by the application module
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_PLATFORM_INCLUDES ${PROJECT_SOURCE_DIR}/platform)
|
|
|
|
add_subdirectory(platform)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Core game logic used by both server and client.
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_GAME_INCLUDES
|
2024-03-07 03:31:25 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/game
|
|
|
|
${PROJECT_SOURCE_DIR}/game/interfaces
|
|
|
|
${PROJECT_SOURCE_DIR}/game/items
|
|
|
|
${PROJECT_SOURCE_DIR}/game/objects
|
|
|
|
${PROJECT_SOURCE_DIR}/game/scripting
|
2024-03-07 03:43:23 +00:00
|
|
|
${PROJECT_SOURCE_DIR}/game/terrain
|
2024-03-07 03:31:25 +00:00
|
|
|
)
|
2024-03-07 03:16:30 +00:00
|
|
|
add_subdirectory(game)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Googletest based tests
|
2024-03-07 03:16:30 +00:00
|
|
|
option(BUILD_TESTING "Build test projects" OFF)
|
|
|
|
if(BUILD_TESTING)
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Starbound stand-alone server.
|
2024-03-07 03:16:30 +00:00
|
|
|
add_subdirectory(server)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# cmdline utilities
|
2024-03-07 03:16:30 +00:00
|
|
|
add_subdirectory(utility)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_BUILD_GUI)
|
2023-06-20 04:33:09 +00:00
|
|
|
# Handles creating windows, keyboard / mouse / joystick input, and the 2d
|
|
|
|
# rendering model.
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_APPLICATION_INCLUDES ${PROJECT_SOURCE_DIR}/application)
|
|
|
|
add_subdirectory(application)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Rendering code not dependent on widget system
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_RENDERING_INCLUDES ${PROJECT_SOURCE_DIR}/rendering)
|
|
|
|
add_subdirectory(rendering)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Panes and Widgets
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_WINDOWING_INCLUDES ${PROJECT_SOURCE_DIR}/windowing)
|
|
|
|
add_subdirectory(windowing)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Client interface code
|
2024-03-07 03:16:30 +00:00
|
|
|
set(STAR_FRONTEND_INCLUDES ${PROJECT_SOURCE_DIR}/frontend)
|
|
|
|
add_subdirectory(frontend)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Starbound game / client
|
2024-03-07 03:16:30 +00:00
|
|
|
add_subdirectory(client)
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
# Qt GUI tools
|
2024-03-07 03:16:30 +00:00
|
|
|
if(STAR_BUILD_QT_TOOLS)
|
|
|
|
add_subdirectory(json_tool)
|
|
|
|
|
|
|
|
if(STAR_ENABLE_STEAM_INTEGRATION)
|
|
|
|
add_subdirectory(mod_uploader)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|