Skip to content

Commit f25b3e4

Browse files
committed
fix(cmake): properly define POCO_DLL and POCO_STATIC based on BUILD_SHARED_LIBS.
1 parent c156f0b commit f25b3e4

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

CppUnit/CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ if(WIN32)
2828
endif()
2929
endif()
3030

31-
if(NOT BUILD_SHARED_LIBS)
32-
target_compile_definitions(CppUnit
33-
PUBLIC
34-
POCO_STATIC
35-
)
36-
elseif(MINGW)
37-
target_compile_definitions(CppUnit
38-
PUBLIC
39-
_DLL)
31+
if(BUILD_SHARED_LIBS AND MINGW)
32+
target_compile_definitions(CppUnit PUBLIC _DLL)
4033
endif()

DNSSD/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ POCO_SOURCES_AUTO( SRCS ${SRCS_G})
3939
file(GLOB_RECURSE HDRS_G "include/*.h" )
4040
POCO_HEADERS_AUTO( SRCS ${HDRS_G})
4141

42-
if (NOT POCO_STATIC)
43-
add_compile_definitions(THREADSAFE)
44-
endif (NOT POCO_STATIC)
45-
4642
add_library( "${LIBNAME}" ${LIB_MODE} ${SRCS} )
4743
add_library( "${POCO_LIBNAME}" ALIAS "${LIBNAME}")
4844
set_target_properties( "${LIBNAME}"
@@ -61,6 +57,10 @@ target_include_directories( "${LIBNAME}"
6157
)
6258
target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS})
6359

60+
if (BUILD_SHARED_LIBS)
61+
target_compile_definitions(${LIBNAME} PUBLIC THREADSAFE)
62+
endif ()
63+
6464
POCO_INSTALL("${LIBNAME}")
6565
POCO_GENERATE_PACKAGE("${LIBNAME}")
6666

Foundation/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ if(NOT DISABLE_CPP14 AND CMAKE_VERSION VERSION_GREATER "3.8")
128128
target_compile_features(Foundation PUBLIC cxx_std_14)
129129
endif()
130130

131-
if(NOT BUILD_SHARED_LIBS)
132-
target_compile_definitions(Foundation
133-
PUBLIC
134-
POCO_STATIC
135-
)
136-
endif()
137-
138131
if(WIN32)
139132
target_compile_definitions(Foundation PUBLIC POCO_OS_FAMILY_WINDOWS UNICODE _UNICODE)
140133
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

build_cmake.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# POCO_STATIC=1 - for static build
3+
# BUILD_SHARED_LIBS=OFF - for static build
44
# POCO_UNBUNDLED - for no built-in version of libs
55
# CMAKE_INSTALL_PREFIX=path - for install path
66

cmake/DefinePlatformSpecific.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
# - PocoXmdd.lib for /MD debug build
2323
# - PocoXmtd.lib for /MT debug build
2424

25+
if(BUILD_SHARED_LIBS)
26+
add_compile_definitions(POCO_DLL)
27+
else()
28+
add_compile_definitions(POCO_STATIC)
29+
endif()
30+
2531
if(MSVC)
2632
if(POCO_MT)
2733
set(CompilerFlags

0 commit comments

Comments
 (0)