Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,235
    • Issues 3,235
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 13
    • Merge Requests 13
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #17986

Closed
Open
Opened May 11, 2018 by Hannes@HannesContributor

FindBoost.cmake doesn't use default installation path if EXACT in provided

Description

Given a call like find_package(Boost 1.66.0 EXACT REQUIRED COMPONENTS filesystem)

The boost find cmake ignores the default installation location for boost on windows (meaning starting the boost installer and only clicking "next").

If EXACT is not set the default installation path is correctly found.

Adding EXACT means boost no longer finds the requested version.

The behaviour I would expect is for EXACT not to fail to find the requested boost version in its default installation path.

Reason for this behaviour

(lines from file version at (45bf6f62)):

The block to test if an exact version should be found finishes by setting _boost_TEST_VERSIONS to the accepted versions based on the argument to find_package. If EXACT isn't supplied it adds all versions equal and greater and if no version is supplied does set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}".

After this point _boost_TEST_VERSIONS either is equal to _Boost_KNOWN_VERSIONS, contains the wanted subset of _Boost_KNOWN_VERSIONS or is equal to the exact requested version. Thus _Boost_KNOWN_VERSIONS probably shouldn't be used because it is either

  • unset if EXACT was used
  • contains versions lower than the minimum version supplied to find_package.

Using the wrong variable

However, in https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindBoost.cmake#L1222 and https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindBoost.cmake#L1533 where the default installation paths are added _Boost_KNOWN_VERSIONS is used:

foreach(ver ${_Boost_KNOWN_VERSIONS})
  string(REPLACE "." "_" ver "${ver}")
  list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS "C:/local/boost_${ver}")
endforeach()

[...]

foreach(ver ${_Boost_KNOWN_VERSIONS})
  string(REPLACE "." "_" ver "${ver}")
  _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/local/boost_${ver}")
endforeach()

Proposed solutions:

a. Replace these uses of _Boost_KNOWN_VERSIONS with _Boost_TEST_VERSIONS

This would however introduce a new behaviour: If the requested version is higher than all installed versions the older versions wouldn't be added to the search path (because _Boost_TEST_VERSIONS is a subset of _Boost_KNOWN_VERSIONS) and the user will no longer get the

Detected version of Boost is too old.

message.

or b. Add C:/local to the _boost_INCLUDE_SEARCH_DIRS and also loop over _Boost_TEST_VERSIONS here

The code using _boost_INCLUDE_SEARCH_DIRS already has provisions to add search paths from _Boost_TEST_VERSIONS via find_path( PATH_SUFFIXES). The code setting _boost_LIBRARY_SEARCH_DIRS however, doesn't.

Edited Oct 29, 2018 by Hannes
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
3.14.0
Milestone
3.14.0 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: cmake/cmake#17986