-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
67 lines (52 loc) · 2.43 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(Raytracer)
MESSAGE("Generating Makefile for Raytracer project")
INCLUDE(FindPkgConfig)
# Pre-define Release build
IF(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
SET(CMAKE_BUILD_TYPE Release)
ENDIF(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
# Pre-define 64-bit build platform
IF(NOT DEFINED BUILD_PLATFORM)
EXECUTE_PROCESS(COMMAND uname -m
OUTPUT_VARIABLE BUILD_PLATFORM OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF(NOT DEFINED BUILD_PLATFORM)
# Set required variables
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -std=c++1y -g")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -O0 -g -std=c++1y")
SET(RT_ROOT_DIRECTORY ${CMAKE_SOURCE_DIR})
SET(RT_OUTPUT_DIRECTORY ${RT_ROOT_DIRECTORY}/Bin/${BUILD_PLATFORM}/${CMAKE_BUILD_TYPE})
SET(RT_CORE_DIRECTORY ${RT_ROOT_DIRECTORY}/Core)
SET(RT_DEMO_DIRECTORY ${RT_ROOT_DIRECTORY}/Demo)
SET(RT_TESTS_DIRECTORY ${RT_ROOT_DIRECTORY}/Tests)
SET(RT_BENCHMARK_DIRECTORY ${RT_ROOT_DIRECTORY}/Benchmark)
ADD_DEFINITIONS("-msse -DRT_USE_SSE")
ADD_DEFINITIONS("-mavx -DRT_USE_AVX")
ADD_DEFINITIONS("-mavx2 -DRT_USE_AVX2")
ADD_DEFINITIONS("-mfma -DRT_USE_FMA")
# Enable more warnings and make them errors
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
# Warnings exceptions
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-four-char-constants")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
ADD_DEFINITIONS(-DRT_ROOT_DIRECTORY="${RT_ROOT_DIRECTORY}/")
ADD_DEFINITIONS(-DRT_COMPILER="${CMAKE_CXX_COMPILER_ID}")
ADD_DEFINITIONS(-DRT_OS="${CMAKE_SYSTEM}")
# Building outputs
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${RT_OUTPUT_DIRECTORY})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${RT_OUTPUT_DIRECTORY})
MESSAGE("Build type is ${CMAKE_BUILD_TYPE}")
MESSAGE("Output path is ${RT_OUTPUT_DIRECTORY}")
MESSAGE("Platform is ${BUILD_PLATFORM}")
# Add all projects
ADD_SUBDIRECTORY("Core")
ADD_SUBDIRECTORY("Demo")
ADD_SUBDIRECTORY("Tests")
ADD_SUBDIRECTORY("Benchmark")
FILE(MAKE_DIRECTORY ${RT_OUTPUT_DIRECTORY})