2022-06-05 14:03:26 +02:00
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# ," /\ ", Azur: A game engine for CASIO fx-CG and PC #
|
|
|
|
# | _/__\_ | Designed by Lephe' and the Planète Casio community. #
|
|
|
|
# "._`\/'_." License: MIT <https://opensource.org/licenses/MIT> #
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Main build system
|
|
|
|
#
|
|
|
|
# The build system consists of this CMakeLists.txt file, the CMakeLists.txt
|
|
|
|
# files of each component folder, and importantly the FindAzur.cmake file
|
|
|
|
# which loads the library for users.
|
|
|
|
#
|
|
|
|
# We build and install third-party dependencies along the engine to alleviate
|
|
|
|
# some packaging/distribution issues. Currently, these are:
|
|
|
|
#
|
|
|
|
# o GL3W, which we rely on to load the OpenGL core profile on PC
|
|
|
|
# o Dear ImGui, for introspection and debugging tools
|
2022-06-02 22:18:58 +02:00
|
|
|
#
|
2022-06-05 14:03:26 +02:00
|
|
|
# The following variables can be set on the command-line at cmake time:
|
2022-06-02 22:18:58 +02:00
|
|
|
#
|
2022-06-05 14:03:26 +02:00
|
|
|
# -DCMAKE_BUILD_TYPE:
|
|
|
|
# Debug Debug build with -O0 -g
|
|
|
|
# Release Release build with -Os [default]
|
2022-06-02 22:18:58 +02:00
|
|
|
#
|
2022-06-05 14:03:26 +02:00
|
|
|
# -DAZUR_PLATFORM:
|
|
|
|
# gint Build for gint for fx-CG
|
|
|
|
# linux Build for Linux with SDL and OpenGL 3.3
|
|
|
|
# emscripten Build for Emscripten with SDL and OpenGL ES 2.0
|
|
|
|
#
|
|
|
|
# -DCMAKE_INSTALL_PREFIX:
|
|
|
|
# The usual install prefix. It must be different for each platform. For gint,
|
|
|
|
# it defaults to the compiler's data folder as usual. The environment
|
|
|
|
# variable AZUR_PATH_<platform> is recognized by the find module.
|
2022-06-02 22:18:58 +02:00
|
|
|
#---
|
2021-07-04 16:58:21 +02:00
|
|
|
|
2022-06-05 14:03:26 +02:00
|
|
|
cmake_minimum_required(VERSION 3.15)
|
|
|
|
project(Azur VERSION 0.1 LANGUAGES C CXX ASM)
|
2022-07-20 00:18:01 +02:00
|
|
|
include(CTest)
|
2022-06-05 14:03:26 +02:00
|
|
|
|
|
|
|
set(CMAKE_INSTALL_MESSAGE LAZY)
|
|
|
|
|
2022-06-02 22:18:58 +02:00
|
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
|
|
set("${CMAKE_BUILD_TYPE}" Release)
|
2021-07-04 16:58:21 +02:00
|
|
|
endif()
|
|
|
|
|
2022-06-02 22:18:58 +02:00
|
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL Debug)
|
|
|
|
set(AZUR_DEBUG TRUE)
|
|
|
|
else()
|
|
|
|
set(AZUR_DEBUG FALSE)
|
|
|
|
endif()
|
2021-07-04 16:58:21 +02:00
|
|
|
|
2022-06-05 14:03:26 +02:00
|
|
|
# Detect when the fxSDK is used, and assume gint. This allows one to simply run
|
|
|
|
# `fxsdk build-cg` to build the engine.
|
2022-06-02 22:18:58 +02:00
|
|
|
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
|
|
|
set(AZUR_PLATFORM gint)
|
|
|
|
endif()
|
2021-07-04 16:58:21 +02:00
|
|
|
|
2022-06-02 22:18:58 +02:00
|
|
|
# Default install paths
|
|
|
|
set(LIBDIR "lib")
|
|
|
|
set(INCDIR "include")
|
2022-06-05 14:03:26 +02:00
|
|
|
set(MODPATH "lib/cmake")
|
2021-07-04 16:58:21 +02:00
|
|
|
|
2022-06-05 14:03:26 +02:00
|
|
|
#---
|
|
|
|
# Target-specific configuration
|
|
|
|
#---
|
|
|
|
|
|
|
|
if(AZUR_PLATFORM STREQUAL gint)
|
2021-07-04 16:58:21 +02:00
|
|
|
set(AZUR_PLATFORM_GENERIC TRUE)
|
|
|
|
set(AZUR_TOOLKIT_GINT TRUE)
|
|
|
|
set(AZUR_GRAPHICS_GINT_CG TRUE)
|
|
|
|
set(AZUR_TERMINAL_NONE TRUE)
|
|
|
|
|
2022-06-05 14:03:26 +02:00
|
|
|
# Link with gint and libprof (we only do this to get include directories)
|
|
|
|
find_package(Gint 2.8 REQUIRED)
|
2021-07-04 16:58:21 +02:00
|
|
|
find_package(LibProf 2.4 REQUIRED)
|
|
|
|
link_libraries(LibProf::LibProf Gint::Gint)
|
|
|
|
|
2022-06-02 22:18:58 +02:00
|
|
|
# Default to the fxSDK install path
|
|
|
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
set(CMAKE_INSTALL_PREFIX "${FXSDK_COMPILER_INSTALL}" CACHE PATH "..." FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# The fxSDK install path has a slightly different structure
|
|
|
|
if(CMAKE_INSTALL_PREFIX STREQUAL "${FXSDK_COMPILER_INSTALL}")
|
|
|
|
set(LIBDIR ".")
|
|
|
|
set(INCDIR "include")
|
2022-06-05 14:03:26 +02:00
|
|
|
set(MODPATH "${FXSDK_CMAKE_MODULE_PATH}")
|
2022-06-02 22:18:58 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
2021-07-04 16:58:21 +02:00
|
|
|
|
2022-06-02 22:18:58 +02:00
|
|
|
if(AZUR_PLATFORM STREQUAL linux)
|
2021-07-04 16:58:21 +02:00
|
|
|
set(AZUR_PLATFORM_GENERIC TRUE)
|
|
|
|
set(AZUR_TOOLKIT_SDL TRUE)
|
|
|
|
set(AZUR_GRAPHICS_OPENGL_3_3 TRUE)
|
|
|
|
set(AZUR_TERMINAL_ANSI TRUE)
|
|
|
|
|
2022-06-05 14:03:26 +02:00
|
|
|
# Once again, we link only for the include paths
|
2021-07-04 16:58:21 +02:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(sdl2 REQUIRED sdl2 IMPORTED_TARGET)
|
|
|
|
pkg_check_modules(sdl2_image REQUIRED SDL2_image IMPORTED_TARGET)
|
|
|
|
pkg_check_modules(opengl REQUIRED opengl IMPORTED_TARGET)
|
2021-07-05 14:03:21 +02:00
|
|
|
pkg_check_modules(glx REQUIRED glx IMPORTED_TARGET)
|
2021-07-04 16:58:21 +02:00
|
|
|
link_libraries(PkgConfig::sdl2_image PkgConfig::sdl2 PkgConfig::opengl -lm)
|
|
|
|
endif()
|
|
|
|
|
2022-06-02 22:18:58 +02:00
|
|
|
if(AZUR_PLATFORM STREQUAL emscripten)
|
2021-07-04 16:58:21 +02:00
|
|
|
set(AZUR_PLATFORM_EMSCRIPTEN TRUE)
|
|
|
|
set(AZUR_TOOLKIT_SDL TRUE)
|
|
|
|
set(AZUR_GRAPHICS_OPENGL_ES_2_0 TRUE)
|
|
|
|
set(AZUR_TERMINAL_PLAIN TRUE)
|
|
|
|
|
|
|
|
set(PORTS -sUSE_SDL=2 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS=["png"])
|
|
|
|
add_compile_options(${PORTS})
|
2021-09-28 14:29:09 +02:00
|
|
|
add_link_options(${PORTS} -O3)
|
2021-07-04 16:58:21 +02:00
|
|
|
endif()
|
|
|
|
|
2022-06-02 22:18:58 +02:00
|
|
|
if(AZUR_GRAPHICS_OPENGL_3_3 OR AZUR_GRAPHICS_OPENGL_ES_2_0)
|
|
|
|
set(AZUR_GRAPHICS_OPENGL TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
#---
|
|
|
|
# Compile options
|
|
|
|
#---
|
|
|
|
|
|
|
|
add_compile_options(
|
|
|
|
-Wall -Wextra
|
|
|
|
$<IF:$<CONFIG:DEBUG>,-O0,-Os>
|
|
|
|
$<$<CONFIG:DEBUG>:-g>
|
|
|
|
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/=)
|
|
|
|
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
set(CMAKE_C_STANDARD_REQUIRED TRUE)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
|
|
|
|
|
|
|
#---
|
|
|
|
# Subdirectory selection
|
2021-07-04 16:58:21 +02:00
|
|
|
#---
|
|
|
|
|
2022-06-02 22:28:00 +02:00
|
|
|
# Exclud third-party software from the build on gint; it wouldn't work
|
2022-06-02 22:18:58 +02:00
|
|
|
if(NOT AZUR_PLATFORM STREQUAL gint)
|
2022-06-02 22:28:00 +02:00
|
|
|
add_subdirectory(3rdparty)
|
2021-07-05 14:03:21 +02:00
|
|
|
endif()
|
|
|
|
|
2022-06-02 22:18:58 +02:00
|
|
|
add_subdirectory(libnum)
|
2021-07-04 16:58:21 +02:00
|
|
|
add_subdirectory(azur)
|
2022-06-05 14:03:26 +02:00
|
|
|
|
|
|
|
#---
|
|
|
|
# Install
|
|
|
|
#---
|
|
|
|
|
|
|
|
# CMake module to find the library
|
|
|
|
install(FILES FindAzur.cmake DESTINATION ${MODPATH})
|
2022-07-20 00:18:01 +02:00
|
|
|
|
|
|
|
#---
|
|
|
|
# Testing
|
|
|
|
#---
|
|
|
|
|
|
|
|
# Force --verbose on CTest
|
|
|
|
add_custom_target(tests COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
|