0

Trying to build samples/mqtt/basic_pub_sub sample from aws-iot-device-sdk-cpp-v2 which contains CMakeList.txt:

cmake_minimum_required(VERSION 3.1)
# note: cxx-17 requires cmake 3.8, cxx-20 requires cmake 3.12
project(basic-pub-sub CXX)

file(GLOB SRC_FILES
       "*.cpp"
)

add_executable(${PROJECT_NAME} ${SRC_FILES})

set_target_properties(${PROJECT_NAME} PROPERTIES
    CXX_STANDARD 14)

#set warnings
if (MSVC)
    target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX /wd4068)
else ()
    target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

find_package(aws-crt-cpp REQUIRED)

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

Trying to build: mkdir build cd build cmake ..

Got errro:

-- The CXX compiler identification is GNU 9.3.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 Error at CMakeLists.txt:21 (find_package):
  By not providing "Findaws-crt-cpp.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "aws-crt-cpp", but CMake did not find one.

  Could not find a package configuration file provided by "aws-crt-cpp" with
  any of the following names:

    aws-crt-cppConfig.cmake
    aws-crt-cpp-config.cmake

  Add the installation prefix of "aws-crt-cpp" to CMAKE_PREFIX_PATH or set
  "aws-crt-cpp_DIR" to a directory containing one of the above files.  If
  "aws-crt-cpp" provides a separate development package or SDK, be sure it
  has been installed.


-- Configuring incomplete, errors occurred!

I found aws-crt-cpp-config.cmake if folder home\a\cpp_projects\sdk-cpp-workspace\lib\aws-crt-cpp\cmake

But how to tell about it to CMake?

vico
  • 17,051
  • 45
  • 159
  • 315
  • 1
    as suggested in the error message set [`CMAKE_MODULE_PATH`](https://cmake.org/cmake/help/latest/variable/CMAKE_MODULE_PATH.html) – Alan Birtles Feb 20 '22 at 11:12
  • You can see [this question](https://stackoverflow.com/questions/28507214/how-to-force-c-compiler-use-one-of-different-installed-packages-versions-usi). Just add PATH to find_package. – GAVD Feb 20 '22 at 11:47

0 Answers0