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

cmake: Fix building capstone as sub-project #2629

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

imphil
Copy link

@imphil imphil commented Feb 19, 2025

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

capstone can be built as sub-project through cmake's fetch_content
mechanism. In this case, CMAKE_SOURCE_DIR refers to the parent project
(that has nothing to do with capstone), while PROJECT_SOURCE_DIR refers
to the root of the capstone source tree.

Recently introduced changes to enable CPack (#2590) are using the wrong
variable and are hence breaking builds that use capstone through
fetch_content. Use the correct variable to fix this issue.

Additionally, harden the setup even further by only including cpack whenever capstone is a top-level project. In theory, either commit is sufficient, but it seems more correct to do both things. (For reference, a look at the fmt library, which is often used through fetch_content, does something similar at https://github.com/fmtlib/fmt/blob/0c9fce2ffefecfdce794e1859584e25877b7b592/CMakeLists.txt#L503).

(Regression from 6.0.0-alpha2, where using capstone with fetch_content still worked.)

capstone can be built as sub-project through cmake's fetch_content
mechanism. In this case, `CMAKE_SOURCE_DIR` refers to the parent project
(that has nothing to do with capstone), while `PROJECT_SOURCE_DIR` refers
to the root of the capstone source tree.

Recently introduced changes to enable CPack (capstone-engine#2590) are using the wrong
variable and are hence breaking builds that use capstone through
fetch_content. Use the correct variable to fix this issue.
Do not include cpack in builds where capstone is used through
fetch_content.
Copy link
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!
@kabeor

@imphil imphil changed the title Fix cmake: Fix building capstone as sub-project Feb 19, 2025
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.

2 participants