diff --git a/packaging/3rdParty-devel/patches/rhash/CMakeLists.txt b/packaging/3rdParty-devel/patches/rhash/CMakeLists.txt new file mode 100644 index 00000000..b3a93485 --- /dev/null +++ b/packaging/3rdParty-devel/patches/rhash/CMakeLists.txt @@ -0,0 +1,58 @@ +# Based on https://raw.githubusercontent.com/rhash/RHash/e601748b1c166791429944e2f4233ba6ba62988f/CMakeLists.txt + +cmake_minimum_required(VERSION 3.1) +project(rhash) + +file(READ "version.h" versionfile) +string(REGEX MATCH "#define VERSION \"([0-9]*)\.([0-9]*)\.([0-9]*)\"" _ ${versionfile}) +set(RHASH_VERSION_MAJOR ${CMAKE_MATCH_1}) +set(RHASH_VERSION_MINOR ${CMAKE_MATCH_2}) +set(RHASH_VERSION_PATCH ${CMAKE_MATCH_3}) +set(RHASH_VERSION "${RHASH_VERSION_MAJOR}.${RHASH_VERSION_MINOR}.${RHASH_VERSION_PATCH}") + +option(USE_GETTEXT "Enable gettext (localization) support") + +set(SOURCE_FILES "calc_sums.c" + "hash_print.c" + "common_func.c" + "hash_update.c" + "file.c" + "file_mask.c" + "file_set.c" + "find_file.c" + "hash_check.c" + "output.c" + "parse_cmdline.c" + "rhash_main.c" + "win_utils.c") + +set(HEADER_FILES "calc_sums.h" + "hash_print.h" + "common_func.h" + "hash_update.h" + "file.h" + "file_mask.h" + "file_set.h" + "find_file.h" + "hash_check.h" + "output.h" + "parse_cmdline.h" + "rhash_main.h" + "win_utils.h" + "platform.h" + "version.h") + +add_subdirectory("librhash") + +add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES}) +target_link_libraries(${CMAKE_PROJECT_NAME} librhash) + +if (USE_GETTEXT) + find_package(Intl REQUIRED) + target_link_libraries(${CMAKE_PROJECT_NAME} ${Intl_LIBRARIES}) + target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${Intl_INCLUDE_DIRS}) + target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE USE_GETTEXT) +endif() + +install(TARGETS ${CMAKE_PROJECT_NAME} + RUNTIME DESTINATION bin) diff --git a/packaging/3rdParty-devel/patches/rhash/librhash/CMakeLists.txt b/packaging/3rdParty-devel/patches/rhash/librhash/CMakeLists.txt new file mode 100644 index 00000000..1699dbdc --- /dev/null +++ b/packaging/3rdParty-devel/patches/rhash/librhash/CMakeLists.txt @@ -0,0 +1,112 @@ +# Based on https://raw.githubusercontent.com/rhash/RHash/e601748b1c166791429944e2f4233ba6ba62988f/librhash/CMakeLists.txt + +cmake_minimum_required(VERSION 3.1) +project(librhash LANGUAGES C) + +include(GNUInstallDirs) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON CACHE BOOL "Export all symbols when building shared library on Windows") + +option(USE_OPENSSL "Enable OpenSSL (optimized hash functions) support") +option(OPENSSL_RUNTIME "Load OpenSSL at runtime if present") + +set(SOURCE_FILES "algorithms.c" + "byte_order.c" + "plug_openssl.c" + "rhash.c" + "rhash_timing.c" + "rhash_torrent.c" + "aich.c" + "crc32.c" + "ed2k.c" + "edonr.c" + "hex.c" + "md4.c" + "md5.c" + "sha1.c" + "sha256.c" + "sha512.c" + "sha3.c" + "ripemd-160.c" + "gost12.c" + "gost94.c" + "has160.c" + "snefru.c" + "tiger.c" + "tiger_sbox.c" + "tth.c" + "torrent.c" + "whirlpool.c" + "whirlpool_sbox.c") + +set(HEADER_FILES "algorithms.h" + "byte_order.h" + "plug_openssl.h" + "rhash.h" + "rhash_timing.h" + "rhash_torrent.h" + "aich.h" + "crc32.h" + "ed2k.h" + "edonr.h" + "hex.h" + "md4.h" + "md5.h" + "sha1.h" + "sha256.h" + "sha512.h" + "sha3.h" + "ripemd-160.h" + "gost12.h" + "gost94.h" + "has160.h" + "snefru.h" + "tiger.h" + "tth.h" + "torrent.h" + "ustd.h" + "util.h" + "whirlpool.h") + +add_library(${PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES}) +set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}") + +if(USE_OPENSSL) + find_package(OpenSSL REQUIRED) + target_link_libraries(${PROJECT_NAME} OpenSSL::Crypto) + target_compile_definitions(${PROJECT_NAME} PUBLIC USE_OPENSSL) +endif() + +if(OPENSSL_RUNTIME) + target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_DL_LIBS}) + target_compile_definitions(${PROJECT_NAME} PRIVATE OPENSSL_RUNTIME) +endif() + +if(MSVC) + target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_DEPRECATE) +endif() + +set_target_properties(${PROJECT_NAME} PROPERTIES + COMPILE_DEFINITIONS IN_RHASH + DEFINE_SYMBOL RHASH_EXPORTS + PREFIX "" + IMPORT_PREFIX "" + VERSION ${RHASH_VERSION} + SOVERSION ${RHASH_VERSION_MAJOR}) + +export(TARGETS ${PROJECT_NAME} + NAMESPACE ${CMAKE_PROJECT_NAME}:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake") + +install(TARGETS ${PROJECT_NAME} + EXPORT ${CMAKE_PROJECT_NAME}Config + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install(FILES "rhash.h" "rhash_torrent.h" + DESTINATION include) + +install(EXPORT ${CMAKE_PROJECT_NAME}Config + DESTINATION "${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/cmake" + NAMESPACE ${CMAKE_PROJECT_NAME}::)