2020-11-21 23:25:44 -06:00
|
|
|
cmake_minimum_required(VERSION 3.19)
|
|
|
|
set(CMAKE_POLICY_DEFAULT_CMP0110 NEW) # requires CMake 3.19
|
2016-03-26 15:49:05 -05:00
|
|
|
|
2017-05-12 16:28:59 -05:00
|
|
|
project(nostalgia)
|
2016-03-26 15:49:05 -05:00
|
|
|
|
2021-03-02 21:02:16 -06:00
|
|
|
set(QTDIR "" CACHE PATH "Path to Qt Libraries")
|
|
|
|
|
|
|
|
set(BUILDCORE_TARGET "Native" CACHE STRING "The type of build to produce(Native/GBA)")
|
2020-05-04 18:22:42 -05:00
|
|
|
set(NOSTALGIA_BUILD_PLAYER ON CACHE BOOL "Build Player")
|
2020-02-09 21:43:56 -06:00
|
|
|
set(NOSTALGIA_BUILD_STUDIO ON CACHE BOOL "Build Studio")
|
2021-03-02 21:02:16 -06:00
|
|
|
set(OX_ENABLE_TRACEHOOK OFF CACHE BOOL "Generate OxTraceHook shared library for uprobes")
|
|
|
|
|
|
|
|
if(BUILDCORE_TARGET STREQUAL "gba")
|
|
|
|
set(NOSTALGIA_BUILD_TYPE "GBA")
|
|
|
|
else()
|
|
|
|
set(NOSTALGIA_BUILD_TYPE "Native")
|
|
|
|
endif()
|
2018-02-06 19:20:07 -06:00
|
|
|
|
2019-03-07 18:00:08 -06:00
|
|
|
if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
|
2019-12-20 00:13:23 -06:00
|
|
|
set(NOSTALGIA_BUILD_STUDIO OFF)
|
2019-06-19 23:43:58 -05:00
|
|
|
set(OX_BARE_METAL ON)
|
|
|
|
set(OX_USE_STDLIB OFF)
|
2019-02-14 17:38:14 -06:00
|
|
|
else()
|
2021-03-02 21:02:16 -06:00
|
|
|
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QTDIR})
|
2020-02-15 12:34:31 -06:00
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
2019-02-14 17:38:14 -06:00
|
|
|
endif()
|
|
|
|
|
2016-03-26 15:49:05 -05:00
|
|
|
|
2019-06-20 00:17:18 -05:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
|
2020-02-15 11:45:03 -06:00
|
|
|
include(GenerateExportHeader)
|
2016-03-26 15:49:05 -05:00
|
|
|
include(address_sanitizer)
|
2016-12-23 17:29:19 -06:00
|
|
|
|
2021-03-02 21:02:16 -06:00
|
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/dist/${BUILDCORE_BUILD_CONFIG}")
|
2020-01-24 23:29:16 -06:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2018-03-13 20:21:18 -05:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
2019-12-06 01:11:30 -06:00
|
|
|
if(NOT OX_BARE_METAL)
|
2020-01-24 23:29:16 -06:00
|
|
|
add_definitions(-DOX_USE_STDLIB)
|
2019-12-06 01:11:30 -06:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
endif()
|
2018-03-13 20:21:18 -05:00
|
|
|
|
2020-04-16 23:37:35 -05:00
|
|
|
# enable ccache
|
2020-03-11 00:21:46 -05:00
|
|
|
find_program(CCACHE_PROGRAM ccache)
|
|
|
|
if(CCACHE_PROGRAM)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
|
|
|
endif()
|
|
|
|
|
2018-03-05 23:09:50 -06:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2018-03-13 20:21:18 -05:00
|
|
|
add_definitions(-DDEBUG)
|
2018-03-05 23:09:50 -06:00
|
|
|
else()
|
2018-03-13 20:21:18 -05:00
|
|
|
add_definitions(-DNDEBUG)
|
2018-03-05 23:09:50 -06:00
|
|
|
endif()
|
|
|
|
|
2018-03-09 21:46:47 -06:00
|
|
|
if(NOT MSVC)
|
2019-12-06 01:11:30 -06:00
|
|
|
# forces colored output when using ninja
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color")
|
|
|
|
|
|
|
|
# enable warnings
|
2018-03-13 20:21:18 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
2019-03-30 17:30:56 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
|
2019-03-30 17:15:21 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdouble-promotion")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=2")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-field-initializers")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnull-dereference")
|
2020-01-14 18:50:30 -06:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
|
2019-03-30 17:15:21 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
|
2018-03-13 20:21:18 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare")
|
2019-03-30 17:15:21 -05:00
|
|
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-variable")
|
2018-03-09 21:46:47 -06:00
|
|
|
|
|
|
|
if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
|
|
|
|
include(GBA)
|
2018-03-13 20:21:18 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
|
2019-06-19 23:43:58 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++")
|
2019-10-22 19:23:14 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-unwind-tables")
|
2018-03-13 20:21:18 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb-interwork")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb")
|
2019-03-30 17:15:21 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=arm7tdmi")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=arm7tdmi")
|
2018-03-09 21:46:47 -06:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
2018-03-13 20:21:18 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
2018-03-09 21:46:47 -06:00
|
|
|
endif()
|
2016-12-23 17:29:19 -06:00
|
|
|
endif()
|
2016-03-26 15:49:05 -05:00
|
|
|
|
2017-10-20 22:14:33 -05:00
|
|
|
if(APPLE)
|
|
|
|
set(CMAKE_MACOSX_RPATH OFF)
|
|
|
|
set(CMAKE_INSTALL_NAME_DIR "@executable_path/../Library/nostalgia")
|
2018-02-14 21:05:20 -06:00
|
|
|
set(NOSTALGIA_DIST_BIN nostalgia-studio.app/Contents/MacOS)
|
|
|
|
set(NOSTALGIA_DIST_LIB nostalgia-studio.app/Contents/Library)
|
2020-12-17 20:40:23 -06:00
|
|
|
set(NOSTALGIA_DIST_MODULE nostalgia-studio.app/Contents/Plugins)
|
2018-02-14 21:05:20 -06:00
|
|
|
set(NOSTALGIA_DIST_RESOURCES nostalgia-studio.app/Contents/Resources)
|
|
|
|
set(NOSTALGIA_DIST_MAC_APP_CONTENTS nostalgia-studio.app/Contents)
|
2017-10-17 19:16:22 -05:00
|
|
|
else()
|
2021-03-02 21:02:16 -06:00
|
|
|
set(CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../lib/ox" "$ORIGIN/../lib/nostalgia" "$ORIGIN/../")
|
|
|
|
if(QTDIR)
|
|
|
|
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} "${QTDIR}/lib")
|
2018-02-06 19:20:07 -06:00
|
|
|
endif()
|
2017-10-17 19:16:22 -05:00
|
|
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
2017-10-20 22:14:33 -05:00
|
|
|
set(NOSTALGIA_DIST_BIN bin)
|
|
|
|
set(NOSTALGIA_DIST_LIB lib)
|
2020-12-17 20:40:23 -06:00
|
|
|
set(NOSTALGIA_DIST_MODULE lib/nostalgia/modules)
|
2017-10-20 22:14:33 -05:00
|
|
|
set(NOSTALGIA_DIST_RESOURCES share)
|
2017-10-17 19:16:22 -05:00
|
|
|
endif()
|
2017-06-30 18:00:10 -05:00
|
|
|
|
2016-03-26 15:49:05 -05:00
|
|
|
enable_testing()
|
|
|
|
|
2020-05-29 19:36:00 -05:00
|
|
|
add_subdirectory(deps/ox)
|
|
|
|
include_directories(SYSTEM deps/ox/src)
|
|
|
|
|
2019-11-03 23:23:43 -06:00
|
|
|
if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
|
|
|
|
add_subdirectory(deps/gbastartup)
|
2020-09-05 19:30:17 -05:00
|
|
|
elseif(NOSTALGIA_BUILD_STUDIO)
|
|
|
|
add_subdirectory(deps/QDark)
|
2019-11-03 23:23:43 -06:00
|
|
|
endif()
|
|
|
|
|
2016-03-26 15:49:05 -05:00
|
|
|
add_subdirectory(src)
|