-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
51 lines (40 loc) · 1.48 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
cmake_minimum_required(VERSION 3.5)
project(main)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES
common.h
glad.c
stb_image.h
main.cpp
ShaderProgram.h
ShaderProgram.cpp)
set(ADDITIONAL_INCLUDE_DIRS
dependencies/include/GLAD)
set(ADDITIONAL_LIBRARY_DIRS
dependencies/lib)
set(ADDITIONAL_RUNTIME_LIBRARY_DIRS
dependencies/bin)
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
if(WIN32)
set(ADDITIONAL_INCLUDE_DIRS
${ADDITIONAL_INCLUDE_DIRS}
dependencies/include)
link_directories(${ADDITIONAL_LIBRARY_DIRS})
else()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
find_package(glfw3 REQUIRED)
endif()
include_directories(${ADDITIONAL_INCLUDE_DIRS})
find_package(OpenGL REQUIRED)
add_executable(main ${SOURCE_FILES})
target_include_directories(main PRIVATE ${OPENGL_INCLUDE_DIR})
add_custom_command(TARGET main POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/shaders" "${PROJECT_BINARY_DIR}")
if(WIN32)
add_custom_command(TARGET main POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/dependencies/bin" $<TARGET_FILE_DIR:main>)
#set(CMAKE_MSVCIDE_RUN_PATH ${ADDITIONAL_RUNTIME_LIBRARY_DIRS})
target_compile_options(main PRIVATE)
target_link_libraries(main LINK_PUBLIC ${OPENGL_gl_LIBRARY} glfw3dll)
else()
target_compile_options(main PRIVATE -Wnarrowing)
target_link_libraries(main LINK_PUBLIC ${OPENGL_gl_LIBRARY} glfw rt dl)
endif()