From 6eae0c0cbbadac05239ae785759c373621fbbfb6 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Thu, 19 Dec 2024 13:18:53 -0800 Subject: [PATCH 1/4] Install cmake config to more standard location --- CMakeLists.txt | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6da225..e04d6b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,26 +3,6 @@ project(aws-c-iot C) option(USE_EXTERNAL_DEPS_SOURCES "Use dependencies provided by add_subdirectory command" OFF) -if (DEFINED CMAKE_PREFIX_PATH) - file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH) -endif() - -if (DEFINED CMAKE_INSTALL_PREFIX) - 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() - -# 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}) - if (USE_EXTERNAL_DEPS_SOURCES) set(IN_SOURCE_BUILD ON) @@ -35,6 +15,11 @@ if (USE_EXTERNAL_DEPS_SOURCES) list(APPEND CMAKE_MODULE_PATH "${aws-c-common_SOURCE_DIR}/cmake") endif() +if (NOT IN_SOURCE_BUILD) + # this is required so we can use aws-c-common's CMake modules + find_package(aws-c-common REQUIRED) +endif() + include(AwsCFlags) include(AwsCheckHeaders) include(AwsSharedLibSetup) @@ -118,7 +103,7 @@ else() endif() install(EXPORT "${PROJECT_NAME}-targets" - DESTINATION "${LIBRARY_DIRECTORY}/${PROJECT_NAME}/cmake/${TARGET_DIR}" + DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}/${TARGET_DIR}" NAMESPACE AWS:: COMPONENT Development) @@ -127,7 +112,7 @@ configure_file("cmake/${PROJECT_NAME}-config.cmake" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" - DESTINATION "${LIBRARY_DIRECTORY}/${PROJECT_NAME}/cmake/" + DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}/" COMPONENT Development) include(CTest) From 8690a68a024300bc4b27bd2be8520872dba9aa7d Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Thu, 19 Dec 2024 16:16:15 -0800 Subject: [PATCH 2/4] respect custom cmake install path for bin/lib/include --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e04d6b5..b27781f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,8 +93,8 @@ aws_use_package(aws-c-mqtt) target_link_libraries(${PROJECT_NAME} PUBLIC ${DEP_AWS_LIBS}) aws_prepare_shared_lib_exports(${PROJECT_NAME}) -install(FILES ${AWS_IOT_HEADERS} DESTINATION "include/aws/iotdevice" COMPONENT Development) -install(FILES ${AWS_IOT_PRIV_EXPOSED_HEADERS} DESTINATION "include/aws/iotdevice/private" COMPONENT Development) +install(FILES ${AWS_IOT_HEADERS} DESTINATION "${INCLUDE_DIRECTORY}/aws/iotdevice" COMPONENT Development) +install(FILES ${AWS_IOT_PRIV_EXPOSED_HEADERS} DESTINATION "${INCLUDE_DIRECTORY}/aws/iotdevice/private" COMPONENT Development) if (BUILD_SHARED_LIBS) set (TARGET_DIR "shared") From 4e800a51352ee7feff770f89d15e93e507c53dc0 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Fri, 20 Dec 2024 10:33:31 -0800 Subject: [PATCH 3/4] Fix CMake Deprecation Warning, by declaring project is known to be compatible with latest versions too --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b27781f..7b9d812 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.9...3.31) project(aws-c-iot C) option(USE_EXTERNAL_DEPS_SOURCES "Use dependencies provided by add_subdirectory command" OFF) From f6c76962efd49d0ac2f50d0e2fd53b17fa6e4e7c Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Fri, 20 Dec 2024 17:48:02 -0800 Subject: [PATCH 4/4] Just use CMAKE_INSTALL_LIBDIR etc, instead of our own custom variables --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b9d812..a629b4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ include(AwsSharedLibSetup) include(AwsSanitizers) include(CheckCCompilerFlag) include(AwsFindPackage) +include(GNUInstallDirs) # Platform specific includes and source @@ -93,8 +94,8 @@ aws_use_package(aws-c-mqtt) target_link_libraries(${PROJECT_NAME} PUBLIC ${DEP_AWS_LIBS}) aws_prepare_shared_lib_exports(${PROJECT_NAME}) -install(FILES ${AWS_IOT_HEADERS} DESTINATION "${INCLUDE_DIRECTORY}/aws/iotdevice" COMPONENT Development) -install(FILES ${AWS_IOT_PRIV_EXPOSED_HEADERS} DESTINATION "${INCLUDE_DIRECTORY}/aws/iotdevice/private" COMPONENT Development) +install(FILES ${AWS_IOT_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/iotdevice" COMPONENT Development) +install(FILES ${AWS_IOT_PRIV_EXPOSED_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/iotdevice/private" COMPONENT Development) if (BUILD_SHARED_LIBS) set (TARGET_DIR "shared") @@ -103,7 +104,7 @@ else() endif() install(EXPORT "${PROJECT_NAME}-targets" - DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}/${TARGET_DIR}" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/${TARGET_DIR}" NAMESPACE AWS:: COMPONENT Development) @@ -112,7 +113,7 @@ configure_file("cmake/${PROJECT_NAME}-config.cmake" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" - DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}/" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/" COMPONENT Development) include(CTest)