-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
103 lines (80 loc) · 2.16 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
# Min. CMake version.
cmake_minimum_required(VERSION 2.8.10)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_PREFIX_PATH "./")
set(GLEW_DIR "./")
# Project name.
set(NAME flocking)
# A name of the project.
project(${NAME})
find_package(GLUT)
find_package(GLEW)
find_package(OpenGL REQUIRED)
# Set general compiler flags.
if (WIN32)
add_definitions(-D__WINDOWS__ -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
endif (WIN32)
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework OpenGL -framework GLUT")
endif (APPLE)
add_definitions(-Wall -pedantic -g)
# Flocking headers and cpps.
file(GLOB F_HDR "src/*.h")
file(GLOB F_SRC "src/*.cpp")
set(HDR ${F_HDR})
set(SRC ${F_SRC} main.cpp)
# Find includes in corresponding build directories.
set(CMAKE_INCLUDE_CURRENT_DIR ON)
source_group("Header Files\\" FILES ${HDR})
source_group("Source Files\\" FILES ${SRC})
# Add all files to excutable.
add_executable(${NAME}
${HDR}
${SRC}
)
# Use freeglut on Windows.
if (WIN32)
if (NOT GLUT_FOUND)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(GLUT_LIB_PATH freeglut/lib/x64)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(GLUT_LIB_PATH freeglut/lib)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(GLUT_LIBRARIES
NAMES freeglut
PATHS
${GLUT_LIB_PATH}
DOC "The GLUT library"
)
find_path(GLUT_INCLUDE_DIR GL/glut.h
freeglut/include
DOC "The directory where GL/glut.h resides"
)
endif (NOT GLUT_FOUND)
endif (WIN32)
# Add include directories.
set(SGL_INCLUDE_DIR ./sgl)
include_directories (SYSTEM
${SGL_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
add_definitions(-DNDEBUG)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
#set(CMAKE_CXX_FLAGS_DEBUG "-g")
endif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
target_link_libraries (${NAME} ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})
# Set output directory.
set(BIN_DIR ${CMAKE_SOURCE_DIR})
# Properties.
set_target_properties(${NAME} PROPERTIES
DEBUG_OUTPUT_NAME ${NAME}_d
RELEASE_OUTPUT_NAME ${NAME}
RUNTIME_OUTPUT_DIRECTORY ${BIN_DIR}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BIN_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BIN_DIR}
)