2022-04-07 00:38:39 +00:00
CMAKE_MINIMUM_REQUIRED(VERSION 2.6...3.20)
2011-08-03 20:05:33 +00:00
PROJECT(Aquaria)
2024-04-15 22:12:56 +00:00
# We don't actually activate this, but the code itself should stay compatible with oldschool C++.
#SET(CMAKE_CXX_STANDARD 98)
2011-08-03 20:05:33 +00:00
2022-04-07 00:38:39 +00:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
2011-08-03 20:05:33 +00:00
INCLUDE(CheckCCompilerFlag)
2017-01-14 12:09:12 +00:00
INCLUDE(CheckCXXCompilerFlag)
2011-08-03 20:05:33 +00:00
INCLUDE(CheckFunctionExists)
2022-04-07 00:38:39 +00:00
# if no build type was provided, set a default one
2024-07-13 23:52:27 +00:00
IF(NOT MSVC)
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)
ENDIF(NOT MSVC)
2011-08-03 20:05:33 +00:00
2022-06-25 01:51:13 +00:00
# System fixups
2012-09-23 03:31:29 +00:00
IF(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
SET(HAIKU TRUE)
ENDIF()
2022-06-25 01:51:13 +00:00
IF(APPLE)
SET(MACOSX TRUE)
ENDIF(APPLE)
2024-04-15 22:12:56 +00:00
if(CMAKE_COMPILER_IS_CLANG OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
set(GCC TRUE)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
set(GCC TRUE)
endif()
set(AQUARIA_WARNING_FLAGS "")
2022-04-08 17:31:16 +00:00
# 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")
2024-04-15 22:12:56 +00:00
2022-05-14 03:14:35 +00:00
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()
2024-04-15 22:12:56 +00:00
elseif(GCC OR CLANG)
set(_FNO_STACK_PROTECTOR "")
# 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(_FNO_STACK_PROTECTOR "-fno-stack-protector")
ENDIF(AQUARIA_GCC_HAS_STACKPROT)
#CHECK_C_COMPILER_FLAG("-Wc++98-compat" AQUARIA_GCC_HAS_WCPP98_COMPAT)
#if(AQUARIA_GCC_HAS_WCPP98_COMPAT)
# set(_WCPP98_COMPAT "-Wc++98-compat")
#endif()
set(AQUARIA_EXTRA_COMPILE_FLAGS "-ffast-math -pipe -fsigned-char ${_FNO_STACK_PROTECTOR}" CACHE STRING "Extra compiler flags for GCC/Clang")
set(AQUARIA_WARNING_FLAGS "-Wall -Wextra ${_WCPP98_COMPAT} -Wno-unused-parameter -Wshadow -Wnon-virtual-dtor -Woverloaded-virtual -Wconversion -Wnull-dereference -Wdouble-promotion")
2022-04-08 17:31:16 +00:00
else()
2024-04-15 22:12:56 +00:00
set(AQUARIA_EXTRA_COMPILE_FLAGS "" CACHE STRING "Extra compiler flags (unknown compiler)")
2022-04-08 17:31:16 +00:00
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
2012-02-10 19:28:35 +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)
2011-08-03 20:05:33 +00:00
2016-08-06 18:03:51 +00:00
OPTION(AQUARIA_USE_SDL2 "Use SDL2" TRUE)
2015-07-12 20:16:55 +00:00
OPTION(AQUARIA_USE_GLM "Use GLM for matrix math" TRUE)
2013-07-18 21:29:55 +00:00
2022-06-20 02:25:18 +00:00
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)
2024-06-27 21:42:45 +00:00
OPTION(AQUARIA_ENABLE_DIR_WATCH "Enable directory watcher component to hot-reload textures in mods. Must be enabled in the game config to be active." TRUE)
2023-12-21 05:05:18 +00:00
#add_compile_options(-fsanitize=address)
#add_link_options(-fsanitize=address)
2011-08-03 20:05:33 +00:00
################ Look for external libraries
2022-04-07 00:38:39 +00:00
### Pick one: SDL 1.2 or SDL2
2011-08-03 20:05:33 +00:00
2022-03-30 20:54:03 +00:00
if(AQUARIA_USE_SDL2)
2022-04-07 00:38:39 +00:00
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)
2022-03-30 20:54:03 +00:00
else()
2022-04-07 00:38:39 +00:00
find_package(SDL REQUIRED)
2022-03-30 20:54:03 +00:00
endif()
2011-08-03 20:05:33 +00:00
2022-04-07 00:38:39 +00:00
SET(BBGEDIR ${CMAKE_CURRENT_SOURCE_DIR}/BBGE)
SET(EXTLIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/ExternalLibs)
2015-09-17 22:55:50 +00:00
2011-08-03 20:05:33 +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 ""))
2013-06-24 01:09:58 +00:00
# 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}\"")
2013-06-24 01:09:58 +00:00
endif (NOT(AQUARIA_OVERRIDE_VERSION_STRING STREQUAL ""))
2013-06-19 00:08:24 +00:00
# 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 ""))
2022-06-20 02:25:18 +00:00
if(AQUARIA_DEBUG_SHOW_PATHS)
ADD_DEFINITIONS(-DAQUARIA_DEBUG_SHOW_PATHS)
endif(AQUARIA_DEBUG_SHOW_PATHS)
2024-06-27 21:42:45 +00:00
if(AQUARIA_ENABLE_DIR_WATCH)
ADD_DEFINITIONS(-DAQUARIA_ENABLE_DIR_WATCH)
endif(AQUARIA_ENABLE_DIR_WATCH)
2022-04-07 00:38:39 +00:00
# Without #define VFS_ENABLE_C_API this is just stubbed out
include_directories(ttvfs_cfileapi)
if(AQUARIA_USE_VFS)
2014-04-07 05:07:31 +00:00
ADD_DEFINITIONS(-DVFS_ENABLE_C_API=1)
2022-04-07 00:38:39 +00:00
ADD_DEFINITIONS(-DBBGE_BUILD_VFS=1)
2014-04-07 00:10:05 +00:00
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)
2012-02-10 19:28:35 +00:00
2015-07-12 20:16:55 +00:00
IF(AQUARIA_USE_GLM)
ADD_DEFINITIONS(-DBBGE_USE_GLM=1)
ENDIF(AQUARIA_USE_GLM)
2022-04-07 00:38:39 +00:00
if(AQUARIA_INTERNAL_FTGL)
ADD_DEFINITIONS(-DAQUARIA_INTERNAL_FTGL=1)
endif()
if(AQUARIA_INTERNAL_LUA)
ADD_DEFINITIONS(-DAQUARIA_INTERNAL_LUA=1)
endif()
2012-02-10 19:28:35 +00:00
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)
2011-08-03 20:05:33 +00:00
2023-12-21 05:05:18 +00:00
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)
2011-08-11 00:26:46 +00:00
2022-04-07 00:38:39 +00:00
# FIXME: These should go
2011-08-03 20:05:33 +00:00
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)
2022-04-07 00:38:39 +00:00
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
2011-08-03 20:05:33 +00:00
ENDIF(WIN32)
CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
IF(HAVE_STRCASECMP)
ADD_DEFINITIONS(-DHAVE_STRCASECMP)
ENDIF(HAVE_STRCASECMP)
2011-08-10 23:42:10 +00:00
2022-04-07 00:38:39 +00:00
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
2022-04-07 00:38:39 +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
2024-04-15 22:12:56 +00:00
if(AQUARIA_WARNING_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AQUARIA_WARNING_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${AQUARIA_WARNING_FLAGS}")
endif()
2011-08-03 20:05:33 +00:00
2022-04-07 00:38:39 +00:00
add_subdirectory(Aquaria)
add_subdirectory(BBGE)