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

CMakeLists.txt - Change ExternalProject_Add to findpackage #130

Closed
c3rb3ru5d3d53c opened this issue May 23, 2022 · 4 comments · Fixed by #135 or #151
Closed

CMakeLists.txt - Change ExternalProject_Add to findpackage #130

c3rb3ru5d3d53c opened this issue May 23, 2022 · 4 comments · Fixed by #135 or #151
Assignees
Labels
enhancement New feature or request

Comments

@c3rb3ru5d3d53c
Copy link
Owner

Is your feature request related to a problem? Please describe.
As mentioned in #127, we should move to using findpackage instead as ExternalProject_Add introduces issues with Windows builds.

Describe the solution you'd like
The solution would be to add git submodules for LIEF, tlsh, and capstone and use findpackage instead.

Describe alternatives you've considered
N/A

Additional context
This was suggested by @mrexodia 😄

@c3rb3ru5d3d53c c3rb3ru5d3d53c added the enhancement New feature or request label May 23, 2022
@c3rb3ru5d3d53c c3rb3ru5d3d53c self-assigned this May 23, 2022
@c3rb3ru5d3d53c c3rb3ru5d3d53c linked a pull request May 28, 2022 that will close this issue
@c3rb3ru5d3d53c
Copy link
Owner Author

So find_package does not appear to be what we would want for git submodules, we would want add_subdirectory

@c3rb3ru5d3d53c
Copy link
Owner Author

c3rb3ru5d3d53c commented May 28, 2022

The downside is that with git submodules it is difficult for us to version control those dependencies unless we use git in cli later to checkout a specific version. I think for repos in which we have control over to help with windows builds we can do forks and still use ExternalProject_Add much like we are doing already

@mrexodia
Copy link
Collaborator

My idea would be something like this: Make a subdirectory deps that has all the ExternalProject_Add calls and builds the third party dependencies.

Then in the main project you create Find<module>.cmake which creates an IMPORTED library pointing to LIEF for example. Then the build process looks like this:

  • cmake -B deps/build -S deps && cmake --build deps/build <- this will pull and build the dependencies
  • cmake -B build -DDEPS_BUILD_FOLDER:FILEPATH=deps/build

Then in the main project's CMakeLists.txt:

list(PREPEND CMAKE_MODULE_PATH "cmake")
find_package(LIEF REQUIRED)

This would then get you IMPORTED targets that point to ${DEPS_BUILD_FOLDER}/install/lief (etc). The advantage of this system is that you only build the dependencies once and you keep your main project clean. Also on CI you can easily do caching of the dependencies etc.

The downside of course is that you end up having to do a lot of work to properly wrap the dependencies. Basically you are recreating vcpkg on a small scale.

@c3rb3ru5d3d53c
Copy link
Owner Author

Alright, I think I'm seeing what you are saying much clearer now, when you do a make clean your builds for the dependencies will not be tampered with. Allowing you to perform full rebuilds of binlex without having to recompile lief, capstone etc.

@c3rb3ru5d3d53c c3rb3ru5d3d53c linked a pull request Mar 2, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants