-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
70 lines (59 loc) · 2.36 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
cmake_minimum_required (VERSION 3.9.2)
project(pebbleofdoom)
###################################################################
# Utilities
###################################################################
# To preserve file hierarchy in Visual Studio
function(assign_source_group)
foreach(_source IN ITEMS ${ARGN})
if (IS_ABSOLUTE "${_source}")
file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
else()
set(_source_rel "${_source}")
endif()
get_filename_component(_source_path "${_source_rel}" PATH)
string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
source_group("${_source_path_msvc}" FILES "${_source}")
endforeach()
endfunction(assign_source_group)
# To enable many many warnings and treat them as errors (portable across msvc/gcc)
function(enable_warnings TARGET)
if (MSVC)
target_compile_options(${TARGET} PRIVATE "/W4" "/WX")
else()
target_compile_options(${TARGET} PRIVATE
"-Werror" "-Wall" "-Wextra"
"-Wpointer-arith" "-Wlogical-op"
"-Wdisabled-optimization" "-Wunsafe-loop-optimizations"
"-Wc++-compat"
)
endif()
endfunction(enable_warnings)
###################################################################
# Dependencies
###################################################################
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
find_package(SDL2 REQUIRED)
find_package(Sanitizers)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
link_libraries(m)
endif()
include(CTest)
include(GoogleTest)
include("${CMAKE_SOURCE_DIR}/cmake/GTest.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/stb.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/glad.cmake")
include("${CMAKE_SOURCE_DIR}/cmake/cimgui.cmake")
if (MSVC AND CMAKE_C_COMPILER_ID STREQUAL "MSVC")
message(FATAL_ERROR " Microsoft C Compiler is not supported, please use GCC or Clang")
endif()
###################################################################
# sub-directories
###################################################################
add_subdirectory("renderer")
add_subdirectory("test")
add_subdirectory("pcmockup")
add_subdirectory("tools")