From 0f3ab86ba0c4fea22e3f0e822fbb2d4b4b58ae75 Mon Sep 17 00:00:00 2001 From: Jan Orend <56254096+3dJan@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:07:14 +0100 Subject: [PATCH] Add option to build as static library --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe8004a5f..cbd8689a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option(USE_INCLUDED_SSL "Use included libressl" ON) option(BUILD_FOR_CODECOVERAGE "Build for code coverage analysis" OFF) option(STRIP_BINARIES "Strip binaries (on non-apple)" ON) option(USE_PLATFORM_UUID "Use UUID geneator that is provided by the OS (always ON for Windows)" OFF) +option(BUILD_AS_STATIC_LIB "Build as static lib (default=OFF)" OFF) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # using GCC @@ -108,10 +109,18 @@ endif() ######################################################### # Shared library -add_library(${PROJECT_NAME} SHARED ${SRCS_COMMON} ${HDRS_COMMON} - ${ACT_GENERATED_SOURCE} - ${VERSION_FILES_OUTPUTLOCATION} +if (BUILD_AS_STATIC_LIB) + add_library(${PROJECT_NAME} STATIC ${SRCS_COMMON} ${HDRS_COMMON} + ${ACT_GENERATED_SOURCE} + ${VERSION_FILES_OUTPUTLOCATION} ) +else() + add_library(${PROJECT_NAME} SHARED ${SRCS_COMMON} ${HDRS_COMMON} + ${ACT_GENERATED_SOURCE} + ${VERSION_FILES_OUTPUTLOCATION} +) +endif() + SOURCE_GROUP("Source Files\\Autogenerated" FILES ${ACT_GENERATED_SOURCE})