-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
100 lines (78 loc) · 4.26 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
############################################
# OpenGL-Playground #
#------------------------------------------#
# @author Nikolaus Rauch #
# @date 13.02.2023 #
#------------------------------------------#
############################################
cmake_minimum_required( VERSION 3.9 )
project( opengl-playground )
message("\n * OpenGL Playground ")
message("\n * https://github.com/nikolausrauch/opengl-playground \n")
message(STATUS "${PROJECT_NAME} build environment --")
message(STATUS "Build system: ${CMAKE_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}")
#########################################
# Options #
#########################################
option(VIEWER_DEBUG "build with debug features" OFF)
option(VIEWER_LOG "build with logging features" ON)
if(VIEWER_DEBUG)
set(VIEWER_DEFINES "${VIEWER_DEFINES}; PLATFORM_DEBUG")
message(STATUS "viewer debug mode enabled")
endif()
if(VIEWER_LOG)
set(VIEWER_DEFINES "${VIEWER_DEFINES}; PLATFORM_LOG")
message(STATUS "viewer logging enabled")
endif()
#########################################
# CMake-Stuff #
#########################################
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
#########################################
# Build External-Libraries #
#########################################
add_subdirectory(external/glm)
target_compile_options(glm_static PRIVATE "$<$<CXX_COMPILER_ID:GNU>:${GCC_COMPILE_SUPPRESS_WARING}>")
target_include_directories( glm_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external>)
add_subdirectory(external/glad)
target_compile_options(glad_static PRIVATE "$<$<CXX_COMPILER_ID:GNU>:${GCC_COMPILE_SUPPRESS_WARING}>")
target_include_directories( glad_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/glad/include> )
add_subdirectory(external/glfw)
target_compile_options(glfw PRIVATE "$<$<CXX_COMPILER_ID:GNU>:${GCC_COMPILE_SUPPRESS_WARING}>")
target_include_directories( glfw PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/glfw/include> )
add_subdirectory(external/imgui)
target_compile_options(imgui_static PRIVATE "$<$<CXX_COMPILER_ID:GNU>:${GCC_COMPILE_SUPPRESS_WARING}>")
add_subdirectory(external/stb_image)
target_compile_options(stb_image PRIVATE "$<$<CXX_COMPILER_ID:GNU>:${GCC_COMPILE_SUPPRESS_WARING}>")
add_subdirectory(external/fmt)
target_compile_options(fmt PRIVATE "$<$<CXX_COMPILER_ID:GNU>:${GCC_COMPILE_SUPPRESS_WARING}>")
target_include_directories( fmt PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/fmt/include> )
add_subdirectory(external/tiny_obj_loader)
target_compile_options(tiny_obj PRIVATE "$<$<CXX_COMPILER_ID:GNU>:${GCC_COMPILE_SUPPRESS_WARING}>")
add_subdirectory(external/tiny_ply)
target_compile_options(tinyply PRIVATE "$<$<CXX_COMPILER_ID:GNU>:${GCC_COMPILE_SUPPRESS_WARING}>")
#########################################
# Global Compiler Options #
#########################################
set(GCC_COMPILE_OPTIONS "-Wall")
set(GCC_COMPILE_DEBUG_OPTIONS "${GCC_COMPILE_OPTIONS};-ggdb;-O0")
set(GCC_COMPILE_RELEASE_OPTIONS "${GCC_COMPILE_OPTIONS};-O3")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(MSVC_COMPILE_OPTIONS "/Wall")
set(MSVC_COMPILE_DEBUG_OPTIONS "${MSVC_COMPILE_OPTIONS};/Zi")
set(MSVC_COMPILE_RELEASE_OPTIONS "${MSVC_COMPILE_OPTIONS};/O2")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:GNU>,$<CONFIG:DEBUG>>:${GCC_COMPILE_DEBUG_OPTIONS}>")
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:GNU>,$<CONFIG:RELEASE>>:${GCC_COMPILE_RELEASE_OPTIONS}>")
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<CONFIG:DEBUG>>:${MSVC_COMPILE_DEBUG_OPTIONS}>")
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<CONFIG:RELEASE>>:${MSVC_COMPILE_RELEASE_OPTIONS}>")
#########################################
# Build OpenGL Wrapper and Viewer #
#########################################
add_subdirectory(viewer)
#########################################
# Build Examples #
#########################################
add_subdirectory(apps)