1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-25 17:53:47 +00:00
Aquaria/CMakeLists.txt

217 lines
7.7 KiB
Text
Raw Normal View History

CMAKE_MINIMUM_REQUIRED(VERSION 2.6...3.20)
PROJECT(Aquaria)
2023-11-19 18:59:06 +00:00
SET(CMAKE_CXX_STANDARD 98)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
INCLUDE(CheckCCompilerFlag)
2017-01-14 12:09:12 +00:00
INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckFunctionExists)
# if no build type was provided, set a default one
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug, RelWithDebInfo, Release)" FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
# System fixups
2012-09-23 03:31:29 +00:00
IF(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
SET(HAIKU TRUE)
ENDIF()
IF(APPLE)
SET(MACOSX TRUE)
ENDIF(APPLE)
# Recommended compiler flags that cmake doesn't set automatically
if(MSVC)
# /MP: parallel builds
# /GS-: disable security cookie (emits calls into vcrt)
# /Oi: enable intrinsic functions
# /fp:fast: -ffast-math
set(AQUARIA_EXTRA_COMPILE_FLAGS "/MP /GS- /Oi /fp:fast" CACHE STRING "Extra compiler flags for MSVC")
option(AQUARIA_MSVC_DEBUG_EDIT_AND_CONTINUE "MSVC: Enable edit+continue for debug builds?" TRUE)
if(AQUARIA_MSVC_DEBUG_EDIT_AND_CONTINUE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set(AQUARIA_EXTRA_COMPILE_FLAGS "-ffast-math" CACHE STRING "Extra compiler flags for GCC/Clang")
else()
set(AQUARIA_EXTRA_COMPILE_FLAGS "" CACHE STRING "Extra compiler flags")
endif()
if(AQUARIA_EXTRA_COMPILE_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AQUARIA_EXTRA_COMPILE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AQUARIA_EXTRA_COMPILE_FLAGS}")
endif()
2013-06-19 15:44:37 +00:00
OPTION(AQUARIA_DEMO_BUILD "Demo Build?" FALSE)
[vfs, #3] All file reading code goes through the VFS now, new mod downloader & mod selector in place. Also a bunch of other stuff. (...) - HTTP networking support, mods can be downloaded via the builtin downloader. All network activity runs in a seperate thread, which is started as soon as any network activity is requested. - The master server is hard-coded to fg.wzff.de/aqmods/ if not specified otherwise; this setting can be overridden in the config file. - The mod selector screen is now a grid-view for much better navigation; also works with joystick. - VFS code is functionally similar to the old molebox-packed release for win32. The game could also have its data shipped in a Zip file or any other kind of archive. - It is still possible to build without VFS support, but then the mod downloader and soft-patching will not be available. The full commit history can be found here: https://github.com/fgenesis/Aquaria_clean/compare/master...vfs The most important commit messages follow: [...] This replaces all std::ifstream with InStream, and fopen(), ... with vfopen(), ... Some code is #ifdef'd for better performance and less memory-copying. VFILE is defined to whatever type of file is in use: - FILE if BBGE_BUILD_VFS is not defined - tttvfs::VFSFile if it is. Other changes: - [un]packFile() is now unused and obsolete. That code has not been adjusted to use VFILE. - glpng can now load from a memory buffer. - TinyXML uses the VFS for reading operations now. - The rather clunky binary stream loading of glfont2 got replaced with ByteBuffer, which gets its data in one block (necessary to use the VFS without implementing a somewhat STL-compliant std::ifstream replacement.) ------------- Implement loading mods from zip files. ------------- Implement soft-patching game data files. (Replacing textures/audio/... on the fly) ------------- Misc bits: - Extended GUI focus handling a bit - Fixed weirdness in texture loading... not sure but this seems more correct to me. Actually, considering that the texture will have its native size after restarting the game, the lines removed with this commit seem pretty useless.
2012-06-01 15:52:19 +00:00
OPTION(AQUARIA_USE_VFS "Use Virtual File System? Required for some additional features." TRUE)
2016-08-06 18:03:51 +00:00
OPTION(AQUARIA_USE_SDL2 "Use SDL2" TRUE)
OPTION(AQUARIA_USE_GLM "Use GLM for matrix math" TRUE)
OPTION(AQUARIA_DEBUG_SHOW_PATHS "Show important paths upon game start to aid in finding path problems" FALSE)
mark_as_advanced(AQUARIA_DEBUG_SHOW_PATHS)
#add_compile_options(-fsanitize=address)
#add_link_options(-fsanitize=address)
################ Look for external libraries
### Pick one: SDL 1.2 or SDL2
if(AQUARIA_USE_SDL2)
find_package(SDL2 REQUIRED)
if(SDL2_FOUND)
set(SDL_FOUND TRUE)
set(SDL_INCLUDE_DIR ${SDL2_INCLUDE_DIR})
set(SDL_LIBRARY ${SDL2_LIBRARY})
endif(SDL2_FOUND)
else()
find_package(SDL REQUIRED)
endif()
SET(BBGEDIR ${CMAKE_CURRENT_SOURCE_DIR}/BBGE)
SET(EXTLIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/ExternalLibs)
2015-09-17 22:55:50 +00:00
################ End of external libraries
# Custom build ID: e.g. "-custom", " (my very own build)"
SET(AQUARIA_CUSTOM_BUILD_ID "" CACHE STRING
"Text to append to the Aquaria version ID on the title screen.")
if (NOT(AQUARIA_CUSTOM_BUILD_ID STREQUAL ""))
ADD_DEFINITIONS("-DAQUARIA_CUSTOM_BUILD_ID=\"${AQUARIA_CUSTOM_BUILD_ID}\"")
endif (NOT(AQUARIA_CUSTOM_BUILD_ID STREQUAL ""))
# Custom version string override (displayed as-is instead of "Aquaria vx.x.x ..." on the title screen
SET(AQUARIA_OVERRIDE_VERSION_STRING "" CACHE STRING
"Text to display instead of the Aquaria version ID on the title screen. (Overrides AQUARIA_CUSTOM_BUILD_ID as well)")
if (NOT(AQUARIA_OVERRIDE_VERSION_STRING STREQUAL ""))
2013-06-26 13:15:00 +00:00
ADD_DEFINITIONS("-DAQUARIA_OVERRIDE_VERSION_STRING=\"${AQUARIA_OVERRIDE_VERSION_STRING}\"")
endif (NOT(AQUARIA_OVERRIDE_VERSION_STRING STREQUAL ""))
# Custom data directories
SET(AQUARIA_DEFAULT_DATA_DIR "" CACHE STRING
"Default data directory (for package maintainers only)")
if(NOT(AQUARIA_DEFAULT_DATA_DIR STREQUAL ""))
ADD_DEFINITIONS("-DAQUARIA_DEFAULT_DATA_DIR=\"${AQUARIA_DEFAULT_DATA_DIR}\"")
endif(NOT(AQUARIA_DEFAULT_DATA_DIR STREQUAL ""))
SET(AQUARIA_EXTRA_DATA_DIR "" CACHE STRING
"Extra data directory, overrides files from default datadir (for package maintainers only)")
if(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL ""))
ADD_DEFINITIONS("-DAQUARIA_EXTRA_DATA_DIR=\"${AQUARIA_EXTRA_DATA_DIR}\"")
endif(NOT(AQUARIA_EXTRA_DATA_DIR STREQUAL ""))
if(AQUARIA_DEBUG_SHOW_PATHS)
ADD_DEFINITIONS(-DAQUARIA_DEBUG_SHOW_PATHS)
endif(AQUARIA_DEBUG_SHOW_PATHS)
# Without #define VFS_ENABLE_C_API this is just stubbed out
include_directories(ttvfs_cfileapi)
if(AQUARIA_USE_VFS)
ADD_DEFINITIONS(-DVFS_ENABLE_C_API=1)
ADD_DEFINITIONS(-DBBGE_BUILD_VFS=1)
INCLUDE_DIRECTORIES(${EXTLIBDIR}/ttvfs)
INCLUDE_DIRECTORIES(${EXTLIBDIR}/ttvfs_zip)
INCLUDE_DIRECTORIES(${EXTLIBDIR}/ttvfs_cfileapi)
[vfs, #3] All file reading code goes through the VFS now, new mod downloader & mod selector in place. Also a bunch of other stuff. (...) - HTTP networking support, mods can be downloaded via the builtin downloader. All network activity runs in a seperate thread, which is started as soon as any network activity is requested. - The master server is hard-coded to fg.wzff.de/aqmods/ if not specified otherwise; this setting can be overridden in the config file. - The mod selector screen is now a grid-view for much better navigation; also works with joystick. - VFS code is functionally similar to the old molebox-packed release for win32. The game could also have its data shipped in a Zip file or any other kind of archive. - It is still possible to build without VFS support, but then the mod downloader and soft-patching will not be available. The full commit history can be found here: https://github.com/fgenesis/Aquaria_clean/compare/master...vfs The most important commit messages follow: [...] This replaces all std::ifstream with InStream, and fopen(), ... with vfopen(), ... Some code is #ifdef'd for better performance and less memory-copying. VFILE is defined to whatever type of file is in use: - FILE if BBGE_BUILD_VFS is not defined - tttvfs::VFSFile if it is. Other changes: - [un]packFile() is now unused and obsolete. That code has not been adjusted to use VFILE. - glpng can now load from a memory buffer. - TinyXML uses the VFS for reading operations now. - The rather clunky binary stream loading of glfont2 got replaced with ByteBuffer, which gets its data in one block (necessary to use the VFS without implementing a somewhat STL-compliant std::ifstream replacement.) ------------- Implement loading mods from zip files. ------------- Implement soft-patching game data files. (Replacing textures/audio/... on the fly) ------------- Misc bits: - Extended GUI focus handling a bit - Fixed weirdness in texture loading... not sure but this seems more correct to me. Actually, considering that the texture will have its native size after restarting the game, the lines removed with this commit seem pretty useless.
2012-06-01 15:52:19 +00:00
ENDIF(AQUARIA_USE_VFS)
IF(AQUARIA_USE_GLM)
ADD_DEFINITIONS(-DBBGE_USE_GLM=1)
ENDIF(AQUARIA_USE_GLM)
if(AQUARIA_INTERNAL_FTGL)
ADD_DEFINITIONS(-DAQUARIA_INTERNAL_FTGL=1)
endif()
if(AQUARIA_INTERNAL_LUA)
ADD_DEFINITIONS(-DAQUARIA_INTERNAL_LUA=1)
endif()
IF(AQUARIA_DEMO_BUILD)
message(STATUS "Demo build.")
ADD_DEFINITIONS(-DAQUARIA_DEMO=1)
ELSE(AQUARIA_DEMO_BUILD)
ADD_DEFINITIONS(-DAQUARIA_BUILD_CONSOLE=1)
ADD_DEFINITIONS(-DAQUARIA_BUILD_SCENEEDITOR=1)
ENDIF(AQUARIA_DEMO_BUILD)
IF(NOT MSVC)
# MSVC defines these in release mode by default, gcc/mingw do not
IF(CMAKE_BUILD_TYPE STREQUAL "Release")
ADD_DEFINITIONS(-DNDEBUG)
message(STATUS "This is a release build.")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release")
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS(-D_DEBUG)
message(STATUS "This is a debug build.")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ENDIF(NOT MSVC)
# FIXME: These should go
IF(UNIX)
ADD_DEFINITIONS(-DBBGE_BUILD_UNIX=1)
ENDIF(UNIX)
IF(MACOSX)
ADD_DEFINITIONS(-DBBGE_BUILD_MACOSX=1)
ENDIF(MACOSX)
IF(WIN32)
ADD_DEFINITIONS(-DBBGE_BUILD_WINDOWS=1)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(WIN32)
IF(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -pipe -fsigned-char")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -pipe -fsigned-char -std=gnu99")
# See if -fno-stack-protector is available to us.
# It doesn't seem to work well, and it adds bulk to the binary.
CHECK_C_COMPILER_FLAG("-fno-stack-protector" AQUARIA_GCC_HAS_STACKPROT)
IF(AQUARIA_GCC_HAS_STACKPROT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
ENDIF(AQUARIA_GCC_HAS_STACKPROT)
# !!! FIXME: probably not safe long-term.
# CMake mailing list had this hack for getting rid of -rdynamic:
# http://public.kitware.com/pipermail/cmake/2006-July/010404.html
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
IF(HAVE_STRCASECMP)
ADD_DEFINITIONS(-DHAVE_STRCASECMP)
ENDIF(HAVE_STRCASECMP)
add_subdirectory(ExternalLibs)
[vfs, #3] All file reading code goes through the VFS now, new mod downloader & mod selector in place. Also a bunch of other stuff. (...) - HTTP networking support, mods can be downloaded via the builtin downloader. All network activity runs in a seperate thread, which is started as soon as any network activity is requested. - The master server is hard-coded to fg.wzff.de/aqmods/ if not specified otherwise; this setting can be overridden in the config file. - The mod selector screen is now a grid-view for much better navigation; also works with joystick. - VFS code is functionally similar to the old molebox-packed release for win32. The game could also have its data shipped in a Zip file or any other kind of archive. - It is still possible to build without VFS support, but then the mod downloader and soft-patching will not be available. The full commit history can be found here: https://github.com/fgenesis/Aquaria_clean/compare/master...vfs The most important commit messages follow: [...] This replaces all std::ifstream with InStream, and fopen(), ... with vfopen(), ... Some code is #ifdef'd for better performance and less memory-copying. VFILE is defined to whatever type of file is in use: - FILE if BBGE_BUILD_VFS is not defined - tttvfs::VFSFile if it is. Other changes: - [un]packFile() is now unused and obsolete. That code has not been adjusted to use VFILE. - glpng can now load from a memory buffer. - TinyXML uses the VFS for reading operations now. - The rather clunky binary stream loading of glfont2 got replaced with ByteBuffer, which gets its data in one block (necessary to use the VFS without implementing a somewhat STL-compliant std::ifstream replacement.) ------------- Implement loading mods from zip files. ------------- Implement soft-patching game data files. (Replacing textures/audio/... on the fly) ------------- Misc bits: - Extended GUI focus handling a bit - Fixed weirdness in texture loading... not sure but this seems more correct to me. Actually, considering that the texture will have its native size after restarting the game, the lines removed with this commit seem pretty useless.
2012-06-01 15:52:19 +00:00
# Set external libs as deps for BBGE & Aquaria...
INCLUDE_DIRECTORIES(${BBGEDIR})
message(STATUS "FTGL_INCLUDE_DIRS: ${FTGL_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(${FTGL_INCLUDE_DIRS})
message(STATUS "LUA_INCLUDE_DIR: ${LUA_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
message(STATUS "OGGVORBIS_INCLUDE_DIRS: ${OGGVORBIS_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIRS})
message(STATUS "SDL_INCLUDE_DIR: ${SDL_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
message(STATUS "OPENAL_INCLUDE_DIR: ${OPENAL_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
message(STATUS "TINYXML2_INCLUDE_DIRS: ${TINYXML2_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(${TINYXML2_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${EXTLIBDIR})
2018-01-02 14:31:47 +00:00
add_subdirectory(Aquaria)
add_subdirectory(BBGE)