Open glaubitz opened 5 years ago
Imho, the proper fix would be to only do find_package(aws-c-common REQUIRED)
.
The aws-c-common-config.cmake
file should modify the CMAKE_MODULE_PATH
accordingly.
The proper fix is thus in aws-c-common
project.
Consumers of aws-c-common
will then be able to include the AwsCFlags
, AwsSharedLibSetup
, AwsFeatureTests
, AwsSanitizers
and AwsSIMD
modules.
I'm having the same issue here while trying to build on amazon linux 2.
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. $LIBDIR/cmake/$PACKAGE
.
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:
# 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})
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.
Can you make PR with the suggested changes?
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 ${LIB_INSTALL_DIR}/cmake/${CMAKE_PROJECT_NAME}
while the AWS C/C++ SDK packages default to ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake/
which is why cmake won't be able to find AWS cmake modules by default.
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.