Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add a working example with boost test #361

Open
amolgawai opened this issue Jun 17, 2022 · 8 comments
Open

Please add a working example with boost test #361

amolgawai opened this issue Jun 17, 2022 · 8 comments

Comments

@amolgawai
Copy link

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
Copy link
Author

amolgawai commented Jun 19, 2022

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?

@OlivierLDff
Copy link
Contributor

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 ?

@amolgawai
Copy link
Author

@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.

@TheLartians
Copy link
Member

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

@ClausKlein
Copy link
Contributor

If you only need asio, you may try this:

chriskohlhoff/asio#1105

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

@ClausKlein
Copy link
Contributor

done, see 7db2d51

@amolgawai
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants