-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
54 lines (42 loc) · 1.68 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
cmake_minimum_required(VERSION 3.10)
project(OpenGLPlayground)
set(CMAKE_CXX_STANDARD 17)
set(OpenGL_GL_PREFERENCE "GLVND")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_package(GLEW 2.0 REQUIRED)
endif()
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
find_package(glm REQUIRED)
find_package(nlohmann_json REQUIRED)
# Include directories for external libraries
include_directories(include ${OPENGL_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} external/imgui external/ImGuiFileDialog)
# SDL2 and OpenGL libraries
set(IMGUI_SOURCES
external/imgui/imgui.cpp
external/imgui/imgui_draw.cpp
external/imgui/imgui_widgets.cpp
external/imgui/imgui_tables.cpp
external/imgui/backends/imgui_impl_sdl2.cpp
external/imgui/backends/imgui_impl_opengl3.cpp
external/ImGuiFileDialog/ImGuiFileDialog.cpp
)
file(GLOB SOURCES src/*.cpp)
# Disable tests and installation for nlohmann_json
set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install OFF CACHE INTERNAL "")
# Create imgui static library for target link
add_library(imgui STATIC ${IMGUI_SOURCES})
target_include_directories(imgui PRIVATE external/imgui)
# Create playground executable
add_executable(playground.app Main.cpp ${SOURCES})
# Add precompiled header
target_precompile_headers(playground.app PRIVATE include/OPPCH.h)
# Link libraries
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(playground.app imgui ${OPENGL_LIBRARIES} ${SDL2_LIBRARIES} GLEW::GLEW nlohmann_json::nlohmann_json)
else()
target_link_libraries(playground.app imgui ${OPENGL_LIBRARIES} ${SDL2_LIBRARIES} GLEW nlohmann_json::nlohmann_json)
endif()