From 85178368d7ee55c52b846bfd54d71fe71bdf6c5e Mon Sep 17 00:00:00 2001 From: Yasser Yassine Date: Tue, 19 Mar 2024 20:59:33 +0000 Subject: [PATCH] Build: Add static icsneo40 target --- CMakeLists.txt | 21 ++++++++++++++++++++ include/icsneo/platform/posix/dynamiclib.h | 5 +++++ include/icsneo/platform/windows/dynamiclib.h | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1c87e8..29397a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ option(LIBICSNEO_BUILD_EXAMPLES "Build examples." ON) option(LIBICSNEO_BUILD_ICSNEOC "Build dynamic C library" ON) option(LIBICSNEO_BUILD_ICSNEOC_STATIC "Build static C library" ON) option(LIBICSNEO_BUILD_ICSNEOLEGACY "Build icsnVC40 compatibility library" ON) +option(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC "Build static icsnVC40 compatibility library" ON) set(LIBICSNEO_NPCAP_INCLUDE_DIR "" CACHE STRING "Npcap include directory; set to build with Npcap") # Device Drivers @@ -448,6 +449,7 @@ if(LIBICSNEO_BUILD_ICSNEOC_STATIC) ) target_link_libraries(icsneoc-static PUBLIC icsneocpp) target_compile_features(icsneoc-static PUBLIC cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums) + target_compile_definitions(icsneoc-static PUBLIC ICSNEOC_BUILD_STATIC) endif() if(LIBICSNEO_BUILD_ICSNEOLEGACY) @@ -468,6 +470,25 @@ if(LIBICSNEO_BUILD_ICSNEOLEGACY) target_compile_features(icsneolegacy PRIVATE cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums) endif() +if(LIBICSNEO_BUILD_ICSNEOLEGACY_STATIC) + add_library(icsneolegacy-static STATIC + api/icsneolegacy/icsneolegacy.cpp + api/icsneolegacy/icsneolegacyextra.cpp + api/icsneoc/icsneoc.cpp + ) + + target_include_directories(icsneolegacy-static + PUBLIC + $ + $ + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include + ) + target_link_libraries(icsneolegacy-static PUBLIC icsneocpp) + target_compile_features(icsneolegacy-static PUBLIC cxx_auto_type cxx_constexpr cxx_lambdas cxx_nullptr cxx_range_for cxx_rvalue_references cxx_sizeof_member cxx_strong_enums) + target_compile_definitions(icsneolegacy-static PUBLIC ICSNEOC_BUILD_STATIC) +endif() + # googletest if(LIBICSNEO_BUILD_TESTS) if(WIN32) diff --git a/include/icsneo/platform/posix/dynamiclib.h b/include/icsneo/platform/posix/dynamiclib.h index bec056c..70e2330 100644 --- a/include/icsneo/platform/posix/dynamiclib.h +++ b/include/icsneo/platform/posix/dynamiclib.h @@ -9,7 +9,12 @@ #include "icsneo/platform/posix/linux/dynamiclib.h" #endif +#ifndef ICSNEOC_BUILD_STATIC #define DLLExport __attribute__((visibility("default"))) +#else +#define DLLExport +#endif + #define LegacyDLLExport DLLExport // #ifndef ICSNEO_NO_AUTO_DESTRUCT diff --git a/include/icsneo/platform/windows/dynamiclib.h b/include/icsneo/platform/windows/dynamiclib.h index efd8a19..3d4b1d8 100644 --- a/include/icsneo/platform/windows/dynamiclib.h +++ b/include/icsneo/platform/windows/dynamiclib.h @@ -3,11 +3,17 @@ #include "icsneo/platform/windows.h" +#ifndef ICSNEOC_BUILD_STATIC #ifdef ICSNEOC_MAKEDLL #define DLLExport __declspec(dllexport) #else #define DLLExport __declspec(dllimport) #endif +#else +#define DLLExport +#endif + + #define LegacyDLLExport DLLExport _stdcall // MSVC does not have the ability to specify a destructor