-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
153 lines (129 loc) · 5.55 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
cmake_minimum_required(VERSION 3.10)
set(BUILD_TYPE "Debug and Release" CACHE STRING "Choose Build type")
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
# set the project name
project(Visual_Node_System_Example LANGUAGES CXX)
# Set compiler flags based on VISUAL_NODE_SYSTEM_USE_STATIC_RUNTIME
if(MSVC)
# Disable C4251 warning
add_compile_options(/wd4251)
if(VISUAL_NODE_SYSTEM_USE_STATIC_RUNTIME)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
endif()
# Always add /MP for multi-processor compilation
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
# Turn on the ability to create folders to organize projects (.vcproj)
# It creates "CMakePredefinedTargets" folder by default and adds CMake
# defined projects like INSTALL.vcproj and ZERO_CHECK.vcproj
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Force your path to Dear ImGui
set(DEAR_IMGUI_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/imgui CACHE PATH "Path to Dear ImGui directory." FORCE)
# Adjust GLFW and GLEW linking based on VISUAL_NODE_SYSTEM_BUILD_SHARED_LIBS and VISUAL_NODE_SYSTEM_USE_STATIC_RUNTIME
if(VISUAL_NODE_SYSTEM_BUILD_SHARED_LIBS)
if(VISUAL_NODE_SYSTEM_USE_STATIC_RUNTIME)
message(WARNING "Building a shared library with static runtime is uncommon and may lead to issues.")
set(VISUAL_NODE_SYSTEM_GLFW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/GLFW/lib/x64/glfw3_mt.lib CACHE PATH "Path to GLFW library." FORCE)
set(GLEW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/glew2/lib/x64/glew32s.lib)
else()
set(VISUAL_NODE_SYSTEM_GLFW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/GLFW/lib/x64/glfw3dll.lib CACHE PATH "Path to GLFW library." FORCE)
set(GLEW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/glew2/lib/x64/glew32.lib)
endif()
set(VISUAL_NODE_SYSTEM_GLFW_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/ CACHE PATH "Path to GLFW include directory." FORCE)
else()
if(VISUAL_NODE_SYSTEM_USE_STATIC_RUNTIME)
set(VISUAL_NODE_SYSTEM_GLFW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/GLFW/lib/x64/glfw3_mt.lib CACHE PATH "Path to GLFW library." FORCE)
set(GLEW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/glew2/lib/x64/glew32s.lib)
else()
set(VISUAL_NODE_SYSTEM_GLFW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/GLFW/lib/x64/glfw3.lib CACHE PATH "Path to GLFW library." FORCE)
set(GLEW_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/glew2/lib/x64/glew32.lib)
endif()
endif()
# Define GLEW_STATIC for static builds
if(USE_STATIC_RUNTIME)
add_definitions(-DGLEW_STATIC)
endif()
if(NOT TARGET VisualNodeSystem)
add_subdirectory(SubSystems/VisualNodeSystem)
endif()
# *************** THIRD_PARTY ***************
set(imgui_SRC "")
if(NOT VISUAL_NODE_SYSTEM_BUILD_SHARED_LIBS)
list(APPEND imgui_SRC
"ThirdParty/imgui/imgui.cpp"
"ThirdParty/imgui/imgui_demo.cpp"
"ThirdParty/imgui/imgui_draw.cpp"
"ThirdParty/imgui/imgui_impl_glfw.cpp"
"ThirdParty/imgui/imgui_impl_opengl3.cpp"
"ThirdParty/imgui/imgui_tables.cpp"
"ThirdParty/imgui/imgui_widgets.cpp"
)
endif()
# *************** THIRD_PARTY END ***************
file(GLOB source_SRC
"CustomNode.h"
"CustomNode.cpp"
"CustomNode2.h"
"CustomNode2.cpp"
"CustomNode3.h"
"CustomNode3.cpp"
"CustomNode4.h"
"CustomNode4.cpp"
"CustomNodeStyleDemonstration.h"
"CustomNodeStyleDemonstration.cpp"
"main.cpp"
)
link_directories(${GLFW_LIB_DIR})
# add the executable
add_executable(Visual_Node_System_Example WIN32
${source_SRC}
# *************** THIRD_PARTY ***************
${imgui_SRC}
)
# Define GLEW_STATIC for static builds
if(VISUAL_NODE_SYSTEM_USE_STATIC_RUNTIME)
add_definitions(-DGLEW_STATIC)
endif()
target_link_libraries(Visual_Node_System_Example
PRIVATE
VisualNodeSystem
${GLEW_LIBRARY}
${VISUAL_NODE_SYSTEM_GLFW_LIBRARY}
opengl32.lib
)
source_group("Source Files" FILES ${source_SRC})
# *************** THIRD_PARTY ***************
source_group("Source Files/ThirdParty/imgui" FILES ${imgui_SRC})
# set the startup project
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Visual_Node_System_Example)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/glew2/include
${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty
${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/imgui
${VISUAL_NODE_SYSTEM_DIR}
${VISUAL_NODE_SYSTEM_THIRDPARTY_DIR}
)
# If building as DLL, copy necessary DLLs to output directory
if(VISUAL_NODE_SYSTEM_BUILD_SHARED_LIBS)
add_custom_command(TARGET Visual_Node_System_Example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/GLFW/lib/x64/glfw3.dll"
"$<TARGET_FILE_DIR:Visual_Node_System_Example>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE_DIR:VisualNodeSystem>/VisualNodeSystem.dll"
"$<TARGET_FILE_DIR:Visual_Node_System_Example>"
)
endif()
# If using dynamic runtime, copy necessary DLLs to output directory
if(NOT VISUAL_NODE_SYSTEM_USE_STATIC_RUNTIME)
add_custom_command(TARGET Visual_Node_System_Example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/glew2/lib/x64/glew32.dll"
"$<TARGET_FILE_DIR:Visual_Node_System_Example>"
)
endif()