I am trying to generate Windows shared lib (dll) of Google flatbuffers (https://github.com/google/flatbuffers) using CMake.
I have used the following cmake
command, but it always generates a static library (*.lib) when I build it.
cmake .. -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=ON
I also tried the options CMAKE_IMPORT_LIBRARY_SUFFIX
and
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
with CMake. Unfortunately it always generates a *.lib
What do I need to do to generate *.dll?
In the Flatbuffers CMake code, there is a CMake option FLATBUFFERS_BUILD_SHAREDLIB
here:
option(FLATBUFFERS_BUILD_SHAREDLIB
"Enable the build of the flatbuffers shared library"
OFF)
You can set this option when you call CMake to enable the shared library build:
cmake .. -G "Visual Studio 16 2019" -DFLATBUFFERS_BUILD_SHAREDLIB=ON
For future reference, you can list all of the cached CMake variables using:
cmake -LH
This will show all of the defined FLATBUFFERS_*
options you can configure for the build.