diff --git a/CMakeLists.txt b/CMakeLists.txt index 536b92c9..58e4d184 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required (VERSION 3.1) +project (opendht) + include(CMakePackageConfigHelpers) include(CMakeDependentOption) include(FindPkgConfig) include(cmake/CheckAtomic.cmake) -project (opendht) set (opendht_VERSION_MAJOR 2) set (opendht_VERSION_MINOR 1.7) set (opendht_VERSION ${opendht_VERSION_MAJOR}.${opendht_VERSION_MINOR}) @@ -301,9 +302,11 @@ if (OPENDHT_HTTP) list (APPEND opendht_HEADERS include/opendht/proxy.h include/opendht/http.h + src/compat/os_cert.h ) list (APPEND opendht_SOURCES src/http.cpp + src/compat/os_cert.cpp ) endif () @@ -324,13 +327,8 @@ if(OPENDHT_ARGON2) include_directories(argon2/include/) endif() -# cross-platform compatibility sources -set (COMPAT_DIR ${PROJECT_SOURCE_DIR}/src/compat/) -list (APPEND opendht_SOURCES ${COMPAT_DIR}/os_cert.cpp) - if (MSVC) - set (MSC_COMPAT_DIR ${COMPAT_DIR}/msvc/) - list (APPEND opendht_SOURCES ${MSC_COMPAT_DIR}/unistd.h) + list (APPEND opendht_HEADERS src/compat/msvc/unistd.h) endif () # Targets diff --git a/src/compat/os_cert.cpp b/src/compat/os_cert.cpp index ea113e08..7e80c5b8 100644 --- a/src/compat/os_cert.cpp +++ b/src/compat/os_cert.cpp @@ -39,6 +39,7 @@ #define GENTIME_LENGTH 15 #define UTCTIME_LENGTH 13 #define ATOI2(ar) ((ar) += 2, ((ar)[-2] - '0') * 10 + ((ar)[-1] - '0')) +extern "C" { // Taken from libressl/src/crypto/asn1/a_time_tm.c int ASN1_time_parse(const char* bytes, size_t len, struct tm* tm, int mode) @@ -116,7 +117,8 @@ ASN1_time_parse(const char* bytes, size_t len, struct tm* tm, int mode) return (-1); } - return (type); + return type; +} } #endif /* EMBEDDED_ASN1_TIME_PARSE */ diff --git a/src/compat/os_cert.h b/src/compat/os_cert.h index 25686543..b037037d 100644 --- a/src/compat/os_cert.h +++ b/src/compat/os_cert.h @@ -34,6 +34,7 @@ #define V_ASN1_UTCTIME 23 #define V_ASN1_GENERALIZEDTIME 24 +extern "C" { /* * Parse an RFC 5280 format ASN.1 time string. * @@ -50,6 +51,7 @@ * Fills in *tm with the corresponding time if tm is non NULL. */ int ASN1_time_parse(const char* bytes, size_t len, struct tm* tm, int mode); +} #endif namespace dht {