2020-08-22 22:30:12 -04:00
|
|
|
# Top Level CMakeLists.txt
|
2021-02-03 21:29:46 -05:00
|
|
|
cmake_minimum_required(VERSION 3.10)
|
2020-12-26 11:09:59 -05:00
|
|
|
|
2022-02-07 19:15:37 -05:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2020-08-22 22:30:12 -04:00
|
|
|
project(jak)
|
2021-02-03 21:29:46 -05:00
|
|
|
include(CTest)
|
2022-02-07 19:15:37 -05:00
|
|
|
|
2020-10-03 09:39:04 -04:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2022-02-07 19:15:37 -05:00
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
2020-10-03 09:39:04 -04:00
|
|
|
endif()
|
2020-08-22 22:30:12 -04:00
|
|
|
|
2022-03-29 22:47:08 -04:00
|
|
|
option(BUILD_FOR_RELEASE "Build for release purposes (static everything)" OFF)
|
|
|
|
if(BUILD_FOR_RELEASE)
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
else()
|
|
|
|
set(BUILD_SHARED_LIBS ON)
|
|
|
|
endif()
|
|
|
|
|
2022-02-07 19:15:37 -05:00
|
|
|
# Set default compile flags
|
|
|
|
# optimization level can be set here. You can overwrite these in a per-project basis if you want.
|
|
|
|
if(MSVC AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
|
|
|
|
message(STATUS "Clang on MSVC detected! Adding compile flags")
|
|
|
|
set(CMAKE_CXX_FLAGS
|
|
|
|
"-Xclang -fcxx-exceptions \
|
|
|
|
-Xclang -fexceptions \
|
|
|
|
-Xclang -std=c++17 \
|
2022-02-24 22:43:00 -05:00
|
|
|
-Xclang -D_CRT_SECURE_NO_WARNINGS \
|
2022-02-19 13:10:10 -05:00
|
|
|
-mavx \
|
2022-03-20 20:29:44 -04:00
|
|
|
-Wno-c++11-narrowing -Wno-c++98-compat -W3")
|
2022-02-07 19:15:37 -05:00
|
|
|
|
|
|
|
# additional c++ flags for release mode for our projects
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES "Release")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# linker flags
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "/STACK:16000000,16384")
|
2020-08-22 22:30:12 -04:00
|
|
|
|
2022-02-07 19:15:37 -05:00
|
|
|
elseif(UNIX)
|
|
|
|
message(STATUS "GCC detected! Adding compile flags")
|
2020-09-06 16:58:25 -04:00
|
|
|
set(CMAKE_CXX_FLAGS
|
2020-09-13 21:10:43 -04:00
|
|
|
"${CMAKE_CXX_FLAGS} \
|
2020-09-03 22:37:00 -04:00
|
|
|
-Wall \
|
2020-09-13 21:10:43 -04:00
|
|
|
-Winit-self \
|
|
|
|
-ggdb \
|
2020-09-03 22:37:00 -04:00
|
|
|
-Wextra \
|
2020-12-02 19:51:42 -05:00
|
|
|
-Wno-cast-align \
|
2020-09-03 22:37:00 -04:00
|
|
|
-Wcast-qual \
|
|
|
|
-Wdisabled-optimization \
|
2020-12-02 19:51:42 -05:00
|
|
|
-Wformat \
|
2020-09-03 22:37:00 -04:00
|
|
|
-Wmissing-include-dirs \
|
|
|
|
-Woverloaded-virtual \
|
|
|
|
-Wredundant-decls \
|
2020-10-09 21:28:41 -04:00
|
|
|
-Wshadow \
|
2021-09-26 11:41:58 -04:00
|
|
|
-Wsign-promo \
|
2022-02-07 19:15:37 -05:00
|
|
|
-fdiagnostics-color=always \
|
2022-02-19 13:10:10 -05:00
|
|
|
-mavx")
|
2022-02-07 19:15:37 -05:00
|
|
|
|
|
|
|
# additional c++ flags for release mode for our projects
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES "Release")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
elseif(MSVC)
|
|
|
|
message(STATUS "MSVC detected!! Adding compile flags")
|
2021-11-09 23:22:49 -05:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
2021-11-12 22:00:41 -05:00
|
|
|
# This actually breaks some standard library things for some reason?
|
|
|
|
# message("Setting Flags to Enable Edit and Continue")
|
|
|
|
# set(CMAKE_CXX_FLAGS_DEBUG "/ZI")
|
2021-11-09 23:22:49 -05:00
|
|
|
endif()
|
2022-02-07 19:15:37 -05:00
|
|
|
# c++ flags for all build types
|
|
|
|
set(CMAKE_CXX_FLAGS "/EHsc /utf-8 /arch:AVX")
|
|
|
|
|
|
|
|
# linker flags
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "/STACK:16000000,16384")
|
|
|
|
endif()
|
2020-08-22 22:30:12 -04:00
|
|
|
|
2021-02-03 21:29:46 -05:00
|
|
|
if(WIN32)
|
2020-09-06 16:58:25 -04:00
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
2021-02-03 21:29:46 -05:00
|
|
|
endif()
|
2020-08-26 22:23:16 -04:00
|
|
|
|
2021-02-03 21:29:46 -05:00
|
|
|
if(ASAN_BUILD)
|
2021-01-04 23:32:51 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1")
|
2021-01-03 12:31:42 -05:00
|
|
|
message(STATUS "Doing ASAN build")
|
2021-02-03 21:29:46 -05:00
|
|
|
endif()
|
2021-01-03 12:31:42 -05:00
|
|
|
|
2020-09-08 19:15:38 -04:00
|
|
|
option(CODE_COVERAGE "Enable Code Coverage Compiler Flags" OFF)
|
2020-11-21 12:52:38 -05:00
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/third-party/cmake/modules/)
|
2020-09-08 14:39:16 -04:00
|
|
|
|
2020-12-02 19:51:42 -05:00
|
|
|
if(UNIX AND CODE_COVERAGE)
|
2020-09-08 16:19:05 -04:00
|
|
|
include(CodeCoverage)
|
|
|
|
append_coverage_compiler_flags()
|
2020-09-08 19:15:38 -04:00
|
|
|
message("Code Coverage build is enabled!")
|
|
|
|
else()
|
|
|
|
message("Code Coverage build is disabled!")
|
2020-09-08 16:19:05 -04:00
|
|
|
endif()
|
2020-08-26 22:23:16 -04:00
|
|
|
|
2020-08-22 22:30:12 -04:00
|
|
|
# includes relative to top level jak-project folder
|
|
|
|
include_directories(./)
|
|
|
|
|
2020-10-09 21:28:41 -04:00
|
|
|
include_directories(SYSTEM third-party/inja)
|
|
|
|
|
2021-03-07 23:41:21 -05:00
|
|
|
# build repl library
|
|
|
|
add_subdirectory(third-party/replxx EXCLUDE_FROM_ALL)
|
|
|
|
|
2021-01-06 12:16:39 -05:00
|
|
|
# build common library
|
|
|
|
add_subdirectory(common)
|
2020-10-31 14:07:43 -04:00
|
|
|
|
2020-08-22 22:30:12 -04:00
|
|
|
# build decompiler
|
|
|
|
add_subdirectory(decompiler)
|
|
|
|
|
2021-03-09 23:51:28 -05:00
|
|
|
# build glfw library
|
|
|
|
add_subdirectory(third-party/glfw)
|
2021-09-21 22:52:18 -04:00
|
|
|
add_subdirectory(third-party/zstd)
|
|
|
|
|
2021-08-29 14:54:16 -04:00
|
|
|
# build imgui
|
2021-03-09 23:51:28 -05:00
|
|
|
include_directories(third-party/glad/include)
|
|
|
|
include_directories(third-party/glfw/include)
|
2021-08-29 14:54:16 -04:00
|
|
|
add_subdirectory(third-party/imgui)
|
|
|
|
|
|
|
|
# build the game code in C++
|
2020-08-22 22:30:12 -04:00
|
|
|
add_subdirectory(game)
|
|
|
|
|
|
|
|
# build the compiler
|
|
|
|
add_subdirectory(goalc)
|
|
|
|
|
2021-01-27 20:46:58 -05:00
|
|
|
# build standalone tools
|
|
|
|
add_subdirectory(tools)
|
|
|
|
|
2020-08-22 22:30:12 -04:00
|
|
|
# build the gtest libraries
|
2021-02-03 21:29:46 -05:00
|
|
|
if(WIN32)
|
|
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
|
|
endif()
|
|
|
|
add_subdirectory(third-party/googletest EXCLUDE_FROM_ALL)
|
|
|
|
include(GoogleTest)
|
2020-08-22 22:30:12 -04:00
|
|
|
|
|
|
|
# build tests
|
2021-02-03 21:29:46 -05:00
|
|
|
include(test/CMakeLists.txt)
|
2020-08-22 23:16:48 -04:00
|
|
|
|
2021-02-06 09:54:23 -05:00
|
|
|
# build lzokay library
|
|
|
|
add_subdirectory(third-party/lzokay EXCLUDE_FROM_ALL)
|
2020-08-23 23:43:11 -04:00
|
|
|
|
|
|
|
# build format library
|
2021-02-03 21:29:46 -05:00
|
|
|
add_subdirectory(third-party/fmt EXCLUDE_FROM_ALL)
|
2022-02-07 23:53:36 -05:00
|
|
|
# discord rich presence
|
|
|
|
include_directories(third-party/discord-rpc/include)
|
|
|
|
add_subdirectory(third-party/discord-rpc EXCLUDE_FROM_ALL)
|
|
|
|
|
2020-10-31 14:31:13 -04:00
|
|
|
# build zydis third party library for disassembling x86
|
2021-02-03 21:29:46 -05:00
|
|
|
# NOTE: Once under CMake 3.13's policy CMP0077, override with `set()` instead
|
|
|
|
option(ZYDIS_BUILD_TOOLS "Zydis: Build tools" OFF)
|
|
|
|
option(ZYDIS_BUILD_EXAMPLES "Zydis: Build examples" OFF)
|
2022-03-29 22:47:08 -04:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
option(ZYDIS_BUILD_SHARED_LIB "Zydis: Build shared library" ON)
|
|
|
|
else()
|
|
|
|
option(ZYDIS_BUILD_SHARED_LIB "Zydis: Build shared library" OFF)
|
|
|
|
endif()
|
2021-02-03 21:29:46 -05:00
|
|
|
add_subdirectory(third-party/zydis EXCLUDE_FROM_ALL)
|
2020-10-31 14:31:13 -04:00
|
|
|
|
2020-08-26 22:23:16 -04:00
|
|
|
# windows memory management lib
|
2021-02-03 21:29:46 -05:00
|
|
|
if(WIN32)
|
2020-09-06 16:58:25 -04:00
|
|
|
add_subdirectory(third-party/mman)
|
2021-02-03 21:29:46 -05:00
|
|
|
endif()
|
2022-03-20 20:29:44 -04:00
|
|
|
|