-
Notifications
You must be signed in to change notification settings - Fork 46
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
AWS C/C++ packages use non-standard cmake module paths breaking most distributions #15
Comments
* Properly handle lib prefix. * Removed unnecessary message.
Imho, the proper fix would be to only do |
I'm having the same issue here while trying to build on amazon linux 2. |
Right now aws-c-event-stream needs a lot of boilerplate code to determine the modules installation path while the aws-c-common package should provide it. This would fix awslabs/aws-c-event-stream#15 simply by moving `find_package(aws-c-common REQUIRED)` before the various module `include`s Using `configure_package_config_file` makes it easier to have a relocatable package.
`aws-c-event-stream` should not need to worry nor now how to find the `aws-c-common` CMake modules. This can be fixed by simply moving up `find_package(aws-c-common REQUIRED)` and making the `aws-c-common` package set the paths correctly. This has been confirmed to work on amazon linux 2. This commit requires awslabs/aws-c-common#587 to be merged first.
FWIW, this issue affects many C/C++ AWS packages. We currently ship these libraries in openSUSE and they all needed to have their cmake paths patched:
I also verified on the cmake paths on Debian/Ubuntu and Fedora/RHEL, they also follow the same directory hierarchy as openSUSE, i.e. Using the proper cmake paths also means that this particular hack that I have found in every CMakeLists.txt of all AWS packages so far is no longer necessary:
I'm currently using this patch for all AWS packages and it fixes the cmake path issues for me: diff -Nru aws-c-event-stream-0.1.6.orig/CMakeLists.txt aws-c-event-stream-0.1.6/CMakeLists.txt
--- aws-c-event-stream-0.1.6.orig/CMakeLists.txt 2020-07-24 02:06:45.000000000 +0200
+++ aws-c-event-stream-0.1.6/CMakeLists.txt 2020-08-25 13:17:04.469790864 +0200
@@ -11,17 +11,11 @@
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
endif()
-if (UNIX AND NOT APPLE)
- include(GNUInstallDirs)
-elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
- set(CMAKE_INSTALL_LIBDIR "lib")
-endif()
+find_package(aws-c-common REQUIRED)
+find_package(aws-checksums REQUIRED)
+set(CMAKE_MODULE_PATH ${aws-c-common_DIR})
-# This is required in order to append /lib/cmake to each element in CMAKE_PREFIX_PATH
-set(AWS_MODULE_DIR "/${CMAKE_INSTALL_LIBDIR}/cmake")
-string(REPLACE ";" "${AWS_MODULE_DIR};" AWS_MODULE_PATH "${CMAKE_PREFIX_PATH}${AWS_MODULE_DIR}")
-# Append that generated list to the module search path
-list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH})
+include(GNUInstallDirs)
include(AwsCFlags)
include(AwsSharedLibSetup)
@@ -92,7 +86,7 @@
endif()
install(EXPORT "${PROJECT_NAME}-targets"
- DESTINATION "${LIBRARY_DIRECTORY}/${PROJECT_NAME}/cmake/${TARGET_DIR}/"
+ DESTINATION "${LIB_INSTALL_DIR}/cmake/${CMAKE_PROJECT_NAME}/${TARGET_DIR}/"
NAMESPACE AWS::
COMPONENT Development)
@@ -101,7 +95,7 @@
@ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
- DESTINATION "${LIBRARY_DIRECTORY}/${PROJECT_NAME}/cmake/"
+ DESTINATION "${LIB_INSTALL_DIR}/cmake/${CMAKE_PROJECT_NAME}"
COMPONENT Development) It's actually a change that was recommend to me by the cmake upstream developers. |
Right now aws-c-event-stream needs a lot of boilerplate code to determine the modules installation path while the aws-c-common package should provide it. This would fix awslabs/aws-c-event-stream#15 simply by moving `find_package(aws-c-common REQUIRED)` before the various module `include`s Using `configure_package_config_file` makes it easier to have a relocatable package.
Right now aws-c-event-stream needs a lot of boilerplate code to determine the modules installation path while the aws-c-common package should provide it. This would fix awslabs/aws-c-event-stream#15 simply by moving `find_package(aws-c-common)` before the various module `include`s Using `configure_package_config_file` makes it easier to have a relocatable package.
Can you make PR with the suggested changes? |
It should be enough to simply switch all packages to using the cmake default paths as they are used by all Linux distributions. It's usually |
I am currently packaging
aws-c-common
,aws-checkums
andaws-c-event-stream
for openSUSE as these packages are now required for theaws-sdk-cpp
which is already part of openSUSE and SLE.While packaging, I have run into the problem that the
cmake
configuration inaws-c-event-stream
couldn't findAwsCFlags
andAwsSanitizers
:A simple workaround fixes the problem for me:
The proper fix is certainly to use
find_library()
instead ofinclude()
in this case.The text was updated successfully, but these errors were encountered: