2020-12-22 18:10:01 +01:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(libimhex)
|
|
|
|
|
2023-01-01 01:01:24 +01:00
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
2021-01-12 23:49:51 +01:00
|
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
|
|
|
|
2021-03-01 08:56:49 +01:00
|
|
|
set(LIBIMHEX_SOURCES
|
2023-04-07 10:21:27 +02:00
|
|
|
source/api/event.cpp
|
|
|
|
source/api/imhex_api.cpp
|
|
|
|
source/api/content_registry.cpp
|
|
|
|
source/api/task.cpp
|
|
|
|
source/api/keybinding.cpp
|
|
|
|
source/api/plugin_manager.cpp
|
|
|
|
source/api/localization.cpp
|
|
|
|
source/api/project_file_manager.cpp
|
|
|
|
source/api/theme_manager.cpp
|
2023-05-11 18:44:50 +02:00
|
|
|
source/api/layout_manager.cpp
|
2023-04-07 10:21:27 +02:00
|
|
|
|
|
|
|
source/data_processor/attribute.cpp
|
|
|
|
source/data_processor/link.cpp
|
|
|
|
source/data_processor/node.cpp
|
|
|
|
|
|
|
|
source/helpers/utils.cpp
|
2023-07-05 20:50:46 +02:00
|
|
|
source/helpers/utils_linux.cpp
|
2023-04-07 10:21:27 +02:00
|
|
|
source/helpers/fs.cpp
|
|
|
|
source/helpers/magic.cpp
|
|
|
|
source/helpers/crypto.cpp
|
|
|
|
source/helpers/http_requests.cpp
|
|
|
|
source/helpers/opengl.cpp
|
|
|
|
source/helpers/patches.cpp
|
|
|
|
source/helpers/encoding_file.cpp
|
|
|
|
source/helpers/logger.cpp
|
|
|
|
source/helpers/stacktrace.cpp
|
|
|
|
source/helpers/tar.cpp
|
|
|
|
|
|
|
|
source/providers/provider.cpp
|
|
|
|
|
|
|
|
source/ui/imgui_imhex_extensions.cpp
|
|
|
|
source/ui/view.cpp
|
|
|
|
source/ui/popup.cpp
|
|
|
|
)
|
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
|
|
|
|
2023-05-14 22:03:04 +02:00
|
|
|
set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES} 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)
|
2023-06-18 14:42:48 +02:00
|
|
|
setupCompilerFlags(libimhex)
|
2022-12-30 11:24:53 +01:00
|
|
|
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2023-01-17 21:38:56 +01:00
|
|
|
target_include_directories(libimhex PUBLIC include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${MAGIC_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${YARA_INCLUDE_DIRS} ${LIBBACKTRACE_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
|
|
|
|
2022-12-30 11:24:53 +01:00
|
|
|
if (WIN32)
|
|
|
|
target_link_options(libimhex PRIVATE -Wl,--export-all-symbols)
|
|
|
|
elseif (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
|
|
|
|
2023-01-04 12:34:38 +01:00
|
|
|
target_link_libraries(libimhex PRIVATE ${FMT_LIBRARIES})
|
2023-06-05 11:57:26 +02:00
|
|
|
target_link_libraries(libimhex PUBLIC dl imgui ${NFD_LIBRARIES} magic ${CAPSTONE_LIBRARIES} LLVMDemangle microtar ${NLOHMANN_JSON_LIBRARIES} ${YARA_LIBRARIES} ${LIBCURL_LIBRARIES} ${MBEDTLS_LIBRARIES} ${LIBBACKTRACE_LIBRARIES} libpl libpl-gen ${MINIAUDIO_LIBRARIES} libwolv-utils libwolv-io libwolv-hash libwolv-net libwolv-containers)
|
2023-06-26 14:01:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
if (DEFINED IMHEX_COMMIT_HASH_LONG AND DEFINED IMHEX_COMMIT_HASH_SHORT AND DEFINED IMHEX_COMMIT_BRANCH)
|
|
|
|
set(GIT_COMMIT_HASH_LONG "${IMHEX_COMMIT_HASH_LONG}")
|
|
|
|
set(GIT_COMMIT_HASH_SHORT "${IMHEX_COMMIT_HASH_SHORT}")
|
|
|
|
set(GIT_BRANCH "${IMHEX_COMMIT_BRANCH}")
|
|
|
|
else()
|
|
|
|
# Get the current working branch
|
|
|
|
execute_process(
|
|
|
|
COMMAND git rev-parse --abbrev-ref HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_BRANCH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
RESULT_VARIABLE RESULT_BRANCH
|
|
|
|
)
|
|
|
|
|
|
|
|
# Get the latest abbreviated commit hash of the working branch
|
|
|
|
execute_process(
|
|
|
|
COMMAND git log -1 --format=%h --abbrev=7
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_COMMIT_HASH_SHORT
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
RESULT_VARIABLE RESULT_HASH_SHORT
|
|
|
|
)
|
|
|
|
|
|
|
|
execute_process(
|
|
|
|
COMMAND git log -1 --format=%H
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_COMMIT_HASH_LONG
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
RESULT_VARIABLE RESULT_HASH_LONG
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if ((NOT GIT_COMMIT_HASH_SHORT STREQUAL "") AND (NOT GIT_COMMIT_HASH_LONG STREQUAL "") AND (NOT GIT_BRANCH STREQUAL ""))
|
|
|
|
addDefineToSource(source/api/imhex_api.cpp "GIT_COMMIT_HASH_SHORT=\"${GIT_COMMIT_HASH_SHORT}\"")
|
|
|
|
addDefineToSource(source/api/imhex_api.cpp "GIT_COMMIT_HASH_LONG=\"${GIT_COMMIT_HASH_LONG}\"")
|
|
|
|
addDefineToSource(source/api/imhex_api.cpp "GIT_BRANCH=\"${GIT_BRANCH}\"")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
addDefineToSource(source/api/imhex_api.cpp "IMHEX_VERSION=\"${IMHEX_VERSION_STRING}\"")
|