-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
74 lines (61 loc) · 2.76 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
# /////////////////////////////////////////////////////////////////////////////
# ///////////////////////////////// SETTINGS //////////////////////////////////
# /////////////////////////////////////////////////////////////////////////////
# Set standards
cmake_minimum_required(VERSION 3.10)
project(opengl-playground C CXX)
set(CMAKE_CXX_STANDARD 17)
set(default_build_type "Release")
# Setup Conan
if (EMSCRIPTEN)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL=2 -s USE_WEBGL2=1 -s BINARYEN_TRAP_MODE='clamp' -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2 -s DEMANGLE_SUPPORT=1 -std=c++17 -g4 --preload-file ../res")
else()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake")
file(DOWNLOAD
"https://raw.githubusercontent.com/conan-io/cmake-conan/v0.14/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_run(CONANFILE conanfile.txt BASIC_SETUP BUILD missing)
endif()
# /////////////////////////////////////////////////////////////////////////////
# ////////////////////////////// PROJECT FILES ////////////////////////////////
# /////////////////////////////////////////////////////////////////////////////
file(GLOB_RECURSE MY_SOURCES src/*)
# /////////////////////////////////////////////////////////////////////////////
# /////////////////////////////// DEPENDENCIES ////////////////////////////////
# /////////////////////////////////////////////////////////////////////////////
find_package(OpenGL REQUIRED)
# ------------------------- BUILD DEPENDENCIES IF NEEDED ----------------------
add_library(GLAD STATIC "lib/glad/src/glad.c")
add_library(STB_IMAGE STATIC "lib/stb_image/stb_image.cpp")
add_library(IMGUI STATIC "lib/imgui/imgui_impl_opengl3.cpp" "lib/imgui/imgui_impl_sdl.cpp")
# /////////////////////////////////////////////////////////////////////////////
# ///////////////////////////////// INCLUDES //////////////////////////////////
# /////////////////////////////////////////////////////////////////////////////
include_directories(
${OPENGL_INCLUDE_DIR}
lib/glad/include
lib
src
res
)
# /////////////////////////////////////////////////////////////////////////////
# /////////////////////////////////// BUILD ///////////////////////////////////
# /////////////////////////////////////////////////////////////////////////////
set(EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})
add_executable(${PROJECT_NAME} ${MY_SOURCES})
target_link_libraries(
${PROJECT_NAME}
${CONAN_LIBS}
${OPENGL_LIBRARIES}
GLAD
STB_IMAGE
IMGUI
)
if (UNIX)
target_link_libraries(${PROJECT_NAME} -ldl)
endif()