2024-02-29 20:55:33 +01:00
|
|
|
#[[**************************************************************************
|
|
|
|
* dtranslatebot Discord Translate Bot
|
|
|
|
* Copyright (C) 2024 Syping
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* This software is provided as-is, no warranties are given to you, we are not
|
|
|
|
* responsible for anything with use of the software, you are self responsible.
|
|
|
|
****************************************************************************]]
|
|
|
|
|
2024-03-05 21:02:05 +01:00
|
|
|
include(ArgumentPassthrough)
|
2024-03-02 22:22:05 +01:00
|
|
|
|
2024-03-03 15:17:03 +01:00
|
|
|
# OpenSSL needs to be configured with perl and build with make
|
2024-02-29 20:55:33 +01:00
|
|
|
find_program(MAKE_EXECUTABLE NAMES make gmake)
|
2024-03-03 15:17:03 +01:00
|
|
|
if (NOT DEFINED MAKE_EXECUTABLE)
|
2024-02-29 20:55:33 +01:00
|
|
|
message(SEND_ERROR "make not found")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_program(NPROC_EXECUTABLE nproc)
|
2024-03-03 15:17:03 +01:00
|
|
|
if (DEFINED NPROC_EXECUTABLE)
|
2024-02-29 20:55:33 +01:00
|
|
|
execute_process(
|
2024-03-05 21:02:05 +01:00
|
|
|
COMMAND "${NPROC_EXECUTABLE}"
|
2024-02-29 20:55:33 +01:00
|
|
|
OUTPUT_VARIABLE NPROC
|
|
|
|
)
|
2024-03-05 21:02:05 +01:00
|
|
|
string(STRIP "${NPROC}" NPROC)
|
2024-03-11 03:24:01 +01:00
|
|
|
set(MAKE_JOBS_ARG "-j${NPROC}")
|
2024-02-29 20:55:33 +01:00
|
|
|
endif()
|
|
|
|
|
2024-03-17 05:22:22 +01:00
|
|
|
find_program(PERL_EXECUTABLE NAMES perl)
|
|
|
|
if (NOT DEFINED PERL_EXECUTABLE)
|
|
|
|
message(SEND_ERROR "perl not found")
|
|
|
|
endif()
|
|
|
|
|
2024-02-29 20:55:33 +01:00
|
|
|
include(ExternalProject)
|
|
|
|
ExternalProject_Add(ZLIB
|
|
|
|
URL https://www.zlib.net/zlib-1.3.1.tar.xz
|
|
|
|
URL_HASH SHA256=38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32
|
|
|
|
CMAKE_ARGS
|
|
|
|
-DBUILD_SHARED_LIBS=OFF
|
2024-03-11 03:24:01 +01:00
|
|
|
${CMAKE_PASSTHROUGH_ARGS}
|
2024-02-29 20:55:33 +01:00
|
|
|
"-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
|
|
|
|
-DZLIB_BUILD_EXAMPLES=OFF
|
2024-03-11 03:24:01 +01:00
|
|
|
${ZLIB_CONFIGURE_ARGS}
|
2024-02-29 20:55:33 +01:00
|
|
|
)
|
|
|
|
ExternalProject_Get_Property(ZLIB INSTALL_DIR)
|
2024-03-02 17:42:20 +01:00
|
|
|
set(ZLIB_INSTALL_DIR "${INSTALL_DIR}")
|
2024-02-29 20:55:33 +01:00
|
|
|
|
2024-03-11 03:24:01 +01:00
|
|
|
set(OPENSSL_PLATFORM_ARG $<$<BOOL:$ENV{MSYSTEM}>:mingw64>)
|
2024-02-29 20:55:33 +01:00
|
|
|
ExternalProject_Add(OpenSSL
|
|
|
|
URL https://www.openssl.org/source/openssl-3.0.13.tar.gz
|
|
|
|
URL_HASH SHA256=88525753f79d3bec27d2fa7c66aa0b92b3aa9498dafd93d7cfa4b3780cdae313
|
|
|
|
CONFIGURE_COMMAND
|
2024-03-05 21:02:05 +01:00
|
|
|
${CMAKE_PASSTHROUGH_ENV}
|
2024-03-03 15:17:03 +01:00
|
|
|
"${PERL_EXECUTABLE}"
|
|
|
|
"<SOURCE_DIR>/Configure"
|
2024-02-29 20:55:33 +01:00
|
|
|
"--prefix=<INSTALL_DIR>"
|
2024-03-02 22:22:05 +01:00
|
|
|
$<$<CONFIG:Debug>:-d>
|
2024-02-29 20:55:33 +01:00
|
|
|
no-deprecated
|
2024-03-02 22:22:05 +01:00
|
|
|
no-dso
|
2024-03-03 15:17:03 +01:00
|
|
|
no-dtls
|
2024-03-02 22:22:05 +01:00
|
|
|
no-engine
|
2024-02-29 20:55:33 +01:00
|
|
|
no-shared
|
|
|
|
no-zlib
|
2024-03-11 03:24:01 +01:00
|
|
|
${OPENSSL_PLATFORM_ARG}
|
|
|
|
${OPENSSL_CONFIGURE_ARGS}
|
|
|
|
BUILD_COMMAND "${MAKE_EXECUTABLE}" ${MAKE_JOBS_ARG} build_libs
|
|
|
|
INSTALL_COMMAND "${MAKE_EXECUTABLE}" ${MAKE_JOBS_ARG} install_dev
|
2024-02-29 20:55:33 +01:00
|
|
|
)
|
|
|
|
ExternalProject_Get_Property(OpenSSL INSTALL_DIR)
|
2024-03-02 17:42:20 +01:00
|
|
|
set(OpenSSL_INSTALL_DIR "${INSTALL_DIR}")
|
2024-02-29 20:55:33 +01:00
|
|
|
|
|
|
|
ExternalProject_Add(DPP
|
2024-03-02 22:22:05 +01:00
|
|
|
URL https://github.com/Syping/DPP/archive/dcd00001dfa145a03f80a0ad5317bc3e63252ead.tar.gz
|
|
|
|
URL_HASH SHA256=42ff04b13a384591e819c100c4f40e12e31c8076769c168631eef85a8eeb0be3
|
2024-02-29 20:55:33 +01:00
|
|
|
CMAKE_ARGS
|
2024-03-11 03:45:48 +01:00
|
|
|
-DAVX_TYPE=AVX0
|
2024-02-29 20:55:33 +01:00
|
|
|
-DBUILD_SHARED_LIBS=OFF
|
|
|
|
-DBUILD_VOICE_SUPPORT=OFF
|
2024-03-11 03:24:01 +01:00
|
|
|
${CMAKE_PASSTHROUGH_ARGS}
|
2024-02-29 20:55:33 +01:00
|
|
|
"-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
|
2024-03-06 16:20:47 +01:00
|
|
|
-DDPP_BUILD_TEST=OFF
|
2024-02-29 20:55:33 +01:00
|
|
|
-DDPP_NO_VCPKG=ON
|
2024-03-02 17:42:20 +01:00
|
|
|
-DRUN_LDCONFIG=OFF
|
2024-02-29 20:55:33 +01:00
|
|
|
"-DOpenSSL_ROOT=${OpenSSL_INSTALL_DIR}"
|
|
|
|
"-DZLIB_ROOT=${ZLIB_INSTALL_DIR}"
|
2024-03-11 03:24:01 +01:00
|
|
|
${DPP_CONFIGURE_ARGS}
|
|
|
|
DEPENDS OpenSSL ZLIB
|
2024-02-29 20:55:33 +01:00
|
|
|
)
|
2024-03-02 17:42:20 +01:00
|
|
|
ExternalProject_Get_Property(DPP INSTALL_DIR)
|
|
|
|
set(DPP_INSTALL_DIR "${INSTALL_DIR}")
|
|
|
|
set(DPP_INCLUDE_DIR "${DPP_INSTALL_DIR}/include")
|
|
|
|
set(DPP_LIBRARIES
|
2024-03-02 22:22:05 +01:00
|
|
|
-Wl,-Bstatic
|
2024-03-02 17:42:20 +01:00
|
|
|
"-L${DPP_INSTALL_DIR}/lib"
|
|
|
|
"-L${DPP_INSTALL_DIR}/lib64"
|
2024-03-06 16:20:47 +01:00
|
|
|
dpp
|
2024-03-02 17:42:20 +01:00
|
|
|
"-L${OpenSSL_INSTALL_DIR}/lib"
|
|
|
|
"-L${OpenSSL_INSTALL_DIR}/lib64"
|
2024-03-06 16:20:47 +01:00
|
|
|
ssl
|
|
|
|
crypto
|
2024-03-02 17:42:20 +01:00
|
|
|
"-L${ZLIB_INSTALL_DIR}/lib"
|
|
|
|
"-L${ZLIB_INSTALL_DIR}/lib64"
|
2024-03-06 16:42:53 +01:00
|
|
|
$<IF:$<BOOL:${WIN32}>,zlibstatic,z>
|
2024-03-02 22:22:05 +01:00
|
|
|
-Wl,-Bdynamic
|
2024-03-02 17:42:20 +01:00
|
|
|
)
|
2024-03-06 16:20:47 +01:00
|
|
|
if (WIN32)
|
|
|
|
set(DPP_DEFINITIONS DPP_STATIC)
|
|
|
|
list(APPEND DPP_LIBRARIES
|
|
|
|
ws2_32
|
|
|
|
)
|
|
|
|
endif()
|