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..a38102ae586 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") @@ -62,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()