mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-26 23:01:04 +08:00
Problem: static build broken on Win + CMake
Solution: revert the objects optimisation, and go back to building everything twice on Windows, as the static builds needs different preprocessor definitions from the shared one, so the objects have to be rebuilt. Keep the optimisation for all the other platforms. Fixes #2858
This commit is contained in:
parent
1dd42fef83
commit
53e536a983
@ -746,16 +746,12 @@ if (BUILD_STATIC)
|
|||||||
list(APPEND target_outputs "libzmq-static")
|
list(APPEND target_outputs "libzmq-static")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# avoid building everything twice for shared + static
|
|
||||||
add_library (objects OBJECT ${sources})
|
|
||||||
set_property(TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Suppress linker warnings caused by #ifdef omission
|
# Suppress linker warnings caused by #ifdef omission
|
||||||
# of file content.
|
# of file content.
|
||||||
set( CMAKE_STATIC_LINKER_FLAGS /ignore:4221 )
|
set( CMAKE_STATIC_LINKER_FLAGS /ignore:4221 )
|
||||||
if (BUILD_SHARED)
|
if (BUILD_SHARED)
|
||||||
add_library (libzmq SHARED $<TARGET_OBJECTS:objects> ${public_headers} ${html-docs} ${readme-docs} ${CMAKE_CURRENT_BINARY_DIR}/NSIS.template.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
add_library (libzmq SHARED ${sources} ${public_headers} ${html-docs} ${readme-docs} ${CMAKE_CURRENT_BINARY_DIR}/NSIS.template.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||||
target_link_libraries (libzmq ${OPTIONAL_LIBRARIES})
|
target_link_libraries (libzmq ${OPTIONAL_LIBRARIES})
|
||||||
set_target_properties (libzmq PROPERTIES
|
set_target_properties (libzmq PROPERTIES
|
||||||
PUBLIC_HEADER "${public_headers}"
|
PUBLIC_HEADER "${public_headers}"
|
||||||
@ -768,7 +764,7 @@ if (MSVC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_STATIC)
|
if (BUILD_STATIC)
|
||||||
add_library (libzmq-static STATIC $<TARGET_OBJECTS:objects> ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
add_library (libzmq-static STATIC ${sources} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||||
set_target_properties (libzmq-static PROPERTIES
|
set_target_properties (libzmq-static PROPERTIES
|
||||||
PUBLIC_HEADER "${public_headers}"
|
PUBLIC_HEADER "${public_headers}"
|
||||||
RELEASE_POSTFIX "${MSVC_TOOLSET}-mt-s-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
|
RELEASE_POSTFIX "${MSVC_TOOLSET}-mt-s-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
|
||||||
@ -778,6 +774,11 @@ if (MSVC)
|
|||||||
OUTPUT_NAME "libzmq")
|
OUTPUT_NAME "libzmq")
|
||||||
endif()
|
endif()
|
||||||
else ()
|
else ()
|
||||||
|
# avoid building everything twice for shared + static
|
||||||
|
# only on *nix, as Windows needs different preprocessor defines in static builds
|
||||||
|
add_library (objects OBJECT ${sources})
|
||||||
|
set_property(TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
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)
|
add_library (libzmq SHARED $<TARGET_OBJECTS:objects> ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||||
target_link_libraries (libzmq ${OPTIONAL_LIBRARIES})
|
target_link_libraries (libzmq ${OPTIONAL_LIBRARIES})
|
||||||
@ -812,9 +813,16 @@ else ()
|
|||||||
OUTPUT_NAME "zmq"
|
OUTPUT_NAME "zmq"
|
||||||
PREFIX "lib")
|
PREFIX "lib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_include_directories (objects
|
||||||
|
PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
foreach (target ${target_outputs} objects)
|
foreach (target ${target_outputs})
|
||||||
target_include_directories (${target}
|
target_include_directories (${target}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user