-
Notifications
You must be signed in to change notification settings - Fork 58
/
CMakeLists.txt
78 lines (69 loc) · 3.19 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
#
# Copyright (c) 2019 Rokas Kupstys.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
cmake_minimum_required(VERSION 3.1)
project(ImNodes)
set(CMAKE_CXX_STANDARD 14)
set(IMNODES_IMGUI_VERSION "1.85" CACHE STRING "ImGui version to use for building sample,")
if (NOT IMGUI_DIR)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (IMGUI_DIR "${CMAKE_CURRENT_BINARY_DIR}/imgui-${IMNODES_IMGUI_VERSION}")
# Build samples and pull in engine dependency only when this library is built
# independently. These are not necessary when user is consuming library in their
# own project.
if (NOT EXISTS "${IMGUI_DIR}.zip")
file(DOWNLOAD "https://github.com/ocornut/imgui/archive/v${IMNODES_IMGUI_VERSION}.zip" ${IMGUI_DIR}.zip)
endif ()
if (NOT EXISTS "${IMGUI_DIR}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${IMGUI_DIR}.zip)
endif ()
endif ()
endif ()
if (NOT EXISTS "${IMGUI_DIR}/CMakeLists.txt")
file(DOWNLOAD "https://gist.githubusercontent.com/rokups/f771217b2d530d170db5cb1e08e9a8f4/raw/CMakeLists.txt" "${IMGUI_DIR}/CMakeLists.txt")
endif ()
set(IMGUI_DISABLE_OBSOLETE_FUNCTIONS ON)
add_subdirectory(${IMGUI_DIR})
# Warnings.
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-Wall -Wextra -Werror -Wunused-parameter -Wformat $<$<COMPILE_LANGUAGE:CXX>:-pedantic>)
endif ()
add_executable(ImNodes
ImNodes.h
ImNodes.cpp
ImNodesEz.h
ImNodesEz.cpp
sample.cpp
)
target_link_libraries(ImNodes PRIVATE imgui)
if (TARGET imgui-sdl)
target_link_libraries(ImNodes PRIVATE imgui-opengl3 imgui-sdl)
target_sources(ImNodes PRIVATE ${IMGUI_DIR}/examples/example_sdl_opengl3/main.cpp)
elseif (TARGET imgui-glfw)
target_link_libraries(ImNodes PRIVATE imgui-opengl3 imgui-glfw)
target_sources(ImNodes PRIVATE ${IMGUI_DIR}/examples/example_glfw_opengl3/main.cpp)
elseif (TARGET imgui-dx11)
target_link_libraries(ImNodes PRIVATE imgui-dx11 imgui-win32)
target_sources(ImNodes PRIVATE ${IMGUI_DIR}/examples/example_win32_directx11/main.cpp)
else ()
message(FATAL_ERROR "No suitable backend found.")
endif ()