-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
70 lines (57 loc) · 2.25 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
# Some functions require a certain version of cmake (for example file GLOB )
cmake_minimum_required(VERSION 2.8)
# Build options
option(BUILD_OPENGL_EXAMPLE "Build OpenGL example." OFF)
# Create the project
set(PROJECT_NAME fluidsim)
project(${PROJECT_NAME})
# Add the external module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/modules)
# Find external packages
find_package( PkgConfig )
pkg_check_modules( EIGEN3 REQUIRED eigen3 )
include_directories(${EIGEN3_INCLUDE_DIRS})
# Our own include directory
set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/include)
include_directories(${COMMON_INCLUDES})
# Debugger flag
set(CMAKE_CXX_FLAGS "-g")
# Creating our own ${PROJECCT_NAME} library
file(GLOB ${PROJECCT_NAME}_lib_SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
file(GLOB ${PROJECCT_NAME}_lib_HEADERS ${PROJECT_SOURCE_DIR}/include/*.h)
add_library(${PROJECT_NAME}_lib
${${PROJECCT_NAME}_lib_SOURCES}
${${PROJECCT_NAME}_lib_HEADERS})
set_target_properties(${PROJECT_NAME}_lib PROPERTIES COMPILE_FLAGS "-std=c++14")
# Add program executable (all examples)
# Simple example
add_executable(${PROJECT_NAME}_simple examples/simple.cpp)
target_link_libraries(${PROJECT_NAME}_simple
${PROJECT_NAME}_lib
)
set_target_properties(${PROJECT_NAME}_simple PROPERTIES COMPILE_FLAGS "-std=c++14")
# OpenGL example
if(BUILD_OPENGL_EXAMPLE)
find_package(GLFW3 REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})
add_subdirectory(${PROJECT_SOURCE_DIR}/ext/ElkEngine)
include_directories(${ELK_INCLUDE_DIRS})
include_directories(${GLEW_INCLUDE_DIR})
include_directories(${GLM_INCLUDE_DIR})
file(GLOB ${PROJECCT_NAME}_openGL_example_SOURCES
${PROJECT_SOURCE_DIR}/examples/opengl_example/*.cpp)
file(GLOB ${PROJECCT_NAME}_openGL_example_HEADERS
${PROJECT_SOURCE_DIR}/examples/opengl_example/*.h)
add_executable(${PROJECT_NAME}_openGL_example
${${PROJECCT_NAME}_openGL_example_SOURCES}
${${PROJECCT_NAME}_openGL_example_HEADERS})
target_link_libraries(${PROJECT_NAME}_openGL_example
${PROJECT_NAME}_lib
${ELK_LIBRARIES}
${GLFW_LIBRARIES}
)
set_target_properties(${PROJECT_NAME}_openGL_example
PROPERTIES COMPILE_FLAGS "-std=c++14")
target_compile_definitions(${PROJECT_NAME}_openGL_example
PRIVATE PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
endif()