2020-12-22 18:10:01 +01:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(libimhex)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
2021-04-18 20:24:42 +02:00
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/imgui ${CMAKE_CURRENT_BINARY_DIR}/external/imgui)
|
2021-12-17 09:52:11 +01:00
|
|
|
set_target_properties(imgui PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/microtar ${CMAKE_CURRENT_BINARY_DIR}/external/microtar EXCLUDE_FROM_ALL)
|
2021-12-17 09:52:11 +01:00
|
|
|
set_target_properties(microtar PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
2022-07-02 20:11:43 +02:00
|
|
|
set(NFD_PORTAL ON CACHE BOOL "Use Portals for Linux file dialogs" FORCE)
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/nativefiledialog ${CMAKE_CURRENT_BINARY_DIR}/external/nativefiledialog EXCLUDE_FROM_ALL)
|
2021-12-17 09:52:11 +01:00
|
|
|
set_target_properties(nfd PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
2021-09-23 22:56:49 +02:00
|
|
|
|
2022-01-15 00:14:12 +01:00
|
|
|
set(LIBROMFS_RESOURCE_LOCATION ${IMHEX_BASE_FOLDER}/resources/romfs)
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/libromfs ${CMAKE_CURRENT_BINARY_DIR}/external/libromfs EXCLUDE_FROM_ALL)
|
2021-12-22 15:06:16 +01:00
|
|
|
set_target_properties(libromfs PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
2022-01-16 14:20:52 +01:00
|
|
|
set(XDGPP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../external/xdgpp")
|
2022-01-13 21:30:42 +01:00
|
|
|
set(CURL_USE_MBEDTLS ON)
|
2021-09-23 22:56:49 +02:00
|
|
|
set(BUILD_CURL_EXE OFF)
|
|
|
|
set(FPHSA_NAME_MISMATCHED ON CACHE BOOL "")
|
2021-05-23 12:16:14 +02:00
|
|
|
|
2021-12-14 20:16:59 +01:00
|
|
|
# Find packages
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
2021-05-23 14:16:38 +02:00
|
|
|
if(NOT USE_SYSTEM_NLOHMANN_JSON)
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/nlohmann_json ${CMAKE_CURRENT_BINARY_DIR}/external/nlohmann_json EXCLUDE_FROM_ALL)
|
2021-09-23 22:01:38 +02:00
|
|
|
set(NLOHMANN_JSON_LIBRARIES nlohmann_json)
|
2021-05-23 14:16:38 +02:00
|
|
|
else()
|
2021-09-21 22:21:43 +02:00
|
|
|
find_package(nlohmann_json 3.10.2 REQUIRED)
|
2021-09-23 22:01:38 +02:00
|
|
|
set(NLOHMANN_JSON_LIBRARIES nlohmann_json::nlohmann_json)
|
2021-05-23 12:16:14 +02:00
|
|
|
endif()
|
|
|
|
|
2021-05-23 14:16:38 +02:00
|
|
|
if(NOT USE_SYSTEM_FMT)
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/fmt ${CMAKE_CURRENT_BINARY_DIR}/external/fmt EXCLUDE_FROM_ALL)
|
2021-09-23 22:01:38 +02:00
|
|
|
set(FMT_LIBRARIES fmt-header-only)
|
2021-05-23 14:16:38 +02:00
|
|
|
else()
|
2021-09-21 22:21:43 +02:00
|
|
|
find_package(fmt 8.0.0 REQUIRED)
|
2021-09-23 22:01:38 +02:00
|
|
|
set(FMT_LIBRARIES fmt::fmt)
|
2021-05-23 14:16:38 +02:00
|
|
|
endif()
|
2021-05-23 12:16:14 +02:00
|
|
|
|
2021-05-23 14:16:38 +02:00
|
|
|
if(NOT USE_SYSTEM_CURL)
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/curl ${CMAKE_CURRENT_BINARY_DIR}/external/curl EXCLUDE_FROM_ALL)
|
2021-05-23 14:16:38 +02:00
|
|
|
set_target_properties(libcurl PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
2021-09-23 22:01:38 +02:00
|
|
|
set(LIBCURL_LIBRARIES libcurl)
|
2021-05-23 14:16:38 +02:00
|
|
|
else()
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2021-09-21 22:21:43 +02:00
|
|
|
pkg_check_modules(LIBCURL REQUIRED IMPORTED_TARGET libcurl>=7.78.0)
|
2021-05-23 14:16:38 +02:00
|
|
|
endif()
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2021-09-23 22:56:49 +02:00
|
|
|
if (NOT USE_SYSTEM_LLVM)
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/llvm ${CMAKE_CURRENT_BINARY_DIR}/external/llvm EXCLUDE_FROM_ALL)
|
2021-12-17 09:52:11 +01:00
|
|
|
set_target_properties(LLVMDemangle PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
2021-09-23 22:56:49 +02:00
|
|
|
else()
|
|
|
|
find_package(LLVM REQUIRED Demangle)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT USE_SYSTEM_YARA)
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/yara ${CMAKE_CURRENT_BINARY_DIR}/external/yara EXCLUDE_FROM_ALL)
|
2021-12-17 09:52:11 +01:00
|
|
|
set_target_properties(libyara PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
2021-09-23 22:56:49 +02:00
|
|
|
set(YARA_LIBRARIES libyara)
|
|
|
|
else()
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(YARA REQUIRED IMPORTED_TARGET yara)
|
|
|
|
endif()
|
|
|
|
|
2021-12-15 23:28:47 +01:00
|
|
|
if (NOT USE_SYSTEM_CAPSTONE)
|
2022-01-15 01:14:19 +01:00
|
|
|
set(CAPSTONE_BUILD_STATIC_RUNTIME OFF CACHE BOOL "Disable shared library building")
|
|
|
|
set(CAPSTONE_BUILD_SHARED OFF CACHE BOOL "Disable shared library building")
|
|
|
|
set(CAPSTONE_BUILD_TESTS OFF CACHE BOOL "Disable tests")
|
2022-01-16 14:20:52 +01:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/capstone ${CMAKE_CURRENT_BINARY_DIR}/external/capstone EXCLUDE_FROM_ALL)
|
2022-03-15 23:45:33 +01:00
|
|
|
set_target_properties(capstone PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
|
|
set(CAPSTONE_LIBRARIES "capstone")
|
2022-02-08 19:22:52 +01:00
|
|
|
set(CAPSTONE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../external/capstone/include)
|
2021-12-15 23:28:47 +01:00
|
|
|
else()
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_search_module(CAPSTONE 4.0.2 REQUIRED capstone)
|
|
|
|
endif()
|
|
|
|
|
2022-04-17 16:57:30 +02:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../external/pattern_language ${CMAKE_CURRENT_BINARY_DIR}/external/pattern_language EXCLUDE_FROM_ALL)
|
|
|
|
set_target_properties(libpl PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
2021-12-15 23:28:47 +01:00
|
|
|
|
2021-12-14 20:16:59 +01:00
|
|
|
find_package(mbedTLS 2.26.0 REQUIRED)
|
|
|
|
configurePython()
|
|
|
|
|
|
|
|
pkg_search_module(MAGIC libmagic>=5.39)
|
|
|
|
if(NOT MAGIC_FOUND)
|
|
|
|
find_library(MAGIC 5.39 magic REQUIRED)
|
|
|
|
else()
|
|
|
|
set(MAGIC_INCLUDE_DIRS ${MAGIC_INCLUDEDIR})
|
|
|
|
endif()
|
|
|
|
|
2021-01-12 23:28:41 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
|
|
|
|
2021-10-16 11:37:29 +02:00
|
|
|
if (WIN32)
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols")
|
|
|
|
endif()
|
|
|
|
|
2021-01-12 23:49:51 +01:00
|
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
|
|
|
|
2021-03-01 08:56:49 +01:00
|
|
|
set(LIBIMHEX_SOURCES
|
|
|
|
source/api/event.cpp
|
|
|
|
source/api/imhex_api.cpp
|
|
|
|
source/api/content_registry.cpp
|
2021-12-16 23:48:52 +01:00
|
|
|
source/api/task.cpp
|
2021-12-23 15:11:38 +01:00
|
|
|
source/api/keybinding.cpp
|
2022-02-01 18:09:40 +01:00
|
|
|
source/api/plugin_manager.cpp
|
|
|
|
source/api/localization.cpp
|
2021-03-01 08:56:49 +01:00
|
|
|
|
2021-08-29 14:18:45 +02:00
|
|
|
source/data_processor/attribute.cpp
|
|
|
|
source/data_processor/link.cpp
|
|
|
|
source/data_processor/node.cpp
|
|
|
|
|
2021-03-01 08:56:49 +01:00
|
|
|
source/helpers/utils.cpp
|
2022-03-04 11:36:37 +01:00
|
|
|
source/helpers/fs.cpp
|
2021-09-06 16:15:05 +02:00
|
|
|
source/helpers/magic.cpp
|
2021-03-01 08:56:49 +01:00
|
|
|
source/helpers/crypto.cpp
|
2021-04-18 20:24:42 +02:00
|
|
|
source/helpers/net.cpp
|
2021-09-08 15:18:24 +02:00
|
|
|
source/helpers/file.cpp
|
2021-12-07 22:47:41 +01:00
|
|
|
source/helpers/socket.cpp
|
|
|
|
source/helpers/patches.cpp
|
|
|
|
source/helpers/project_file_handler.cpp
|
|
|
|
source/helpers/encoding_file.cpp
|
2022-01-17 20:06:00 +01:00
|
|
|
source/helpers/logger.cpp
|
2022-06-16 15:42:08 +02:00
|
|
|
source/helpers/tar.cpp
|
2021-09-08 15:18:24 +02:00
|
|
|
|
2021-03-01 08:56:49 +01:00
|
|
|
source/providers/provider.cpp
|
2021-02-03 11:54:41 +01:00
|
|
|
|
2021-12-31 01:10:06 +01:00
|
|
|
source/ui/imgui_imhex_extensions.cpp
|
2022-02-01 18:09:40 +01:00
|
|
|
source/ui/view.cpp
|
2022-06-16 15:42:08 +02:00
|
|
|
)
|
2020-12-27 14:12:53 +01:00
|
|
|
|
2021-03-01 08:56:49 +01:00
|
|
|
if (APPLE)
|
|
|
|
set(OSX_11_0_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk)
|
|
|
|
if (NOT CMAKE_OSX_SYSROOT)
|
|
|
|
if (IS_DIRECTORY ${OSX_11_0_SDK_PATH})
|
|
|
|
set(CMAKE_OSX_SYSROOT ${OSX_11_0_SDK_PATH})
|
|
|
|
else ()
|
|
|
|
message(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
2021-01-11 23:54:12 +01:00
|
|
|
|
2022-06-25 12:19:59 +02:00
|
|
|
set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES}
|
|
|
|
source/helpers/fs_macos.m
|
|
|
|
source/helpers/utils_macos.m)
|
2021-03-01 08:56:49 +01:00
|
|
|
endif ()
|
2020-12-27 14:12:53 +01:00
|
|
|
|
2022-02-02 17:19:50 +01:00
|
|
|
add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
|
|
|
|
2021-03-01 08:56:49 +01:00
|
|
|
add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
|
2021-12-17 09:52:11 +01:00
|
|
|
set_target_properties(libimhex PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
2022-03-27 00:01:28 +01:00
|
|
|
target_compile_options(libimhex PRIVATE -Wall -Wextra -Werror)
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2021-12-14 21:27:15 +01:00
|
|
|
target_include_directories(libimhex PUBLIC include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${Python_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${YARA_INCLUDE_DIRS})
|
2021-09-23 22:56:49 +02:00
|
|
|
target_link_directories(libimhex PUBLIC ${MBEDTLS_LIBRARY_DIR} ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS})
|
2021-02-03 11:54:41 +01:00
|
|
|
|
2021-04-18 20:24:42 +02:00
|
|
|
if (APPLE)
|
2021-03-01 08:56:49 +01:00
|
|
|
find_library(FOUNDATION NAMES Foundation)
|
2021-09-23 22:56:49 +02:00
|
|
|
target_link_libraries(libimhex PUBLIC ${FOUNDATION})
|
2021-05-23 14:16:38 +02:00
|
|
|
endif ()
|
2021-09-23 22:56:49 +02:00
|
|
|
|
2022-04-17 16:57:30 +02:00
|
|
|
target_link_libraries(libimhex PUBLIC dl imgui nfd magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${LIBCURL_LIBRARIES} ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES} ${Python_LIBRARIES} libromfs libpl)
|