From 2580200a6c51dc0b9a5b47b235c2a211098b7654 Mon Sep 17 00:00:00 2001 From: "Jonathan M. Henson" Date: Mon, 21 Jan 2019 09:59:35 -0800 Subject: [PATCH] Added support for RHEL variant lib paths, general install improvements. (#5) * Added support for RHEL variant lib paths, general install improvements. --- CMakeLists.txt | 34 ++++++++++++------- .../cmake/BuildAwsCCommon.cmake | 5 ++- aws-common-runtime/cmake/BuildAwsCIO.cmake | 5 ++- aws-common-runtime/cmake/BuildS2N.cmake | 4 ++- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5501ba8c..54002317b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,10 @@ elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR) set(CMAKE_INSTALL_LIBDIR "lib") endif() +if (${CMAKE_INSTALL_LIBDIR} STREQUAL "lib64") + set(FIND_LIBRARY_USE_LIB64_PATHS true) +endif() + if (BUILD_DEPS) set(AWS_DEPS_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps) if (DEFINED CMAKE_INSTALL_PREFIX) @@ -16,12 +20,12 @@ if (BUILD_DEPS) set(AWS_DEPS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/install) endif() + list(APPEND CMAKE_MODULE_PATH "${AWS_DEPS_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake") + if (NOT DEFINED CMAKE_PREFIX_PATH) set(CMAKE_PREFIX_PATH ${AWS_DEPS_INSTALL_DIR}) endif() - list(APPEND CMAKE_MODULE_PATH "${AWS_DEPS_INSTALL_DIR}/lib/cmake") - file(MAKE_DIRECTORY ${AWS_DEPS_BUILD_DIR}) if(TARGET_ARCH STREQUAL "ANDROID") execute_process( @@ -35,6 +39,7 @@ if (BUILD_DEPS) -DANDROID_STL=${ANDROID_STL} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} @@ -50,6 +55,7 @@ if (BUILD_DEPS) -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}/bin @@ -80,6 +86,7 @@ else() #the following two lines are done in this branch intentionally, don't move it. project() does some magic that #we want happening exactly right now. project(aws-crt-cpp CXX) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") endif() @@ -106,7 +113,7 @@ file(GLOB AWS_CRT_EXTERNAL_HEADERS file(GLOB AWS_CRT_CPP_HEADERS ${AWS_CRT_HEADERS} - ${AWS_CRT_IO_HEADERS} + ${AWS_CRT_IO_HEADERS} ${AWS_CRT_MQTT_HEADERS} ) @@ -176,28 +183,31 @@ target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC find_package(aws-c-mqtt REQUIRED) target_link_libraries(${CMAKE_PROJECT_NAME} AWS::aws-c-mqtt) -install(FILES ${AWS_CRT_HEADERS} DESTINATION "include/aws/crt") -install(FILES ${AWS_CRT_IO_HEADERS} DESTINATION "include/aws/crt/io") -install(FILES ${AWS_CRT_MQTT_HEADERS} DESTINATION "include/aws/crt/mqtt") -install(FILES ${AWS_CRT_EXTERNAL_HEADERS} DESTINATION "include/aws/crt/external") +install(FILES ${AWS_CRT_HEADERS} DESTINATION "include/aws/crt" COMPONENT Development) +install(FILES ${AWS_CRT_IO_HEADERS} DESTINATION "include/aws/crt/io" COMPONENT Development) +install(FILES ${AWS_CRT_MQTT_HEADERS} DESTINATION "include/aws/crt/mqtt" COMPONENT Development) +install(FILES ${AWS_CRT_EXTERNAL_HEADERS} DESTINATION "include/aws/crt/external" COMPONENT Development) install( TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib - LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development + RUNTIME DESTINATION bin COMPONENT Runtime ) install(EXPORT "${CMAKE_PROJECT_NAME}-targets" - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_PROJECT_NAME}/cmake/" - NAMESPACE AWS::) + DESTINATION "${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/cmake/" + NAMESPACE AWS:: + COMPONENT Development) configure_file("cmake/${CMAKE_PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake" - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_PROJECT_NAME}/cmake/") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/${CMAKE_PROJECT_NAME}/cmake/" + COMPONENT Development) enable_testing() add_subdirectory(tests) diff --git a/aws-common-runtime/cmake/BuildAwsCCommon.cmake b/aws-common-runtime/cmake/BuildAwsCCommon.cmake index 545a35eda..169b5e12e 100644 --- a/aws-common-runtime/cmake/BuildAwsCCommon.cmake +++ b/aws-common-runtime/cmake/BuildAwsCCommon.cmake @@ -6,6 +6,7 @@ if("${TARGET_ARCH}" STREQUAL ANDROID) BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -27,6 +28,7 @@ elseif(MSVC) BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -43,6 +45,7 @@ else() BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -50,4 +53,4 @@ else() -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ) -endif() \ No newline at end of file +endif() diff --git a/aws-common-runtime/cmake/BuildAwsCIO.cmake b/aws-common-runtime/cmake/BuildAwsCIO.cmake index cad68a5a8..103e0d19a 100644 --- a/aws-common-runtime/cmake/BuildAwsCIO.cmake +++ b/aws-common-runtime/cmake/BuildAwsCIO.cmake @@ -6,6 +6,7 @@ if("${TARGET_ARCH}" STREQUAL ANDROID) BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -27,6 +28,7 @@ elseif(MSVC) BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -43,6 +45,7 @@ else() BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -50,4 +53,4 @@ else() -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ) -endif() \ No newline at end of file +endif() diff --git a/aws-common-runtime/cmake/BuildS2N.cmake b/aws-common-runtime/cmake/BuildS2N.cmake index 65e8d861c..57952e5b4 100644 --- a/aws-common-runtime/cmake/BuildS2N.cmake +++ b/aws-common-runtime/cmake/BuildS2N.cmake @@ -8,6 +8,7 @@ if("${TARGET_ARCH}" STREQUAL ANDROID) BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -29,6 +30,7 @@ else() BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS + -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -36,4 +38,4 @@ else() -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ) -endif() \ No newline at end of file +endif()