Question is about the difference of using Boost_INCLUDE_DIR and Boost_INCLUDE_DIRS to indicate where boost header files are in the system.
As I understood so far from the documentation and from different posts on SO and other forums:
Boost_INCLUDE_DIR is cached after a first run of cmake in the project
Boost_INCLUDE_DIRS is set each time that cmake is run in the project
From the examples in the documentation, Boost_INCLUDE_DIRS is the variable used to indicate where boost header files are in the system.
But my question is, if we decided to use Boost_INCLUDE_DIR, should results be different that with Boost_INCLUDE_DIRS ?
Because in our library, we decided to go with Boost_INCLUDE_DIR, it worked so far. But one developer encountered an error because Boost_INCLUDE_DIR was empty (it was not Boost_INCLUDE_DIR-NOT_FOUND) and Boost_INCLUDE_DIRS was correctly set.
Boost_INCLUDE_DIR is the directory Boost found for itself. This does not happen for BoostConfig.cmake based searches. Boost_INCLUDE_DIRS is the list of include directories needed to use Boost. This should include any directories to dependencies needed.
It’s a typical pattern that things directly found are singular while aggregates which may include dependencies is plural. Since config.cmake files don’t need to actually search for anything, the singular variants tend to not exist and only the plural versions are “end results” of the find_package call. There are some older modules which have not migrated to this usage pattern however.