From 395c08433a5887b07a74fcc8495b7cd091538c39 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 5 Dec 2025 23:14:40 -0600 Subject: [PATCH 1/2] Enable BUILD_CORE_DLL --- cmake/compileroptions.cmake | 2 +- cmake/options.cmake | 3 --- lib/CMakeLists.txt | 4 ++++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/compileroptions.cmake b/cmake/compileroptions.cmake index 4112ddd2418..58cbfdfbe6c 100644 --- a/cmake/compileroptions.cmake +++ b/cmake/compileroptions.cmake @@ -36,7 +36,7 @@ function(target_dll_compile_definitions TARGET) endif() - if (BUILD_SHARED_LIBS AND MSVC) + if ((BUILD_SHARED_LIBS OR BUILD_CORE_DLL) AND MSVC) if(PARSE_EXPORT) target_compile_definitions(${TARGET} PRIVATE ${PARSE_EXPORT}) endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index 5765f9a9595..efc44be2b62 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -53,9 +53,6 @@ else() endif() option(BUILD_CORE_DLL "Build lib as cppcheck-core.dll with Visual Studio" OFF) -if(BUILD_CORE_DLL AND NOT MSVC) - message(FATAL_ERROR "Building of lib as DLL is only supported with Visual Studio") -endif() option(BUILD_TESTS "Build tests" OFF) option(REGISTER_TESTS "Register tests in CTest" ON) option(ENABLE_CHECK_INTERNAL "Enable internal checks" OFF) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d7a94de352e..f6f6c35e0fa 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,3 +1,7 @@ +if(BUILD_CORE_DLL) + set(BUILD_SHARED_LIBS On) +endif() + file(GLOB_RECURSE hdrs "*.h") file(GLOB_RECURSE srcs "*.cpp") From dd79f1602d01c3ccd3984656643cd27c5bd6e8c8 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 9 Dec 2025 13:19:12 -0600 Subject: [PATCH 2/2] Add install for dll --- lib/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index f6f6c35e0fa..a38102ae586 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -66,3 +66,9 @@ endif() if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) target_precompile_headers(cppcheck-core PRIVATE precompiled.h) endif() + +if(BUILD_CORE_DLL) + install(TARGETS cppcheck-core + RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} + COMPONENT applications) +endif()