fix typo that droped 3/4 of the srouce

generate config.h

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
pull/2045/head
Rachel Powers 2023-03-24 13:57:10 -07:00
parent 8f57b06689
commit fb7c8d2ee4
5 changed files with 822 additions and 704 deletions

View File

@ -1,27 +1,43 @@
cmake_minimum_required(VERSION 3.15)
project(aria2 LANGUAGES CXX C VERSION 1.36.0)
project(
aria2
VERSION 1.36.0
HOMEPAGE_URL https://aria2.github.io/
LANGUAGES CXX C
)
# include(ConfigureChecks.cmake)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
######## Set compiler flags ########
# ####### Set compiler flags ########
set(CMAKE_CXX_STANDARD_REQUIRED true)
set(CMAKE_C_STANDARD_REQUIRED true)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)
include(GenerateExportHeader)
if (WIN32)
#include(GenerateExportHeader)
include(GenerateConfigH)
config_h_add_compile_definitions(PACKAGE="${PROJECT_NAME}")
config_h_add_compile_definitions(PACKAGE_NAME="${PROJECT_NAME}")
config_h_add_compile_definitions(PACKAGE_STRING="${PROJECT_NAME} ${PROJECT_VERSION}")
config_h_add_compile_definitions(PACKAGE_TARNAME="${PROJECT_NAME}")
config_h_add_compile_definitions(PACKAGE_URL="${PROJECT_HOMEPAGE_URL}")
config_h_add_compile_definitions(PACKAGE_BUGREPORT="https://github.com/aria2/aria2/issues")
config_h_add_compile_definitions(PACKAGE_VERSION="${PROJECT_VERSION}")
config_h_add_compile_definitions(VERSION="${PROJECT_VERSION}")
config_h_add_compile_definitions(HOST="${CMAKE_HOST_SYSTEM_PROCESSOR}")
config_h_add_compile_definitions(BUILD="${CMAKE_HOST_SYSTEM_PROCESSOR}")
config_h_add_compile_definitions(TARGET="${CMAKE_SYSTEM_PROCESSOR}")
if(WIN32)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -D_POSIX_C_SOURCE=1)
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat)
set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat)
set(CMAKE_STATIC_LINKER_FLAGS_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat)
set(EXTRALIBS -lws2_32 -lwsock32 -lgdi32 -liphlpapi -lpsapi ${EXTRALIBS})
endif()
option(WITH_LIBUV "Build with libuv" off)
@ -53,19 +69,19 @@ set(CA_BUNDLE "" CACHE FILEPATH "Define to choose default CA bundle.[Use FILE as
set(DISK_CACHE "" CACHE STRING "Define to choose default disk-cache size")
set(BASHCOMPLETIONDIR "" CACHE STRING "Directory to install bash_completion file")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -pipe)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
endif()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -pipe)
endif()
@ -76,7 +92,7 @@ option(ARIA2_STATIC "Set 'on' to build a statically linked aria2" off)
# define it as override. Use CXX11_OVERRIDE instead of override.
message(STATUS "Checking whether the C++ compiler supports `override` keyword")
set(_tmp_src
"\
"\
struct Base {
virtual void f() = 0;
};
@ -92,16 +108,17 @@ try_compile(CXX11_OVERRIDE
SOURCE_FROM_VAR cx11_override.cc _tmp_src
)
unset(_tmp_src)
if(CXX11_OVERRIDE)
add_compile_definitions(CXX11_OVERRIDE=override)
config_h_add_compile_definitions(CXX11_OVERRIDE=override)
message(STATUS "Checking whether the C++ compiler supports `override` keyword - yes")
else()
add_compile_definitions(CXX11_OVERRIDE=)
config_h_add_compile_definitions(CXX11_OVERRIDE=)
message(STATUS "Checking whether the C++ compiler supports `override` keyword - no")
endif()
if (ARIA2_STATIC)
if (WIN32)
if(ARIA2_STATIC)
if(WIN32)
# Define _USE_32BIT_TIME_T because 32bit library of MinGW-w64
# does not implement many 64bit version functions.
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -D_USE_32BIT_TIME_T)
@ -109,12 +126,12 @@ if (ARIA2_STATIC)
endif()
option(ENABLE_GNUTIL_SYSTEM_CRYPTO_POLICY "Enable gnutls system wide crypto policy" off)
if(ENABLE_GNUTIL_SYSTEM_CRYPTO_POLICY)
set(USE_GNUTLS_SYSTEM_CRYPTO_POLICY yes CACHE BOOL "Define to 1 if using gnutls system wide crypto policy .")
endif()
##### Check for Libraries #####
# #### Check for Libraries #####
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckCXXSymbolExists)
@ -123,6 +140,7 @@ include(CheckTypeSize)
include(CheckFunctionExists)
find_package(CPPUNIT)
if(CPPUNIT_FOUND)
set(HAVE_CPPUNIT yes CACHE BOOL "Define if you have CPPUNIT" FORCE)
else()
@ -130,11 +148,12 @@ else()
endif()
find_package(ZLIB 1.2.3)
if(ZLIB_FOUND)
set(HAVE_ZLIB yes CACHE BOOL "Define if you have zlib" FORCE)
set(ZLIB_CFLAGS "")
set(ZLIB_LIBS ${ZLIB_LIBRARIES})
add_compile_definitions(HAVE_ZLIB=1)
config_h_add_compile_definitions(HAVE_ZLIB=1)
set(save_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(save_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
@ -142,13 +161,15 @@ if(ZLIB_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
check_cxx_symbol_exists(gzbuffer zlib.h HAVE_GZBUFFER)
if(HAVE_GZBUFFER)
add_compile_definitions(HAVE_GZBUFFER)
config_h_add_compile_definitions(HAVE_GZBUFFER)
endif()
check_cxx_symbol_exists(gzsetparams zlib.h HAVE_GZSETPARAMS)
if(HAVE_GZSETPARAMS)
add_compile_definitions(HAVE_GZSETPARAMS)
config_h_add_compile_definitions(HAVE_GZSETPARAMS)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${save_CMAKE_REQUIRED_LIBRARIES})
@ -160,41 +181,45 @@ else()
endif()
find_package(LibUV 1.13)
if(LIBUV_FOUND)
set(HAVE_LIBUV yes CACHE BOOL "Define if you have libuv" FORCE)
set(LIBUV_CFLAGS "")
set(LIBUV_LIBS ${LIBUV_LIBRARIES})
add_compile_definitions(HAVE_LIBUV=1)
config_h_add_compile_definitions(HAVE_LIBUV=1)
else()
set(HAVE_LIBUV no CACHE BOOL "Define if you have libuv" FORCE)
endif()
find_package(LibXml2)
if(LibXml2_FOUND)
set(HAVE_LIBXML2 yes CACHE BOOL "Define if you have libxml2" FORCE)
set(LIBXML2_CFLAGS "")
set(LIBXML2_LIBS ${LIBXML2_LIBRARIES})
add_compile_definitions(HAVE_LIBXML2=1)
config_h_add_compile_definitions(HAVE_LIBXML2=1)
else()
set(HAVE_LIBXML2 no CACHE BOOL "Define if you have libxml2" FORCE)
endif()
find_package(EXPAT)
if(EXPAT_FOUND)
if(EXPAT_FOUND AND NOT HAVE_LIBXML2)
set(HAVE_LIBEXPAT yes CACHE BOOL "Define if you have libexpat" FORCE)
set(LIBEXPAT_CFLAGS "")
set(LIBEXPAT_LIBS ${EXPAT_LIBRARIES})
add_compile_definitions(HAVE_LIBEXPAT=1)
config_h_add_compile_definitions(HAVE_LIBEXPAT=1)
else()
set(HAVE_LIBEXPAT no CACHE BOOL "Define if you have libexpat" FORCE)
endif()
find_package(SQLite3)
if(SQLite3_FOUND)
set(HAVE_SQLITE3 yes CACHE BOOL "Define if you have sqlite3" FORCE)
set(SQLITE3_CFLAGS "")
set(SQLITE3_LIBS ${SQLite3_LIBRARIES})
add_compile_definitions(HAVE_SQLITE3=1)
config_h_add_compile_definitions(HAVE_SQLITE3=1)
set(save_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(save_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
@ -202,8 +227,9 @@ if(SQLite3_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${SQLite3_INCLUDE_DIRS})
check_cxx_symbol_exists(sqlite3_open_v2 sqlite3.h HAVE_SQLITE3_OPEN_V2)
if(HAVE_SQLITE3_OPEN_V2)
add_compile_definitions(HAVE_SQLITE3_OPEN_V2)
config_h_add_compile_definitions(HAVE_SQLITE3_OPEN_V2)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${save_CMAKE_REQUIRED_LIBRARIES})
@ -212,7 +238,7 @@ else()
set(HAVE_SQLITE3 no CACHE BOOL "Define if you have sqlite3" FORCE)
endif()
if (APPLE)
if(APPLE)
set(HAVE_OSX yes CACHE BOOL "On Mac OS X" FORCE)
else()
set(HAVE_OSX no CACHE BOOL "On Mac OS X" FORCE)
@ -231,18 +257,20 @@ if(WIN32)
share.h
)
foreach (header ${_check_headers})
foreach(header ${_check_headers})
string(TOUPPER ${header} header_var)
string(REPLACE "." "_" header_var ${header_var})
string(REPLACE "/" "_" header_var ${header_var})
set(header_var "HAVE_${header_var}")
set(${header_var})
check_include_file(${header} ${header_var})
if (${header_var})
add_compile_definitions(${header_var})
if(${header_var})
config_h_add_compile_definitions(${header_var})
else()
endif()
endforeach()
unset(_check_headers)
else()
@ -250,10 +278,11 @@ else()
endif()
set(HAVE_APPLETLS no CACHE BOOL "Define if you have Apple TLS" FORCE)
if(WITH_APPLETLS)
if(HAVE_OSX)
set(HAVE_APPLETLS yes CACHE BOOL "Define if you have Apple TLS" FORCE)
add_compile_definitions(HAVE_APPLETLS=1)
config_h_add_compile_definitions(HAVE_APPLETLS=1)
set(APPLETLS_LD_FLAGS "-framework CoreFoundation" "-framework Security")
set(HAVE_SSL yes CACHE BOOL "Have SSL support" FORCE)
set(HAVE_NATIVETLS yes CACHE BOOL "Have Native TLS" FORCE)
@ -262,6 +291,7 @@ if(WITH_APPLETLS)
endif()
set(HAVE_WINTLS no CACHE BOOL "Define if you have Windows TLS support" FORCE)
if(WITH_WINTLS)
if(WIN32)
find_library(HAVE_WINTLS_LIBS crypt32)
@ -272,8 +302,8 @@ if(WITH_WINTLS)
if(HAVE_WINTLS_LIBS AND HAVE_WINTLS_HEADERS)
set(HAVE_WINTLS yes CACHE BOOL "Define if you have Windows TLS support" FORCE)
add_compile_definitions(HAVE_WINTLS=1)
add_compile_definitions(SECURITY_WIN32=1) # Use security.h in WIN32 mode
config_h_add_compile_definitions(HAVE_WINTLS=1)
config_h_add_compile_definitions(SECURITY_WIN32=1) # Use security.h in WIN32 mode
set(WINTLS_LIBS "-lcrypt32 -lsecur32 -ladvapi32")
set(HAVE_SSL yes CACHE BOOL "Have SSL support" FORCE)
set(HAVE_NATIVETLS yes CACHE BOOL "Have Native TLS" FORCE)
@ -283,13 +313,15 @@ if(WITH_WINTLS)
endif()
set(HAVE_LIBGNUTLS no CACHE BOOL "Define if you have libguntls" FORCE)
if(WITH_GNUTLS)
find_package(GnuTLS 2.2.0)
if(GNUTLS_FOUND AND NOT HAVE_SSL)
set(HAVE_LIBGNUTLS yes CACHE BOOL "Define if you have libguntls" FORCE)
set(LIBGNUTLS_CFLAGS "${GNUTLS_DEFINITIONS}")
set(LIBGNUTLS_LIBS ${GNUTLS_LIBRARIES})
add_compile_definitions(HAVE_LIBGNUTLS=1)
config_h_add_compile_definitions(HAVE_LIBGNUTLS=1)
set(HAVE_SSL yes CACHE BOOL "Have SSL support" FORCE)
set(save_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@ -300,8 +332,9 @@ if(WITH_GNUTLS)
set(CMAKE_REQUIRED_DEFINITIONS ${GNUTLS_DEFINITIONS})
check_cxx_symbol_exists(gnutls_certificate_set_x509_system_trust gnutls/gnutls.h HAVE_GNUTLS_CERTIFICATE_SET_X509_SYSTEM_TRUST)
if(HAVE_GNUTLS_CERTIFICATE_SET_X509_SYSTEM_TRUST)
add_compile_definitions(HAVE_GNUTLS_CERTIFICATE_SET_X509_SYSTEM_TRUST)
config_h_add_compile_definitions(HAVE_GNUTLS_CERTIFICATE_SET_X509_SYSTEM_TRUST)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${save_CMAKE_REQUIRED_LIBRARIES})
@ -311,11 +344,13 @@ if(WITH_GNUTLS)
endif()
set(HAVE_OPENSSL no CACHE BOOL "Define is you have openssl" FORCE)
if(WITH_OPENSSL)
find_package(OpenSSL)
if(OPENSSL_FOUND AND NOT HAVE_SSL)
set(HAVE_OPENSSL yes CACHE BOOL "Define is you have openssl" FORCE)
add_compile_definitions(HAVE_OPENSSL=1)
config_h_add_compile_definitions(HAVE_OPENSSL=1)
set(save_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(save_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
@ -323,66 +358,75 @@ if(WITH_OPENSSL)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_cxx_symbol_exists(EVP_DigestInit_ex evp.h HAVE_EVP_DIGESTINIT_EX)
if(HAVE_EVP_DIGESTINIT_EX)
set(HAVE_OLD_OPENSSL yes CACHE BOOL "Define if you have old openssl" FORCE)
add_compile_definitions(HAVE_OLD_OPENSSL=1)
config_h_add_compile_definitions(HAVE_OLD_OPENSSL=1)
endif()
check_cxx_symbol_exists(EVP_sha224 evp.h HAVE_EVP_SHA224)
if(HAVE_EVP_SHA224)
add_compile_definitions(HAVE_EVP_SHA224)
config_h_add_compile_definitions(HAVE_EVP_SHA224)
endif()
check_cxx_symbol_exists(EVP_sha256 evp.h HAVE_EVP_SHA256)
if(HAVE_EVP_SHA256)
add_compile_definitions(HAVE_EVP_SHA256)
config_h_add_compile_definitions(HAVE_EVP_SHA256)
endif()
check_cxx_symbol_exists(EVP_sha384 evp.h HAVE_EVP_SHA384)
if(HAVE_EVP_SHA384)
add_compile_definitions(HAVE_EVP_SHA384)
config_h_add_compile_definitions(HAVE_EVP_SHA384)
endif()
check_cxx_symbol_exists(EVP_sha512 evp.h HAVE_EVP_SHA512)
if(HAVE_EVP_SHA512)
add_compile_definitions(HAVE_EVP_SHA512)
config_h_add_compile_definitions(HAVE_EVP_SHA512)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${save_CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${save_CMAKE_REQUIRED_INCLUDES})
endif()
endif()
set(HAVE_LIBNETTLE no CACHE BOOL "Define if you have libnettle" FORCE)
set(HAVE_LIBGMP no CACHE BOOL "Define if you have GNU Multiple Precision Arithmetis Library (GMP)" FORCE)
set(HAVE_LIBGCRYPT no CACHE BOOL "Define is you have LibGcrypt" FORCE)
if(NOT HAVE_OPENSSL)
if(WITH_LIBNETTLE)
find_package(Nettle)
if(NETTLE_FOUND AND NOT HAVE_NATIVETLS)
set(HAVE_LIBNETTLE yes CACHE BOOL "Define if you have libnettle" FORCE)
set(LIBNETTLE_CFLAGS "")
set(LIBNETTLE_LIBS ${NETTLE_LIBRARIES})
add_compile_definitions(HAVE_LIBNETTLE=1)
config_h_add_compile_definitions(HAVE_LIBNETTLE=1)
endif()
endif()
if(WITH_LIBGMP)
find_package(GMP)
if(GMP_FOUND AND (HAVE_LIBNETTLE OR HAVE_NATIVETLS) AND ENABLE_BITTORRENT)
set(LIBGMP_LIBS ${GMP_LIBRARIES} )
set(LIBGMP_CFLAGS "" )
if(GMP_FOUND AND(HAVE_LIBNETTLE OR HAVE_NATIVETLS) AND ENABLE_BITTORRENT)
set(LIBGMP_LIBS ${GMP_LIBRARIES})
set(LIBGMP_CFLAGS "")
set(HAVE_LIBGMP yes CACHE BOOL "Define if you have GNU Multiple Precision Arithmetis Library (GMP)" FORCE)
add_compile_definitions(HAVE_LIBGMP=1)
config_h_add_compile_definitions(HAVE_LIBGMP=1)
set(save_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
set(save_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_LIBRARIES ${GMP_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${GMP_INCLUDE_DIR})
check_cxx_symbol_exists(__gmpz_powm_sec gmp.h HAVE_MPZ_POWM_SEC)
if(HAVE_MPZ_POWM_SEC)
add_compile_definitions(HAVE_GMP_SEC=1)
config_h_add_compile_definitions(HAVE_GMP_SEC=1)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${save_CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${save_CMAKE_REQUIRED_INCLUDES})
endif()
@ -390,35 +434,39 @@ if(NOT HAVE_OPENSSL)
if(WITH_LIBGCRYPT)
find_package(LibGcrypt)
if(LibGcrypt_FOUND AND NOT HAVE_NATIVETLS AND NOT HAVE_LIBNETTLE)
set(LIBGCRYPT_CFLAGS "")
set(LIBGCRYPT_LIBS ${LibGcrypt_LIBRARIES})
set(HAVE_LIBGCRYPT yes CACHE BOOL "Define is you have LibGcrypt" FORCE)
add_compile_definitions(HAVE_LIBGCRYPT=1)
config_h_add_compile_definitions(HAVE_LIBGCRYPT=1)
endif()
endif()
endif()
set(HAVE_LIBSSH2 no CACHE BOOL "Define if you have LibSSH2" FORCE)
if(WITH_LIBSSH2)
find_package(LibSSH2)
if(LIBSSH2_FOUND)
set(HAVE_LIBSSH2 yes CACHE BOOL "Define if you have LibSSH2" FORCE)
set(LIBSSH2_CFLAGS "")
set(LIBSSH2_LIBS ${LIBSSH2_LIBRARIES})
add_compile_definitions(HAVE_LIBSSH2=1)
config_h_add_compile_definitions(HAVE_LIBSSH2=1)
endif()
endif()
set(HAVE_LIBCARES no CACHE BOOL "Define if you hae libcares" FORCE)
if(WITH_LIBCARES)
find_package(Libcares)
if(LIBCARES_FOUND)
set(HAVE_LIBCARES yes CACHE BOOL "Define if you hae libcares" FORCE)
set(LIBCARES_CFLAGS "")
set(LIBCARES_LIBS ${LIBCARES_LIBRARIES})
add_compile_definitions(HAVE_LIBCARES=1)
config_h_add_compile_definitions(HAVE_LIBCARES=1)
set(save_CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES})
set(save_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@ -429,12 +477,15 @@ if(WITH_LIBCARES)
set(CMAKE_EXTRA_INCLUDE_FILES ares.h)
check_type_size(ares_addr_node ARES_ADDR_NODE LANGUAGE CXX)
check_type_size(ares_set_servers ARES_SET_SERVERS LANGUAGE C)
if(ARES_ADDR_NODE)
add_compile_definitions(HAVE_ARES_ADDR_NODE)
config_h_add_compile_definitions(HAVE_ARES_ADDR_NODE)
endif()
if(ARES_SET_SERVERS)
add_compile_definitions(HAVE_ARES_SET_SERVERS)
config_h_add_compile_definitions(HAVE_ARES_SET_SERVERS)
endif()
set(CMAKE_REQUIRED_LIBRARIES ${save_CMAKE_REQUIRED_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${save_CMAKE_REQUIRED_INCLUDES})
set(CMAKE_EXTRA_INCLUDE_FILES ${save_CMAKE_EXTRA_INCLUDE_FILES})
@ -442,21 +493,22 @@ if(WITH_LIBCARES)
endif()
set(USE_MD "" CACHE STRING "What message digest implementation to use")
if(HAVE_APPLETLS)
set(USE_MD "apple" CACHE STRING "What message digest implementation to use" FORCE)
add_compile_definitions(USE_APPLE_MD=1)
config_h_add_compile_definitions(USE_APPLE_MD=1)
elseif(HAVE_LIBNETTLE)
set(USE_MD "libnettle" CACHE STRING "What message digest implementation to use" FORCE)
add_compile_definitions(USE_LIBNETTLE_MD=1)
config_h_add_compile_definitions(USE_LIBNETTLE_MD=1)
elseif(HAVE_LIBGCRYPT)
set(USE_MD "libgcrypt" CACHE STRING "What message digest implementation to use" FORCE)
add_compile_definitions(USE_LIBGCRYPT_MD=1)
config_h_add_compile_definitions(USE_LIBGCRYPT_MD=1)
elseif(HAVE_OPENSSL)
set(USE_MD "openssl" CACHE STRING "What message digest implementation to use" FORCE)
add_compile_definitions(USE_OPEMSSL_MD=1)
config_h_add_compile_definitions(USE_OPEMSSL_MD=1)
else()
set(USE_MD "internal" CACHE STRING "What message digest implementation to use" FORCE)
add_compile_definitions(USE_INTERNAL_MD=1)
config_h_add_compile_definitions(USE_INTERNAL_MD=1)
endif()
if(HAVE_SSL)
@ -464,8 +516,9 @@ if(HAVE_SSL)
else()
set(ENABLE_SSL no CACHE BOOL "If SSL support is enabled" FORCE)
endif()
if(ENABLE_SSL)
add_compile_definitions(ENABLE_SSL=1)
config_h_add_compile_definitions(ENABLE_SSL=1)
endif()
if(HAVE_LIBGMP OR HAVE_LIBGCRYPT OR HAVE_OPENSSL)
@ -473,8 +526,9 @@ if(HAVE_LIBGMP OR HAVE_LIBGCRYPT OR HAVE_OPENSSL)
else()
set(USE_INTERNAL_BIGNUM yes)
endif()
if(USE_INTERNAL_BIGNUM)
add_compile_definitions(USE_INTERNAL_BIGNUM=1)
config_h_add_compile_definitions(USE_INTERNAL_BIGNUM=1)
endif()
if(HAVE_LIBNETTLE OR HAVE_LIBGCRYPT OR HAVE_OPENSSL)
@ -482,28 +536,30 @@ if(HAVE_LIBNETTLE OR HAVE_LIBGCRYPT OR HAVE_OPENSSL)
else()
set(USE_INTERNAL_ARC4 yes)
endif()
if(USE_INTERNAL_ARC4)
add_compile_definitions(USE_INTERNAL_ARC4)
config_h_add_compile_definitions(USE_INTERNAL_ARC4)
endif()
if(ENABLE_BITTORRENT)
add_compile_definitions(ENABLE_BITTORRENT=1)
config_h_add_compile_definitions(ENABLE_BITTORRENT=1)
endif()
if((HAVE_LIBXML2 OR HAVE_LIBEXPAT) AND ENABLE_METALINK)
add_compile_definitions(ENABLE_METALINK=1)
config_h_add_compile_definitions(ENABLE_METALINK=1)
endif()
if(HAVE_LIBXML2 OR HAVE_LIBEXPAT)
set(HAVE_SOME_XMLLIB yes CACHE BOOL "either libxml2 or libxpax present" FORCE)
add_compile_definitions(HAVE_SOME_XMLLIB=1)
config_h_add_compile_definitions(HAVE_SOME_XMLLIB=1)
set(ENABLE_XML_RPC yes CACHE BOOL "XML RPC Enabled")
else()
set(HAVE_SOME_XMLLIB no CACHE BOOL "either libxml2 or libxpax present" FORCE)
set(ENABLE_XML_RPC no CACHE BOOL "XML RPC Enabled" FORCE)
endif()
if(ENABLE_XML_RPC)
add_compile_definitions(ENABLE_XML_RPC=1)
config_h_add_compile_definitions(ENABLE_XML_RPC=1)
endif()
if(HAVE_LIBCARES)
@ -511,13 +567,15 @@ if(HAVE_LIBCARES)
else()
set(ENABLE_ASYNC_DNS no CACHE BOOL "Async DNS Enabled" FORCE)
endif()
if(ENABLE_ASYNC_DNS)
add_compile_definitions(ENABLE_ASYNC_DNS=1)
config_h_add_compile_definitions(ENABLE_ASYNC_DNS=1)
endif()
check_cxx_symbol_exists(alloca "alloca.h;stdlib.h;cstdlib;malloc.h" HAVE_ALLOCA_H)
if(HAVE_ALLOCA_H)
add_compile_definitions(HAVE_ALLOCA_H)
config_h_add_compile_definitions(HAVE_ALLOCA_H)
endif()
set(_check_headers
@ -560,23 +618,26 @@ set(_check_headers
pwd.h
)
foreach (header ${_check_headers})
foreach(header ${_check_headers})
string(TOUPPER ${header} header_var)
string(REPLACE "." "_" header_var ${header_var})
string(REPLACE "/" "_" header_var ${header_var})
set(header_var "HAVE_${header_var}")
set(${header_var})
check_include_file(${header} ${header_var})
if (${header_var})
add_compile_definitions(${header_var})
if(${header_var})
config_h_add_compile_definitions(${header_var})
else()
endif()
endforeach()
unset(_check_headers)
check_include_file(stdbool.h HAVE_STDBOOL_H)
if(HAVE_STDBOOL_H)
add_compile_definitions(HAVE_STDBOOL_H=1)
config_h_add_compile_definitions(HAVE_STDBOOL_H=1)
endif()
if(cxx_constexpr IN_LIST CMAKE_CXX_COMPILE_FEATURES)
@ -591,7 +652,8 @@ check_type_size("struct timespec" HAVE_A2_STRUCT_TIMESPEC LANGUAGE CXX)
set(CMAKE_EXTRA_INCLUDE_FILES ${save_CMAKE_EXTRA_INCLUDE_FILES})
if(HAVE_A2_STRUCT_TIMESPEC)
add_compile_definitions(HAVE_A2_STRUCT_TIMESPEC)
set(HAVE_A2_STRUCT_TIMESPEC true)
config_h_add_compile_definitions(HAVE_A2_STRUCT_TIMESPEC)
endif()
find_package(Gettext)
@ -644,16 +706,18 @@ set(_check_funcs
utimes
)
foreach (func ${_check_funcs})
foreach(func ${_check_funcs})
string(TOUPPER ${func} func_var)
set(func_var "HAVE_${func_var}")
set(${func_var})
check_function_exists (${func} ${func_var})
if (${func_var})
add_compile_definitions(${func_var})
check_function_exists(${func} ${func_var})
if(${func_var})
config_h_add_compile_definitions(${func_var})
else()
endif()
endforeach()
unset(_check_funcs)
if(WITH_TCMALLOC AND WITH_JEMALLOC)
@ -661,16 +725,20 @@ if(WITH_TCMALLOC AND WITH_JEMALLOC)
endif()
set(HAVE_TCMALLOC no CACHE BOOL "If you have tcmalloc" FORCE)
if(WITH_TCMALLOC)
find_package(Tcmalloc)
if(Tcmalloc_FOUND)
set(HAVE_TCMALLOC yes CACHE BOOL "If you have tcmalloc" FORCE)
endif()
endif()
set(HAVE_JEMALLOC no CACHE BOOL "if you have jemalloc" FORCE)
if(WITH_JEMALLOC)
find_package(Jemalloc)
if(Jemalloc_FOUND)
set(HAVE_JEMALLOC yes CACHE BOOL "if you have jemalloc" FORCE)
endif()
@ -678,27 +746,38 @@ endif()
if(ENABLE_EPOLL)
check_function_exists(epoll_create HAVE_EPOLL)
if(HAVE_EPOLL)
add_compile_definitions(HAVE_EPOLL=1)
config_h_add_compile_definitions(HAVE_EPOLL=1)
endif()
endif()
check_function_exists(posix_fallocate HAVE_POSIX_FALLOCATE)
if(HAVE_POSIX_FALLOCATE)
config_h_add_compile_definitions(HAVE_POSIX_FALLOCATE=1)
endif()
check_function_exists(fallocate HAVE_FALLOCATE)
if(HAVE_FALLOCATE)
config_h_add_compile_definitions(HAVE_FALLOCATE=1)
endif()
if(HAVE_POSIX_FALLOCATE OR HAVE_FALLOCATE OR HAVE_OSX OR WIN_BUILD)
set(HAVE_SOME_FALLOCATE yes CACHE BOOL "if there is some fallocate support" FORCE)
add_compile_definitions(HAVE_SOME_FALLOCATE=1)
config_h_add_compile_definitions(HAVE_SOME_FALLOCATE=1)
else()
set(HAVE_SOME_FALLOCATE no CACHE BOOL "if there is some fallocate support" FORCE)
endif()
check_cxx_symbol_exists(asctime_r time.h HAVE_ASCTIME_R)
if(HAVE_ASCTIME_R)
add_compile_definitions(HAVE_ASCTIME_R=1)
config_h_add_compile_definitions(HAVE_ASCTIME_R=1)
endif()
check_cxx_symbol_exists(localtime_r time.h HAVE_LOCALTIME_R)
if(HAVE_LOCALTIME_R)
add_compile_definitions(HAVE_LOCALTIME_R=1)
config_h_add_compile_definitions(HAVE_LOCALTIME_R=1)
endif()
set(_check_funcs
@ -713,22 +792,24 @@ set(_check_funcs
kqueue
)
foreach (func ${_check_funcs})
foreach(func ${_check_funcs})
string(TOUPPER ${func} func_var)
set(func_var "HAVE_${func_var}")
set(${func_var})
check_function_exists (${func} ${func_var})
if (${func_var})
add_compile_definitions(${func_var})
check_function_exists(${func} ${func_var})
if(${func_var})
config_h_add_compile_definitions(${func_var})
else()
endif()
endforeach()
unset(_check_funcs)
if(HAVE_KQUEUE)
message(STATUS "Checking whether struct kevent.udata is intptr_t")
set(_tmp_src
"\
"\
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
@ -742,9 +823,10 @@ int main(int argc, char* argv[]) {
SOURCE_FROM_VAR kevent_udata_intptr_t_src.c _tmp_src
)
unset(_tmp_src)
if(KEVENT_UDATA_INTPTR_T)
message(STATUS "Checking whether struct kevent.udata is intptr_t - yes")
add_compile_definitions(KEVENT_UDATA_INTPTR_T=1)
config_h_add_compile_definitions(KEVENT_UDATA_INTPTR_T=1)
else()
message(STATUS "Checking whether struct kevent.udata is intptr_t - no")
endif()
@ -753,18 +835,22 @@ endif()
set(save_CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES})
set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h netinet/in.h)
check_type_size("struct sockaddr_in.sin_len" HAVE_SOCKADDR_IN_SIN_LEN)
if(HAVE_SOCKADDR_IN_SIN_LEN)
add_compile_definitions(HAVE_SOCKADDR_IN_SIN_LEN=1)
config_h_add_compile_definitions(HAVE_SOCKADDR_IN_SIN_LEN=1)
endif()
check_type_size("struct sockaddr_in6.sin6_len" HAVE_SOCKADDR_IN6_SIN6_LEN)
if(HAVE_SOCKADDR_IN6_SIN6_LEN)
add_compile_definitions(HAVE_SOCKADDR_IN6_SIN6_LEN=1)
config_h_add_compile_definitions(HAVE_SOCKADDR_IN6_SIN6_LEN=1)
endif()
set(CMAKE_EXTRA_INCLUDE_FILES ${save_CMAKE_EXTRA_INCLUDE_FILES})
message(STATUS "Checking whether struct option.name is assignable from const char*")
set(_tmp_src
"\
"\
#include <unistd.h>
#include <getopt.h>
int main(int argc, char* argv[]) {
@ -778,49 +864,55 @@ try_compile(HAVE_OPTION_CONST_NAME
SOURCE_FROM_VAR option_const_name.c _tmp_src
)
unset(_tmp_src)
if(HAVE_OPTION_CONST_NAME)
message(STATUS "Checking whether struct option.name is assignable from const char* - yes")
add_compile_definitions(HAVE_OPTION_CONST_NAME=1)
config_h_add_compile_definitions(HAVE_OPTION_CONST_NAME=1)
else()
message(STATUS "Checking whether struct option.name is assignable from const char* - no")
endif()
if(ENABLE_WEBSOCKET)
add_compile_definitions(ENABLE_WEBSOCKET=1)
config_h_add_compile_definitions(ENABLE_WEBSOCKET=1)
endif()
if (ARIA2_STATIC)
if (NOT WIN32 AND NOT APPLE)
if(ARIA2_STATIC)
if(NOT WIN32 AND NOT APPLE)
set(EXTRALIBS -lpthread -ldl -lrt ${EXTRALIBS})
endif()
endif()
if(ENABLE_WERROR)
add_compile_options( -Wall -Werror -Wformat-security)
add_compile_options(-Wall -Werror -Wformat-security)
endif()
add_link_options(${EXTRALIBS})
config_h_generate_header(config)
# pickup the generated config.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_compile_definitions(HAVE_CONFIG_H)
# add_subdirectory(po)
add_subdirectory(lib)
add_subdirectory(deps)
add_subdirectory(src)
# add_subdirectory(doc)
# add_subdirectory(test)
message(STATUS "summary of build options: \n\
Build: ${BUILD}
Host: ${HOST}
Target: ${TARGET}
Install prefix: ${PREFIX}
CC: ${CC}
CXX: ${CXX}
CPP: ${CPP}
CXXFLAGS: ${CXXFLAGS}
CFLAGS: ${CFLAGS}
CPPFLAGS: ${CPPFLAGS}
LDFLAGS: ${LDFLAGS}
Build: ${CMAKE_HOST_SYSTEM_PROCESSOR}
Host: ${CMAKE_HOST_SYSTEM_PROCESSOR}
Target: ${CMAKE_SYSTEM_PROCESSOR}
Install prefix: ${CMAKE_INSTALL_PREFIX}
CC: ${CMAKE_C_COMPILER}
CXX: ${CMAKE_CXX_COMPILER}
CPP: ${CMAKE_CPP_COMPILER}
CXXFLAGS: ${CMAKE_CXX_FLAGS}
CFLAGS: ${CMAKE_C_FLAGS}
CPPFLAGS: ${CMAKE_CPP_FLAGS}
LDFLAGS: EXE: ${CMAKE_EXE_LINKER_FLAGS} SHARED: ${CMAKE_SHARED_LINKER_FLAGS}
LIBS: ${LIBS}
DEFS: ${DEFS}
CXX1XCXXFLAGS: ${CXX1XCXXFLAGS}
@ -859,24 +951,21 @@ bash_completion dir: ${BASHCOMPLETIONDIR}
Static build: ${ARIA2_STATIC}
")
##### README Generation #####
# #### README Generation #####
find_package(Docutils)
if (Docutils_FOUND)
if (WIN32)
if(Docutils_FOUND)
if(WIN32)
find_package(PythonInterp)
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/README.html
COMMAND ${PYTHON_EXECUTABLE} ${RST2HTML_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/README.rst ${CMAKE_CURRENT_SOURCE_DIR}/README.html
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/README.rst
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/README.rst
)
add_custom_target(readme_html ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/README.html)
add_custom_target(readme_html ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/README.html)
else()
message(WARNING "rst2html not installed. Placing only a dummy file for README.html")
write_file(${CMAKE_CURRENT_SOURCE_DIR}/README.html
@ -900,21 +989,18 @@ add_custom_target(clang-format
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
########### install files ###############
# ########## install files ###############
install(FILES README README.rst README.html DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
install(FILES LICENSE.OpenSSL DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
# original Makefile.am contents follow:
#original Makefile.am contents follow:
#SUBDIRS = po lib deps src doc test
# SUBDIRS = po lib deps src doc test
#
#ACLOCAL_AMFLAGS = -I m4 --install
#RST2HTML = @RST2HTML@
# ACLOCAL_AMFLAGS = -I m4 --install
# RST2HTML = @RST2HTML@
#
#EXTRA_DIST = config.rpath \
# EXTRA_DIST = config.rpath \
# script-helper \
# makerelease \
# mingw-config mingw-release mingw-build-memo \
@ -924,26 +1010,26 @@ install(FILES LICENSE.OpenSSL DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
# Dockerfile.raspberrypi \
# examples/libaria2ex.cc examples/libaria2wx.cc
#
#dist_doc_DATA = README README.rst README.html
# dist_doc_DATA = README README.rst README.html
#
#.PHONY: clang-format
# .PHONY: clang-format
#
#if HAVE_RST2HTML
#README.html: README.rst
# if HAVE_RST2HTML
# README.html: README.rst
# $(RST2HTML) $< > $@
#else # !HAVE_RST2HTML
#README.html: README.rst
# else # !HAVE_RST2HTML
# README.html: README.rst
# @echo Warning: rst2html not installed. Placing only a dummy file for $@
# echo "<!doctype html>" > $@
# echo "<p>Readme has not been built!.<br>Instead see <a href='README.rst'>README.rst</a></p>" >> $@
#endif # !HAVE_RST2HTML
# endif # !HAVE_RST2HTML
#
#dist_noinst_DATA = LICENSE.OpenSSL
# dist_noinst_DATA = LICENSE.OpenSSL
#
## Format source files using clang-format. Don't format source files
## under deps directory since we are not responsible for their coding
## style.
#clang-format:
# # Format source files using clang-format. Don't format source files
# # under deps directory since we are not responsible for their coding
# # style.
# clang-format:
# CLANGFORMAT=`git config --get clangformat.binary`; \
# test -z $${CLANGFORMAT} && CLANGFORMAT="clang-format"; \
# $${CLANGFORMAT} -i $(top_srcdir)/src/*.{c,cc,h} $(top_srcdir)/src/includes/aria2/*.h \

View File

@ -0,0 +1,22 @@
function(config_h_add_compile_definitions definitions)
set(${PROJECT_NAME}_CONFIG_H_definitions ${${PROJECT_NAME}_CONFIG_H_definitions} ${definitions} PARENT_SCOPE)
endfunction()
function(config_h_generate_header name)
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "/* config.h.in. Generated from cmake*/\n")
foreach(def ${${PROJECT_NAME}_CONFIG_H_definitions})
set(def_var ${def})
string(REPLACE "=" ";" def_var ${def_var})
list(POP_FRONT def_var def_name)
if(def_var)
set(${def_name}_config_h_val ${def_var})
else()
set(${def_name}_config_h_val "${${def_name}}")
string(REPLACE "yes" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
string(REPLACE "ON" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
string(REPLACE "TRUE" "1" ${def_name}_config_h_val ${${def_name}_config_h_val})
endif()
write_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in "#define ${def_name} @${def_name}_config_h_val@\n" APPEND)
endforeach()
configure_file(${CMAKE_CURRENT_BINARY_DIR}/${name}.h.cmake.in ${name}.h)
endfunction()

View File

@ -1,5 +1,26 @@
project(wslay LANGUAGES CXX C VERSION 1.1.1)
include(GenerateConfigH)
config_h_add_compile_definitions(PACKAGE="${PROJECT_NAME}")
config_h_add_compile_definitions(PACKAGE_NAME="${PROJECT_NAME}")
config_h_add_compile_definitions(PACKAGE_STRING="${PROJECT_NAME} ${PROJECT_VERSION}")
config_h_add_compile_definitions(PACKAGE_TARNAME="${PROJECT_NAME}")
config_h_add_compile_definitions(PACKAGE_URL="${PROJECT_HOMEPAGE_URL}")
config_h_add_compile_definitions(PACKAGE_BUGREPORT="t-tujikawa@users.sourceforge.net")
config_h_add_compile_definitions(PACKAGE_VERSION="${PROJECT_VERSION}")
config_h_add_compile_definitions(VERSION="${PROJECT_VERSION}")
config_h_add_compile_definitions(HOST="${CMAKE_HOST_SYSTEM_PROCESSOR}")
config_h_add_compile_definitions(BUILD="${CMAKE_HOST_SYSTEM_PROCESSOR}")
config_h_add_compile_definitions(TARGET="${CMAKE_SYSTEM_PROCESSOR}")
add_link_options(${EXTRALIBS})
config_h_generate_header(config)
# pickup the generated config.h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_compile_definitions(HAVE_CONFIG_H)
add_subdirectory(lib)
add_subdirectory(tests)

View File

@ -26,8 +26,7 @@ set(WSLAY_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/includes)
add_library(wslay STATIC ${wslay_STAT_SRCS})
target_compile_definitions(wslay PUBLIC PACKAGE_VERSION="${PROJECT_VERSION}")
target_compile_definitions(wslay PUBLIC PACKAGE="${PROJECT_NAME}")
target_include_directories(wslay PUBLIC ${WSLAY_INCLUDE_DIR})
target_include_directories(wslay INTERFACE ${WSLAY_INCLUDE_DIR})

View File

@ -2,24 +2,19 @@
add_subdirectory(includes)
########### next target ###############
# ########## next target ###############
set(aria2c_SRCS main.cc)
add_library(main OBJECT ${aria2c_SRCS})
target_compile_definitions(main PUBLIC PACKAGE_VERSION="${PROJECT_VERSION}")
target_compile_definitions(main PUBLIC PACKAGE="${PROJECT_NAME}")
target_include_directories(main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/includes)
target_include_directories(main PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(aria2c $<TARGET_OBJECTS:main>)
target_link_libraries(aria2c PUBLIC main)
target_link_libraries(aria2c main)
install(TARGETS aria2c ${INSTALL_TARGETS_DEFAULT_ARGS})
########### next target ###############
# ########## next target ###############
set(aria2_SRCS
a2algo.h
a2functional.h
@ -513,8 +508,7 @@ else()
)
endif()
if (HAVE_SOME_XMLLIB)
if(HAVE_SOME_XMLLIB)
set(aria2_SRCS
${aria2_SRCS}
@ -526,7 +520,7 @@ if (HAVE_SOME_XMLLIB)
)
endif()
if (HAVE_LIBXML2)
if(HAVE_LIBXML2)
set(aria2_SRCS
${aria2_SRCS}
@ -535,7 +529,7 @@ if (HAVE_LIBXML2)
)
endif()
if (HAVE_LIBEXPAT)
if(HAVE_LIBEXPAT)
set(aria2_SRCS
${aria2_SRCS}
@ -544,36 +538,31 @@ if (HAVE_LIBEXPAT)
)
endif()
if (ENABLE_XML_RPC)
if(ENABLE_XML_RPC)
set(aria2_SRCS
${aria2_SRCS}
)
endif()
if (HAVE_SOME_FALLOCATE)
if(HAVE_SOME_FALLOCATE)
set(aria2_SRCS
${aria2_SRCS}
FallocFileAllocationIterator.cc
FallocFileAllocationIterator.h
)
endif()
if (HAVE_EPOLL)
if(HAVE_EPOLL)
set(aria2_SRCS
${aria2_SRCS}
EpollEventPoll.cc
EpollEventPoll.h
)
endif()
if (ENABLE_SSL)
if(ENABLE_SSL)
set(aria2_SRCS
${aria2_SRCS}
@ -582,16 +571,15 @@ if (ENABLE_SSL)
)
endif()
if (USE_APPLE_MD)
if(USE_APPLE_MD)
set(aria2_SRCS
${aria2_SRCS}
AppleMessageDigestImpl.cc
)
endif()
if (HAVE_APPLETLS)
if(HAVE_APPLETLS)
set(aria2_SRCS
${aria2_SRCS}
@ -602,7 +590,7 @@ if (HAVE_APPLETLS)
)
endif()
if (HAVE_WINTLS)
if(HAVE_WINTLS)
set(aria2_SRCS
${aria2_SRCS}
@ -622,7 +610,7 @@ if(USE_INTERNAL_BIGNUM)
)
endif()
if (USE_INTERNAL_ARC4)
if(USE_INTERNAL_ARC4)
set(aria2_SRCS
${aria2_SRCS}
@ -631,7 +619,7 @@ if (USE_INTERNAL_ARC4)
)
endif()
if (USE_INTERNAL_MD)
if(USE_INTERNAL_MD)
set(aria2_SRCS
${aria2_SRCS}
@ -641,8 +629,9 @@ if (USE_INTERNAL_MD)
)
endif()
if (HAVE_LIBGNUTLS)
if(HAVE_LIBGNUTLS)
set(aria2_SRCS
${aria2_SRCS}
LibgnutlsTLSContext.cc
LibgnutlsTLSContext.h
@ -651,7 +640,7 @@ if (HAVE_LIBGNUTLS)
)
endif()
if (HAVE_LIBGCRYPT)
if(HAVE_LIBGCRYPT)
set(aria2_SRCS
${aria2_SRCS}
@ -660,7 +649,8 @@ if (HAVE_LIBGCRYPT)
LibgcryptDHKeyExchange.cc
LibgcryptDHKeyExchange.h
)
if (USE_LIBGCRYPT_MD)
if(USE_LIBGCRYPT_MD)
set(aria2_SRCS
${aria2_SRCS}
@ -669,14 +659,15 @@ if (HAVE_LIBGCRYPT)
endif()
endif()
if (HAVE_LIBNETTLE)
if(HAVE_LIBNETTLE)
set(aria2_SRCS
${aria2_SRCS}
LibnettleARC4Encryptor.cc
LibnettleARC4Encryptor.h
)
if (USE_LIBNETTLE_MD)
if(USE_LIBNETTLE_MD)
set(aria2_SRCS
${aria2_SRCS}
@ -685,7 +676,7 @@ if (HAVE_LIBNETTLE)
endif()
endif()
if (HAVE_LIBGMP)
if(HAVE_LIBGMP)
set(aria2_SRCS
${aria2_SRCS}
@ -696,7 +687,7 @@ if (HAVE_LIBGMP)
)
endif()
if (HAVE_OPENSSL)
if(HAVE_OPENSSL)
set(aria2_SRCS
${aria2_SRCS}
@ -705,7 +696,8 @@ if (HAVE_OPENSSL)
LibsslDHKeyExchange.cc
LibsslDHKeyExchange.h
)
if (NOT HAVE_APPLETLS)
if(NOT HAVE_APPLETLS)
set(aria2_SRCS
${aria2_SRCS}
@ -715,7 +707,8 @@ if (HAVE_OPENSSL)
LibsslTLSSession.h
)
endif()
if (USE_OPENSSL_MD)
if(USE_OPENSSL_MD)
set(aria2_SRCS
${aria2_SRCS}
@ -724,7 +717,7 @@ if (HAVE_OPENSSL)
endif()
endif()
if (HAVE_ZLIB)
if(HAVE_ZLIB)
set(aria2_SRCS
${aria2_SRCS}
@ -739,7 +732,7 @@ if (HAVE_ZLIB)
)
endif()
if (HAVE_SQLITE3)
if(HAVE_SQLITE3)
set(aria2_SRCS
${aria2_SRCS}
@ -750,7 +743,7 @@ if (HAVE_SQLITE3)
)
endif()
if (HAVE_LIBSSH2)
if(HAVE_LIBSSH2)
set(aria2_SRCS
${aria2_SRCS}
@ -766,7 +759,7 @@ if (HAVE_LIBSSH2)
)
endif()
if (ENABLE_ASYNC_DNS)
if(ENABLE_ASYNC_DNS)
set(aria2_SRCS
${aria2_SRCS}
@ -777,7 +770,7 @@ if (ENABLE_ASYNC_DNS)
)
endif()
if (ENABLE_BITTORRENT)
if(ENABLE_BITTORRENT)
set(aria2_SRCS
${aria2_SRCS}
@ -1102,7 +1095,7 @@ if (ENABLE_BITTORRENT)
)
endif()
if (ENABLE_METALINK)
if(ENABLE_METALINK)
set(aria2_SRCS
${aria2_SRCS}
@ -1135,7 +1128,7 @@ if (ENABLE_METALINK)
)
endif()
if (NOT HAVE_ASCTIME_R)
if(NOT HAVE_ASCTIME_R)
set(aria2_SRCS
${aria2_SRCS}
@ -1144,7 +1137,7 @@ if (NOT HAVE_ASCTIME_R)
)
endif()
if (NOT HAVE_BASENAME)
if(NOT HAVE_BASENAME)
set(aria2_SRCS
${aria2_SRCS}
@ -1153,7 +1146,7 @@ if (NOT HAVE_BASENAME)
)
endif()
if (NOT HAVE_GETADDRINFO)
if(NOT HAVE_GETADDRINFO)
set(aria2_SRCS
${aria2_SRCS}
@ -1162,7 +1155,7 @@ if (NOT HAVE_GETADDRINFO)
)
endif()
if (NOT HAVE_GAI_STRERROR)
if(NOT HAVE_GAI_STRERROR)
set(aria2_SRCS
${aria2_SRCS}
@ -1171,7 +1164,7 @@ if (NOT HAVE_GAI_STRERROR)
)
endif()
if (NOT HAVE_GETTIMEOFDAY)
if(NOT HAVE_GETTIMEOFDAY)
set(aria2_SRCS
${aria2_SRCS}
@ -1180,7 +1173,7 @@ if (NOT HAVE_GETTIMEOFDAY)
)
endif()
if (NOT HAVE_LOCALTIME_R)
if(NOT HAVE_LOCALTIME_R)
set(aria2_SRCS
${aria2_SRCS}
@ -1189,7 +1182,7 @@ if (NOT HAVE_LOCALTIME_R)
)
endif()
if (NOT HAVE_STRPTIME)
if(NOT HAVE_STRPTIME)
set(aria2_SRCS
${aria2_SRCS}
@ -1198,7 +1191,7 @@ if (NOT HAVE_STRPTIME)
)
endif()
if (NOT HAVE_TIMEGM)
if(NOT HAVE_TIMEGM)
set(aria2_SRCS
${aria2_SRCS}
@ -1207,7 +1200,7 @@ if (NOT HAVE_TIMEGM)
)
endif()
if (NOT HAVE_DAEMON)
if(NOT HAVE_DAEMON)
set(aria2_SRCS
${aria2_SRCS}
@ -1216,7 +1209,7 @@ if (NOT HAVE_DAEMON)
)
endif()
if (HAVE_POLL)
if(HAVE_POLL)
set(aria2_SRCS
${aria2_SRCS}
@ -1225,7 +1218,7 @@ if (HAVE_POLL)
)
endif()
if (HAVE_PORT_ASSOCIATE)
if(HAVE_PORT_ASSOCIATE)
set(aria2_SRCS
${aria2_SRCS}
@ -1234,7 +1227,7 @@ if (HAVE_PORT_ASSOCIATE)
)
endif()
if (HAVE_KQUEUE)
if(HAVE_KQUEUE)
set(aria2_SRCS
${aria2_SRCS}
@ -1243,7 +1236,7 @@ if (HAVE_KQUEUE)
)
endif()
if (HAVE_LIBUV)
if(HAVE_LIBUV)
set(aria2_SRCS
${aria2_SRCS}
@ -1252,7 +1245,7 @@ if (HAVE_LIBUV)
)
endif()
if (ENABLE_LIBARIA2)
if(ENABLE_LIBARIA2)
set(aria2_SRCS
${aria2_SRCS}
@ -1263,14 +1256,17 @@ if (ENABLE_LIBARIA2)
KeepRunningCommand.cc
KeepRunningCommand.h
)
add_library(aria2 SHARED ${aria2_SRCS})
set(LIBARIA2_BUILD_MODE SHARED)
# add_library(aria2 SHARED ${aria2_SRCS})
else()
add_library(aria2 STATIC ${aria2_SRCS})
set(LIBARIA2_BUILD_MODE STATIC)
# add_library(aria2 STATIC ${aria2_SRCS})
endif()
target_compile_definitions(aria2 PUBLIC PACKAGE_VERSION="${PROJECT_VERSION}")
target_compile_definitions(aria2 PUBLIC PACKAGE="${PROJECT_NAME}")
add_library(aria2 ${LIBARIA2_BUILD_MODE} ${aria2_SRCS})
target_include_directories(aria2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/includes)
target_include_directories(aria2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
@ -1278,125 +1274,119 @@ target_include_directories(aria2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/includes)
if(HAVE_ZLIB)
target_include_directories(aria2 PUBLIC ${ZLIB_INCLUDE_DIRS})
target_link_libraries(aria2 INTERFACE ZLIB::ZLIB)
target_link_libraries(aria2 ZLIB::ZLIB)
endif()
if(HAVE_LIBUV)
target_include_directories(aria2 PUBLIC ${LIBUV_INCLUDE_DIRS})
target_link_libraries(aria2 INTERFACE LIBUV::LIBUV)
target_link_libraries(aria2 LIBUV::LIBUV)
endif()
if(HAVE_LIBXML2)
target_include_directories(aria2 PUBLIC ${LIBXML2_INCLUDE_DIR})
target_link_libraries(aria2 INTERFACE LibXml2::LibXml2)
target_link_libraries(aria2 LibXml2::LibXml2)
endif()
if(HAVE_LIBEXPAT)
target_include_directories(aria2 PUBLIC ${EXPAT_INCLUDE_DIRS})
target_link_libraries(aria2 INTERFACE EXPAT::EXPAT)
target_link_libraries(aria2 EXPAT::EXPAT)
endif()
if(HAVE_SQLITE3)
target_include_directories(aria2 PUBLIC ${SQLite3_INCLUDE_DIRS})
target_link_libraries(aria2 INTERFACE SQLite::SQLite3)
target_link_libraries(aria2 SQLite::SQLite3)
endif()
if(HAVE_APPLETLS)
target_link_libraries(aria2 INTERFACE ${APPLETLS_LD_FLAGS})
target_link_libraries(aria2 ${APPLETLS_LD_FLAGS})
endif()
if(HAVE_WINTLS)
target_link_libraries(aria2 INTERFACE ${WINTLS_LIBS})
target_link_libraries(aria2 ${WINTLS_LIBS})
endif()
if(HAVE_LIBGNUTLS)
target_include_directories(aria2 PUBLIC ${GNUTLS_INCLUDE_DIR})
target_compile_definitions(aria2 PUBLIC ${LIBGNUTLS_CFLAGS})
target_link_libraries(aria2 INTERFACE GnuTLS::GnuTLS)
target_link_libraries(aria2 GnuTLS::GnuTLS)
endif()
if(HAVE_OPENSSL)
target_include_directories(aria2 PUBLIC ${OPENSSL_INCLUDE_DIR})
target_link_libraries(aria2 INTERFACE OpenSSL::SSL)
target_link_libraries(aria2 OpenSSL::SSL)
# target_link_libraries(aria2 INTERFACE OpenSSL::Crypto)
endif()
if(HAVE_LIBNETTLE)
target_include_directories(aria2 PUBLIC ${NETTLE_INCLUDE_DIR})
target_link_libraries(aria2 INTERFACE Nettle::Nettle)
target_link_libraries(aria2 Nettle::Nettle)
endif()
if(HAVE_LIBGMP)
target_include_directories(aria2 PUBLIC ${GMP_INCLUDE_DIR})
target_link_libraries(aria2 INTERFACE GMP::GMP)
target_link_libraries(aria2 GMP::GMP)
endif()
if(HAVE_LIBGCRYPT)
target_include_directories(aria2 PUBLIC ${LibGcrypt_INCLUDE_DIR})
target_link_libraries(aria2 INTERFACE LibGcrypt::LibGcrypt)
target_link_libraries(aria2 LibGcrypt::LibGcrypt)
endif()
if(HAVE_LIBSSH2)
target_include_directories(aria2 PUBLIC ${LIBSSH2_INCLUDE_DIR})
target_link_libraries(aria2 INTERFACE LibSSH2::LibSSH2)
target_link_libraries(aria2 LibSSH2::LibSSH2)
endif()
if(HAVE_LIBCARES)
target_include_directories(aria2 PUBLIC ${LIBCARES_INCLUDE_DIR})
target_link_libraries(aria2 INTERFACE Libcares::Libcares)
target_link_libraries(aria2 Libcares::Libcares)
endif()
if(ENABLE_WEBSOCKET)
target_include_directories(aria2 PUBLIC ${WSLAY_INCLUDE_DIR})
target_link_libraries(aria2 INTERFACE wslay)
target_link_libraries(aria2 wslay)
endif()
set_target_properties(aria2 PROPERTIES VERSION 0.0.0 SOVERSION 1)
install(TARGETS aria2 ${INSTALL_TARGETS_DEFAULT_ARGS})
target_link_libraries(aria2c PUBLIC aria2)
target_link_libraries(aria2c aria2)
########### next target ###############
# ########## next target ###############
# add_library(aria2_static STATIC ${aria2_SRCS})
########### install files ###############
# ########## install files ###############
install(FILES libaria2.pc DESTINATION lib)
# original Makefile.am contents follow:
#original Makefile.am contents follow:
#SUBDIRS = includes
#bin_PROGRAMS = aria2c
#aria2c_SOURCES = main.cc
# SUBDIRS = includes
# bin_PROGRAMS = aria2c
# aria2c_SOURCES = main.cc
#
#AR = @AR@
# AR = @AR@
#
#if ENABLE_LIBARIA2
#pkgconfigdir = $(libdir)/pkgconfig
#pkgconfig_DATA = libaria2.pc
#DISTCLEANFILES = $(pkgconfig_DATA)
# if ENABLE_LIBARIA2
# pkgconfigdir = $(libdir)/pkgconfig
# pkgconfig_DATA = libaria2.pc
# DISTCLEANFILES = $(pkgconfig_DATA)
#
#lib_LTLIBRARIES = libaria2.la
#SRCS += \
# lib_LTLIBRARIES = libaria2.la
# SRCS += \
# ApiCallbackDownloadEventListener.cc ApiCallbackDownloadEventListener.h\
# aria2api.cc aria2api.h \
# KeepRunningCommand.cc KeepRunningCommand.h
#else # !ENABLE_LIBARIA2
#noinst_LTLIBRARIES = libaria2.la
#endif # !ENABLE_LIBARIA2
# else # !ENABLE_LIBARIA2
# noinst_LTLIBRARIES = libaria2.la
# endif # !ENABLE_LIBARIA2
#
#libaria2_la_SOURCES = $(SRCS)
# libaria2_la_SOURCES = $(SRCS)
#
#
#AM_CPPFLAGS = \
# AM_CPPFLAGS = \
# -I$(top_srcdir)/lib -I$(top_srcdir)/intl\
# -I$(srcdir)/includes -I$(builddir)/includes\
# -DLOCALEDIR=\"@localedir@\" @DEFS@ \
@ -1417,11 +1407,11 @@ install(FILES libaria2.pc DESTINATION lib)
# @TCMALLOC_CFLAGS@ \
# @JEMALLOC_CFLAGS@
#
#AM_LDFLAGS = \
# AM_LDFLAGS = \
# @EXTRALDFLAGS@ \
# @APPLETLS_LDFLAGS@
#
#EXTLDADD = @ALLOCA@ \
# EXTLDADD = @ALLOCA@ \
# @EXTRALIBS@ \
# @ZLIB_LIBS@ \
# @LIBUV_LIBS@ \
@ -1441,15 +1431,15 @@ install(FILES libaria2.pc DESTINATION lib)
# @JEMALLOC_LIBS@ \
# @LTLIBINTL@
#
#LDADD = libaria2.la
# LDADD = libaria2.la
#
#if ENABLE_LIBARIA2
#libaria2_la_LIBADD = $(EXTLDADD)
#else # !ENABLE_LIBARIA2
#LDADD += $(EXTLDADD)
#endif # !ENABLE_LIBARIA2
# if ENABLE_LIBARIA2
# libaria2_la_LIBADD = $(EXTLDADD)
# else # !ENABLE_LIBARIA2
# LDADD += $(EXTLDADD)
# endif # !ENABLE_LIBARIA2
#
#AM_CFLAGS = @EXTRACFLAGS@
# AM_CFLAGS = @EXTRACFLAGS@
#
#AM_CXXFLAGS = @WARNCXXFLAGS@ @CXX1XCXXFLAGS@ @EXTRACXXFLAGS@
# AM_CXXFLAGS = @WARNCXXFLAGS@ @CXX1XCXXFLAGS@ @EXTRACXXFLAGS@
#