-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
111 lines (83 loc) · 3.19 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
################################################
# CMake App Constants
################################################
SET( MAIN_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/src" )
SET( MAIN_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/src" )
SET( TEST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/tests" )
SET( APP_NAME "path_tracer_demo" )
SET( LIB_NAME "path_tracer_lib" )
SET( TEST_NAME "path_tracer_test" )
################################################
# App Generation Code
################################################
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.7 )
PROJECT( "path_tracer" CXX C )
################################################
# App Compiler Flags
################################################
IF( WIN32 )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W4" )
ELSE( WIN32 )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pedantic -Wall -Werror -Wno-unknown-pragmas -Wno-missing-braces" )
ENDIF( WIN32 )
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
#########################################################
# FIND glfw
#########################################################
FIND_PACKAGE( GLFW )
IF( GLFW_FOUND )
INCLUDE_DIRECTORIES( ${GLFW_INCLUDE_DIR} )
ELSE( GLFW_FOUND )
MESSAGE(WARNING "GLFW library was not found. Only tests will be available.")
ENDIF( GLFW_FOUND )
#########################################################
# FIND OpenGL
#########################################################
FIND_PACKAGE( OpenGL )
IF( OPENGL_FOUND )
INCLUDE_DIRECTORIES( ${OpenGL_INCLUDE_DIRS} )
LINK_DIRECTORIES ( ${OpenGL_LIBRARY_DIRS} )
ADD_DEFINITIONS ( ${OpenGL_DEFINITIONS} )
ELSE( OPENGL_FOUND )
MESSAGE(WARNING "OpenGL library was not found. Only tests will be available.")
ENDIF( OPENGL_FOUND )
#########################################################
# FIND Boost
#########################################################
FIND_PACKAGE(Boost 1.30.0 REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
# Setup and Get Projects Sources/Headers
INCLUDE_DIRECTORIES( ${MAIN_INCLUDE_DIR} )
ADD_SUBDIRECTORY( ${MAIN_SOURCE_DIR} )
#########################################################
# Library Generation Configuration
#########################################################
ADD_LIBRARY(${LIB_NAME} STATIC ${LIB_SOURCES})
TARGET_LINK_LIBRARIES( ${LIB_NAME}
${Boost_LIBRARIES}
)
#########################################################
# App Generation Configuration
#########################################################
IF( GLFW_FOUND AND OPENGL_FOUND )
ADD_EXECUTABLE( ${APP_NAME} ${APP_SOURCES} )
TARGET_LINK_LIBRARIES( ${APP_NAME}
${LIB_NAME}
${OPENGL_LIBRARY}
${GLFW_LIBRARIES}
${Boost_LIBRARIES}
)
ENDIF( GLFW_FOUND AND OPENGL_FOUND )
#########################################################
# Tests Generation Configuration
#########################################################
ADD_SUBDIRECTORY( ${TEST_SOURCE_DIR} )
ADD_EXECUTABLE( ${TEST_NAME} ${TEST_SOURCES} )
TARGET_LINK_LIBRARIES( ${TEST_NAME}
${LIB_NAME}
${Boost_LIBRARIES}
)
# Setup Projects Source Groups
INCLUDE("${MAIN_SOURCE_DIR}/CMakeSourceGroups.txt")