Unverified Commit 9f83a598 authored by Jim Klimov's avatar Jim Klimov Committed by GitHub

Merge pull request #2844 from bluca/cmake_double_build

Problems: CMake rebuilds everything twice, warnings with Tweetnacl, no autoconf option to disable Werror
parents b3bf5171 574d72b0
......@@ -86,8 +86,8 @@ matrix:
sudo: required
before_install:
- if [ $TRAVIS_OS_NAME == "osx" -a $BUILD_TYPE == "android" ] ; then brew install binutils ; fi
- if [ $TRAVIS_OS_NAME == "osx" -a $CURVE == "libsodium" ] ; then brew install libsodium ; fi
- if [ $TRAVIS_OS_NAME == "osx" -a $BUILD_TYPE == "android" ] ; then brew update; brew install binutils ; fi
- if [ $TRAVIS_OS_NAME == "osx" -a $CURVE == "libsodium" ] ; then brew update; brew install libsodium ; fi
before_script:
# ZMQ stress tests need more open socket (files) than the usual default
......
......@@ -575,8 +575,6 @@ set (cxx-sources
gather.cpp
zap_client.cpp)
set (rc-sources version.rc)
if (MINGW)
# Generate the right type when using -m32 or -m64
macro (set_rc_arch rc_target)
......@@ -643,10 +641,7 @@ foreach (source ${cxx-sources})
list (APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/src/${source})
endforeach ()
foreach (source ${rc-sources})
list (APPEND sources ${CMAKE_CURRENT_BINARY_DIR}/${source})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/${source}.in ${CMAKE_CURRENT_BINARY_DIR}/${source})
endforeach ()
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/src/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
# Delete any src/platform.hpp left by configure
file (REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/src/platform.hpp)
......@@ -751,12 +746,16 @@ if (BUILD_STATIC)
list(APPEND target_outputs "libzmq-static")
endif()
# avoid building everything twice for shared + static
add_library (objects OBJECT ${sources})
set_property(TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON)
if (MSVC)
# Suppress linker warnings caused by #ifdef omission
# of file content.
set( CMAKE_STATIC_LINKER_FLAGS /ignore:4221 )
if (BUILD_SHARED)
add_library (libzmq SHARED ${sources} ${public_headers} ${html-docs} ${readme-docs} ${CMAKE_CURRENT_BINARY_DIR}/NSIS.template.in)
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)
target_link_libraries (libzmq ${OPTIONAL_LIBRARIES})
set_target_properties (libzmq PROPERTIES
PUBLIC_HEADER "${public_headers}"
......@@ -769,7 +768,7 @@ if (MSVC)
endif()
if (BUILD_STATIC)
add_library (libzmq-static STATIC ${sources})
add_library (libzmq-static STATIC $<TARGET_OBJECTS:objects> ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
set_target_properties (libzmq-static PROPERTIES
PUBLIC_HEADER "${public_headers}"
RELEASE_POSTFIX "${MSVC_TOOLSET}-mt-s-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}"
......@@ -780,7 +779,7 @@ if (MSVC)
endif()
else ()
if (BUILD_SHARED)
add_library (libzmq SHARED ${sources} ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig})
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})
# NOTE: the SOVERSION MUST be the same as the one generated by libtool!
set_target_properties (libzmq PROPERTIES
......@@ -806,7 +805,7 @@ else ()
endif()
if (BUILD_STATIC)
add_library (libzmq-static STATIC ${sources} ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig})
add_library (libzmq-static STATIC $<TARGET_OBJECTS:objects> ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
set_target_properties (libzmq-static PROPERTIES
PUBLIC_HEADER "${public_headers}"
COMPILE_DEFINITIONS "ZMQ_STATIC"
......@@ -815,7 +814,7 @@ else ()
endif()
endif ()
foreach (target ${target_outputs})
foreach (target ${target_outputs} objects)
target_include_directories (${target}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
......
......@@ -79,6 +79,9 @@
* Add new autoconf --disable-libunwind option to stop building with libunwind
even if it is available.
* Add new autoconf --disable-Werror option to avoid building with the Werror
flag.
* Use pkg-config as the first method for finding and building with external
optional dependencies such as libnorm, libpgm and gssapi.
......
......@@ -144,8 +144,11 @@ else
AC_MSG_RESULT([no])
fi
# By default compiling with -Werror except OSX.
libzmq_werror="yes"
# By default compiling with -Werror except OSX and on Solaris when building
# with libsodium.
AC_ARG_ENABLE([Werror],
[AS_HELP_STRING([--disable-Werror], [disable Werror compiler flag [default=enabled]])],
[libzmq_werror=$enableval], [libzmq_werror=yes])
# By default use DSO visibility
libzmq_dso_visibility="yes"
......
......@@ -145,8 +145,12 @@ if(WIN32)
endif()
# add library and include dirs for all targets
link_libraries(libzmq ${OPTIONAL_LIBRARIES})
include_directories("${CMAKE_SOURCE_DIR}/../include")
if (BUILD_SHARED)
link_libraries(libzmq ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
else ()
link_libraries(libzmq-static ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
endif ()
include_directories("${CMAKE_SOURCE_DIR}/../include" "${CMAKE_BINARY_DIR}")
foreach(test ${tests})
# target_sources not supported before CMake 3.1
......@@ -195,7 +199,8 @@ if(ZMQ_HAVE_CURVE)
endif()
#add additional required flags
if(ZMQ_HAVE_CURVE)
#ZMQ_USE_TWEETNACL will already be defined when not using sodium
if(ZMQ_HAVE_CURVE AND NOT ZMQ_USE_TWEETNACL)
target_compile_definitions(test_security_curve PRIVATE "-DZMQ_USE_TWEETNACL")
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