Library types

There are two types of libaries: shared or static.

Specify SHARED in the call to the add_library command to force the library type to be shared:


add_library(archive SHARED archive.cpp zip.cpp lzma.cpp)

Specify STATIC in the call to the add_library command to force the library type to be static:


add_library(archive STATIC archive.cpp zip.cpp lzma.cpp)

Recommendation

Ideally your CMakeLists.txt files are simple and flexible. It is recommended that neither SHARED nor STATIC is specified. In that case the CMake variable BUILD_SHARED_LIBS can be used to determine whether shared or static libraries are built. This can be provided on the command line to CMake. For example:


cmake -G "Ninja" -DBUILD_SHARED_LIBS=ON %SOURCE%