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

Why there's no need to use include_directories() in 01-basic\H-third-party-library #75

Open
JunJieChenpete opened this issue Dec 24, 2021 · 2 comments

Comments

@JunJieChenpete
Copy link

In 01-basic\H-third-party-library, the example project uses find_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system) to find the third-party-library Boost, but without using include_directories(${Boost_INCLUDE_DIRS}), how can the target find where the "XXX.h" files are?
And in the file README.adoc, in Checking if the package is found part, the example uses include_directories(${Boost_INCLUDE_DIRS})

if(Boost_FOUND)
    message ("boost found")
    include_directories(${Boost_INCLUDE_DIRS})
else()
    message (FATAL_ERROR "Cannot find Boost")
endif()

In fact, without writing include_directories(${Boost_INCLUDE_DIRS}), the example project can compile and run without any problems, but it really confuse me whether I need to use include_directories(${XXX_INCLUDE_DIRS}) after using find_package(XXX) and why or why not.

@paangyubok
Copy link

I think the reason is that boost has installed in default include path.

@Nngxu
Copy link

Nngxu commented Apr 18, 2023

therer is also another reason. The target_link_libraries(third_party_include )method will also get the INTERFACE_INCLUDE_DIRECTORIES of Boost::filesystem to it's INCLUDE_DIRECTORIES.

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