diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e662fde6..c962390fb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,26 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -find_package(ZeroMQ 4 REQUIRED) +#From: https://github.com/zeromq/cppzmq/ +if (NOT TARGET libzmq) + find_package(ZeroMQ 4 QUIET) + + # libzmq autotools install: fallback to pkg-config + if(NOT ZeroMQ_FOUND) + message(STATUS "CMake libzmq package not found, trying again with pkg-config (normal install of zeromq)") + list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config) + find_package(ZeroMQ 4 REQUIRED) + endif() + + # TODO "REQUIRED" above should already cause a fatal failure if not found, but this doesn't seem to work + if(NOT ZeroMQ_FOUND) + message(FATAL_ERROR "ZeroMQ was not found, neither as a CMake package nor via pkg-config") + endif() + + if (ZeroMQ_FOUND AND NOT TARGET libzmq) + message(FATAL_ERROR "ZeroMQ version not supported!") + endif() +endif() if (SLS_USE_TESTS) enable_testing() diff --git a/cmake/FindZeroMQ.cmake b/cmake/FindZeroMQ.cmake deleted file mode 100755 index 5bc561386..000000000 --- a/cmake/FindZeroMQ.cmake +++ /dev/null @@ -1,112 +0,0 @@ - -# This file is originally from https://github.com/zeromq/azmq and distributed -# under Boost Software Lincese 1.0 -# Boost Software License - Version 1.0 - August 17th, 2003 - -# Permission is hereby granted, free of charge, to any person or organization -# obtaining a copy of the software and accompanying documentation covered by -# this license (the "Software") to use, reproduce, display, distribute, -# execute, and transmit the Software, and to prepare derivative works of the -# Software, and to permit third-parties to whom the Software is furnished to -# do so, all subject to the following: - -# The copyright notices in the Software and this entire statement, including -# the above license grant, this restriction and the following disclaimer, -# must be included in all copies of the Software, in whole or in part, and -# all derivative works of the Software, unless such copies or derivative -# works are solely in the form of machine-executable object code generated by -# a source language processor. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -------------------------------------------------------------------------------- - -# Find ZeroMQ Headers/Libs - -# Variables -# ZMQ_ROOT - set this to a location where ZeroMQ may be found -# -# ZeroMQ_FOUND - True of ZeroMQ found -# ZeroMQ_INCLUDE_DIRS - Location of ZeroMQ includes -# ZeroMQ_LIBRARIES - ZeroMQ libraries - -include(FindPackageHandleStandardArgs) - -if (NOT ZMQ_ROOT) - set(ZMQ_ROOT "$ENV{ZMQ_ROOT}") -endif() - -if (NOT ZMQ_ROOT) - find_path(_ZeroMQ_ROOT NAMES include/zmq.h) -else() - set(_ZeroMQ_ROOT "${ZMQ_ROOT}") -endif() - -find_path(ZeroMQ_INCLUDE_DIRS NAMES zmq.h HINTS ${_ZeroMQ_ROOT}/include) - -if (ZeroMQ_INCLUDE_DIRS) - set(_ZeroMQ_H ${ZeroMQ_INCLUDE_DIRS}/zmq.h) - - function(_zmqver_EXTRACT _ZeroMQ_VER_COMPONENT _ZeroMQ_VER_OUTPUT) - set(CMAKE_MATCH_1 "0") - set(_ZeroMQ_expr "^[ \\t]*#define[ \\t]+${_ZeroMQ_VER_COMPONENT}[ \\t]+([0-9]+)$") - file(STRINGS "${_ZeroMQ_H}" _ZeroMQ_ver REGEX "${_ZeroMQ_expr}") - string(REGEX MATCH "${_ZeroMQ_expr}" ZeroMQ_ver "${_ZeroMQ_ver}") - set(${_ZeroMQ_VER_OUTPUT} "${CMAKE_MATCH_1}" PARENT_SCOPE) - endfunction() - - _zmqver_EXTRACT("ZMQ_VERSION_MAJOR" ZeroMQ_VERSION_MAJOR) - _zmqver_EXTRACT("ZMQ_VERSION_MINOR" ZeroMQ_VERSION_MINOR) - _zmqver_EXTRACT("ZMQ_VERSION_PATCH" ZeroMQ_VERSION_PATCH) - - message(STATUS "ZeroMQ version: ${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}.${ZeroMQ_VERSION_PATCH}") - - # We should provide version to find_package_handle_standard_args in the same format as it was requested, - # otherwise it can't check whether version matches exactly. - if (ZeroMQ_FIND_VERSION_COUNT GREATER 2) - set(ZeroMQ_VERSION "${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}.${ZeroMQ_VERSION_PATCH}") - else() - # User has requested ZeroMQ version without patch part => user is not interested in specific patch => - # any patch should be an exact match. - set(ZeroMQ_VERSION "${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}") - endif() - - if (NOT ${CMAKE_CXX_PLATFORM_ID} STREQUAL "Windows") - find_library(ZeroMQ_LIBRARIES NAMES zmq HINTS ${_ZeroMQ_ROOT}/lib) - else() - find_library( - ZeroMQ_LIBRARY_RELEASE - NAMES - libzmq - "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}" - HINTS - ${_ZeroMQ_ROOT}/lib - ) - - find_library( - ZeroMQ_LIBRARY_DEBUG - NAMES - libzmq_d - "libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-gd-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}" - HINTS - ${_ZeroMQ_ROOT}/lib) - - # On Windows we have to use corresponding version (i.e. Release or Debug) of ZeroMQ because of `errno` CRT global variable - # See more at http://www.drdobbs.com/avoiding-the-visual-c-runtime-library/184416623 - set(ZeroMQ_LIBRARIES optimized "${ZeroMQ_LIBRARY_RELEASE}" debug "${ZeroMQ_LIBRARY_DEBUG}") - endif() -endif() - -find_package_handle_standard_args(ZeroMQ FOUND_VAR ZeroMQ_FOUND - REQUIRED_VARS ZeroMQ_INCLUDE_DIRS ZeroMQ_LIBRARIES - VERSION_VAR ZeroMQ_VERSION) - -if (ZeroMQ_FOUND) - mark_as_advanced(ZeroMQ_INCLUDE_DIRS ZeroMQ_LIBRARIES ZeroMQ_VERSION - ZeroMQ_VERSION_MAJOR ZeroMQ_VERSION_MINOR ZeroMQ_VERSION_PATCH) -endif() \ No newline at end of file diff --git a/cmake/package_config.cmake b/cmake/package_config.cmake index bfa0a31a8..7c07ee344 100755 --- a/cmake/package_config.cmake +++ b/cmake/package_config.cmake @@ -25,6 +25,12 @@ install(FILES DESTINATION ${CMAKE_INSTALL_DIR} ) +install(FILES + "${CMAKE_SOURCE_DIR}/libzmq-pkg-config/FindZeroMQ.cmake" + COMPONENT devel + DESTINATION ${CMAKE_INSTALL_DIR}/libzmq-pkg-config +) + if (PROJECT_LIBRARIES OR PROJECT_STATIC_LIBRARIES) install( EXPORT "${TARGETS_EXPORT_NAME}" diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in index 3d8646c6e..034688953 100755 --- a/cmake/project-config.cmake.in +++ b/cmake/project-config.cmake.in @@ -12,8 +12,21 @@ include(CMakeFindDependencyMacro) set(SLS_USE_HDF5 "@SLS_USE_HDF5@") -# Add optional dependencies here + +find_package(ZeroMQ 4 QUIET) +# libzmq autotools install: fallback to pkg-config +if(NOT ZeroMQ_FOUND) + list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config) + find_package(ZeroMQ 4 REQUIRED) +endif() + +if(NOT ZeroMQ_FOUND) + message(FATAL_ERROR "ZeroMQ was NOT found!") +endif() + find_dependency(Threads) + +# Add optional dependencies here if (SLS_USE_HDF5) find_dependency(HDF5) endif () diff --git a/conda-recepie/build.sh b/conda-recepie/build.sh index 45607594c..4d573a716 100755 --- a/conda-recepie/build.sh +++ b/conda-recepie/build.sh @@ -13,8 +13,9 @@ cmake .. \ -DCMAKE_BUILD_TYPE=Release \ -DSLS_USE_HDF5=OFF\ - -cmake --build . -- -j10 +NCORES=$(getconf _NPROCESSORS_ONLN) +echo "Building using: ${NCORES} cores" +cmake --build . -- -j${NCORES} cmake --build . --target install -CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2 \ No newline at end of file +CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2 diff --git a/conda-recepie/copy_gui.sh b/conda-recepie/copy_gui.sh index 956ec8073..c35d018b0 100755 --- a/conda-recepie/copy_gui.sh +++ b/conda-recepie/copy_gui.sh @@ -1,3 +1,3 @@ #Copy the GUI -mkdir $PREFIX/bin -cp build/bin/slsDetectorGui $PREFIX/bin/. +mkdir -p $PREFIX/bin +cp build/install/bin/slsDetectorGui $PREFIX/bin/. diff --git a/conda-recepie/copy_lib.sh b/conda-recepie/copy_lib.sh index fa624418d..e153ad869 100755 --- a/conda-recepie/copy_lib.sh +++ b/conda-recepie/copy_lib.sh @@ -1,6 +1,6 @@ -mkdir $PREFIX/lib -mkdir $PREFIX/bin +mkdir -p $PREFIX/lib +mkdir -p $PREFIX/bin mkdir -p $PREFIX/include/sls # mkdir $PREFIX/include/slsDetectorPackage diff --git a/conda-recepie/meta.yaml b/conda-recepie/meta.yaml index d3bf39d60..216e509d5 100755 --- a/conda-recepie/meta.yaml +++ b/conda-recepie/meta.yaml @@ -59,6 +59,16 @@ outputs: script: copy_lib.sh requirements: + build: + - {{ compiler('c') }} + - {{compiler('cxx')}} + - libstdcxx-ng + - libgcc-ng + - zeromq + + host: + - zeromq + run: - libstdcxx-ng - libgcc-ng @@ -78,6 +88,8 @@ outputs: host: - python + - {{ pin_subpackage('slsdetlib', exact=True) }} + run: - libstdcxx-ng @@ -94,6 +106,13 @@ outputs: - name: slsdetgui script: copy_gui.sh requirements: + + build: + - {{ compiler('c') }} + - {{compiler('cxx')}} + - {{ pin_subpackage('slsdetlib', exact=True) }} + - qwt 6.* + run: - {{ pin_subpackage('slsdetlib', exact=True) }} - qwt 6.* diff --git a/libzmq-pkg-config/FindZeroMQ.cmake b/libzmq-pkg-config/FindZeroMQ.cmake new file mode 100755 index 000000000..9d9a4dfbf --- /dev/null +++ b/libzmq-pkg-config/FindZeroMQ.cmake @@ -0,0 +1,27 @@ +#From: https://github.com/zeromq/cppzmq/ +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) +find_package(PkgConfig) +pkg_check_modules(PC_LIBZMQ QUIET libzmq) + +set(ZeroMQ_VERSION ${PC_LIBZMQ_VERSION}) +find_library(ZeroMQ_LIBRARY NAMES libzmq.so libzmq.dylib libzmq.dll + PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS}) +find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a + PATHS ${PC_LIBZMQ_LIBDIR} ${PC_LIBZMQ_LIBRARY_DIRS}) + +if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY) + set(ZeroMQ_FOUND ON) +endif() + +if (TARGET libzmq) + # avoid errors defining targets twice + return() +endif() + +add_library(libzmq SHARED IMPORTED) +set_property(TARGET libzmq PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS}) +set_property(TARGET libzmq PROPERTY IMPORTED_LOCATION ${ZeroMQ_LIBRARY}) + +add_library(libzmq-static STATIC IMPORTED ${PC_LIBZMQ_INCLUDE_DIRS}) +set_property(TARGET libzmq-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PC_LIBZMQ_INCLUDE_DIRS}) +set_property(TARGET libzmq-static PROPERTY IMPORTED_LOCATION ${ZeroMQ_STATIC_LIBRARY}) \ No newline at end of file diff --git a/slsDetectorGui/CMakeLists.txt b/slsDetectorGui/CMakeLists.txt index 244fe2733..70e8a2e9b 100755 --- a/slsDetectorGui/CMakeLists.txt +++ b/slsDetectorGui/CMakeLists.txt @@ -91,7 +91,6 @@ target_include_directories(slsDetectorGui PUBLIC target_link_libraries(slsDetectorGui PUBLIC slsProjectOptions - slsProjectWarnings slsDetectorStatic ${QT_QTCORE_LIBRARIES} ${QT_QTGUI_LIBRARIES} @@ -101,6 +100,9 @@ target_link_libraries(slsDetectorGui PUBLIC Qt4::QtOpenGL Qt4::QtSvg expat + + PRIVATE + slsProjectWarnings ) set_target_properties(slsDetectorGui PROPERTIES @@ -111,7 +113,7 @@ if(SLS_LTO_AVAILABLE) endif() install(TARGETS slsDetectorGui - EXPORT "${TARGETS_EXPORT_NAME}" + # EXPORT "${TARGETS_EXPORT_NAME}" #do not export gui RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index d0a41b867..9a47d90f9 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -54,7 +54,7 @@ bool CmdProxy::ReplaceIfDepreciated(std::string &command) { if (d_it != depreciated_functions.end()) { LOG(logWARNING) << command - << " is depreciated and will be removed. Please migrate to: " + << " is deprecated and will be removed. Please migrate to: " << d_it->second; // insert old command into arguments (for dacs) if (d_it->second == "dac") { diff --git a/slsSupportLib/CMakeLists.txt b/slsSupportLib/CMakeLists.txt index 215a625b5..421c9041d 100755 --- a/slsSupportLib/CMakeLists.txt +++ b/slsSupportLib/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCES src/ZmqSocket.cpp src/UdpRxSocket.cpp src/sls_detector_exceptions.cpp - # src/sls_detector_defs.cpp ) # Header files to install as a part of the library @@ -57,14 +56,12 @@ target_include_directories(slsSupportObject PUBLIC "$" "$" - PRIVATE - ${ZeroMQ_INCLUDE_DIRS} ) target_link_libraries(slsSupportObject PUBLIC slsProjectOptions - ${ZeroMQ_LIBRARIES} + libzmq rapidjson PRIVATE slsProjectWarnings @@ -76,7 +73,6 @@ endif(SLS_USE_TESTS) # Add shared library version of the support lib add_library(slsSupportShared SHARED $) - target_link_libraries(slsSupportShared PUBLIC slsSupportObject) set_target_properties(slsSupportShared PROPERTIES @@ -108,3 +104,4 @@ install(TARGETS slsSupportShared slsSupportStatic slsSupportObject PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sls ) + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3cdb3d634..93c52afeb 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,22 +18,24 @@ set_target_properties(testserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) add_executable(tests ${SLS_TEST_SOURCES}) -target_link_libraries(tests - slsProjectOptions - slsProjectWarnings - slsSupportShared - pthread - rt +target_link_libraries(tests + PUBLIC + slsProjectOptions + slsSupportShared + pthread + rt + PRIVATE + slsProjectWarnings ) if (SLS_USE_TEXTCLIENT) - target_link_libraries(tests + target_link_libraries(tests PUBLIC slsDetectorShared ) endif (SLS_USE_TEXTCLIENT) if (SLS_USE_RECEIVER) - target_link_libraries(tests + target_link_libraries(tests PUBLIC slsReceiverShared ) endif (SLS_USE_RECEIVER)