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

Modernize CMake and switch to CMake 3.15 #1841

Merged
merged 1 commit into from
Feb 26, 2022

Conversation

mrexodia
Copy link
Contributor

@mrexodia mrexodia commented Feb 25, 2022

Closes #1826

Some context

This refactors capstone's CMake to be compatible with both find_package and FetchContent. You can build capstone like this:

cmake -B build -DBUILD_SHARED_LIBS=OFF # or whatever options you want
cmake --build build
cmake --install build --prefix build/install

Then in your project's CMakeLists.txt:

find_package(capstone REQUIRED)

add_executable(my_tool src/main.cpp)
target_link_libraries(my_tool PRIVATE capstone::capstone)

And to build you point CMAKE_PREFIX_PATH to the build/install you just created:

cmake -B build -DCMAKE_PREFIX_PATH=/path/to/capstone/build/install

Or alternatively you can use FetchContent:

include(FetchContent)

message(STATUS "Fetching capstone (cmake-packaging)...")
FetchContent_Declare(
	capstone
	GIT_REPOSITORY
		https://github.com/LLVMParty/capstone
	GIT_TAG
		cmake-packaging
)
FetchContent_MakeAvailable(capstone) 

add_executable(my_tool src/main.cpp)
target_link_libraries(my_tool PRIVATE capstone::capstone)

This seems to be the "intended" way to use CMake and it should make it easier for other tools (like Triton) to link capstone in a way consistent with other packages. It should also be compatible with vcpkg/Hunter without any custom work.

Stuff left

  • Fuzzing is failing (no idea why, it seems to clone the wrong branch)
  • Fix python distribution

@kabeor
Copy link
Member

kabeor commented Feb 26, 2022

Very cool! Merged.

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.

None yet

2 participants