diff --git a/CppUnit/CMakeLists.txt b/CppUnit/CMakeLists.txt index 6b48c4305..1784f7155 100644 --- a/CppUnit/CMakeLists.txt +++ b/CppUnit/CMakeLists.txt @@ -28,6 +28,8 @@ if(WIN32) endif() endif() -if(BUILD_SHARED_LIBS AND MINGW) +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(CppUnit PUBLIC POCO_STATIC) +elseif (MINGW) target_compile_definitions(CppUnit PUBLIC _DLL) endif() diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index e985cc39a..352a54c89 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -128,6 +128,12 @@ if(NOT DISABLE_CPP14 AND CMAKE_VERSION VERSION_GREATER "3.8") target_compile_features(Foundation PUBLIC cxx_std_14) endif() +if(NOT BUILD_SHARED_LIBS) + # The define must be set here to be included in the generated CMake files + # and properly detect build in the installed files. + target_compile_definitions(Foundation PUBLIC POCO_STATIC) +endif() + if(WIN32) target_compile_definitions(Foundation PUBLIC POCO_OS_FAMILY_WINDOWS UNICODE _UNICODE) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")