From c8408620c078c7c8a94a9fb4dda6b42b3279ddad Mon Sep 17 00:00:00 2001 From: clfreville2 Date: Wed, 18 Oct 2023 14:47:30 +0200 Subject: [PATCH] Link against the system library or the local build --- CMakeLists.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e4c718..0482a7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.14) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) project(planificador) @@ -15,10 +15,11 @@ FetchContent_MakeAvailable(tomlplusplus) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config) find_package(ZeroMQ QUIET) +add_executable(planificador src/host.cpp src/runner.cpp src/config.cpp src/main.cpp) if (NOT ZeroMQ_FOUND) message(STATUS "ZeroMQ not found, using bundled version") FetchContent_Declare( - zeromq + zmq GIT_REPOSITORY https://github.com/zeromq/libzmq.git GIT_TAG v4.3.5 ) @@ -32,16 +33,19 @@ if (NOT ZeroMQ_FOUND) set(ZMQ_BUILD_TESTS OFF) set(WITH_TLS OFF) set(WITH_DOC OFF) + set(BUILD_STATIC OFF) + set(BUILD_SHARED ON) + set(ZMQ_BUILD_TESTS OFF) set(CPPZMQ_BUILD_TESTS OFF) - FetchContent_MakeAvailable(zeromq cppzmq) - include_directories(${zeromq_SOURCE_DIR}/include) + FetchContent_MakeAvailable(zmq cppzmq) + include_directories(${zmq_SOURCE_DIR}/include) include_directories(${cppzmq_SOURCE_DIR}) + target_link_libraries(planificador PRIVATE libzmq) +else () + target_link_libraries(planificador PRIVATE zmq) endif () -add_executable(planificador src/host.cpp src/runner.cpp src/config.cpp src/main.cpp) target_compile_options(planificador PUBLIC -Wall -Wextra -pedantic) target_compile_features(planificador PUBLIC cxx_std_17) include_directories(${tomlplusplus_SOURCE_DIR}/include) -include_directories(${cppzmq_SOURCE_DIR}) -target_link_libraries(planificador PRIVATE zmq)