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

Add cmake config and export targets. #1637

Merged
merged 1 commit into from
Jun 2, 2020
Merged

Add cmake config and export targets. #1637

merged 1 commit into from
Jun 2, 2020

Conversation

mcmtroffaes
Copy link
Contributor

Generates a few more files on install to add support for cmake's find_package system, thereby simplifying the use of capstone in cmake projects, for instance:

cmake_minimum_required(VERSION 3.0)
project(test)
find_package(capstone CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE capstone::capstone-static)

Also see CMakePackageConfigHelpers. Tested with Visual Studio 2019 and CMake 3.17 using the following code for main.cpp:

#include <capstone/capstone.h>
#include <stdio.h>

int main()
{
    int major = -1, minor = -1;
    cs_version(&major, &minor);
    printf("capstone version %i.%i\n", major, minor);
    getchar();
    return 0;
}

@mcmtroffaes mcmtroffaes changed the base branch from master to next May 25, 2020 13:16
@mcmtroffaes mcmtroffaes changed the base branch from next to master May 25, 2020 13:17
These additions simplify using capstone in cmake projects:

find_package(capstone CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE capstone::capstone-static)
@mcmtroffaes mcmtroffaes changed the base branch from master to next May 25, 2020 13:23
@mcmtroffaes
Copy link
Contributor Author

I figured this makes more sense for next rather than master, so I've rebased it. If next is the intended branch for pull requests, note that you can configure the default pull request branch in github (settings -> branches -> default branch).

@aquynh aquynh merged commit 852c075 into capstone-engine:next Jun 2, 2020
@aquynh
Copy link
Collaborator

aquynh commented Jun 2, 2020

merged, thanks!

@mcmtroffaes
Copy link
Contributor Author

Thanks so much! Could this be backported to master as well? Happy to create a pull request for it. Or will next be merged into master soon?

@mcmtroffaes mcmtroffaes deleted the feature/cmake-config-targets branch June 2, 2020 13:21
@aquynh
Copy link
Collaborator

aquynh commented Jun 2, 2020

i am thinking about merging next to master.

@tmfink
Copy link
Contributor

tmfink commented Jun 3, 2020

@aquynh should there even a master branch at this point? Why not just have next, v2, v3, and so on?

@tmfink
Copy link
Contributor

tmfink commented Jun 3, 2020

on a separate note, I think there should be developer documentation explaining the purpose of the "mainline" branches and the release model

@riptl riptl mentioned this pull request Jul 22, 2022
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.

None yet

3 participants