John Thacker 56c1fab216 cmake: Fix Windows static build
BUILD_SHARED_LIBS is a CMake variable. Due to how MSVC exports
and imports symbols from DLLs*, we still need to appropriately
define symbols so that __declspec(dllexport) and __declspec(dllimport)
are used properly, and also so that they're *not* used when building
statically, to avoid MSVC and LINK warnings LNK4217 and LNK4286,
and errors C2734, LNK2019, and LNK1120.

Do this by defining the compile-time definition ENABLE_STATIC
(not to be confused with the previous CMake variable ENABLE_STATIC)
whenever BUILD_SHARED_LIBS is set to OFF, and also defining
ENABLE_STATIC specifically for the static version of wsutil and
dumpcap / writecap that use it.

Also, eliminate some non-fatal warnings that occurred before by
defining WSUTIL_EXPORT to just be extern in the all static case.

Fixup 67bb36a181f9e643533bbfc96f52207edb47de0c

* - Data and functions are not directly exported, there's indirection
through an address table, but the appearance of direct export can be
obtained via syntactic sugar, See
https://learn.microsoft.com/en-us/cpp/build/importing-data-using-declspec-dllimport
https://learn.microsoft.com/en-us/cpp/c-language/rules-and-limitations-for-dllimport-dllexport
https://gcc.gnu.org/onlinedocs/gcc/Microsoft-Windows-Function-Attributes.html
2025-06-03 23:05:03 +00:00
..
2025-06-03 23:05:03 +00:00