forked from danielkrupinski/Osiris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
53 lines (42 loc) · 1.75 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
cmake_minimum_required(VERSION 3.16.0)
project(Osiris)
if (NOT WIN32)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-exceptions -Wfatal-errors")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-rtti")
endif()
add_compile_options($<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:GNU>,$<C_COMPILER_ID:GNU>>:-s>)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} --no-gnu-unique")
endif()
add_library(OsirisOBJ OBJECT "")
set_target_properties(OsirisOBJ PROPERTIES CXX_VISIBILITY_PRESET hidden C_VISIBILITY_PRESET hidden)
add_subdirectory(Dependencies)
add_subdirectory(Source)
set_target_properties(OsirisOBJ PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_precompile_headers(OsirisOBJ PRIVATE "${CMAKE_SOURCE_DIR}/Source/pch.h")
target_include_directories(OsirisOBJ PUBLIC "${CMAKE_SOURCE_DIR}/Source")
target_include_directories(OsirisOBJ PUBLIC "${CMAKE_SOURCE_DIR}/Dependencies")
if (NOT WIN32)
target_link_libraries(OsirisOBJ PRIVATE ${CMAKE_DL_LIBS})
target_compile_options(OsirisOBJ PRIVATE -flto)
target_link_options(OsirisOBJ PUBLIC -flto LINKER:--no-undefined)
else()
target_compile_definitions(OsirisOBJ PRIVATE _USE_MATH_DEFINES)
target_compile_options(OsirisOBJ PRIVATE /utf-8)
add_subdirectory(Source/Resources/Shaders)
add_dependencies(OsirisOBJ Shaders)
endif()
add_library(Osiris SHARED "${CMAKE_SOURCE_DIR}/Source/Osiris.cpp")
target_link_libraries(Osiris PUBLIC OsirisOBJ)
if (NOT WIN32)
target_link_options(Osiris PRIVATE -flto)
else()
target_link_options(Osiris PRIVATE /ENTRY:DllEntryPoint)
endif()
option(BUILD_TESTS "Build unit tests" OFF)
if (BUILD_TESTS)
enable_testing()
add_subdirectory(Tests)
endif()