diff --git a/.drone.yml b/.drone.yml index 3e29fca..ce1a964 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,5 +6,5 @@ steps: - name: build image: hub.codefirst.iut.uca.fr/clement.freville2/planificador-build-image:latest commands: - - mkdir build && cd build && cmake .. - - make + - cmake -B build -S . + - cmake --build build --parallel $(nproc) diff --git a/.gitignore b/.gitignore index 3b1c59a..6a848fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ bin build obj + +.idea +.vscode +cmake-build-debug diff --git a/CMakeLists.txt b/CMakeLists.txt index 76873a8..3e4c718 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,45 @@ cmake_minimum_required(VERSION 3.10) +set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) project(planificador) -add_compile_options(-Wall -Wextra -pedantic) - include(FetchContent) FetchContent_Declare( - tomlplusplus - GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git - GIT_TAG v3.3.0 + tomlplusplus + GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git + GIT_TAG v3.3.0 ) FetchContent_MakeAvailable(tomlplusplus) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/libzmq-pkg-config) +find_package(ZeroMQ QUIET) + +if (NOT ZeroMQ_FOUND) + message(STATUS "ZeroMQ not found, using bundled version") + FetchContent_Declare( + zeromq + GIT_REPOSITORY https://github.com/zeromq/libzmq.git + GIT_TAG v4.3.5 + ) + FetchContent_Declare( + cppzmq + GIT_REPOSITORY https://github.com/zeromq/cppzmq.git + GIT_TAG v4.10.0 + ) + set(WITH_PERF_TOOL OFF) + set(ENABLE_CPACK OFF) + set(ZMQ_BUILD_TESTS OFF) + set(WITH_TLS OFF) + set(WITH_DOC OFF) + set(CPPZMQ_BUILD_TESTS OFF) + FetchContent_MakeAvailable(zeromq cppzmq) + include_directories(${zeromq_SOURCE_DIR}/include) + include_directories(${cppzmq_SOURCE_DIR}) +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) diff --git a/libzmq-pkg-config/FindZeroMQ.cmake b/libzmq-pkg-config/FindZeroMQ.cmake new file mode 100644 index 0000000..892762c --- /dev/null +++ b/libzmq-pkg-config/FindZeroMQ.cmake @@ -0,0 +1,28 @@ +# Adapted from https://github.com/zeromq/cppzmq/blob/master/CMakeLists.txt +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) + set(ZeroMQ_FOUND ON) +endif() + +set ( ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY} ) +set ( ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR} ) + +include ( FindPackageHandleStandardArgs ) +# handle the QUIETLY and REQUIRED arguments and set ZMQ_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args ( ZeroMQ DEFAULT_MSG ZeroMQ_LIBRARIES ZeroMQ_INCLUDE_DIRS )