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

Fix Boost link flags in pkg-config file. #6083

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

mjjbell
Copy link
Member

@mjjbell mjjbell commented Jul 17, 2021

Issue

In newer versions of cmake, FindBoost uses Imported Targets for library component variables, rather than file paths to the Boost libraries.

cmake uses these targets when linking (e.g. target_link_library) and knows how to correctly substitute the values. However, the OSRM pkg-config file that we generate doesn't do this, and ends up writing the actual target symbols, hence the errors trying to link Boost::<component>.

To fix this for newer cmake versions, we create an intermediate configure step that references TARGET_LINKER_FILE for each imported target. This is followed by a file(GENERATE step that performs the correct substitution.
See this thread for more details: https://cmake.org/pipermail/cmake/2018-December/068812.html

This is backwards compatible to the existing min cmake version (3.1). However, building using cmake 3.1 fails with an unrelated package.json parsing error:

CMake Error at cmake/JSONParser.cmake:287 (string):
  string end index: 1 is out of range -1 - 0
Call Stack (most recent call first):
  cmake/JSONParser.cmake:232 (_sbeMoveToNextNonEmptyCharacter)
  cmake/JSONParser.cmake:71 (_sbeParseObject)
  cmake/JSONParser.cmake:22 (_sbeParse)
  CMakeLists.txt:69 (sbeParseJson)

Given 3.1 is nearly 7 years old, I don't think it's worth investigating. Instead, this PR also bumps the min version to 3.2.

Tasklist

Requirements / Relations

Fixes #5687

Copy link
Member

@TheMarex TheMarex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. 👍

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, we can probably even go higher if that makes things easier, given most people build this in docker images anyway.

In newer versions of cmake, FindBoost uses Imported Targets for library
component variables, rather than file paths to the Boost libraries.

cmake uses these targets when linking (e.g. target_link_library) and
knows how to correctly substitute the values. However, the OSRM
pkg-config file that we generate doesn't do this, and ends up writing
the actual target symbols, hence the errors trying to link Boost::<component>.

To fix this for newer cmake versions, we create an intermediate configure step
that references the linker files for the imported targets. This is followed
by a generate step that performs the correct substitution.
See this thread for more details: https://cmake.org/pipermail/cmake/2018-December/068812.html

This is backwards compatible to the existing min cmake version (3.1).
However, building using cmake 3.1 fails with a package.json parsing error,
so this commit also bumps the min version to 3.2.
@mjjbell mjjbell force-pushed the mbell/pkgconfig_libs branch from 7847bbe to 98f7b0d Compare September 3, 2021 22:01
@mjjbell mjjbell merged commit d413d06 into Project-OSRM:master Sep 3, 2021
@mjjbell mjjbell deleted the mbell/pkgconfig_libs branch September 3, 2021 22:49
@mjjbell mjjbell mentioned this pull request Sep 3, 2021
6 tasks
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

Successfully merging this pull request may close these issues.

find_package cannot find Boost
2 participants