-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CMake Config mode support for Curl #2717
Comments
Hi @pr0g , thank you for submitting this issue.
I'm not a 100% expert in cmake, so maybe wrong here, is there a reason you are not able to use Best regards, |
Hi @SergeyRyabinin, Thank you for getting back to me so quickly about this. Ah yes, the # from aws-sdk-cpp root directory
cmake -B build -G Ninja -DCMAKE_PREFIX_PATH=path/to/curl/install \
-DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY=cognito-identity \
-DENABLE_TESTING=OFF -DAUTORUN_UNIT_TESTS=OFF \
-DFORCE_CURL=ON
cmake --build build The build fails at link time because the Curl libraries cannot be found (this is for the reason mentioned in the issue where For completeness this is the CMakeLists.txt I used to build and install Curl cmake_minimum_required(VERSION 3.22)
project(curl-external)
include(ExternalProject)
include(ProcessorCount)
ProcessorCount(CPU_COUNT)
ExternalProject_Add(
openssl
GIT_REPOSITORY https://github.com/openssl/openssl.git
GIT_TAG openssl-3.2.0-alpha2
GIT_SHALLOW ON
UPDATE_COMMAND ""
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/openssl/build/Debug
CONFIGURE_COMMAND
perl <SOURCE_DIR>/Configure no-docs no-tests no-legacy
--prefix=${CMAKE_CURRENT_BINARY_DIR}
--openssldir=ssl
BUILD_COMMAND make -j ${CPU_COUNT}
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
INSTALL_COMMAND make install_sw)
ExternalProject_Add(
curl
GIT_REPOSITORY https://github.com/curl/curl.git
GIT_TAG curl-8_2_1
DEPENDS openssl
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/curl/build/Debug
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DOPENSSL_ROOT_DIR=<INSTALL_DIR>
CMAKE_CACHE_ARGS -DCMAKE_DEBUG_POSTFIX:STRING=d) I just created a new directory for this and ran
And that build folder is what I pointed |
Also for reference the issue manifests as this:
With my quick hacky change (see #2718 and https://github.com/pr0g/aws-sdk-cpp/tree/experiment-curl-cmake) I am unblocked, but it would be really cool if this could be fixed upstream. Thanks very much for your time! |
FYI this Stack Overflow question/answer seems to describe the same issue (not in the context of aws-sdk-cpp, but it's the same situation described above). |
Hey @pr0g i opened a PR that optionally falls back to using |
Change #2817 looks good to me! Thanks very much for adding support for this! 🥳 🎉 |
@pr0g with the above PR merged does this work for you? If so we can close this issue |
Hey @jmklix, I haven't had a chance to test this out yet but I think it's safe to close for now. When I do get to it, if there's any issues I'll reopen with a repro. Thanks! |
|
Describe the bug
Right now it does not seem possible to use a custom build of Curl built with CMake when it is installed in Config mode.
When building aws-sdk-cpp, CURL will be found in Config mode, but the include directories and library variables are not populated.
This is because in Config mode the variables
${<library>_INCLUDE_DIRS}
and${<library>_LIBRARIES}
are not populated (in this case${CURL_INCLUDE_DIRS}
and${CURL_LIBRARIES}
).There is a workaround for this (please see this experimental draft PR - #2718) where we use the CMake
find_package
command to find Curl, and then link against the Curl target inaws-sdk-cpp/src/aws-cpp-sdk-core/CMakeLists.txt
I realize this is a super hacky change and is not fit for purpose as is, but it proves that this can work with a fairly minor modification.
Expected Behavior
aws-sdk-cpp can be built when using a build of CURL in Config mode (see CMake Finding packages for details).
Current Behavior
Currently aws-sdk-cpp does not build when using a build of CURL in Config mode.
Reproduction Steps
To reproduce this issue (tested on macOS) you can use this simple CMake project:
And then build with...
Possible Solution
Please see this experimental draft PR - #2718
This is by no means a full and proper solution but shows the general idea to start a discussion.
Additional Information/Context
I'd be very grateful to hear how this could be resolved. I'm happy to have a stab at making the above change more robust (handling scenarios where CURL shouldn't be linked etc...). Or maybe there is another approach where it is possible to populate the variables mentioned earlier with a CMake library in Config mode.
AWS CPP SDK version used
main
Compiler and Version used
Apple clang version 15.0.0 (clang-1500.0.40.1) (CMake 3.26.1)
Operating System and version
macOS Ventura 13.5.2
The text was updated successfully, but these errors were encountered: