Skip to content

Commit

Permalink
Added support for RHEL variant lib paths, general install improvement…
Browse files Browse the repository at this point in the history
…s. (#5)

* Added support for RHEL variant lib paths, general install improvements.
  • Loading branch information
JonathanHenson authored Jan 21, 2019
1 parent 5246899 commit 2580200
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
34 changes: 22 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -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}
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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}
)

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion aws-common-runtime/cmake/BuildAwsCCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -43,11 +45,12 @@ 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}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
)
endif()
endif()
5 changes: 4 additions & 1 deletion aws-common-runtime/cmake/BuildAwsCIO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -43,11 +45,12 @@ 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}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
)
endif()
endif()
4 changes: 3 additions & 1 deletion aws-common-runtime/cmake/BuildS2N.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -29,11 +30,12 @@ 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}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
)
endif()
endif()

0 comments on commit 2580200

Please sign in to comment.