CPM.cmake icon indicating copy to clipboard operation
CPM.cmake copied to clipboard

Please add a working example with boost test

Open amolgawai opened this issue 3 years ago • 8 comments

Somehow I am not able to get boost test working with cpm.cmake. I have used the snippet for boost libraries, used cache but neither the include nor libraries are found.

amolgawai avatar Jun 17 '22 21:06 amolgawai

Following is something that is currently working for me (taken from this another issue)

  set(Boost_USE_STATIC_LIBS ON)
  set(Boost_USE_MULTITHREADED ON)
  set(Boost_USE_STATIC_RUNTIME OFF)
  CPMAddPackage(
    NAME Boost
    VERSION 1.79.0
    GITHUB_REPOSITORY "boostorg/boost"
    GIT_TAG "boost-1.79.0"
  )
  if(Boost_ADDED)
      message("boost asio downloaded at " ${Boost_SOURCE_DIR}/libs/asio/include)

      file(GLOB files "${Boost_SOURCE_DIR}/libs/*/include")
      foreach(filename ${files})
          include_directories(${filename})
      endforeach()

      file(GLOB files "${Boost_SOURCE_DIR}/libs/*/*/include")
      foreach(filename ${files})
          include_directories(${filename})
      endforeach()
  endif()

Is this the correct way? Can this be properly documented in examples?

amolgawai avatar Jun 19 '22 13:06 amolgawai

You shouldn't use include_directories in modern cmake but rather create a target and use target_include_directories Did you took a look at boost-cmake ?

OlivierLDff avatar Jul 01 '22 11:07 OlivierLDff

@OlivierLDff , I am not using include_directories in my actual targets, but what target should I specify for things that are added by CPMAddPackage? I want to use CPMAddPackage for all external dependencies and don't want to bother separate solutions like boost-make.

amolgawai avatar Jul 03 '22 13:07 amolgawai

Seems that boost still has poor CMake support. See #359 for our rollback to boost-cmake.

TheLartians avatar Sep 13 '22 19:09 TheLartians

If you only need asio, you may try this:

https://github.com/chriskohlhoff/asio/pull/1105

It is much faster to fetch and is an interface library.

ClausKlein avatar Sep 15 '22 19:09 ClausKlein

done, see https://github.com/cpm-cmake/CPM.cmake/pull/359/commits/7db2d511ae4c4228a0620ce58872990c460386c3

ClausKlein avatar Feb 20 '23 07:02 ClausKlein

done, see 7db2d51

Thanks @ClausKlein , where is the part to download boost? I am not able to see top level CMakeLists.txt where this code might be.

amolgawai avatar May 14 '23 17:05 amolgawai

https://github.com/cpm-cmake/CPM.cmake/blob/7db2d511ae4c4228a0620ce58872990c460386c3/examples/boost/CMakeLists.txt

ClausKlein avatar Jun 02 '23 05:06 ClausKlein