From 2ff2c8d447bf2ac5c832194356a34d3db53f259a Mon Sep 17 00:00:00 2001 From: Pavel Odintsov Date: Mon, 3 Apr 2023 21:20:04 +0100 Subject: [PATCH] Added all missing parts to be able to build fastnetmon_client --- src/CMakeLists.txt | 11 +++++++++++ src/fastnetmon_client.cpp | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37749ee..073affd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,6 +34,17 @@ set(LIB_CPP_KAFKA_INSTALL_PATH "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/cppkafka_0_3 set(LIB_RDKAFKA_INSTALL_PATH "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/rdkafka_1_7_0") set(GTEST_INSTALL_PATH "${FASTNETMON_LIBRARIES_GLOBAL_PATH}/gtest_1_13_0") +# On Windows we need to build libgcc and libstdc++ statically to avoid need to carry dlls with us +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ ${CMAKE_CXX_STANDARD_LIBRARIES}") +endif() + +# We need this to avoid dependency on libwinpthread-1.dll +# Details: https://cmake.org/pipermail/cmake/2019-June/069611.html +if (MINGW) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive") +endif() + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} --std=c++2a") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --std=c++2a") diff --git a/src/fastnetmon_client.cpp b/src/fastnetmon_client.cpp index ab414c4..4365c33 100644 --- a/src/fastnetmon_client.cpp +++ b/src/fastnetmon_client.cpp @@ -7,6 +7,8 @@ #ifdef _WIN32 // msys2 and mingw use nested path for some reasons but Linux keeps it in include directly: https://packages.msys2.org/package/mingw-w64-x86_64-ncurses +// On Windows we do only static builds to avoid carrying bunch of dlls with us +#define NCURSES_STATIC #include #else #include