diff --git a/CppUnit/CMakeLists.txt b/CppUnit/CMakeLists.txt index 78b89d442..6b48c4305 100644 --- a/CppUnit/CMakeLists.txt +++ b/CppUnit/CMakeLists.txt @@ -28,13 +28,6 @@ if(WIN32) endif() endif() -if(NOT BUILD_SHARED_LIBS) - target_compile_definitions(CppUnit - PUBLIC - POCO_STATIC - ) -elseif(MINGW) - target_compile_definitions(CppUnit - PUBLIC - _DLL) +if(BUILD_SHARED_LIBS AND MINGW) + target_compile_definitions(CppUnit PUBLIC _DLL) endif() diff --git a/DNSSD/CMakeLists.txt b/DNSSD/CMakeLists.txt index e9ce1a558..ca27100a9 100644 --- a/DNSSD/CMakeLists.txt +++ b/DNSSD/CMakeLists.txt @@ -39,10 +39,6 @@ POCO_SOURCES_AUTO( SRCS ${SRCS_G}) file(GLOB_RECURSE HDRS_G "include/*.h" ) POCO_HEADERS_AUTO( SRCS ${HDRS_G}) -if (NOT POCO_STATIC) - add_compile_definitions(THREADSAFE) -endif (NOT POCO_STATIC) - add_library( "${LIBNAME}" ${LIB_MODE} ${SRCS} ) add_library( "${POCO_LIBNAME}" ALIAS "${LIBNAME}") set_target_properties( "${LIBNAME}" @@ -61,6 +57,10 @@ target_include_directories( "${LIBNAME}" ) target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) +if (BUILD_SHARED_LIBS) + target_compile_definitions(${LIBNAME} PUBLIC THREADSAFE) +endif () + POCO_INSTALL("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}") diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index 942f98700..5898d22f5 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -128,13 +128,6 @@ 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) - 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") diff --git a/build_cmake.sh b/build_cmake.sh index 61d1b2915..2500da5b4 100755 --- a/build_cmake.sh +++ b/build_cmake.sh @@ -1,6 +1,6 @@ #!/bin/bash -# POCO_STATIC=1 - for static build +# BUILD_SHARED_LIBS=OFF - for static build # POCO_UNBUNDLED - for no built-in version of libs # CMAKE_INSTALL_PREFIX=path - for install path diff --git a/cmake/DefinePlatformSpecific.cmake b/cmake/DefinePlatformSpecific.cmake index d2b175a0c..e71f7abd8 100644 --- a/cmake/DefinePlatformSpecific.cmake +++ b/cmake/DefinePlatformSpecific.cmake @@ -22,6 +22,12 @@ # - PocoXmdd.lib for /MD debug build # - PocoXmtd.lib for /MT debug build +if(BUILD_SHARED_LIBS) + add_compile_definitions(POCO_DLL) +else() + add_compile_definitions(POCO_STATIC) +endif() + if(MSVC) if(POCO_MT) set(CompilerFlags