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
|
|
|
|
2021-03-01 08:56:49 +01:00
|
|
|
set(LIBIMHEX_SOURCES
|
2023-04-07 10:21:27 +02:00
|
|
|
source/api/imhex_api.cpp
|
|
|
|
source/api/content_registry.cpp
|
2023-11-18 14:50:43 +01:00
|
|
|
source/api/event_manager.cpp
|
|
|
|
source/api/task_manager.cpp
|
|
|
|
source/api/shortcut_manager.cpp
|
2023-04-07 10:21:27 +02:00
|
|
|
source/api/plugin_manager.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-12-11 15:54:22 +01:00
|
|
|
source/api/workspace_manager.cpp
|
2023-08-06 21:33:15 +02:00
|
|
|
source/api/achievement_manager.cpp
|
2023-11-21 14:38:01 +01:00
|
|
|
source/api/localization_manager.cpp
|
2023-12-13 11:24:25 +01:00
|
|
|
source/api/tutorial_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
|
2023-10-04 12:00:32 +02:00
|
|
|
source/helpers/http_requests_native.cpp
|
|
|
|
source/helpers/http_requests_emscripten.cpp
|
2023-04-07 10:21:27 +02:00
|
|
|
source/helpers/opengl.cpp
|
|
|
|
source/helpers/patches.cpp
|
|
|
|
source/helpers/encoding_file.cpp
|
|
|
|
source/helpers/logger.cpp
|
|
|
|
source/helpers/tar.cpp
|
2023-10-13 23:46:48 +02:00
|
|
|
source/helpers/debugging.cpp
|
2023-04-07 10:21:27 +02:00
|
|
|
|
2024-02-26 20:51:08 +01:00
|
|
|
source/test/tests.cpp
|
|
|
|
|
2023-04-07 10:21:27 +02:00
|
|
|
source/providers/provider.cpp
|
2023-12-23 22:01:47 +01:00
|
|
|
source/providers/memory_provider.cpp
|
2023-11-25 12:43:48 +01:00
|
|
|
source/providers/undo/stack.cpp
|
2023-04-07 10:21:27 +02:00
|
|
|
|
|
|
|
source/ui/imgui_imhex_extensions.cpp
|
|
|
|
source/ui/view.cpp
|
|
|
|
source/ui/popup.cpp
|
2023-12-19 23:21:20 +01:00
|
|
|
source/ui/toast.cpp
|
2023-07-13 14:08:23 +02:00
|
|
|
|
|
|
|
source/subcommands/subcommands.cpp
|
2023-04-07 10:21:27 +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
|
|
|
|
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
|
|
|
|
2023-12-22 23:39:38 +01:00
|
|
|
if (IMHEX_EXTERNAL_PLUGIN_BUILD)
|
|
|
|
add_library(libimhex IMPORTED SHARED GLOBAL)
|
|
|
|
set(LIBIMHEX_LIBRARY_TYPE INTERFACE)
|
2023-10-04 12:00:32 +02:00
|
|
|
else()
|
2023-12-22 23:39:38 +01:00
|
|
|
if (IMHEX_STATIC_LINK_PLUGINS)
|
|
|
|
add_library(libimhex STATIC ${LIBIMHEX_SOURCES})
|
|
|
|
else()
|
|
|
|
add_library(libimhex SHARED ${LIBIMHEX_SOURCES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(LIBIMHEX_LIBRARY_TYPE PUBLIC)
|
2024-01-04 01:06:38 +01:00
|
|
|
target_compile_definitions(libimhex PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
|
2023-10-04 12:00:32 +02:00
|
|
|
endif()
|
|
|
|
|
2024-02-29 21:15:51 +01:00
|
|
|
|
|
|
|
if (DEFINED IMHEX_COMMIT_HASH_LONG AND DEFINED IMHEX_COMMIT_BRANCH)
|
|
|
|
set(GIT_COMMIT_HASH_LONG "${IMHEX_COMMIT_HASH_LONG}")
|
|
|
|
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
|
|
|
|
ERROR_QUIET
|
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
ERROR_QUIET
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (GIT_COMMIT_HASH_LONG STREQUAL "" OR GIT_BRANCH STREQUAL "")
|
|
|
|
message(WARNING "Failed to to determine commit hash/branch")
|
|
|
|
else()
|
|
|
|
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}\"")
|
|
|
|
|
2023-11-30 10:22:15 +01:00
|
|
|
enableUnityBuild(libimhex)
|
2023-06-18 14:42:48 +02:00
|
|
|
setupCompilerFlags(libimhex)
|
2022-12-30 11:24:53 +01:00
|
|
|
|
2023-07-25 11:25:59 +02:00
|
|
|
include(GenerateExportHeader)
|
|
|
|
generate_export_header(libimhex)
|
2020-12-22 18:10:01 +01:00
|
|
|
|
2024-01-26 12:13:22 +01:00
|
|
|
target_include_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} include ${XDGPP_INCLUDE_DIRS} ${MBEDTLS_INCLUDE_DIR} ${MAGIC_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} ${FMT_INCLUDE_DIRS} ${LIBBACKTRACE_INCLUDE_DIRS})
|
2023-12-22 23:39:38 +01:00
|
|
|
target_link_directories(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${MBEDTLS_LIBRARY_DIR} ${MAGIC_LIBRARY_DIRS})
|
2021-02-03 11:54:41 +01:00
|
|
|
|
2023-11-02 20:48:34 +01:00
|
|
|
if (NOT EMSCRIPTEN)
|
2023-10-04 12:00:32 +02:00
|
|
|
# curl is only used in non-emscripten builds
|
2024-01-26 12:13:22 +01:00
|
|
|
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${CURL_LIBRARIES})
|
2023-10-04 12:00:32 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2023-12-22 23:39:38 +01:00
|
|
|
if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD)
|
|
|
|
if (WIN32)
|
|
|
|
set_target_properties(libimhex PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
|
|
|
target_link_options(libimhex PRIVATE -Wl,--export-all-symbols)
|
|
|
|
elseif (APPLE)
|
|
|
|
find_library(FOUNDATION NAMES Foundation)
|
|
|
|
target_link_libraries(libimhex PUBLIC ${FOUNDATION})
|
|
|
|
endif ()
|
|
|
|
|
2024-01-26 12:36:07 +01:00
|
|
|
target_link_libraries(libimhex PRIVATE microtar libwolv ${NFD_LIBRARIES} magic dl ${JTHREAD_LIBRARIES})
|
2024-01-21 18:39:32 +01:00
|
|
|
target_link_libraries(libimhex PUBLIC libpl ${IMGUI_LIBRARIES})
|
2024-02-29 21:15:51 +01:00
|
|
|
|
|
|
|
precompileHeaders(libimhex "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
2023-12-22 23:39:38 +01:00
|
|
|
endif()
|
2021-09-23 22:56:49 +02:00
|
|
|
|
2024-05-01 20:36:10 +02:00
|
|
|
target_link_libraries(libimhex ${LIBIMHEX_LIBRARY_TYPE} ${NLOHMANN_JSON_LIBRARIES} imgui_all_includes ${MBEDTLS_LIBRARIES} ${FMT_LIBRARIES} ${LUNASVG_LIBRARIES})
|
2023-06-26 14:01:45 +02:00
|
|
|
|
2023-07-26 12:57:38 +02:00
|
|
|
set_property(TARGET libimhex PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
|
2023-06-26 14:01:45 +02:00
|
|
|
|
2024-03-11 21:08:23 +01:00
|
|
|
add_dependencies(imhex_all libimhex)
|
|
|
|
|
|
|
|
install(FILES "$<TARGET_FILE:libimhex>" DESTINATION "${CMAKE_INSTALL_LIBDIR}" PERMISSIONS ${LIBRARY_PERMISSIONS})
|
|
|
|
set_target_properties(libimhex PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
2024-04-27 20:19:26 +02:00
|
|
|
set_target_properties(libimhex PROPERTIES PREFIX "")
|