Closed redboltz closed 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)
Merging #990 (dc90578) into master (070c25a) will decrease coverage by
5.37%
. The diff coverage isn/a
.
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}")
Removed boost system and date_time from dependency.