Skip to content

cmake: Fix building capstone as sub-project#2629

Merged
kabeor merged 2 commits intocapstone-engine:nextfrom
imphil:build-with-fetch-content
Mar 3, 2025
Merged

cmake: Fix building capstone as sub-project#2629
kabeor merged 2 commits intocapstone-engine:nextfrom
imphil:build-with-fetch-content

Conversation

@imphil
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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
@notxvilka
Copy link
Copy Markdown

@kabeor take a look at this one too, please

Copy link
Copy Markdown
Member

@kabeor kabeor left a comment

Choose a reason for hiding this comment

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

Thank you, merged.

@kabeor kabeor merged commit dc0c090 into capstone-engine:next Mar 3, 2025
kabeor pushed a commit that referenced this pull request Apr 2, 2025
* Fix wrong version requirement of tricore instructions: (#2620)

crc32.b
crc32b.w
crc32l.w
crcn
popcnt.w
shuffle

Remove invalid instruction:
BISR_rc_v161

Learn up misconfigure of nor and not

* Switch to ubuntu-24.04-arm runner image (#2625)

* Build Tarball before DEB/RPM package. (#2627)

Because it was run after the RPM/DEB package build it contained the 'build' directory
with all its files. Which made it way too big.

* Add aliases mapping for MIPS & test for id, alias_id (#2635)

* Add checks for MIPS details on cstest_py (#2640)

* Give the user some guidance where to add missing enumeration values. (#2639)

* - Added missing files for sdist archive (#2624)

* cmake: Fix building capstone as sub-project (#2629)

* cmake: Use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR

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.

* cmake: Only include cpack in top-level builds

Do not include cpack in builds where capstone is used through
fetch_content.

* Update operand type enums of all arch modules to the one in `capstone.h` (#2633)

* Set all operand types to the main CS_OP_ types from capstone.h.

* Add test cases from issue.

* Enhance shift value and types of shift instructions. (#2638)

* Enhance shift value and types of shift instructions.

Shifts via registers now save the register id in cs_arch64_op.shift.value
and set the shift type accordingly.

* Sort table

* Fix build for compilers requiring explicit static for inline functions.. (#2645)

* Tms32c64x Little Endian (#2648)

* Add little endian support for TMS320c64x.
This requires now to initialize TMS320c64x with the
CS_MODE_BIG_ENDIAN flag.

* Fix typo

* Add Call group to svc, smc and hvc. (#2651)

* Decode BH field in print_insn_detail_ppc (#2662)

---------

Co-authored-by: Changqing  Jing <changqing.jing@bmw.com>
Co-authored-by: @Antelox <anteloxrce@gmail.com>
Co-authored-by: Giovanni <561184+wargio@users.noreply.github.com>
Co-authored-by: Philipp Wagner <mail@philipp-wagner.com>
Co-authored-by: Tim Haines <thaines.astro@gmail.com>
kabeor pushed a commit that referenced this pull request Apr 9, 2025
* cmake: Use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR

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.

* cmake: Only include cpack in top-level builds

Do not include cpack in builds where capstone is used through
fetch_content.
Rot127 pushed a commit that referenced this pull request Apr 11, 2025
* cmake: Use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR

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.

* cmake: Only include cpack in top-level builds

Do not include cpack in builds where capstone is used through
fetch_content.
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.

4 participants