-
Notifications
You must be signed in to change notification settings - Fork 28
/
CMakeLists.txt
114 lines (91 loc) · 4.44 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
# check cmake version first
cmake_minimum_required(VERSION 3.13)
# disable inplace builds to prevent source tree corruption.
# if (" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
# message (FATAL_ERROR "Building inplace are not allowed. You should create a separate directory.")
# endif ()
# set cmake_install_prefix path
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation directory")
endif()
# project name
project(nn-editor)
option(NETEDIT_LOADER_CCCC "support cccc model loader" ON)
option(NETEDIT_LOADER_NCNN "support ncnn model loader" ON)
option(NETEDIT_LOADER_YAML_YOLO "support yaml yolo model loader" ON)
# import IMGUI
include(${CMAKE_SOURCE_DIR}/cmake/imgui.cmake)
# overlook, take care of severe warnings
# include(${CMAKE_SOURCE_DIR}/cmake/overlook.cmake)
# add a target
add_executable(${PROJECT_NAME})
set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS NDEBUG)
set_target_properties (${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
# collect the source files
list (APPEND NODE_EDITOR_SRCS nn-editor/nn_editor.cpp)
# list (APPEND NODE_EDITOR_SRCS nn-editor/nodeloader.cpp)
list (APPEND NODE_EDITOR_SRCS nn-editor/Fileloader.cpp)
# cccc is always loaded. qing zhi chi cccc.
list (APPEND NODE_EDITOR_SRCS 3rdparty/singlefilegraph/sfg.c)
list (APPEND NODE_EDITOR_SRCS nn-editor/ccccloader.cpp)
add_definitions(-DNETEDIT_LOADER_CCCC)
if(NETEDIT_LOADER_NCNN)
list (APPEND NODE_EDITOR_SRCS nn-editor/ncnnloader.cpp)
add_definitions(-DNETEDIT_LOADER_NCNN)
endif()
if(NETEDIT_LOADER_YAML_YOLO)
list (APPEND NODE_EDITOR_SRCS nn-editor/yamlyololoader.cpp)
add_definitions(-DNETEDIT_LOADER_YAML_YOLO)
set ( CMAKE_PREFIX_PATH "YAML-CPP-PATH")
find_package(YAML-CPP)
target_include_directories(${PROJECT_NAME} PRIVATE ${YAML_CPP_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${YAML_CPP_LIBRARIES})
endif()
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR})
enable_language(OBJCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-weak -Wunused-command-line-argument")
set(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -x objective-c++ -fobjc-weak -Wunused-command-line-argument")
set(CMAKE_EXE_LINKER_FLAGS "-framework Metal -framework MetalKit -framework Foundation -framework Cocoa -framework Carbon -framework GameController")
set(RESOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/nn-editor/ncnn-metadata.json)
target_sources(${PROJECT_NAME} PRIVATE ${RESOURCE_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/nn-editor/Info.plist
RESOURCE "${RESOURCE_FILES}")
list (APPEND NODE_EDITOR_SRCS nn-editor/main.mm)
else()
list (APPEND NODE_EDITOR_SRCS nn-editor/main.cpp)
endif(APPLE)
aux_source_directory(${CMAKE_SOURCE_DIR}/imnodes2 NODE_EDITOR_NODE_SRCS)
list (APPEND NODE_EDITOR_NB_SRCS 3rdparty/mlcc/convert.cpp)
list (APPEND NODE_EDITOR_NB_SRCS 3rdparty/mlcc/File.cpp)
list (APPEND NODE_EDITOR_DIALOG_SRCS 3rdparty/ImGuiFileDialog/ImGuiFileDialog.cpp)
target_sources (${PROJECT_NAME} PRIVATE ${NODE_EDITOR_SRCS})
target_sources (${PROJECT_NAME} PRIVATE ${NODE_EDITOR_NODE_SRCS})
target_sources (${PROJECT_NAME} PRIVATE ${NODE_EDITOR_NB_SRCS})
target_sources (${PROJECT_NAME} PRIVATE ${NODE_EDITOR_DIALOG_SRCS})
target_include_directories (${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/example)
target_include_directories (${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/nb)
target_include_directories (${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/imnodes)
target_include_directories (${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/ImGuiFileDialog)
target_link_libraries (${PROJECT_NAME} PRIVATE IMGUI)
if(NOT APPLE)
set ( CMAKE_PREFIX_PATH "SDL2-PATH")
find_package(SDL2 REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS} "./3rdparty/mlcc" "./3rdparty/singlefilegraph")
target_link_libraries(${PROJECT_NAME} PRIVATE ${SDL2_LIBRARIES})
endif(NOT APPLE)
if (UNIX)
target_link_directories (${PROJECT_NAME} PRIVATE /usr/local/lib)
target_link_libraries (${PROJECT_NAME} PRIVATE dl)
endif ()
target_link_libraries (${PROJECT_NAME} PRIVATE yaml-cpp)
if(APPLE)
install(TARGETS ${PROJECT_NAME} BUNDLE DESTINATION bin)
else()
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
endif(APPLE)
# summary
include(${CMAKE_SOURCE_DIR}/cmake/summary.cmake)