From 7664c6f511da489900a700481f640d3bd6402c2e Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 30 Jul 2025 10:02:34 +0200 Subject: [PATCH] feature: Add control flag for static compile (#21635) --- .../src/main/resources/C-libcurl/CMakeLists.txt.mustache | 6 +++++- samples/client/others/c/bearerAuth/CMakeLists.txt | 6 +++++- samples/client/petstore/c-useJsonUnformatted/CMakeLists.txt | 6 +++++- samples/client/petstore/c/CMakeLists.txt | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/C-libcurl/CMakeLists.txt.mustache b/modules/openapi-generator/src/main/resources/C-libcurl/CMakeLists.txt.mustache index 97a44e464432..31a3c22a95cd 100644 --- a/modules/openapi-generator/src/main/resources/C-libcurl/CMakeLists.txt.mustache +++ b/modules/openapi-generator/src/main/resources/C-libcurl/CMakeLists.txt.mustache @@ -91,7 +91,11 @@ include(PreTarget.cmake OPTIONAL) set(PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") # Add library with project file with project name as library name -add_library(${pkgName} ${SRCS} ${HDRS}) +if(NOT BUILD_STATIC_LIBS) + add_library(${pkgName} ${SRCS} ${HDRS}) +else() + add_library(${pkgName} STATIC ${SRCS} ${HDRS}) +endif() # Link dependent libraries if(NOT CMAKE_VERSION VERSION_LESS 3.4) target_link_libraries(${pkgName} PRIVATE OpenSSL::SSL OpenSSL::Crypto) diff --git a/samples/client/others/c/bearerAuth/CMakeLists.txt b/samples/client/others/c/bearerAuth/CMakeLists.txt index 30076da6c6eb..6f6c55866496 100644 --- a/samples/client/others/c/bearerAuth/CMakeLists.txt +++ b/samples/client/others/c/bearerAuth/CMakeLists.txt @@ -69,7 +69,11 @@ include(PreTarget.cmake OPTIONAL) set(PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") # Add library with project file with project name as library name -add_library(${pkgName} ${SRCS} ${HDRS}) +if(NOT BUILD_STATIC_LIBS) + add_library(${pkgName} ${SRCS} ${HDRS}) +else() + add_library(${pkgName} STATIC ${SRCS} ${HDRS}) +endif() # Link dependent libraries if(NOT CMAKE_VERSION VERSION_LESS 3.4) target_link_libraries(${pkgName} PRIVATE OpenSSL::SSL OpenSSL::Crypto) diff --git a/samples/client/petstore/c-useJsonUnformatted/CMakeLists.txt b/samples/client/petstore/c-useJsonUnformatted/CMakeLists.txt index 5ad5652ad3a3..eca42ccb016c 100644 --- a/samples/client/petstore/c-useJsonUnformatted/CMakeLists.txt +++ b/samples/client/petstore/c-useJsonUnformatted/CMakeLists.txt @@ -93,7 +93,11 @@ include(PreTarget.cmake OPTIONAL) set(PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") # Add library with project file with project name as library name -add_library(${pkgName} ${SRCS} ${HDRS}) +if(NOT BUILD_STATIC_LIBS) + add_library(${pkgName} ${SRCS} ${HDRS}) +else() + add_library(${pkgName} STATIC ${SRCS} ${HDRS}) +endif() # Link dependent libraries if(NOT CMAKE_VERSION VERSION_LESS 3.4) target_link_libraries(${pkgName} PRIVATE OpenSSL::SSL OpenSSL::Crypto) diff --git a/samples/client/petstore/c/CMakeLists.txt b/samples/client/petstore/c/CMakeLists.txt index 5ad5652ad3a3..eca42ccb016c 100644 --- a/samples/client/petstore/c/CMakeLists.txt +++ b/samples/client/petstore/c/CMakeLists.txt @@ -93,7 +93,11 @@ include(PreTarget.cmake OPTIONAL) set(PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") # Add library with project file with project name as library name -add_library(${pkgName} ${SRCS} ${HDRS}) +if(NOT BUILD_STATIC_LIBS) + add_library(${pkgName} ${SRCS} ${HDRS}) +else() + add_library(${pkgName} STATIC ${SRCS} ${HDRS}) +endif() # Link dependent libraries if(NOT CMAKE_VERSION VERSION_LESS 3.4) target_link_libraries(${pkgName} PRIVATE OpenSSL::SSL OpenSSL::Crypto)