Skip to content

Move to submodules. #87

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

Merged
merged 2 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "aws-common-runtime/aws-crt-cpp"]
path = aws-common-runtime/aws-crt-cpp
url = https://github.com/awslabs/aws-crt-cpp.git
110 changes: 25 additions & 85 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(aws-iot-device-sdk-cpp-v2)

include(CTest)

option(BUILD_DEPS "Builds aws common runtime dependencies as part of build, only do this if you don't want to control your dependency chain." OFF)
option(BUILD_SAMPLES "Build samples as part of the build" ON)
Expand All @@ -11,107 +14,44 @@ if (DEFINED CMAKE_INSTALL_PREFIX)
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
endif()

if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()

if (UNIX AND NOT APPLE)
include(GNUInstallDirs)
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
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 CACHE STRING "If BUILD_DEPS is on, aws common runtime dependencies build in this directory.")
if (DEFINED CMAKE_INSTALL_PREFIX)
set(AWS_DEPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
else()
set(AWS_DEPS_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps/install)
endif()

if (NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${AWS_DEPS_INSTALL_DIR})
endif()

file(MAKE_DIRECTORY ${AWS_DEPS_BUILD_DIR})
if(TARGET_ARCH STREQUAL "ANDROID")
execute_process(
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
-DTARGET_ARCH=${TARGET_ARCH}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}
-DANDROID_ABI=${ANDROID_ABI}
-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME}
-DANDROID_STANDALONE_TOOLCHAIN=${ANDROID_STANDALONE_TOOLCHAIN}
-DANDROID_STL=${ANDROID_STL}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR}
-DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
${CMAKE_CURRENT_SOURCE_DIR}/aws-common-runtime
WORKING_DIRECTORY ${AWS_DEPS_BUILD_DIR}
)

else()
execute_process(
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
-DTARGET_ARCH=${TARGET_ARCH}
-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
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
${CMAKE_CURRENT_SOURCE_DIR}/aws-common-runtime
WORKING_DIRECTORY ${AWS_DEPS_BUILD_DIR}
RESULT_VARIABLE BUILD_AWSCRT_EXIT_CODE
)
endif()

if (NOT ${BUILD_AWSCRT_EXIT_CODE} EQUAL 0)
message(FATAL_ERROR "Failed to configure aws crt libraries.")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build ${AWS_DEPS_BUILD_DIR} --config ${CMAKE_BUILD_TYPE}
RESULT_VARIABLE BUILD_AWSCRT_EXIT_CODE)

if (NOT ${BUILD_AWSCRT_EXIT_CODE} EQUAL 0)
message(FATAL_ERROR "Failed to build aws crt libraries.")
endif()
message(STATUS "AWS Common Runtime is installed at: ${AWS_DEPS_INSTALL_DIR}")

#the following two lines are done in this branch intentionally, don't move it. project() does some magic that
#we don't want happening until we're done with the above code.
list(APPEND CMAKE_PREFIX_PATH "${AWS_DEPS_INSTALL_DIR}")

project(aws-iot-device-sdk-cpp-v2)

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-iot-device-sdk-cpp-v2)

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 (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

set(IS_SUBDIRECTORY_INCLUDE true)
find_package(aws-crt-cpp REQUIRED)
if (BUILD_DEPS)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/aws-common-runtime/aws-crt-cpp/aws-common-runtime/aws-c-common/cmake")

include(AwsFindPackage)
set(IN_SOURCE_BUILD ON)
set(BUILD_TESTING_PREV BUILD_TESTING)
set(BUILD_TESTING OFF)
add_subdirectory(aws-common-runtime/aws-crt-cpp)

set(BUILD_TESTING BUILD_TESTING_PREV)
else()
include(AwsFindPackage)
set(IN_SOURCE_BUILD OFF)
endif()

add_subdirectory(jobs)
add_subdirectory(shadow)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ is provided by code that been generated from a model of the service.
## Build from source
### Automatically Build and Install AWS Dependencies
```
git clone https://github.com/awslabs/aws-iot-device-sdk-cpp-v2.git
git clone --recursive https://github.com/awslabs/aws-iot-device-sdk-cpp-v2.git
mkdir aws-iot-device-sdk-cpp-v2-build
cd aws-iot-device-sdk-cpp-v2-build
cmake -DCMAKE_INSTALL_PREFIX="<path to where you install>" -DBUILD_DEPS=ON ../aws-iot-device-sdk-cpp-v2
Expand Down
23 changes: 0 additions & 23 deletions aws-common-runtime/CMakeLists.txt

This file was deleted.

1 change: 1 addition & 0 deletions aws-common-runtime/aws-crt-cpp
Submodule aws-crt-cpp added at 1f045a
63 changes: 0 additions & 63 deletions aws-common-runtime/cmake/BuildAwsCrtCpp.cmake

This file was deleted.

1 change: 1 addition & 0 deletions codebuild/common-posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if [ "$TRAVIS_OS_NAME" != "osx" ]; then
fi

# build SDK
git submodule update --init --recursive
mkdir -p build
pushd build
cmake $CMAKE_ARGS ../
Expand Down
2 changes: 2 additions & 0 deletions codebuild/common-windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ mkdir %INSTALL_DIR%

@rem build SDK
mkdir %BUILDS_DIR%\aws-iot-device-sdk-cpp-v2-build
cd %CODEBUILD_SRC_DIR%
git submodule update --init --recursive
cd %BUILDS_DIR%\aws-iot-device-sdk-cpp-v2-build
cmake %CMAKE_ARGS% -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%" -DCMAKE_PREFIX_PATH="%INSTALL_DIR%" -DBUILD_DEPS=ON %CODEBUILD_SRC_DIR% || goto error
cmake --build . || goto error
Expand Down
14 changes: 10 additions & 4 deletions discovery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,23 @@ target_include_directories(Discovery-cpp PUBLIC
$<INSTALL_INTERFACE:include>)

if (NOT IS_SUBDIRECTORY_INCLUDE)
find_package(aws-crt-cpp REQUIRED)
aws_use_package(aws-crt-cpp)
endif()

target_link_libraries(Discovery-cpp AWS::aws-crt-cpp)
target_link_libraries(Discovery-cpp ${DEP_AWS_LIBS})

install(FILES ${AWS_DISCOVERY_HEADERS} DESTINATION "include/aws/discovery/" COMPONENT Development)

if (BUILD_SHARED_LIBS)
set (TARGET_DIR "shared")
else()
set (TARGET_DIR "static")
endif()

install(EXPORT "Discovery-cpp-targets"
DESTINATION "lib/Discovery-cpp/cmake/"
NAMESPACE AWS::)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/Discovery-cpp/cmake/${TARGET_DIR}"
NAMESPACE AWS::
COMPONENT Development)

configure_file("cmake/Discovery-cpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/Discovery-cpp-config.cmake"
Expand Down
6 changes: 5 additions & 1 deletion discovery/cmake/Discovery-cpp-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ include(CMakeFindDependencyMacro)

find_dependency(aws-crt-cpp)

include(${CMAKE_CURRENT_LIST_DIR}/Discovery-cpp-targets.cmake)
if (BUILD_SHARED_LIBS)
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
else ()
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
endif()
14 changes: 10 additions & 4 deletions jobs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,23 @@ target_include_directories(IotJobs-cpp PUBLIC
$<INSTALL_INTERFACE:include>)

if (NOT IS_SUBDIRECTORY_INCLUDE)
find_package(aws-crt-cpp REQUIRED)
aws_use_package(aws-crt-cpp)
endif()

target_link_libraries(IotJobs-cpp AWS::aws-crt-cpp)
target_link_libraries(IotJobs-cpp ${DEP_AWS_LIBS})

install(FILES ${AWS_IOTJOBS_HEADERS} DESTINATION "include/aws/iotjobs/" COMPONENT Development)

if (BUILD_SHARED_LIBS)
set (TARGET_DIR "shared")
else()
set (TARGET_DIR "static")
endif()

install(EXPORT "IotJobs-cpp-targets"
DESTINATION "lib/IotJobs-cpp/cmake/"
NAMESPACE AWS::)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/IotJobs-cpp/cmake/${TARGET_DIR}"
NAMESPACE AWS::
COMPONENT Development)

configure_file("cmake/IotJobs-cpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/IotJobs-cpp-config.cmake"
Expand Down
6 changes: 5 additions & 1 deletion jobs/cmake/IotJobs-cpp-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ include(CMakeFindDependencyMacro)

find_dependency(aws-crt-cpp)

include(${CMAKE_CURRENT_LIST_DIR}/IotJobs-cpp-targets.cmake)
if (BUILD_SHARED_LIBS)
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
else ()
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
endif()
3 changes: 2 additions & 1 deletion samples/mqtt/basic_pub_sub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ target_include_directories(${PUB_SUB_PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

target_link_libraries(${PUB_SUB_PROJECT_NAME} AWS::aws-crt-cpp)
aws_use_package(aws-crt-cpp)
target_link_libraries(${PUB_SUB_PROJECT_NAME} ${DEP_AWS_LIBS})
3 changes: 2 additions & 1 deletion samples/mqtt/raw_pub_sub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ target_include_directories(${PUB_SUB_PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

target_link_libraries(${PUB_SUB_PROJECT_NAME} AWS::aws-crt-cpp)
aws_use_package(aws-crt-cpp)
target_link_libraries(${PUB_SUB_PROJECT_NAME} ${DEP_AWS_LIBS})
14 changes: 10 additions & 4 deletions shadow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,23 @@ target_include_directories(IotShadow-cpp PUBLIC
$<INSTALL_INTERFACE:include>)

if (NOT IS_SUBDIRECTORY_INCLUDE)
find_package(aws-crt-cpp REQUIRED)
aws_use_package(aws-crt-cpp)
endif()

target_link_libraries(IotShadow-cpp AWS::aws-crt-cpp)
target_link_libraries(IotShadow-cpp ${DEP_AWS_LIBS})

install(FILES ${AWS_IOTSHADOW_HEADERS} DESTINATION "include/aws/iotshadow/" COMPONENT Development)

if (BUILD_SHARED_LIBS)
set (TARGET_DIR "shared")
else()
set (TARGET_DIR "static")
endif()

install(EXPORT "IotShadow-cpp-targets"
DESTINATION "lib/IotShadow-cpp/cmake/"
NAMESPACE AWS::)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/IotShadow-cpp/cmake/${TARGET_DIR}"
NAMESPACE AWS::
COMPONENT Development)

configure_file("cmake/IotShadow-cpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/IotShadow-cpp-config.cmake"
Expand Down
6 changes: 5 additions & 1 deletion shadow/cmake/IotShadow-cpp-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ include(CMakeFindDependencyMacro)

find_dependency(aws-crt-cpp)

include(${CMAKE_CURRENT_LIST_DIR}/IotShadow-cpp-targets.cmake)
if (BUILD_SHARED_LIBS)
include(${CMAKE_CURRENT_LIST_DIR}/shared/@[email protected])
else ()
include(${CMAKE_CURRENT_LIST_DIR}/static/@[email protected])
endif()