c++cmakeboostbitset

Adding boost/dynamic_bitset using CPM Package Manager


I have been struggling with this for some time. I use CPM package manager to pull libraries from github for my project. I prefer it this way, instead of other linking methods. I also tried gh:boostorg/dynamic_bitset but that gave me issues as well. I was able to get cmake to generate for the cMakeList below.

The header #include <boost/dynamic_bitset.hpp> is underlined in purple (I use visual studio), "cannot open source file 'boost/dynamic_bitset.hpp'"

cmake_minimum_required( VERSION 3.5 )
find_package(Git)

include(get_cpm.cmake)

set(SFML_BUILD_EXAMPLES OFF)
set(BUILD_SHARED_LIBS OFF)
set(SFML_DIR "${SFML_SOURCE_DIR}")
set(TGUI_BACKEND "SFML_GRAPHICS")

CPMAddPackage("gh:skypjack/entt#v3.10.1")
CPMAddPackage("gh:SFML/SFML#2.6.x")
CPMAddPackage("gh:texus/[email protected]")
CPMAddPackage("gh:nlohmann/[email protected]")
CPMAddPackage("gh:boostorg/boost#boost-1.83.0")

project( Eridanus )

find_package( OpenGL REQUIRED )

include_directories( ${OPENGL_INCLUDE_DIRS} )

get_filename_component(PARENT_DIR ../ ABSOLUTE)
include_directories(
    ${PROJECT_SOURCE_DIR}
    "${PARENT_DIR}/Eridanus4x/headers"
    "${PARENT_DIR}/Eridanus4x"
    "${PARENT_DIR}/Eridanus4x/SelbaWard"
    )

add_executable(${CMAKE_PROJECT_NAME} 
    main.cpp
    game.cpp
    .... etc.

target_link_libraries(${PROJECT_NAME} PRIVATE sfml-graphics sfml-window sfml-system EnTT::EnTT TGUI::TGUI nlohmann_json::nlohmann_json Boost::dynamic_bitset)

option(BUILD_EXAMPLES "Build examples" OFF)

Solution

  • Weird it won't work the way CPM usually allows me, replacing the CPMAddPackage line for boost with the one below resolved it. CPMAddPackage( NAME Boost URL "https://github.com/boostorg/boost/releases/download/boost-1.83.0/boost-1.83.0.tar.xz")

    Source: https://github.com/cpm-cmake/CPM.cmake/issues/501