-
Notifications
You must be signed in to change notification settings - Fork 27
/
CMakeLists.txt
186 lines (140 loc) · 4.73 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Original file Copyright CMU462 Fall 2015:
# Kayvon Fatahalian, Keenan Crane,
# Sky Gao, Bryce Summers, Michael Choquette.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
cmake_minimum_required(VERSION 2.8)
project(HW0)
#-------------------------------------------------------------------------------
# Build options
#-------------------------------------------------------------------------------
option(BUILD_DEBUG "Build with debug settings" OFF)
option(BUILD_DOCS "Build documentation" OFF)
#-------------------------------------------------------------------------------
# Platform-specific settings
#-------------------------------------------------------------------------------
###################
# Building on OSX #
###################
if(APPLE)
# Clang configuration
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CLANG_CXX_FLAGS "-std=c++11 -m64")
if(BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else(BUILD_DEBUG)
set(CLANG_CXX_FLAGS "${CLANG_CXX_FLAGS} -O3")
set(CLANG_CXX_FLAGS "${CLANG_CXX_FLAGS} -funroll-loops")
set(CLANG_CXX_FLAGS "${CLANG_CXX_FLAGS} -Wno-narrowing")
set(CLANG_CXX_FLAGS "${CLANG_CXX_FLAGS} -Wno-deprecated-register")
endif(BUILD_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_CXX_FLAGS}")
endif()
# GCC configuration
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(GCC_CXX_FLAGS "-std=c++11 -m64")
if(BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else(BUILD_DEBUG)
set(GCC_CXX_FLAGS "${GCC_CXX_FLAGS} -O3")
set(GCC_CXX_FLAGS "${GCC_CXX_FLAGS} -fopenmp")
endif(BUILD_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CXX_FLAGS}")
endif()
endif(APPLE)
##################
# Build on Linux #
##################
set(LINUX UNIX AND NOT APPLE)
if(LINUX)
# GCC only
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(GCC_CXX_FLAGS "-std=c++11 -m64")
# Debug configuration
if(BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else(BUILD_DEBUG)
set(GCC_CXX_FLAGS "${GCC_CXX_FLAGS} -O3")
set(GCC_CXX_FLAGS "${GCC_CXX_FLAGS} -fopenmp")
endif(BUILD_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CXX_FLAGS}")
endif()
endif(LINUX)
####################
# Build on Windows #
####################
if(WIN32)
if(MSVC)
set(MSVC_CXX_FLAGS "-std=c++11")
if(BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else(BUILD_DEBUG)
endif(BUILD_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_FLAGS}")
endif(MSVC)
if(MINGW)
set(MSVC_CXX_FLAGS "-std=c++11")
if(BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
else(BUILD_DEBUG)
endif(BUILD_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_FLAGS}")
endif(MINGW)
endif(WIN32)
#-------------------------------------------------------------------------------
# Find dependencies
#-------------------------------------------------------------------------------
# Required packages
find_package(OpenGL REQUIRED)
find_package(Threads REQUIRED)
find_package(Freetype REQUIRED)
# CGL
add_subdirectory(CGL)
include_directories(CGL/include)
# Original file Copyright CMU462 Fall 2015:
# Kayvon Fatahalian, Keenan Crane,
# Sky Gao, Bryce Summers, Michael Choquette.
cmake_minimum_required(VERSION 2.8)
# Application source
set(APPLICATION_SOURCE
quad_test.cpp
)
#-------------------------------------------------------------------------------
# Set include directories
#-------------------------------------------------------------------------------
include_directories(
${GLEW_INCLUDE_DIRS}
${GLFW_INCLUDE_DIRS}
${CGL_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS}
)
if (WIN32)
include_directories(dirent)
endif(WIN32)
#-------------------------------------------------------------------------------
# Set link directories
#-------------------------------------------------------------------------------
link_directories(
${GLEW_LIBRARY_DIRS}
${GLFW_LIBRARY_DIRS}
${CGL_LIBRARY_DIRS}
${FREETYPE_LIBRARY_DIRS}
)
#-------------------------------------------------------------------------------
# Add executable
#-------------------------------------------------------------------------------
add_executable(quad_test ${APPLICATION_SOURCE})
target_link_libraries( quad_test
CGL ${CGL_LIBRARIES}
glew ${GLEW_LIBRARIES}
glfw ${GLFW_LIBRARIES}
${OPENGL_LIBRARIES}
${FREETYPE_LIBRARIES}
${CMAKE_THREADS_INIT}
)
#-------------------------------------------------------------------------------
# Platform-specific configurations for target
#-------------------------------------------------------------------------------
if(APPLE)
set_property( TARGET quad_test APPEND_STRING PROPERTY COMPILE_FLAGS
"-Wno-deprecated-declarations -Wno-c++11-extensions")
endif(APPLE)