mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-19 10:30:02 +02:00
Internal zmq using FetchContent (#780)
* using fetchcontent to get zmq * local copy of libzmq * added guard for policy setting * removed the need to export by using build interface * removed zmq hint from cmk script --------- Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch> Co-authored-by: froejdh_e <erik.frojdh@psi.ch>
This commit is contained in:
parent
c628ae2192
commit
fd79d59f4e
@ -1,15 +1,61 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(slsDetectorPackage)
|
project(slsDetectorPackage)
|
||||||
set(PROJECT_VERSION 7.0.0)
|
set(PROJECT_VERSION 7.0.0)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||||
|
|
||||||
cmake_policy(SET CMP0074 NEW)
|
cmake_policy(SET CMP0074 NEW)
|
||||||
|
|
||||||
|
if (${CMAKE_VERSION} VERSION_GREATER "3.24")
|
||||||
|
cmake_policy(SET CMP0135 NEW) #Fetch content download timestamp
|
||||||
|
endif()
|
||||||
include(cmake/project_version.cmake)
|
include(cmake/project_version.cmake)
|
||||||
include(cmake/SlsAddFlag.cmake)
|
include(cmake/SlsAddFlag.cmake)
|
||||||
include(cmake/SlsFindZeroMQ.cmake)
|
|
||||||
|
|
||||||
|
|
||||||
|
# Using FetchContent to get libzmq
|
||||||
|
include(FetchContent)
|
||||||
|
option(SLS_FETCH_ZMQ_FROM_GITHUB "Fetch zmq from github" OFF)
|
||||||
|
|
||||||
|
if(SLS_FETCH_ZMQ_FROM_GITHUB)
|
||||||
|
# Opt in to pull down a zmq version from github instead of
|
||||||
|
# using the bundled verison
|
||||||
|
FetchContent_Declare(
|
||||||
|
libzmq
|
||||||
|
GIT_REPOSITORY https://github.com/zeromq/libzmq.git
|
||||||
|
GIT_TAG v4.3.4
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# Standard behaviour use libzmq included in this repo (libs/libzmq)
|
||||||
|
FetchContent_Declare(
|
||||||
|
libzmq
|
||||||
|
URL ${CMAKE_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz
|
||||||
|
URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Disable unwanted options from libzmq
|
||||||
|
set(BUILD_TESTS OFF CACHE BOOL "Switch off libzmq test build")
|
||||||
|
set(BUILD_SHARED OFF CACHE BOOL "Switch off libzmq shared libs")
|
||||||
|
set(WITH_PERF_TOOL OFF CACHE BOOL "")
|
||||||
|
set(ENABLE_CPACK OFF CACHE BOOL "")
|
||||||
|
set(ENABLE_CLANG OFF CACHE BOOL "")
|
||||||
|
set(ENABLE_CURVE OFF CACHE BOOL "")
|
||||||
|
set(ENABLE_DRAFTS OFF CACHE BOOL "")
|
||||||
|
|
||||||
|
# Using GetProperties and Populate to be able to exclude zmq
|
||||||
|
# from install (not possible with FetchContent_MakeAvailable(libzmq))
|
||||||
|
FetchContent_GetProperties(libzmq)
|
||||||
|
if(NOT libzmq_POPULATED)
|
||||||
|
FetchContent_Populate(libzmq)
|
||||||
|
add_subdirectory(${libzmq_SOURCE_DIR} ${libzmq_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# If conda build, always set lib dir to 'lib'
|
# If conda build, always set lib dir to 'lib'
|
||||||
@ -215,10 +261,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|||||||
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
||||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||||
|
|
||||||
|
|
||||||
custom_find_zmq()
|
|
||||||
|
|
||||||
|
|
||||||
if (SLS_USE_TESTS)
|
if (SLS_USE_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
function(custom_find_zmq)
|
|
||||||
set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
|
||||||
#Adapted from: https://github.com/zeromq/cppzmq/
|
|
||||||
if (NOT TARGET libzmq)
|
|
||||||
if(ZeroMQ_HINT)
|
|
||||||
message(STATUS "Looking for ZeroMQ in: ${ZeroMQ_HINT}")
|
|
||||||
find_package(ZeroMQ 4
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
HINTS ${ZeroMQ_HINT}
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
find_package(ZeroMQ 4 QUIET)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# libzmq autotools install: fallback to pkg-config
|
|
||||||
if(ZeroMQ_FOUND)
|
|
||||||
message(STATUS "Found libzmq using find_package")
|
|
||||||
else()
|
|
||||||
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}/cmake/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()
|
|
||||||
|
|
||||||
get_target_property(VAR libzmq IMPORTED_LOCATION)
|
|
||||||
message(STATUS "Using libzmq: ${VAR}")
|
|
||||||
|
|
||||||
|
|
||||||
endfunction()
|
|
@ -1,36 +0,0 @@
|
|||||||
#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_path(ZeroMQ_INCLUDE_DIR zmq.h
|
|
||||||
PATHS ${ZeroMQ_DIR}/include
|
|
||||||
${PC_LIBZMQ_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(ZeroMQ_LIBRARY
|
|
||||||
NAMES zmq
|
|
||||||
PATHS ${ZeroMQ_DIR}/lib
|
|
||||||
${PC_LIBZMQ_LIBDIR}
|
|
||||||
${PC_LIBZMQ_LIBRARY_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
|
|
||||||
set(ZeroMQ_FOUND ON)
|
|
||||||
message(STATUS "Found libzmq using PkgConfig")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set ( ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY} )
|
|
||||||
set ( ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR} )
|
|
||||||
|
|
||||||
if (NOT TARGET libzmq)
|
|
||||||
add_library(libzmq UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(libzmq PROPERTIES
|
|
||||||
IMPORTED_LOCATION ${ZeroMQ_LIBRARIES}
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include ( FindPackageHandleStandardArgs )
|
|
||||||
find_package_handle_standard_args ( ZeroMQ DEFAULT_MSG ZeroMQ_LIBRARIES ZeroMQ_INCLUDE_DIRS )
|
|
@ -25,11 +25,6 @@ install(FILES
|
|||||||
DESTINATION ${CMAKE_INSTALL_DIR}
|
DESTINATION ${CMAKE_INSTALL_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(FILES
|
|
||||||
"${CMAKE_SOURCE_DIR}/cmake/libzmq-pkg-config/FindZeroMQ.cmake"
|
|
||||||
COMPONENT devel
|
|
||||||
DESTINATION ${CMAKE_INSTALL_DIR}/libzmq-pkg-config
|
|
||||||
)
|
|
||||||
|
|
||||||
if (PROJECT_LIBRARIES OR PROJECT_STATIC_LIBRARIES)
|
if (PROJECT_LIBRARIES OR PROJECT_STATIC_LIBRARIES)
|
||||||
install(
|
install(
|
||||||
|
@ -13,17 +13,6 @@ include(CMakeFindDependencyMacro)
|
|||||||
set(SLS_USE_HDF5 "@SLS_USE_HDF5@")
|
set(SLS_USE_HDF5 "@SLS_USE_HDF5@")
|
||||||
|
|
||||||
|
|
||||||
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)
|
find_dependency(Threads)
|
||||||
|
|
||||||
# Add optional dependencies here
|
# Add optional dependencies here
|
||||||
|
15
cmk.sh
15
cmk.sh
@ -18,7 +18,6 @@ CTBGUI=0
|
|||||||
MANUALS=0
|
MANUALS=0
|
||||||
MANUALS_ONLY_RST=0
|
MANUALS_ONLY_RST=0
|
||||||
MOENCHZMQ=0
|
MOENCHZMQ=0
|
||||||
ZMQ_HINT_DIR=""
|
|
||||||
|
|
||||||
|
|
||||||
CLEAN=0
|
CLEAN=0
|
||||||
@ -27,7 +26,7 @@ CMAKE_PRE=""
|
|||||||
CMAKE_POST=""
|
CMAKE_POST=""
|
||||||
|
|
||||||
usage() { echo -e "
|
usage() { echo -e "
|
||||||
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [-q <Zmq hint directory>] [r] [s] [t] [u] [z]
|
Usage: $0 [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of threads>] [-k <CMake command>] [-l <Install directory>] [m] [n] [-p] [r] [s] [t] [u] [z]
|
||||||
-[no option]: only make
|
-[no option]: only make
|
||||||
-b: Builds/Rebuilds CMake files normal mode
|
-b: Builds/Rebuilds CMake files normal mode
|
||||||
-c: Clean
|
-c: Clean
|
||||||
@ -42,7 +41,6 @@ Usage: $0 [-b] [-c] [-d <HDF5 directory>] [e] [g] [-h] [i] [-j <Number of thread
|
|||||||
-m: Manuals
|
-m: Manuals
|
||||||
-n: Manuals without compiling doxygen (only rst)
|
-n: Manuals without compiling doxygen (only rst)
|
||||||
-p: Builds/Rebuilds Python API
|
-p: Builds/Rebuilds Python API
|
||||||
-q: Zmq hint directory
|
|
||||||
-r: Build/Rebuilds only receiver
|
-r: Build/Rebuilds only receiver
|
||||||
-s: Simulator
|
-s: Simulator
|
||||||
-t: Build/Rebuilds only text client
|
-t: Build/Rebuilds only text client
|
||||||
@ -140,10 +138,6 @@ while getopts ":bcd:eghij:k:l:mnpq:rstuz" opt ; do
|
|||||||
PYTHON=1
|
PYTHON=1
|
||||||
REBUILD=1
|
REBUILD=1
|
||||||
;;
|
;;
|
||||||
q)
|
|
||||||
echo "Zmq hint directory: $OPTARG"
|
|
||||||
ZMQ_HINT_DIR=$OPTARG
|
|
||||||
;;
|
|
||||||
r)
|
r)
|
||||||
echo "Compiling Options: Receiver"
|
echo "Compiling Options: Receiver"
|
||||||
RECEIVER=1
|
RECEIVER=1
|
||||||
@ -260,13 +254,6 @@ if [ $TESTS -eq 1 ]; then
|
|||||||
echo "Tests Option enabled"
|
echo "Tests Option enabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#zmq hint dir
|
|
||||||
if [ -n "$ZMQ_HINT_DIR" ]; then
|
|
||||||
CMAKE_POST+=" -DZeroMQ_HINT="$ZMQ_HINT_DIR
|
|
||||||
CMAKE_POST+=" -DZeroMQ_DIR="
|
|
||||||
# echo "Enabling Zmq Hint Directory: $ZMQ_HINT_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#hdf5 rebuild
|
#hdf5 rebuild
|
||||||
if [ $HDF5 -eq 1 ]; then
|
if [ $HDF5 -eq 1 ]; then
|
||||||
# CMAKE_PRE+="HDF5_ROOT="$HDF5DIR
|
# CMAKE_PRE+="HDF5_ROOT="$HDF5DIR
|
||||||
|
BIN
libs/libzmq/libzmq-4.3.4.tar.gz
Normal file
BIN
libs/libzmq/libzmq-4.3.4.tar.gz
Normal file
Binary file not shown.
@ -88,10 +88,11 @@ message(STATUS "RAPID: ${SLS_INTERNAL_RAPIDJSON_DIR}")
|
|||||||
target_link_libraries(slsSupportObject
|
target_link_libraries(slsSupportObject
|
||||||
PUBLIC
|
PUBLIC
|
||||||
slsProjectOptions
|
slsProjectOptions
|
||||||
libzmq
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
slsProjectWarnings
|
slsProjectWarnings
|
||||||
md5sls
|
md5sls
|
||||||
|
"$<BUILD_INTERFACE:libzmq-static>"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (SLS_USE_TESTS)
|
if (SLS_USE_TESTS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user