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

When using FetchContent it is looking for boost #791

Open
peterritter opened this issue Jun 14, 2023 · 2 comments
Open

When using FetchContent it is looking for boost #791

peterritter opened this issue Jun 14, 2023 · 2 comments

Comments

@peterritter
Copy link

I am including the cereal library in my project via cmake's FetchContent like:

FetchContent_Declare(
cereal
GIT_REPOSITORY https://github.com/USCiLab/cereal.git
GIT_TAG v1.3.2
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(cereal)

This tries to build the library and in the process starts looking for 'Boost' which fails - since my project does not required 'Boost' and there is no FetchContent for 'Boost'. I also don't want to link with Boost. I have traced this to the SKIP_PERFORMANCE_COMPARISON option which is set to OFF - in other words it tries to enable the feature and starts looking for Boost and fails if not present.

I don't think a default build should rely on 'boost' being installed. I'm trying to keep my project self contained, hence the use of FetchContent. I think this SKIP_PERFORMANCE_COMPARISON option should be ON by default.
Alternatively, the option can be set to ON when the cereal project is not a top level project. This could be checked like this:

project(MyProject)
...
if(PROJECT_IS_TOP_LEVEL)
include(CTest)
endif()

I don't have such a problem with any of the other dependencies. I think a self contained default build should be possible for a 'header only' library like cereal.

I did find my own workaround (thanks for ChatGPT) but frankly I still think this could trip up other people. Here is the workaround:

FetchContent_Declare(
cereal
GIT_REPOSITORY https://github.com/USCiLab/cereal.git
GIT_TAG v1.3.2
GIT_SHALLOW TRUE)

FetchContent_GetProperties(cereal)
if(NOT cereal_POPULATED)
FetchContent_Populate(cereal)
# Set the option to skip performance comparison (this tries to find 'Boost' and fails!
set(SKIP_PERFORMANCE_COMPARISON ON CACHE BOOL "" FORCE)
# Add cereal to the build
add_subdirectory(${cereal_SOURCE_DIR} ${cereal_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

@KYLChiu
Copy link

KYLChiu commented Jun 20, 2023

Thank you for the workaround @peterritter, I hit the exact same issue.

@f-michaut
Copy link

f-michaut commented Dec 10, 2023

You can also do :

FetchContent_Declare(
cereal
GIT_REPOSITORY https://github.com/USCiLab/cereal.git
GIT_TAG v1.3.2
GIT_SHALLOW TRUE)

set(JUST_INSTALL_CEREAL ON) 

FetchContent_MakeAvailable(cereal) 

This will disable even more things.

I do agree that theses extras (boost benchmark, build examples and documentation) should be opt-in instead of opt-out.

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

3 participants