aws-iot-device-sdk-cpp-v2: Samples CMake Files don't work in Standalone project
Confirm by changing [ ] to [x] below to ensure that it’s a bug:
- I’ve searched for previous similar issues and didn’t find any solution
Known Issue
- I’m using ATS data type endpoint: the endpoint should look like
<prefix>-ats.iot.<region>.amazonaws.com
Describe the bug I successfully installed the SDK according to the instructions on the Github page. I am looking to include the aws-iot-device-sdk-cpp-v2 in my own project that uses them. I had a feeling the CMake bit was going to be trouble, so I started by forking my own branch and adding my project under the Samples directory. That worked. Now it is time to pull the band-aid off by separating out my project and finding the relevant packages. I had hoped to modify the CMakeLists.txt files provided in the Samples, but this isn’t working at all. It seems like there are dependencies upon information upstream of the Sample CMakeLists.txt and it is not clear what it is. I’ve tried, but I am getting very frustrated. I believe the path towards integrating the SDK into other projects is buggy. I don’t think this is an additional feature.
Platform/OS/Device Ubuntu 16.04
SDK version number It is the V2 SDK, but I’m not sure where the version information is. I synced with master on July 10 2020
To Reproduce (observed behavior) Make an external project that looks to bring in the SDK and see what happens. LMK if I am doing something wrong
Expected behavior If you do what I’m doing, it won’t work. It seems like the required information to integrate the SDK into a project is spread over several cmake files. Shouldn’t one be able to adapt one of the example Sample CMakeLists.txt?
Logs/output
I run cmake with cmake -DCMAKE_INSTALL_PREFIX=/path/to/aws-iot-device-sdk-cpp-v2/build/install ..
In my CMakeList.txt, I have…
cmake_minimum_required(VERSION 3.1)
project(My-App CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/lib/cmake")
MESSAGE(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
file(GLOB MY_APP_SRC
"*.cpp"
)
MESSAGE(STATUS "MY_APP_SRC: ${MY_APP_SRC}")
set(MY_APP_PROJECT_NAME My-App)
add_executable(${MY_APP_PROJECT_NAME} ${MY_APP_SRC})
set_target_properties(${MY_APP_PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
set(CMAKE_CXX_STANDARD 11)
include(AwsFindPackage)
#set warnings
if (MSVC)
target_compile_options(${MY_APP_PROJECT_NAME} PRIVATE /W4 /WX /wd4068)
else ()
target_compile_options(${MY_APP_PROJECT_NAME} PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(${MY_APP_PROJECT_NAME} PRIVATE "-DDEBUG_BUILD")
endif ()
aws_use_package(aws-crt-cpp)
target_include_directories(${MY_APP_PROJECT_NAME} PUBLIC
${PNG_INCLUDE_DIR}
${CMAKE_INSTALL_PREFIX}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(${MY_APP_PROJECT_NAME} ${DEP_AWS_LIBS})
When I run the cmake command, I get…
-- The CXX compiler identification is GNU 6.5.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_MODULE_PATH: /path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/cmake
-- MY_APP_SRC: My-App.cpp
CMake Warning (dev) at /path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/cmake/AwsFindPackage.cmake:14 (option):
Policy CMP0077 is not set: option() honors normal variables. Run "cmake
--help-policy CMP0077" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
For compatibility with older versions of CMake, option is clearing the
normal variable 'IN_SOURCE_BUILD'.
Call Stack (most recent call first):
CMakeLists.txt:21 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found LibCrypto: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
CMake Warning (dev) at /usr/me/.local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
The package name passed to `find_package_handle_standard_args` (LibCrypto)
does not match the name of the calling package (LibCryptoCAL). This can
lead to problems in calling code that expects `find_package` result
variables (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/cmake/FindLibCryptoCAL.cmake:61 (find_package_handle_standard_args)
/usr/me/.local/share/cmake-3.17/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/aws-c-cal/cmake/aws-c-cal-config.cmake:4 (find_dependency)
/usr/me/.local/share/cmake-3.17/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/aws-crt-cpp/cmake/aws-crt-cpp-config.cmake:5 (find_dependency)
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/cmake/AwsFindPackage.cmake:29 (find_package)
CMakeLists.txt:64 (aws_use_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
CMake Warning (dev) at /usr/me/.local/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:272 (message):
The package name passed to `find_package_handle_standard_args` (LibCrypto)
does not match the name of the calling package (LibCryptoCAL). This can
lead to problems in calling code that expects `find_package` result
variables (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/cmake/FindLibCryptoCAL.cmake:61 (find_package_handle_standard_args)
/usr/me/.local/share/cmake-3.17/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/aws-c-cal/cmake/aws-c-cal-config.cmake:4 (find_dependency)
/usr/me/.local/share/cmake-3.17/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/aws-c-auth/cmake/aws-c-auth-config.cmake:4 (find_dependency)
/usr/me/.local/share/cmake-3.17/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/aws-crt-cpp/cmake/aws-crt-cpp-config.cmake:6 (find_dependency)
/path/to/aws-iot-device-sdk-cpp-v2/build/install/lib/cmake/AwsFindPackage.cmake:29 (find_package)
CMakeLists.txt:64 (aws_use_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- LibCrypto Include Dir: /usr/local/include
-- LibCrypto Shared Lib: /usr/local/lib/libcrypto.so
-- LibCrypto Static Lib: /usr/local/lib/libcrypto.a
-- DEP_AWS_LIBS: AWS::aws-crt-cpp.
-- Configuring done
-- Generating done
-- Build files have been written to: /path/to/MyApp/build
Which is similiar to what I see when I run cmake with MyApp as another Sample. Though, one difference is that I build the Dependencies, so IN_SOURCE_BUILD is set to ON. This doesn’t seem to matter. When I don’t set IN_SOURCE_BUILD and run make I get:
`CMakeFiles/My-App.dir/build.make:129: *** target pattern contains no `%'. Stop.
make[1]: *** [CMakeFiles/My-App.dir/all] Error 2
make: *** [all] Error 2
`
And when I look at the build.make file, AWS::aws-crt-cpp is NOT FOUND. When I run my cmake command with IN_SOURCE_BUILD set to ON, make returns:
/usr/bin/x86_64-linux-gnu-ld: cannot find -laws-crt-cpp
collect2: error: ld returned 1 exit status
make[2]: *** [My-App] Error 1
make[1]: *** [CMakeFiles/My-App.dir/all] Error 2
make: *** [all] Error 2
I have even tried manually including the specific library, but then is complains about missing all other dependency libraries. At this point, am reduced to including them by hand. This is not a good solution. Am I doing something wrong? Is there a problem?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 16 (7 by maintainers)
Commits related to this issue
- Pass github token to update script (#135) — committed to yourslab/aws-iot-device-sdk-cpp-v2 by deleted user 4 years ago
find_package(aws-iot-device-sdk-cpp-v2) doesn’t seem to work. Building and Installing aws-iot-device-sdk-cpp-v2 doesn’t install the required cmake script to use find_package
`By not providing “Findaws-iot-device-sdk-cpp-v2.cmake” in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by “aws-iot-device-sdk-cpp-v2”, but CMake did not find one.
Could not find a package configuration file provided by “aws-iot-device-sdk-cpp-v2” with any of the following names:
aws-iot-device-sdk-cpp-v2Config.cmake aws-iot-device-sdk-cpp-v2-config.cmake`
Did a
find . -name *aws-iot-device-sdk-cpp-v2*.cmakebut nothing found.
The samples follow a different cmake pattern than a consuming application would. For example, if you run cmake on aws-iot-device-SDK-v2 with BUILD_DEPS=ON, and install it to a predefined location, then use CMAKE_PREFIX_PATH when building your app, you’ll need to use find_package(aws-iot-device-sdk-cpp-v2) that should work. If you include it as a subdirectory (as the samples do), you don’t use find_package