-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
67 lines (54 loc) · 2.12 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.8.12)
project(infinityterrain)
find_package(OpenGL REQUIRED)
find_package(GLU REQUIRED)
# Suppress warnings of the deprecation of glut functions on macOS.
if(APPLE)
add_definitions(-Wno-deprecated-declarations)
endif()
### Output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
### Compilation flags: adapt to your needs ###
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj") ### Enable parallel compilation
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} )
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
### Add src to the include directories
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
### Add OpenGL
set(INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
set(LIBRARIES ${OPENGL_LIBRARIES})
### Include Eigen for linear algebra
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/ext/eigen")
### Include GLM
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/ext/glm")
### Compile GLFW3 statically
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
set(GLFW_BUILD_INSTALL OFF CACHE BOOL " " FORCE)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw" "glfw")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/ext/glfw/include")
set(LIBRARIES "glfw" ${GLFW_LIBRARIES})
### On windows, you also need glew
if((UNIX AND NOT APPLE) OR WIN32)
set(GLEW_INSTALL OFF CACHE BOOL " " FORCE)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/ext/glew" "glew")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/ext/glew/include")
list(APPEND LIBRARIES "glew")
endif()
if(APPLE)
list(APPEND LIBRARIES "-framework OpenGL")
endif()
### Compile all the cpp files in src
file(GLOB SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/lib/*.cpp"
)
add_executable(${PROJECT_NAME}_bin ${SOURCES})
target_link_libraries(${PROJECT_NAME}_bin ${LIBRARIES} ${OPENGL_LIBRARIES})