-
Notifications
You must be signed in to change notification settings - Fork 190
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
Enhancement: add option PATCHES in which we can pass filepathes for patches to apply to the lib/package #494
Comments
I've dug into this, and it seems Also, if you don't have |
CPM already has the patch command, is this to add more convenience? If this is to add convenience, CPM could do This would be much better if At any rate, one can currently do something like: find_package(Patch REQUIRED)
# magic_enum
# Reflection for enumerations, pretty cool really.
# Note the limitations: https://github.com/Neargye/magic_enum/blob/master/doc/limitations.md
set(CMAKE_FOLDER "${BASE_FOLDER}/magic_enum")
CPMAddPackage(
NAME magic_enum
URL https://github.com/Neargye/magic_enum/archive/refs/tags/v0.9.5.tar.gz
URL_HASH SHA256=44ad80db5a72f5047e01d90e18315751d9ac90c0ab42cbea7a6f9ec66a4cd679
SYSTEM True
PATCH_COMMAND
"${Patch_EXECUTABLE}" -p1 < "${CMAKE_CURRENT_LIST_DIR}/magic_enum_format.patch"
) |
@ScottBailey Here's just search at codebase of cpm for word |
It would be GREAT if |
I've given such command to CPM....(PATCH_COMMAND):
But it doesn't work Example I tried:
a patch for example:
I see the result in cmake logs, that it doesn't apply
Instead of
|
I think your syntax for patch is wrong. I appreciate that you want to simply apply all the patches, but why dont you take a step back and do this instead:
set(PATCH_ARGS "")
CPMAddPackage(
NAME Boost
URL "https://github.com/boostorg/boost/releases/download/boost-${TRY_BOOST_VERSION}/boost-${TRY_BOOST_VERSION}.tar.xz"
OPTIONS "BOOST_ENABLE_CMAKE ON"
PATCH_COMMAND
"${Patch_EXECUTABLE}" ${PATCH_ARGS} -p1 < "${CMAKE_CURRENT_SOURCE_DIR}/patches/boost/000boost.patch"
"${Patch_EXECUTABLE}" ${PATCH_ARGS} -p1 < "${CMAKE_CURRENT_SOURCE_DIR}/patches/boost/001boost.patch"
) I know this works. And maybe you/CPM have your quotes in the wrong place? |
Here is the cmake issue for adding This CPM issue could be done by adding a This is a pretty quick change. Writing the documentation or the automated tests will take longer than the code itself. CMake is not moving on that Patching is an essential part of package management, it might be nice if it was easier. @TheLartians @iboB Opinions? |
It seems to not to.
as you see, it's exactly like you proposed . And yes, I deleted cache of CPM, deleted build folder, and it's still the same |
Got a simple repo? I know the magic_enum patch sample I have works. What OS are you on? |
Gentoo linux. |
Like you can clone my repo for example and try it in docker: https://github.com/Gerodote/ModernCppStarterExampleBoostCmake
|
Try this instead: CPMAddPackage(
NAME Boost
URL "https://github.com/boostorg/boost/releases/download/boost-${TRY_BOOST_VERSION}/boost-${TRY_BOOST_VERSION}.tar.xz"
PATCH_COMMAND
"${Patch_EXECUTABLE}" ${PATCH_COMMAND_ARGS} -p1 < "${CMAKE_CURRENT_SOURCE_DIR}/patches/boost/boost_cmake_enable_install_rules_for_add_subdirectory_case.patch"
&&
"${Patch_EXECUTABLE}" ${PATCH_COMMAND_ARGS} -p1 < "${CMAKE_CURRENT_SOURCE_DIR}/patches/boost/boost_cmake_give_all_boost_deps_please.patch"
OPTIONS "BOOST_ENABLE_CMAKE ON"
)
And |
Yep, it works I tried some stuff.
|
Thank you, Scott Bailey |
My pleasure. Now lets see what everyone else thinks about adding |
@Gerodote I wrote #558 to address adding patch files. Check it out and tell me what you think. It needs some unit or integration tests before I move it from draft state. |
Assume we have a bad library that needs to be patched and we don't want to create a pull request, wait until a miracle happens and so on, or library just don't have github/gitlab pull request capability.
We would like to make a patch.
How to?
somehow get the lib
cd the_lib_folder
git init
git add .
git commit -m "initial"
git diff | tee /path_to_your_package/patches/pkg_name/patch_name.patch
apply -p1 -rnN -d ${library_name_SOURCE_DIR} -i filepath_to_the_patch
there's also a
git am
command, you can find it somewhere at internet just googling, it will do the same, maybe its better option because IDK is theapply
command portable on Windows and other environments.How to apply patches in cmake ?
Current solution:
What is the proposal?
Add PATCHES option in CPMAddPackage . ( Maybe in CPMFindPackage too ).
It should take filepathes for patches. e.g. it should take ${CMAKE_CURRENT_SOURCE_DIR}/patches/${pkg_name}/* ( it can be a list of patches, which we could get using
file(GLOB_RECURSE pkg_name_patches CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/patches/pkg_name/*.patch )
The text was updated successfully, but these errors were encountered: