-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
71 lines (58 loc) · 2.08 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
cmake_minimum_required(VERSION 3.5)
project(solar_system VERSION 1.0)
# set output directory to ${CMAKE_SOURCE_DIR}/bin
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
find_package(OpenGL REQUIRED)
set(SOLAR_SYSTEM solar_system.out)
add_subdirectory(include)
if(APPLE)
find_package(Freetype REQUIRED)
message(STATUS "Found Freetype in ${FREETYPE_INCLUDE_DIRS}")
endif(APPLE)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include/glfw/include
${CMAKE_CURRENT_SOURCE_DIR}/include/glad/include
${CMAKE_CURRENT_SOURCE_DIR}/include/common
${CMAKE_CURRENT_SOURCE_DIR}/include/glm
)
add_library(GLAD "include/glad/src/glad.c")
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
GLAD
freetype
)
file(GLOB SHADERS
"src/shaders/*.glsl"
)
file(GLOB SRC_SOLAR_SYSTEM
"src/*.h"
"src/main.cpp"
${SHADERS}
)
add_executable(${SOLAR_SYSTEM} ${SRC_SOLAR_SYSTEM})
target_link_libraries(${SOLAR_SYSTEM} ${ALL_LIBS})
# copy shaders to ${CMAKE_SOURCE_DIR}/bin/shaders directory
# POST_BUILD is to override shaders directory
if (WIN32)
add_custom_command(
TARGET ${SOLAR_SYSTEM} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/shaders $<TARGET_FILE_DIR:${SOLAR_SYSTEM}>/shaders
)
elseif (UNIX AND NOT APPLE)
file(COPY ${CMAKE_SOURCE_DIR}/src/shaders DESTINATION ${CMAKE_SOURCE_DIR}/bin/)
elseif (APPLE)
makeLink(${CMAKE_SOURCE_DIR}/src/shaders ${CMAKE_SOURCE_DIR}/bin/shaders ${SOLAR_SYSTEM})
endif (WIN32)
# copy resources to ${CMAKE_SOURCE_DIR}/bin/resources directory
# POST_BUILD is to override resources directory
if (WIN32)
add_custom_command(
TARGET ${SOLAR_SYSTEM} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:${SOLAR_SYSTEM}>/resources
)
elseif (UNIX AND NOT APPLE)
file(COPY ${CMAKE_SOURCE_DIR}/resources DESTINATION ${CMAKE_SOURCE_DIR}/bin/)
elseif (APPLE)
makeLink(${CMAKE_SOURCE_DIR}/resources ${CMAKE_SOURCE_DIR}/bin/resources ${SOLAR_SYSTEM})
endif (WIN32)