nostalgia/deps/ox/CMakeLists.txt

86 lines
2.6 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.19)
set(CMAKE_POLICY_DEFAULT_CMP0110 NEW) # requires CMake 3.19
project(Ox)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
include(address_sanitizer)
if(NOT DEFINED OX_RUN_TESTS)
2019-06-26 21:54:41 -05:00
set(OX_RUN_TESTS ON)
endif()
2019-06-26 21:54:41 -05:00
if(NOT DEFINED OX_BUILD_EXEC)
set(OX_BUILD_EXEC ON)
endif()
if(NOT DEFINED OX_USE_STDLIB)
set(OX_USE_STDLIB ON)
endif()
if(NOT DEFINED OX_BARE_METAL)
set(OX_BARE_METAL OFF)
endif()
2019-06-26 21:54:41 -05:00
set(OX_RUN_TESTS ${OX_RUN_TESTS} CACHE BOOL "Run tests (ON/OFF)")
set(OX_BUILD_EXEC ${OX_BUILD_EXEC} CACHE BOOL "Build executables (ON/OFF)")
set(OX_USE_STDLIB ${OX_USE_STDLIB} CACHE BOOL "Build libraries that need the std lib (ON/OFF)")
set(OX_BARE_METAL ${OX_BARE_METAL} CACHE BOOL "Bare metal build (TRUE/FALSE)")
if(DEFINED ENV{OX_NODEBUG})
set(OX_NODEBUG ON)
endif()
# can't run tests without building them
2019-06-26 21:54:41 -05:00
if(NOT OX_BUILD_EXEC OR NOT OX_USE_STDLIB)
set(OX_BUILD_EXEC OFF)
set(OX_RUN_TESTS OFF)
endif()
set(CMAKE_CXX_STANDARD 20)
2018-03-09 21:45:46 -06:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
add_definitions(-DNDEBUG)
else()
add_definitions(-DDEBUG)
endif()
2019-06-26 21:54:41 -05:00
if(NOT OX_USE_STDLIB)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
2018-03-06 23:07:39 -06:00
endif()
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
2019-03-04 19:43:29 -06: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")
2019-03-04 19:43:29 -06:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare")
2019-03-04 19:43:29 -06: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")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
2018-03-09 21:45:46 -06:00
endif()
# forces colored output when using ninja
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color")
2018-03-09 21:45:46 -06:00
endif()
enable_testing()
2022-03-12 02:34:04 -06:00
include_directories(src)
install(FILES OxConfig.cmake DESTINATION lib/cmake/ox)
if(OX_USE_STDLIB)
2022-03-12 02:34:04 -06:00
set(JSONCPP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/jsoncpp/include")
add_subdirectory(deps/jsoncpp)
endif()
add_subdirectory(src)