-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
210 lines (172 loc) · 6.6 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
cmake_minimum_required(VERSION 3.6.0)
project(infiniteExplorer VERSION 0.1.0)
cmake_policy(SET CMP0079 NEW)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_STANDARD 20)
add_executable(infiniteExplorer)
# build libInfinite first
set(INFINITE_EXPORT_OODLE ON)
set(INFINITE_COPY_OODLE_DLL ON)
set(INFINITE_OODLE_DLL oo2core_8_win64.dll)
set(FUSE ON)
option(YTTRIUM_3D_VIEWER "Build the 3D viewer" ON)
option(BUILD_CLI_VERSION "Build CLI" ON)
option(SANITIZE_ADDRESS "use ASAN" OFF)
option(DOWNLOAD_PNGPP "Download libpng++ 2.10 from launchpad" OFF)
option(DOWNLOAD_PEDEPS_WIN "Download win64 version of pedeps from the github releases (used for windows CI builds)" OFF)
option(PEDEPS_COPY "Copy required libraries using pedeps" OFF)
set(PACKAGE_OUT_DIR "package/")
############################################################################
#
# For some reason, setting I can't add anything to PKG_CONFIG_PATH
# from within CMake, so it has to be done outside as an
# environment variable
#
# Because the .pc files don't support static linking, this path is still needed though
if(WIN32)
# where pkg-config can find the .pc files for winFSP installed by chocolatey
set(WINFSP_DIR "/c/Program Files (x86)/WinFSP/lib")
endif()
if(SANITIZE_ADDRESS)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
endif()
if(NOT DEFINED LIBINFINITE)
add_subdirectory(libInfinite/)
else()
add_library(Infinite UNKNOWN IMPORTED)
message(STATUS "Using libInfinite from ${LIBINFINITE}")
set_target_properties(Infinite PROPERTIES IMPORTED_LOCATION ${LIBINFINITE})
endif()
# all of this copying around is needed with linoodle because linoodle expects the dll to be in the cwd
if(${INFINITE_COPY_OODLE_DLL})
configure_file(libInfinite/${INFINITE_OODLE_DLL} ${INFINITE_OODLE_DLL} COPYONLY)
endif()
# 3D stuff
if(YTTRIUM_3D_VIEWER)
include(3D/CMakeLists.txt)
target_include_directories(infiniteExplorer PRIVATE 3D/yttrium/)
target_link_libraries(infiniteExplorer yttrium)
endif()
#include(net/CMakeLists.txt)
# FUSE
if(FUSE)
find_package(PkgConfig)
#if(WIN32)
# message(STATUS "adding WinFSP to PKG_CONFIG_PATH")
# set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}:${WINFSP_DIR}")
#endif()
pkg_check_modules(FUSE IMPORTED_TARGET fuse3)
if(NOT DEFINED FUSE_INCLUDE_DIRS)
message(STATUS "Could not find libfuse with pkgconfig")
find_package(FUSE)
if(NOT FUSE_FOUND)
if(WIN32)
message(STATUS "If you're trying to use winFSP, add the path to the lib folder to the PKG_CONFIG_PATH environment variable")
endif()
message(WARNING "Could not find libFuse. Disabling FUSE support")
set(FUSE OFF)
else()
target_include_directories(infiniteExplorer PRIVATE ${FUSE_INCLUDE_DIRS})
target_link_libraries(infiniteExplorer ${FUSE_LIBRARIES})
endif()
else()
string(REPLACE ";" " " FUSE_INCLUDE_DIRS "${FUSE_INCLUDE_DIRS}")
string(REPLACE ";" " " FUSE_LDFLAGS "${FUSE_LDFLAGS}")
message(STATUS "${FUSE_LDFLAGS}")
target_include_directories(infiniteExplorer PRIVATE "${FUSE_INCLUDE_DIRS}")
target_link_libraries(infiniteExplorer "${FUSE_LDFLAGS}")
endif()
endif()
#GTKmm
# only use pkgconfig when not cross compiling
if(NOT CUSTOM_GTKMM)
find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)
if(NOT DEFINED GTKMM_INCLUDE_DIRS)
message(STATUS "Could not find pkgconfig, trying to find gtkmm directly")
find_package(gtkmm-3.0)
#find_path(GTKMM_INCLUDE_DIRS gtkmm.h)
#message(STATUS "GTKmm include at ${GTKMM_INCLUDE_DIRS}")
else()
include_directories(${GTKMM_INCLUDE_DIRS})
#target_link_directories(infiniteExplorer ${GTKMM_LIBRARY_DIRS})
target_include_directories(infiniteExplorer PRIVATE ${GTKMM_INCLUDE_DIRS})
target_link_libraries(infiniteExplorer ${GTKMM_LIBRARIES})
message(STATUS "using system gtkmm from pkgconfig")
endif()
endif()
# Assimp
find_package(assimp REQUIRED)
target_link_libraries(infiniteExplorer assimp)
#find_package(jsoncpp REQUIRED)
#target_link_libraries(infiniteExplorer jsoncpp)
#find_package(PNG REQUIRED)
#target_link_libraries(infiniteExplorer ${PNG_LIBRARIES})
set_property(TARGET infiniteExplorer PROPERTY CXX_STANDARD 20)
set(sources PRIVATE main.cpp
MainWindow.cpp
FileList.cpp
ModuleDisplayManager.cpp
PropertiesDialog.cpp
LogViewer.cpp
LogManager.cpp
ManagedLogger.cpp
FileViewerManager.cpp
InfiniteFileViewer.cpp
ClosableTab.cpp
DataTableViewer.cpp
ContentTableViewer.cpp
StringTableViewer.cpp
TextureViewer.cpp
StringUtils.cpp
MeshViewer.cpp
BspViewer.cpp
VartViewer.cpp
VectorViewer.cpp
PmdfViewer.cpp
materialDialog.cpp)
target_sources(infiniteExplorer PRIVATE BitmapViewer.cpp)
if(FUSE)
set(sources ${sources} FuseDialog.cpp FuseProvider.cpp)
target_compile_definitions(infiniteExplorer PRIVATE USE_FUSE)
endif()
if(WIN32)
target_sources(infiniteExplorer PRIVATE ${sources} res/Icon.rc)
else()
target_sources(infiniteExplorer PRIVATE ${sources})
endif()
target_include_directories(infiniteExplorer PUBLIC .)
if(BUILD_CLI_VERSION)
add_subdirectory(argparse/)
include(cli/CMakeLists.txt)
endif()
# link libInfinite
target_link_libraries(infiniteExplorer Infinite)
# copy resource files
include(res/CMakeLists.txt)
copyres("")
configure_file(libInfinite/3rd_party/detex/LICENSE detex_LICENSE COPYONLY)
if(DOWNLOAD_PEDEPS_WIN)
include(FetchContent)
FetchContent_Declare(pedeps_release URL "https://github.com/brechtsanders/pedeps/releases/download/0.1.13/pedeps-0.1.13-win64.zip"
URL_HASH SHA256=3ac8b970f4e8525bf3fc5a699bd892a4be28bfad72946758d991ec5af18bfbeb)
FetchContent_MakeAvailable(pedeps_release)
#file(DOWNLOAD "https://github.com/brechtsanders/pedeps/releases/download/0.1.13/pedeps-0.1.13-win64.zip" "pedeps_win64.zip" SHOW_PROGRESS TLS_VERIFY ON)
#file(ARCHIVE_EXTRACT INPUT "pedeps_win64.zip" DESTINATION "pedeps/" PATTERNS "bin/*")
set(PEDEPS_COPYDEPS "${pedeps_release_SOURCE_DIR}/bin/copypedeps.exe")
endif()
if(PEDEPS_COPY)
copyres(${PACKAGE_OUT_DIR})
add_custom_command(TARGET infiniteExplorer
POST_BUILD
COMMENT "Copying required libraries to package directory"
COMMAND ${PEDEPS_COPYDEPS} ARGS "-r" $<TARGET_FILE:infiniteExplorer> ${PACKAGE_OUT_DIR})
add_custom_command(TARGET infiniteExplorer
POST_BUILD
COMMENT "Setting up the rest of the package's environment"
COMMAND "bash" ARGS "${CMAKE_CURRENT_LIST_DIR}/wincreatepackage.sh" ${PACKAGE_OUT_DIR}
DEPENDS wincreatepackage.sh)
endif()