From c21ed31889704add1682b1b8385485b7d2f08eab Mon Sep 17 00:00:00 2001 From: Syping Date: Sat, 2 Mar 2024 22:22:05 +0100 Subject: [PATCH] minor fixes for DPPAsExternalProject --- CMakeLists.txt | 2 +- README.md | 3 ++- cmake/DPPAsExternalProject.cmake | 28 +++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 420013f..ec2568b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ target_compile_definitions(dtranslatebot PRIVATE if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914) target_compile_options(dtranslatebot PRIVATE $<$:/Zc:__cplusplus>) endif() -target_link_libraries(dtranslatebot PRIVATE Threads::Threads ${DPP_LIBRARIES} ${DTRANSLATEBOT_LIBRARIES}) +target_link_libraries(dtranslatebot PRIVATE ${DPP_LIBRARIES} ${DTRANSLATEBOT_LIBRARIES} Threads::Threads) target_include_directories(dtranslatebot PRIVATE ${DPP_INCLUDE_DIR}) set_target_properties(dtranslatebot PROPERTIES CXX_STANDARD 17 diff --git a/README.md b/README.md index c84ce50..1c79c3a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Open Source Discord Translation Bot - Translate incoming channel messages to a Webhook -- Support configuration through slashcommands and JSON +- Support configuration through slash commands and JSON - Cross-Platform #### Build Dependencies @@ -24,4 +24,5 @@ sudo cmake --install dtranslatebot-build ##### Optional CMake flags `-DWITH_BOOST=TRUE` +`-DWITH_DPP_AS_EXTERNAL_PROJECT=TRUE` `-DWITH_SYSTEMD=TRUE` diff --git a/cmake/DPPAsExternalProject.cmake b/cmake/DPPAsExternalProject.cmake index 50afe0c..d1cbcbf 100644 --- a/cmake/DPPAsExternalProject.cmake +++ b/cmake/DPPAsExternalProject.cmake @@ -16,7 +16,17 @@ * responsible for anything with use of the software, you are self responsible. ****************************************************************************]] -# OpenSSL needs to build with make +# Needed for compiler passthrough +if (DEFINED CMAKE_C_COMPILER) + set(CC_ENV "CC=${CMAKE_C_COMPILER}") + set(DEFINE_CMAKE_C_COMPILER "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}") +endif() + +if (DEFINED CMAKE_CXX_COMPILER) + set(DEFINE_CMAKE_CXX_COMPILER "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") +endif() + +# OpenSSL needs to be build with make find_program(MAKE_EXECUTABLE NAMES make gmake) if (NOT MAKE_EXECUTABLE) message(SEND_ERROR "make not found") @@ -36,9 +46,10 @@ include(ExternalProject) ExternalProject_Add(ZLIB URL https://www.zlib.net/zlib-1.3.1.tar.xz URL_HASH SHA256=38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32 - DOWNLOAD_EXTRACT_TIMESTAMP TRUE CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF + "-DCMAKE_BUILD_TYPE=$" + "${DEFINE_CMAKE_C_COMPILER}" "-DCMAKE_INSTALL_PREFIX=" -DZLIB_BUILD_EXAMPLES=OFF ) @@ -48,12 +59,15 @@ set(ZLIB_INSTALL_DIR "${INSTALL_DIR}") ExternalProject_Add(OpenSSL URL https://www.openssl.org/source/openssl-3.0.13.tar.gz URL_HASH SHA256=88525753f79d3bec27d2fa7c66aa0b92b3aa9498dafd93d7cfa4b3780cdae313 - DOWNLOAD_EXTRACT_TIMESTAMP TRUE CONFIGURE_COMMAND + "${CC_ENV}" "/config" "--prefix=" + $<$:-d> no-deprecated no-dtls + no-dso + no-engine no-shared no-zlib BUILD_COMMAND ${MAKE_EXECUTABLE} ${JOBS_ARGUMENT} @@ -63,11 +77,13 @@ ExternalProject_Get_Property(OpenSSL INSTALL_DIR) set(OpenSSL_INSTALL_DIR "${INSTALL_DIR}") ExternalProject_Add(DPP - GIT_REPOSITORY https://github.com/Syping/DPP.git - GIT_TAG dcd00001dfa145a03f80a0ad5317bc3e63252ead + URL https://github.com/Syping/DPP/archive/dcd00001dfa145a03f80a0ad5317bc3e63252ead.tar.gz + URL_HASH SHA256=42ff04b13a384591e819c100c4f40e12e31c8076769c168631eef85a8eeb0be3 CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF -DBUILD_VOICE_SUPPORT=OFF + "-DCMAKE_BUILD_TYPE=$" + "${DEFINE_CMAKE_CXX_COMPILER}" "-DCMAKE_INSTALL_PREFIX=" -DDPP_NO_VCPKG=ON -DRUN_LDCONFIG=OFF @@ -80,6 +96,7 @@ ExternalProject_Get_Property(DPP INSTALL_DIR) set(DPP_INSTALL_DIR "${INSTALL_DIR}") set(DPP_INCLUDE_DIR "${DPP_INSTALL_DIR}/include") set(DPP_LIBRARIES + -Wl,-Bstatic "-L${DPP_INSTALL_DIR}/lib" "-L${DPP_INSTALL_DIR}/lib64" -ldpp @@ -90,4 +107,5 @@ set(DPP_LIBRARIES "-L${ZLIB_INSTALL_DIR}/lib" "-L${ZLIB_INSTALL_DIR}/lib64" -lz + -Wl,-Bdynamic )