-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
74 lines (61 loc) · 2.46 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
71
72
73
74
# Invoking the CMake build from the command line is a two step process, first, *generate* a build by running the following:
#
# cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release
#
# Where `Release` can be replaced with `Debug`, which contains gdb and address sanitiser definitions already written for you.
# Once a build is created, proceed with *compilation*:
#
# cmake --build build --target RedNoise --config Release # optionally, for parallel build, append -j $(nproc)
#
# This creates the executable in the build directory. You only need to *generate* a build if you modify the CMakeList.txt file.
# For any other changes to the source code, simply recompile.
cmake_minimum_required(VERSION 3.12)
project(RedNoise)
set(CMAKE_CXX_STANDARD 14)
# Note, we do this for glm because it's a header only library and because we shipped it with the project
# normally you would use find_package(<package_name>) for libraries with actual objects
set(GLM_INCLUDE_DIRS libs/glm-0.9.7.2)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS} ${GLM_INCLUDE_DIRS})
include_directories(libs/sdw)
add_executable(RedNoise
libs/sdw/CanvasPoint.cpp
libs/sdw/CanvasTriangle.cpp
libs/sdw/Colour.cpp
libs/sdw/DrawingWindow.cpp
libs/sdw/ModelTriangle.cpp
libs/sdw/RayTriangleIntersection.cpp
libs/sdw/TextureMap.cpp
libs/sdw/TexturePoint.cpp
libs/sdw/Utils.cpp
src/RedNoise.cpp)
if (MSVC)
target_compile_options(RedNoise
PUBLIC
/W3
/Zc:wchar_t
)
set(DEBUG_OPTIONS /MTd)
set(RELEASE_OPTIONS /MT /GF /Gy /O2 /fp:fast)
if (NOT DEFINED SDL2_LIBRARIES)
set(SDL2_LIBRARIES SDL2::SDL2 SDL2::SDL2main)
endif()
else ()
target_compile_options(RedNoise
PUBLIC
-Wall
-Wextra
-Wcast-align
-Wfatal-errors
-Werror=return-type
-Wno-unused-parameter
-Wno-unused-variable
-Wno-ignored-attributes)
set(DEBUG_OPTIONS -O2 -fno-omit-frame-pointer -g)
set(RELEASE_OPTIONS -O3 -march=native -mtune=native)
target_link_libraries(RedNoise PUBLIC $<$<CONFIG:Debug>:-Wl,-lasan>)
endif()
target_compile_options(RedNoise PUBLIC "$<$<CONFIG:RelWithDebInfo>:${RELEASE_OPTIONS}>")
target_compile_options(RedNoise PUBLIC "$<$<CONFIG:Release>:${RELEASE_OPTIONS}>")
target_compile_options(RedNoise PUBLIC "$<$<CONFIG:Debug>:${DEBUG_OPTIONS}>")
target_link_libraries(RedNoise PRIVATE ${SDL2_LIBRARIES})