mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 18:40:42 +02:00
Cleaning up the find zmq (#431)
This commit is contained in:
parent
52882cba20
commit
086d22f1a3
@ -12,6 +12,8 @@ include(cmake/project_version.cmake)
|
|||||||
#functions to add compiler flags
|
#functions to add compiler flags
|
||||||
include(cmake/SlsAddFlag.cmake)
|
include(cmake/SlsAddFlag.cmake)
|
||||||
|
|
||||||
|
include(cmake/SlsFindZeroMQ.cmake)
|
||||||
|
|
||||||
# Include additional modules that are used unconditionally
|
# Include additional modules that are used unconditionally
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
@ -186,42 +188,11 @@ install(TARGETS slsProjectOptions slsProjectWarnings rapidjson
|
|||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
set(CMAKE_INSTALL_RPATH $ORIGIN)
|
||||||
# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
|
||||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||||
|
|
||||||
|
|
||||||
set(ZeroMQ_HINT "" CACHE STRING "Hint where ZeroMQ could be found")
|
custom_find_zmq()
|
||||||
#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_DIR}
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
find_package(ZeroMQ 4 QUIET)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# 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()
|
|
||||||
|
|
||||||
get_target_property(VAR libzmq INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
message(STATUS "zmq: ${VAR}")
|
|
||||||
|
|
||||||
if (SLS_USE_TESTS)
|
if (SLS_USE_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
38
cmake/SlsFindZeroMQ.cmake
Normal file
38
cmake/SlsFindZeroMQ.cmake
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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_DIR}
|
||||||
|
)
|
||||||
|
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()
|
@ -11,6 +11,7 @@ find_library(ZeroMQ_STATIC_LIBRARY NAMES libzmq-static.a libzmq.a libzmq.dll.a
|
|||||||
|
|
||||||
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
|
if(ZeroMQ_LIBRARY OR ZeroMQ_STATIC_LIBRARY)
|
||||||
set(ZeroMQ_FOUND ON)
|
set(ZeroMQ_FOUND ON)
|
||||||
|
message(STATUS "Found libzmq using PkgConfig")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (TARGET libzmq)
|
if (TARGET libzmq)
|
Loading…
x
Reference in New Issue
Block a user