Commit c7876c09 authored by Tony Theodore's avatar Tony Theodore

Problem: mingw static/shared builds have different preprocessor defines

Solution: remove objects optimisation in library build (similar to #2860)
and set PUBLIC compile definitions on all static builds instead of MSVC
only.
parent 794d7a31
...@@ -911,20 +911,27 @@ if (MSVC) ...@@ -911,20 +911,27 @@ if (MSVC)
DEBUG_POSTFIX "${MSVC_TOOLSET}-mt-sgd-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}" DEBUG_POSTFIX "${MSVC_TOOLSET}-mt-sgd-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
COMPILE_FLAGS "/DZMQ_STATIC" COMPILE_FLAGS "/DZMQ_STATIC"
OUTPUT_NAME "libzmq") OUTPUT_NAME "libzmq")
target_compile_definitions(libzmq-static
PUBLIC ZMQ_STATIC
)
endif() endif()
else () else ()
# avoid building everything twice for shared + static # avoid building everything twice for shared + static
# only on *nix, as Windows needs different preprocessor defines in static builds # only on *nix, as Windows needs different preprocessor defines in static builds
add_library (objects OBJECT ${sources}) if (NOT MINGW)
set_property(TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON) add_library (objects OBJECT ${sources})
set_property(TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories (objects
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
endif ()
if (BUILD_SHARED) if (BUILD_SHARED)
add_library (libzmq SHARED $<TARGET_OBJECTS:objects> ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) if (MINGW)
add_library (libzmq SHARED ${sources} ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
else ()
add_library (libzmq SHARED $<TARGET_OBJECTS:objects> ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif ()
# NOTE: the SOVERSION and VERSION MUST be the same as the one generated by libtool! It is NOT the same as the version of the package. # NOTE: the SOVERSION and VERSION MUST be the same as the one generated by libtool! It is NOT the same as the version of the package.
set_target_properties (libzmq PROPERTIES set_target_properties (libzmq PROPERTIES
COMPILE_DEFINITIONS "DLL_EXPORT" COMPILE_DEFINITIONS "DLL_EXPORT"
...@@ -949,19 +956,22 @@ else () ...@@ -949,19 +956,22 @@ else ()
endif() endif()
if (BUILD_STATIC) if (BUILD_STATIC)
add_library (libzmq-static STATIC $<TARGET_OBJECTS:objects> ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) if (MINGW)
add_library (libzmq-static STATIC ${sources} ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
else ()
add_library (libzmq-static STATIC $<TARGET_OBJECTS:objects> ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif ()
set_target_properties (libzmq-static PROPERTIES set_target_properties (libzmq-static PROPERTIES
PUBLIC_HEADER "${public_headers}" PUBLIC_HEADER "${public_headers}"
COMPILE_DEFINITIONS "ZMQ_STATIC"
OUTPUT_NAME "zmq" OUTPUT_NAME "zmq"
PREFIX "lib") PREFIX "lib")
endif() endif()
target_include_directories (objects endif ()
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> if (BUILD_STATIC)
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> target_compile_definitions(libzmq-static
$<INSTALL_INTERFACE:include> PUBLIC ZMQ_STATIC
) )
endif () endif ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment