diff --git a/CMakeLists.txt b/CMakeLists.txt index c4dbca0..4694e30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,14 +44,17 @@ endif() include(CheckFunctionExists) include(CheckSymbolExists) file(WRITE "libndt.hpp" "// AUTOGENERATED BY CMake! DON'T EDIT!\n\n") -file(READ "sys.hpp" MK_AMALGAMATE_1172_0) +file(READ "preamble.hpp" MK_AMALGAMATE_1172_0) file(APPEND "libndt.hpp" "${MK_AMALGAMATE_1172_0}") file(APPEND "libndt.hpp" "\n\n") -file(READ "api.hpp" MK_AMALGAMATE_1172_1) +file(READ "sys.hpp" MK_AMALGAMATE_1172_1) file(APPEND "libndt.hpp" "${MK_AMALGAMATE_1172_1}") file(APPEND "libndt.hpp" "\n\n") -file(READ "impl.hpp" MK_AMALGAMATE_1172_2) +file(READ "api.hpp" MK_AMALGAMATE_1172_2) file(APPEND "libndt.hpp" "${MK_AMALGAMATE_1172_2}") +file(APPEND "libndt.hpp" "\n\n") +file(READ "impl.hpp" MK_AMALGAMATE_1172_3) +file(APPEND "libndt.hpp" "${MK_AMALGAMATE_1172_3}") check_function_exists(strtonum LIBNDT_HAVE_STRTONUM) if(${LIBNDT_HAVE_STRTONUM}) add_definitions(-DLIBNDT_HAVE_STRTONUM) @@ -72,9 +75,9 @@ endif() message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include" - RESULT_VARIABLE FAILURE_2218) -if("${FAILURE_2218}") - message(FATAL_ERROR "${FAILURE_2218}") + RESULT_VARIABLE FAILURE_2350) +if("${FAILURE_2350}") + message(FATAL_ERROR "${FAILURE_2350}") endif() message(STATUS "download: https://raw.githubusercontent.com/adishavit/argh/v1.3.1/argh.h") file(DOWNLOAD https://raw.githubusercontent.com/adishavit/argh/v1.3.1/argh.h @@ -82,8 +85,8 @@ file(DOWNLOAD https://raw.githubusercontent.com/adishavit/argh/v1.3.1/argh.h EXPECTED_HASH SHA256=ddb7dfc18dcf90149735b76fb2cff101067453a1df1943a6911233cb7085980c TLS_VERIFY ON) LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include") -CHECK_INCLUDE_FILE_CXX("argh.h" MK_HAVE_HEADER_2718) -if(NOT ("${MK_HAVE_HEADER_2718}")) +CHECK_INCLUDE_FILE_CXX("argh.h" MK_HAVE_HEADER_2850) +if(NOT ("${MK_HAVE_HEADER_2850}")) message(FATAL_ERROR "cannot find: argh.h") endif() @@ -94,9 +97,9 @@ endif() message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include" - RESULT_VARIABLE FAILURE_3042) -if("${FAILURE_3042}") - message(FATAL_ERROR "${FAILURE_3042}") + RESULT_VARIABLE FAILURE_3174) +if("${FAILURE_3174}") + message(FATAL_ERROR "${FAILURE_3174}") endif() message(STATUS "download: https://github.com/catchorg/Catch2/releases/download/v2.8.0/catch.hpp") file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v2.8.0/catch.hpp @@ -104,8 +107,8 @@ file(DOWNLOAD https://github.com/catchorg/Catch2/releases/download/v2.8.0/catch. EXPECTED_HASH SHA256=2791047e459b981a1035f4ee16a2ad031f5bfb4ba66487ad4d3fc816c8946f61 TLS_VERIFY ON) LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include") -CHECK_INCLUDE_FILE_CXX("catch.hpp" MK_HAVE_HEADER_3559) -if(NOT ("${MK_HAVE_HEADER_3559}")) +CHECK_INCLUDE_FILE_CXX("catch.hpp" MK_HAVE_HEADER_3691) +if(NOT ("${MK_HAVE_HEADER_3691}")) message(FATAL_ERROR "cannot find: catch.hpp") endif() @@ -118,9 +121,9 @@ if(("${WIN32}")) message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/download") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/download" - RESULT_VARIABLE FAILURE_3940) - if("${FAILURE_3940}") - message(FATAL_ERROR "${FAILURE_3940}") + RESULT_VARIABLE FAILURE_4072) + if("${FAILURE_4072}") + message(FATAL_ERROR "${FAILURE_4072}") endif() message(STATUS "download: https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-curl-7.61.1-1.tar.gz") file(DOWNLOAD https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-curl-7.61.1-1.tar.gz @@ -131,28 +134,28 @@ if(("${WIN32}")) execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/.mkbuild/download/windows-curl-7.61.1-1.tar.gz" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.mkbuild/download" - RESULT_VARIABLE FAILURE_4763) - if("${FAILURE_4763}") - message(FATAL_ERROR "${FAILURE_4763}") + RESULT_VARIABLE FAILURE_4895) + if("${FAILURE_4895}") + message(FATAL_ERROR "${FAILURE_4895}") endif() LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/include") - CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_5008) - if(NOT ("${MK_HAVE_HEADER_5008}")) + CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_5140) + if(NOT ("${MK_HAVE_HEADER_5140}")) message(FATAL_ERROR "cannot find: curl/curl.h") endif() - CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib" "curl_easy_init" "" MK_HAVE_LIB_5167) - if(NOT ("${MK_HAVE_LIB_5167}")) + CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib" "curl_easy_init" "" MK_HAVE_LIB_5299) + if(NOT ("${MK_HAVE_LIB_5299}")) message(FATAL_ERROR "cannot find: ${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib") endif() LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/curl/7.61.1-1/${MK_WIN32_ARCH}/lib/libcurl.lib") LIST(APPEND CMAKE_REQUIRED_DEFINITIONS -DCURL_STATICLIB) else() - CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_5725) - if(NOT ("${MK_HAVE_HEADER_5725}")) + CHECK_INCLUDE_FILE_CXX("curl/curl.h" MK_HAVE_HEADER_5857) + if(NOT ("${MK_HAVE_HEADER_5857}")) message(FATAL_ERROR "cannot find: curl/curl.h") endif() - CHECK_LIBRARY_EXISTS("curl" "curl_easy_init" "" MK_HAVE_LIB_5884) - if(NOT ("${MK_HAVE_LIB_5884}")) + CHECK_LIBRARY_EXISTS("curl" "curl_easy_init" "" MK_HAVE_LIB_6016) + if(NOT ("${MK_HAVE_LIB_6016}")) message(FATAL_ERROR "cannot find: curl") endif() LIST(APPEND CMAKE_REQUIRED_LIBRARIES "curl") @@ -165,9 +168,9 @@ endif() message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/download") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/download" - RESULT_VARIABLE FAILURE_6308) -if("${FAILURE_6308}") - message(FATAL_ERROR "${FAILURE_6308}") + RESULT_VARIABLE FAILURE_6440) +if("${FAILURE_6440}") + message(FATAL_ERROR "${FAILURE_6440}") endif() message(STATUS "download: https://github.com/measurement-kit/generic-assets/releases/download/20190520205742/generic-assets-20190520205742.tar.gz") file(DOWNLOAD https://github.com/measurement-kit/generic-assets/releases/download/20190520205742/generic-assets-20190520205742.tar.gz @@ -178,9 +181,9 @@ message(STATUS "Extract: ${CMAKE_BINARY_DIR}/.mkbuild/download/generic-assets-20 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/.mkbuild/download/generic-assets-20190520205742.tar.gz" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.mkbuild/download" - RESULT_VARIABLE FAILURE_7169) -if("${FAILURE_7169}") - message(FATAL_ERROR "${FAILURE_7169}") + RESULT_VARIABLE FAILURE_7301) +if("${FAILURE_7301}") + message(FATAL_ERROR "${FAILURE_7301}") endif() # @@ -190,9 +193,9 @@ endif() message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/include") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/include" - RESULT_VARIABLE FAILURE_7454) -if("${FAILURE_7454}") - message(FATAL_ERROR "${FAILURE_7454}") + RESULT_VARIABLE FAILURE_7586) +if("${FAILURE_7586}") + message(FATAL_ERROR "${FAILURE_7586}") endif() message(STATUS "download: https://raw.githubusercontent.com/nlohmann/json/v3.6.1/single_include/nlohmann/json.hpp") file(DOWNLOAD https://raw.githubusercontent.com/nlohmann/json/v3.6.1/single_include/nlohmann/json.hpp @@ -200,8 +203,8 @@ file(DOWNLOAD https://raw.githubusercontent.com/nlohmann/json/v3.6.1/single_incl EXPECTED_HASH SHA256=d2eeb25d2e95bffeb08ebb7704cdffd2e8fca7113eba9a0b38d60a5c391ea09a TLS_VERIFY ON) LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/include") -CHECK_INCLUDE_FILE_CXX("json.hpp" MK_HAVE_HEADER_8006) -if(NOT ("${MK_HAVE_HEADER_8006}")) +CHECK_INCLUDE_FILE_CXX("json.hpp" MK_HAVE_HEADER_8138) +if(NOT ("${MK_HAVE_HEADER_8138}")) message(FATAL_ERROR "cannot find: json.hpp") endif() @@ -214,9 +217,9 @@ if(("${WIN32}")) message(STATUS "mkdirAll: ${CMAKE_BINARY_DIR}/.mkbuild/download") execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/.mkbuild/download" - RESULT_VARIABLE FAILURE_8388) - if("${FAILURE_8388}") - message(FATAL_ERROR "${FAILURE_8388}") + RESULT_VARIABLE FAILURE_8520) + if("${FAILURE_8520}") + message(FATAL_ERROR "${FAILURE_8520}") endif() message(STATUS "download: https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-libressl-2.7.4-1.tar.gz") file(DOWNLOAD https://github.com/measurement-kit/prebuilt/releases/download//testing/windows-libressl-2.7.4-1.tar.gz @@ -227,22 +230,22 @@ if(("${WIN32}")) execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/.mkbuild/download/windows-libressl-2.7.4-1.tar.gz" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.mkbuild/download" - RESULT_VARIABLE FAILURE_9226) - if("${FAILURE_9226}") - message(FATAL_ERROR "${FAILURE_9226}") + RESULT_VARIABLE FAILURE_9358) + if("${FAILURE_9358}") + message(FATAL_ERROR "${FAILURE_9358}") endif() LIST(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/include") - CHECK_INCLUDE_FILE_CXX("openssl/rsa.h" MK_HAVE_HEADER_9474) - if(NOT ("${MK_HAVE_HEADER_9474}")) + CHECK_INCLUDE_FILE_CXX("openssl/rsa.h" MK_HAVE_HEADER_9606) + if(NOT ("${MK_HAVE_HEADER_9606}")) message(FATAL_ERROR "cannot find: openssl/rsa.h") endif() - CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/crypto.lib" "RSA_new" "" MK_HAVE_LIB_9637) - if(NOT ("${MK_HAVE_LIB_9637}")) + CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/crypto.lib" "RSA_new" "" MK_HAVE_LIB_9769) + if(NOT ("${MK_HAVE_LIB_9769}")) message(FATAL_ERROR "cannot find: ${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/crypto.lib") endif() LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/crypto.lib") - CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/ssl.lib" "SSL_new" "" MK_HAVE_LIB_10128) - if(NOT ("${MK_HAVE_LIB_10128}")) + CHECK_LIBRARY_EXISTS("${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/ssl.lib" "SSL_new" "" MK_HAVE_LIB_10260) + if(NOT ("${MK_HAVE_LIB_10260}")) message(FATAL_ERROR "cannot find: ${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/ssl.lib") endif() LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${CMAKE_BINARY_DIR}/.mkbuild/download/MK_DIST/windows/libressl/2.7.4-1/${MK_WIN32_ARCH}/lib/ssl.lib") @@ -256,21 +259,21 @@ else() set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/opt/openssl@1.1/lib") endif() endif() - CHECK_INCLUDE_FILE_CXX("openssl/rsa.h" MK_HAVE_HEADER_11075) - if(NOT ("${MK_HAVE_HEADER_11075}")) + CHECK_INCLUDE_FILE_CXX("openssl/rsa.h" MK_HAVE_HEADER_11207) + if(NOT ("${MK_HAVE_HEADER_11207}")) message(FATAL_ERROR "cannot find: openssl/rsa.h") endif() - CHECK_LIBRARY_EXISTS("crypto" "RSA_new" "" MK_HAVE_LIB_11240) - if(NOT ("${MK_HAVE_LIB_11240}")) + CHECK_LIBRARY_EXISTS("crypto" "RSA_new" "" MK_HAVE_LIB_11372) + if(NOT ("${MK_HAVE_LIB_11372}")) message(FATAL_ERROR "cannot find: crypto") endif() LIST(APPEND CMAKE_REQUIRED_LIBRARIES "crypto") - CHECK_INCLUDE_FILE_CXX("openssl/ssl.h" MK_HAVE_HEADER_11445) - if(NOT ("${MK_HAVE_HEADER_11445}")) + CHECK_INCLUDE_FILE_CXX("openssl/ssl.h" MK_HAVE_HEADER_11577) + if(NOT ("${MK_HAVE_HEADER_11577}")) message(FATAL_ERROR "cannot find: openssl/ssl.h") endif() - CHECK_LIBRARY_EXISTS("ssl" "SSL_read" "" MK_HAVE_LIB_11610) - if(NOT ("${MK_HAVE_LIB_11610}")) + CHECK_LIBRARY_EXISTS("ssl" "SSL_read" "" MK_HAVE_LIB_11742) + if(NOT ("${MK_HAVE_LIB_11742}")) message(FATAL_ERROR "cannot find: ssl") endif() LIST(APPEND CMAKE_REQUIRED_LIBRARIES "ssl") @@ -351,20 +354,33 @@ include_directories(${CMAKE_REQUIRED_INCLUDES}) add_executable( libndt-client - libndt-client.cpp + libndt-client.cpp api.hpp impl.hpp sys.hpp ) target_link_libraries( libndt-client ${CMAKE_REQUIRED_LIBRARIES} ) +# +# libndt-standalne-builds +# + +add_executable( + libndt-standalne-builds + libndt-standalone-builds.cpp libndt.hpp +) +target_link_libraries( + libndt-standalne-builds + ${CMAKE_REQUIRED_LIBRARIES} +) + # # sys_test # add_executable( sys_test - sys_test.cpp + sys_test.cpp api.hpp impl.hpp sys.hpp ) target_link_libraries( sys_test @@ -377,7 +393,7 @@ target_link_libraries( add_executable( tests-curl - curlx_test.cpp + curlx_test.cpp api.hpp impl.hpp sys.hpp ) target_link_libraries( tests-curl @@ -390,7 +406,7 @@ target_link_libraries( add_executable( tests-libndt - libndt_test.cpp + libndt_test.cpp api.hpp impl.hpp sys.hpp ) target_link_libraries( tests-libndt diff --git a/MKBuild.yaml b/MKBuild.yaml index fa2e2ec..705a7d2 100644 --- a/MKBuild.yaml +++ b/MKBuild.yaml @@ -5,6 +5,7 @@ docker_tc_disabled: true amalgamate: libndt.hpp: + - preamble.hpp - sys.hpp - api.hpp - impl.hpp @@ -32,13 +33,15 @@ dependencies: targets: executables: libndt-client: - compile: [libndt-client.cpp] + compile: [libndt-client.cpp api.hpp impl.hpp sys.hpp] + libndt-standalne-builds: + compile: [libndt-standalone-builds.cpp libndt.hpp] sys_test: - compile: [sys_test.cpp] + compile: [sys_test.cpp api.hpp impl.hpp sys.hpp] tests-curl: - compile: [curlx_test.cpp] + compile: [curlx_test.cpp api.hpp impl.hpp sys.hpp] tests-libndt: - compile: [libndt_test.cpp] + compile: [libndt_test.cpp api.hpp impl.hpp sys.hpp] tests: curl_unit_tests: diff --git a/curlx_test.cpp b/curlx_test.cpp index c8d690c..530c4b8 100644 --- a/curlx_test.cpp +++ b/curlx_test.cpp @@ -3,7 +3,8 @@ // and LICENSE for more information on the copying conditions. #include "json.hpp" -#include "libndt.hpp" + +#include "impl.hpp" // not standalone #define CATCH_CONFIG_MAIN #include "catch.hpp" diff --git a/impl.hpp b/impl.hpp index b290f8e..b1ab827 100644 --- a/impl.hpp +++ b/impl.hpp @@ -1,6 +1,11 @@ #ifndef MEASUREMENT_KIT_LIBNDT_IMPL_HPP #define MEASUREMENT_KIT_LIBNDT_IMPL_HPP +#ifndef LIBNDT_STANDALONE +#include "sys.hpp" +#include "api.hpp" +#endif // !LIBNDT_STANDALONE + // Implementation section // `````````````````````` // This is a single header library. In some use cases you may want to split diff --git a/libndt-client.cpp b/libndt-client.cpp index 91bff60..ad22d80 100644 --- a/libndt-client.cpp +++ b/libndt-client.cpp @@ -3,7 +3,8 @@ // and LICENSE for more information on the copying conditions. #include "json.hpp" -#include "libndt.hpp" + +#include "impl.hpp" // not standalone #include diff --git a/libndt-standalone-builds.cpp b/libndt-standalone-builds.cpp new file mode 100644 index 0000000..7f830fe --- /dev/null +++ b/libndt-standalone-builds.cpp @@ -0,0 +1,12 @@ +// The purpose of this file is to make sure the standalone +// header is building. We're now using the individual headers +// elsewhere, and specifically "impl.hpp", such that it's +// significantly simpler to do development. +#include "json.hpp" +#include "libndt.hpp" +int main() { + measurement_kit::libndt::Client client{ + measurement_kit::libndt::Settings{} + }; + client.run(); +} diff --git a/libndt_test.cpp b/libndt_test.cpp index 5ec0710..050c16f 100644 --- a/libndt_test.cpp +++ b/libndt_test.cpp @@ -3,7 +3,8 @@ // and LICENSE for more information on the copying conditions. #include "json.hpp" -#include "libndt.hpp" + +#include "impl.hpp" // not standalone #ifndef _WIN32 #include diff --git a/preamble.hpp b/preamble.hpp new file mode 100644 index 0000000..d095158 --- /dev/null +++ b/preamble.hpp @@ -0,0 +1,3 @@ +#ifndef LIBNDT_STANDALONE +#define LIBNDT_STANDALONE 1 +#endif