|
| 1 | +# This file is generated |
| 2 | + |
| 3 | +cmake_minimum_required(VERSION 3.9...3.31) |
| 4 | + |
| 5 | +project(IotCommands-cpp LANGUAGES CXX VERSION ${SIMPLE_VERSION}) |
| 6 | + |
| 7 | +set(GENERATED_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") |
| 8 | +set(GENERATED_INCLUDE_DIR "${GENERATED_ROOT_DIR}/include") |
| 9 | +set(GENERATED_CONFIG_HEADER "${GENERATED_INCLUDE_DIR}/aws/iotcommands/Config.h") |
| 10 | +configure_file(include/aws/iotcommands/Config.h.in ${GENERATED_CONFIG_HEADER} @ONLY) |
| 11 | + |
| 12 | +if (NOT CMAKE_CXX_STANDARD) |
| 13 | + set(CMAKE_CXX_STANDARD 11) |
| 14 | +endif() |
| 15 | + |
| 16 | +file(GLOB AWS_IOTCOMMANDS_HEADERS |
| 17 | + "include/aws/iotcommands/*.h" |
| 18 | + ${GENERATED_CONFIG_HEADER} |
| 19 | +) |
| 20 | + |
| 21 | +file(GLOB AWS_IOTCOMMANDS_SRC |
| 22 | + "source/*.cpp" |
| 23 | +) |
| 24 | + |
| 25 | +file(GLOB AWS_IOTCOMMANDS_CPP_SRC |
| 26 | + ${AWS_IOTCOMMANDS_SRC} |
| 27 | +) |
| 28 | + |
| 29 | +if (WIN32) |
| 30 | + if (MSVC) |
| 31 | + source_group("Header Files\\aws\\iotcommands\\" FILES ${AWS_IOTCOMMANDS_HEADERS}) |
| 32 | + |
| 33 | + source_group("Source Files" FILES ${AWS_IOTCOMMANDS_SRC}) |
| 34 | + endif () |
| 35 | +endif() |
| 36 | + |
| 37 | +add_library(IotCommands-cpp ${AWS_IOTCOMMANDS_CPP_SRC}) |
| 38 | + |
| 39 | +set_target_properties(IotCommands-cpp PROPERTIES LINKER_LANGUAGE CXX) |
| 40 | + |
| 41 | +set(CMAKE_C_FLAGS_DEBUGOPT "") |
| 42 | + |
| 43 | +#set warnings |
| 44 | +if (MSVC) |
| 45 | + target_compile_options(IotCommands-cpp PRIVATE /W4 /WX) |
| 46 | +else () |
| 47 | + target_compile_options(IotCommands-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror) |
| 48 | +endif () |
| 49 | + |
| 50 | +target_compile_definitions(IotCommands-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>) |
| 51 | + |
| 52 | +if (BUILD_SHARED_LIBS) |
| 53 | + target_compile_definitions(IotCommands-cpp PUBLIC "-DAWS_IOTCOMMANDS_USE_IMPORT_EXPORT") |
| 54 | + target_compile_definitions(IotCommands-cpp PRIVATE "-DAWS_IOTCOMMANDS_EXPORTS") |
| 55 | + |
| 56 | + install(TARGETS IotCommands-cpp |
| 57 | + EXPORT IotCommands-cpp-targets |
| 58 | + ARCHIVE |
| 59 | + DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 60 | + COMPONENT Development |
| 61 | + LIBRARY |
| 62 | + DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 63 | + NAMELINK_SKIP |
| 64 | + COMPONENT Runtime |
| 65 | + RUNTIME |
| 66 | + DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 67 | + COMPONENT Runtime) |
| 68 | + |
| 69 | + install(TARGETS IotCommands-cpp |
| 70 | + EXPORT IotCommands-cpp-targets |
| 71 | + LIBRARY |
| 72 | + DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 73 | + NAMELINK_ONLY |
| 74 | + COMPONENT Development) |
| 75 | +else() |
| 76 | + install(TARGETS IotCommands-cpp |
| 77 | + EXPORT IotCommands-cpp-targets |
| 78 | + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 79 | + COMPONENT Development) |
| 80 | +endif() |
| 81 | + |
| 82 | +target_include_directories(IotCommands-cpp PUBLIC |
| 83 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 84 | + $<INSTALL_INTERFACE:include>) |
| 85 | + |
| 86 | +if (BUILD_DEPS) |
| 87 | + if (NOT IS_SUBDIRECTORY_INCLUDE) |
| 88 | + aws_use_package(aws-crt-cpp) |
| 89 | + endif() |
| 90 | +endif() |
| 91 | + |
| 92 | +aws_add_sanitizers(IotCommands-cpp) |
| 93 | +target_link_libraries(IotCommands-cpp PUBLIC ${DEP_AWS_LIBS}) |
| 94 | + |
| 95 | +install(FILES ${AWS_IOTCOMMANDS_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/iotcommands/" COMPONENT Development) |
| 96 | + |
| 97 | +if (BUILD_SHARED_LIBS) |
| 98 | + set(TARGET_DIR "shared") |
| 99 | +else() |
| 100 | + set(TARGET_DIR "static") |
| 101 | +endif() |
| 102 | + |
| 103 | +include(CMakePackageConfigHelpers) |
| 104 | +if (DEFINED SIMPLE_VERSION) |
| 105 | + write_basic_package_version_file( |
| 106 | + "${CMAKE_CURRENT_BINARY_DIR}/iotcommands-cpp-config-version.cmake" |
| 107 | + COMPATIBILITY SameMajorVersion |
| 108 | + ) |
| 109 | +endif() |
| 110 | + |
| 111 | +install(EXPORT "IotCommands-cpp-targets" |
| 112 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IotCommands-cpp/${TARGET_DIR}" |
| 113 | + NAMESPACE AWS:: |
| 114 | + COMPONENT Development) |
| 115 | + |
| 116 | +configure_file("cmake/iotcommands-cpp-config.cmake" |
| 117 | + "${CMAKE_CURRENT_BINARY_DIR}/iotcommands-cpp-config.cmake" |
| 118 | + @ONLY) |
| 119 | + |
| 120 | +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/iotcommands-cpp-config.cmake" |
| 121 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/IotCommands-cpp/" |
| 122 | + COMPONENT Development) |
| 123 | + |
| 124 | +if(NOT CMAKE_CROSSCOMPILING) |
| 125 | + if (BUILD_TESTING AND NOT BYO_CRYPTO) |
| 126 | + add_subdirectory(tests) |
| 127 | + endif() |
| 128 | +endif() |
0 commit comments