fix(cmake): properly define POCO_DLL and POCO_STATIC based on BUILD_SHARED_LIBS.

This commit is contained in:
Matej Kenda 2024-11-07 09:01:45 +01:00
parent db9ba69f7d
commit cb91880bfb
5 changed files with 13 additions and 21 deletions

View File

@ -28,13 +28,6 @@ if(WIN32)
endif() endif()
endif() endif()
if(NOT BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS AND MINGW)
target_compile_definitions(CppUnit target_compile_definitions(CppUnit PUBLIC _DLL)
PUBLIC
POCO_STATIC
)
elseif(MINGW)
target_compile_definitions(CppUnit
PUBLIC
_DLL)
endif() endif()

View File

@ -39,10 +39,6 @@ POCO_SOURCES_AUTO( SRCS ${SRCS_G})
file(GLOB_RECURSE HDRS_G "include/*.h" ) file(GLOB_RECURSE HDRS_G "include/*.h" )
POCO_HEADERS_AUTO( SRCS ${HDRS_G}) 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( "${LIBNAME}" ${LIB_MODE} ${SRCS} )
add_library( "${POCO_LIBNAME}" ALIAS "${LIBNAME}") add_library( "${POCO_LIBNAME}" ALIAS "${LIBNAME}")
set_target_properties( "${LIBNAME}" set_target_properties( "${LIBNAME}"
@ -61,6 +57,10 @@ target_include_directories( "${LIBNAME}"
) )
target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS}) target_compile_definitions("${LIBNAME}" PUBLIC ${LIB_MODE_DEFINITIONS})
if (BUILD_SHARED_LIBS)
target_compile_definitions(${LIBNAME} PUBLIC THREADSAFE)
endif ()
POCO_INSTALL("${LIBNAME}") POCO_INSTALL("${LIBNAME}")
POCO_GENERATE_PACKAGE("${LIBNAME}") POCO_GENERATE_PACKAGE("${LIBNAME}")

View File

@ -128,13 +128,6 @@ if(NOT DISABLE_CPP14 AND CMAKE_VERSION VERSION_GREATER "3.8")
target_compile_features(Foundation PUBLIC cxx_std_14) target_compile_features(Foundation PUBLIC cxx_std_14)
endif() endif()
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(Foundation
PUBLIC
POCO_STATIC
)
endif()
if(WIN32) if(WIN32)
target_compile_definitions(Foundation PUBLIC POCO_OS_FAMILY_WINDOWS UNICODE _UNICODE) target_compile_definitions(Foundation PUBLIC POCO_OS_FAMILY_WINDOWS UNICODE _UNICODE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# POCO_STATIC=1 - for static build # BUILD_SHARED_LIBS=OFF - for static build
# POCO_UNBUNDLED - for no built-in version of libs # POCO_UNBUNDLED - for no built-in version of libs
# CMAKE_INSTALL_PREFIX=path - for install path # CMAKE_INSTALL_PREFIX=path - for install path

View File

@ -22,6 +22,12 @@
# - PocoXmdd.lib for /MD debug build # - PocoXmdd.lib for /MD debug build
# - PocoXmtd.lib for /MT 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(MSVC)
if(POCO_MT) if(POCO_MT)
set(CompilerFlags set(CompilerFlags