-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
128 lines (100 loc) · 4.34 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
cmake_minimum_required(VERSION 3.15.0)
project(include)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/" ${CMAKE_MODULE_PATH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Use modern C++
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(OpenGL_GL_PREFERENCE GLVND)
#-------------------------------------------------------------------------------
# https://github.com/adishavit/argh/releases/tag/v1.3.1
include_directories(SYSTEM thirdparty/argh-1.3.1/)
#-------------------------------------------------------------------------------
# http://glew.sourceforge.net/
# include_directories(SYSTEM thirdparty/glew-2.1.0/include)
# https://glad.dav1d.de/
add_subdirectory(thirdparty/glad)
set(LIBRARIES ${LIBRARIES} glad)
#-------------------------------------------------------------------------------
# https://www.glfw.org/
# Turn off building their docs/tests/examples.
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(thirdparty/glfw-3.3.2)
set(LIBRARIES ${LIBRARIES} glfw)
#-------------------------------------------------------------------------------
# https://github.com/gurki/vivid/releases/tag/v2.2.1
include_directories(SYSTEM thirdparty/vivid-2.2.1/include)
include_directories(SYSTEM thirdparty/vivid-2.2.1/dependencies/glm)
#-------------------------------------------------------------------------------
# https://glm.g-truc.net/0.9.9/index.html
include_directories(SYSTEM thirdparty/glm-0.9.9.7/)
#-------------------------------------------------------------------------------
# https://fmt.dev/latest/index.html
# Turn off building their tests
set(FMT_TES OFF CACHE BOOL "" FORCE)
add_subdirectory(thirdparty/fmt-7.0.3)
set(LIBRARIES ${LIBRARIES} fmt::fmt)
include_directories(SYSTEM thirdparty/fmt-7.0.3/include)
include_directories(SYSTEM thirdparty/stb-2.26)
include_directories(SYSTEM thirdparty/imgui-1.78)
find_package(OpenGL REQUIRED)
set(LIBRARIES ${LIBRARIES} ${OPENGL_gl_LIBRARY})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
list(APPEND _453_CMAKE_CXX_FLAGS ${_453_CMAKE_CXX_FLAGS} "-Wall" "-pedantic")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
list(APPEND _453_CMAKE_CXX_FLAGS ${_453_CMAKE_CXX_FLAGS} "-fdiagnostics-color=always" "-Wall" "-pedantic")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_compile_options("/permissive-")
add_compile_options("/Zc:preprocessor")
# Remove the default warning level.
# https://stackoverflow.com/questions/58708772/cmake-project-in-visual-studio-gives-flag-override-warnings-command-line-warnin
string(REGEX REPLACE "/W[3|4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# The above preprocessor warns about certain things in windows headers.
# Turn those off: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5105?view=vs-2019
add_compile_options("/wd5105")
set(_453_CMAKE_CXX_FLAGS ${_453_CMAKE_CXX_FLAGS} /W3)
endif()
if(APPLE)
set(LIBRARIES ${LIBRARIES} pthread dl)
elseif(UNIX)
set(LIBRARIES ${LIBRARIES} pthread GL dl)
elseif(WIN32)
endif()
add_definitions(-DIMGUI_IMPL_OPENGL_LOADER_GLAD=ON)
# include_directories(SYSTEM thirdparty/imgui thirdparty/imgui/examples)
# include_directories(src)
include_directories(src)
# Compile our main application
file(GLOB SOURCES
include/*
#thirdparty/glew-2.1.0/src/glew.c
src/*
src/*.h
thirdparty/imgui-1.78/imgui/*.cpp
)
set(INCLUDES ${INCLUDES} src)
set(APP_NAME "orrery")
# Copy all the shaders and tell the build system to re-run CMAKE if one of them changes
file(GLOB files include/shaders/*)
foreach(file ${files})
get_filename_component(name ${file} NAME)
configure_file(${file} shaders/${name})
endforeach()
file(GLOB files_t textures/*)
foreach(file ${files_t})
get_filename_component(name ${file} NAME)
configure_file(${file} textures/${name} COPYONLY)
endforeach()
add_executable(${APP_NAME} ${SOURCES})
target_include_directories(${APP_NAME} PRIVATE ${INCLUDES})
target_link_libraries(${APP_NAME} ${LIBRARIES})
target_compile_definitions(${APP_NAME} PRIVATE ${DEFINITIONS})
target_compile_options(${APP_NAME} PRIVATE ${_453_CMAKE_CXX_FLAGS})
set_target_properties(${APP_NAME} PROPERTIES INSTALL_RPATH "./" BUILD_RPATH "./")