redboltz / mqtt_cpp

Boost Software License 1.0
441 stars 107 forks source link

Fixed #989. #990

Closed redboltz closed 1 year ago

redboltz commented 1 year ago

Removed boost system and date_time from dependency.

lproj commented 1 year ago

This works now with this CMakeLists.txt (I've installed mqtt_cpp#fix_989):

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(CPMExampleBoost)

# ---- Create binary ----

add_executable(CPMExampleBoost main.cpp)
target_compile_features(CPMExampleBoost PRIVATE cxx_std_17)

# ---- Dependencies ----

file(
  DOWNLOAD
  https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.38.3/CPM.cmake
  ${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
  EXPECTED_HASH SHA256=cc155ce02e7945e7b8967ddfaff0b050e958a723ef7aad3766d368940cb15494
)
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)

CPMAddPackage(
  NAME Boost
  VERSION 1.81.0
  GITHUB_REPOSITORY "boostorg/boost"
  GIT_TAG "boost-1.81.0"
)

set(MQTT_BUILD_EXAMPLES OFF CACHE BOOL "build mqtt_cpp examples" FORCE)
set(MQTT_BUILD_TESTS OFF CACHE BOOL "build mqtt_cpp tests" FORCE)
cpmaddpackage("gh:redboltz/mqtt_cpp#fix_989")

target_link_libraries(CPMExampleBoost PRIVATE Boost::asio)
codecov[bot] commented 1 year ago

Codecov Report

Merging #990 (dc90578) into master (070c25a) will decrease coverage by 5.37%. The diff coverage is n/a.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #990 +/- ## ========================================== - Coverage 84.13% 78.77% -5.37% ========================================== Files 65 65 Lines 10749 10402 -347 ========================================== - Hits 9044 8194 -850 - Misses 1705 2208 +503 ```
lproj commented 1 year ago

Sorry to bother you again, but I am getting this error now when trying with master. I think it's a CPM limit:

CMake Error at /home/me/build/_deps/mqtt_cpp-src/include/CMakeLists.txt:62 (ADD_LIBRARY): Target "check_deps" links to target "Boost::boost" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?

-- Generating done CMake Generate step failed. Build files cannot be regenerated correctly. CMake process exited with exit code 1.

As a work-around I first have to define the Boost::boost target before installing mqtt_cpp:

add_library(Boost::boost INTERFACE IMPORTED)
target_include_directories(Boost::boost INTERFACE "${Boost_SOURCE_DIR}")