Closed GMellar closed 1 year ago
Well, I'd say a clean target as interface library might be great.
Here's how I import azmq library.
However, the issue is that the codebase use concept
to name structure,
which is a reserved keyword in C++20 for ... concept specifications.
So, the issue is you cannot set a target_property CXX_STANDARD on an INTERFACE library,
thus a C++20 target cannot properly compile when it consume the library
include(FetchContent)
FetchContent_Declare(azmq_download
GIT_REPOSITORY https://github.com/zeromq/azmq.git
# GIT_TAG v1.0.2
UPDATE_DISCONNECTED true
)
set(azmq_NO_TESTS on)
FetchContent_GetProperties(azmq_download)
if(NOT azmq_download_POPULATED)
FetchContent_Populate(azmq_download)
file(MAKE_DIRECTORY ${azmq_download_SOURCE_DIR}/includes)
file(COPY ${azmq_download_SOURCE_DIR}/azmq DESTINATION ${azmq_download_SOURCE_DIR}/includes)
add_subdirectory(${azmq_download_SOURCE_DIR} ${azmq_download_BINARY_DIR})
endif()
add_library(azmq INTERFACE)
target_include_directories(azmq
INTERFACE
${azmq_download_SOURCE_DIR}/includes
)
find_package(Boost REQUIRED COMPONENTS system date_time thread chrono regex random)
list(APPEND CMAKE_MODULE_PATH ${azmq_download_SOURCE_DIR}/config)
find_package(ZeroMQ REQUIRED)
add_library(ZeroMQ_library IMPORTED SHARED)
set_target_properties(ZeroMQ_library PROPERTIES
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
IMPORTED_LOCATION ${ZeroMQ_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${ZeroMQ_INCLUDE_DIRS}
)
target_link_libraries(azmq
INTERFACE
Boost::chrono
Boost::date_time
Boost::random
Boost::regex
Boost::system
Boost::thread
ZeroMQ_library
)
[edit] add linkage
@GMellar, yes please, then it could be consumed in the standard way
I wonder if any of the azmq library use it inside an existing source tree without the need for installation. CMake offers interface libraries for that so one can just use azmq as library and all the link dependencies are considered and all include directories are appended to the search path as well. I made some changes to the CMakeLists file on my local repository. Is there any interest in including it to the public repository? Let me know and I'd like to share these changes.