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

[C++] cmake: cannot create imported target "Boost::headers" #32307

Closed
asfimport opened this issue Jul 6, 2022 · 9 comments
Closed

[C++] cmake: cannot create imported target "Boost::headers" #32307

asfimport opened this issue Jul 6, 2022 · 9 comments
Assignees
Milestone

Comments

@asfimport
Copy link
Collaborator

asfimport commented Jul 6, 2022

Hi,

I just tried to build arrow/cpp using cmake, and on the master branch I get the error

 

arrow-build $ cmake -DARROW_PARQUET=ON -DCMAKE_BUILD_TYPE=DEBUG ../arrow/cpp/
...
CMake Error at cmake_modules/ThirdpartyToolchain.cmake:873 (add_library):
  add_library cannot create imported target "Boost::headers" because another
  target with the same name already exists.
Call Stack (most recent call first):
  cmake_modules/ThirdpartyToolchain.cmake:139 (build_boost)
  cmake_modules/ThirdpartyToolchain.cmake:236 (build_dependency)
  cmake_modules/ThirdpartyToolchain.cmake:1014 (resolve_dependency)
  CMakeLists.txt:552 (include) 
...
-- Configuring incomplete, errors occurred!
See also "/app/arrow-build/CMakeFiles/CMakeOutput.log".
See also "/app/arrow-build/CMakeFiles/CMakeError.log".

and CMake exits with status 1.  The project configures successfully on the apache-arrow-8.0.0 tag.  Running a git bisect, the defect was introduced in the commit:


d653b71d79fc381c43f59d3095cc1c9fb0c1cf7c
ARROW-16168: [C++][CMake] Use target to add include paths

I have attached CMakeOutput.log and CMakeError.log.

Thanks!

Reporter: Jefferson Carpenter
Assignee: Kouhei Sutou / @kou

Related issues:

Original Issue Attachments:

PRs and other links:

Note: This issue was originally created as ARROW-16993. Please see the migration documentation for further details.

@asfimport
Copy link
Collaborator Author

David Li / @lidavidm:
The issue is that we need the Boost headers but not the Boost libraries for non-test builds but the CMake code does not reflect that and tries to find the libraries anyways. When that fails it tries to build Boost as a subproject but by then we've already found a Boost installation and so CMake errors when we try to (re)define the Boost targets.

ARROW-16947 will fix this. I would vote that this is a duplicate/symptom of that unless there's something I missed here.

@asfimport
Copy link
Collaborator Author

Jefferson Carpenter:
@lidavidm That sounds like a good explanation to me, I don't think you missed something.  I'll let you know if this isn't resolved after that issue is closed.

@asfimport
Copy link
Collaborator Author

Kouhei Sutou / @kou:
[~jcarpenter2] Could you also attach the full output of cmake -DARROW_PARQUET=ON -DCMAKE_BUILD_TYPE=DEBUG ../arrow/cpp/?

@asfimport
Copy link
Collaborator Author

Jefferson Carpenter:
@kou Attached

@asfimport
Copy link
Collaborator Author

Kouhei Sutou / @kou:
Thanks.


-- Could NOT find Boost: missing: system filesystem (found /usr/local/lib/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.58"))

is the root cause. You have system Boost but it doesn't include system and filesystem components. So Boost::headers is loaded but system Boost detection is failed. If system Boost detection is failed, we use bundled Boost and create Boost::headers for bundled Boost but Boost::headers already exists. It causes this error.

CMake doesn't provide a feature to remove a created target (Boost::headers). We may be able to support this case by reusing (overriding) Boost::headers defined by system Boost but it may not be a good CMake manner...

I think that installing Boost's system and filesystem components to your system is the best solution for this case for now.

@asfimport
Copy link
Collaborator Author

Neal Richardson / @nealrichardson:
I think these lines should be conditional on ARROW_BOOST_REQUIRE_LIBRARY because we don't need boost::system and boost::filesystem if we only need the headers: https://github.com/apache/arrow/blob/master/cpp/cmake_modules/ThirdpartyToolchain.cmake#L1025-L1027

We currently set and use ARROW_BOOST_REQUIRE_LIBRARY in the build_boost macro, but it has no effect on the find_package step or anything after it, and that seems off.

@asfimport
Copy link
Collaborator Author

Kouhei Sutou / @kou:
You're right. I was wrong. Sorry. I opened a pull request for it.

(I noticed that the David's first comment already described the reason...)

@asfimport
Copy link
Collaborator Author

Kouhei Sutou / @kou:
Oh, I didn't notice that a pull request is already opened: #13845

@asfimport
Copy link
Collaborator Author

Kouhei Sutou / @kou:
Issue resolved by pull request 13846
#13846

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants