forked from dfranx/ImFileDialog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
68 lines (55 loc) · 1.85 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
cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 17)
project(ImFileDialogExample)
# source code
set(SOURCES
example.cpp
ImFileDialog.cpp
libs/imgui/imgui.cpp
libs/imgui/imgui_widgets.cpp
libs/imgui/imgui_draw.cpp
libs/imgui/imgui_tables.cpp
libs/imgui/backends/imgui_impl_opengl3.cpp
libs/imgui/backends/imgui_impl_sdl.cpp
)
# cmake toolchain
if(CMAKE_TOOLCHAIN_FILE)
include(${CMAKE_TOOLCHAIN_FILE})
endif(CMAKE_TOOLCHAIN_FILE)
# pkg
if (UNIX)
find_package(PkgConfig REQUIRED)
endif()
# sdl2
if(WIN32 OR APPLE OR NOT ${USE_PKG_CHECK_SDL})
find_package(SDL2 REQUIRED)
else()
pkg_check_modules(SDL2 REQUIRED sdl2)
endif()
# opengl
set(OpenGL_GL_PREFERENCE GLVND CACHE STRING "Linux only: if GLVND, use the vendor-neutral GL libraries (default). If LEGACY, use the legacy ones (might be necessary to have working optirun/primusrun)")
set_property(CACHE OpenGL_GL_PREFERENCE PROPERTY STRINGS GLVND LEGACY)
find_package(OpenGL REQUIRED)
# glew
find_package(GLEW REQUIRED)
# create executable
add_executable(ImFileDialogExample ${SOURCES})
# properties
set_target_properties(ImFileDialogExample PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)
# include directories
target_include_directories(ImFileDialogExample PRIVATE ${SDL2_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS})
target_include_directories(ImFileDialogExample PRIVATE libs libs/imgui)
# link libraries
target_link_libraries(ImFileDialogExample ${OPENGL_LIBRARIES})
if(WIN32)
# link specific win32 libraries
target_link_libraries(ImFileDialogExample GLEW::GLEW SDL2::SDL2 SDL2::SDL2main)
elseif(UNIX AND NOT APPLE)
# link linux libraries
target_link_libraries(ImFileDialogExample ${GLEW_LIBRARIES} ${SDL2_LIBRARIES} ${CMAKE_DL_LIBS} stdc++fs pthread)
elseif(APPLE)
target_link_libraries(ImFileDialogExample GLEW::GLEW ${SDL2_LIBRARIES} ${CMAKE_DL_LIBS})
endif()