2019-09-25 01:21:12 +03:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2020-03-10 23:54:43 +03:00
|
|
|
cmake_minimum_required (VERSION 3.10)
|
2019-10-10 03:27:16 +03:00
|
|
|
|
2020-04-30 01:26:50 +03:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules")
|
2020-02-28 02:59:10 +03:00
|
|
|
|
2019-12-14 09:10:47 +03:00
|
|
|
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON)
|
2020-05-13 01:03:45 +03:00
|
|
|
option(TRANSPORT_CURL "Build internal http transport implementation with CURL for HTTP Pipeline" OFF)
|
2020-02-28 02:59:10 +03:00
|
|
|
option(UNIT_TESTING "Build unit test projects" OFF)
|
2020-05-13 01:03:45 +03:00
|
|
|
option(UNIT_TESTING_MOCKS "wrap PAL functions with mock implementation for tests" OFF)
|
2020-05-13 01:58:31 +03:00
|
|
|
option(TRANSPORT_PAHO "Build IoT Samples with Paho MQTT support" OFF)
|
2020-05-13 01:03:45 +03:00
|
|
|
option(PRECONDITIONS "Build SDK with preconditions enabled" ON)
|
2020-04-16 01:05:30 +03:00
|
|
|
|
2020-04-30 19:40:03 +03:00
|
|
|
# disable preconditions when it's set to OFF
|
2020-05-13 01:03:45 +03:00
|
|
|
if (NOT PRECONDITIONS)
|
2020-04-30 07:19:11 +03:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DAZ_NO_PRECONDITION_CHECKING")
|
2020-04-16 01:05:30 +03:00
|
|
|
endif()
|
2020-03-12 22:04:19 +03:00
|
|
|
|
2020-04-30 19:40:03 +03:00
|
|
|
# enable mock functions with link option -ld
|
2020-05-13 01:03:45 +03:00
|
|
|
if(UNIT_TESTING_MOCKS)
|
2020-04-30 07:19:11 +03:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_az_MOCK_ENABLED")
|
2020-03-12 22:04:19 +03:00
|
|
|
endif()
|
2019-12-14 09:10:47 +03:00
|
|
|
|
2019-10-10 03:27:16 +03:00
|
|
|
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|
|
|
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
|
|
|
CACHE STRING "")
|
|
|
|
elseif(DEFINED ENV{VCPKG_INSTALLATION_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|
|
|
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
|
|
|
CACHE STRING "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
|
|
|
|
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "")
|
|
|
|
endif()
|
|
|
|
|
2019-09-20 21:40:56 +03:00
|
|
|
project(az LANGUAGES C)
|
2019-09-25 01:21:12 +03:00
|
|
|
enable_testing ()
|
2020-01-17 03:47:19 +03:00
|
|
|
|
|
|
|
include(eng/cmake/global_compile_options.txt)
|
|
|
|
|
2020-04-03 03:10:20 +03:00
|
|
|
# List of projects that generate coverage
|
|
|
|
# This write empty makes sure that if file is already there, we replace it for an empty one
|
|
|
|
# Then each project will APPEND to this file
|
|
|
|
# At the end of cmake generate, this file will list the targets for code cov
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/coverage_targets.txt "")
|
|
|
|
|
2019-09-20 21:40:56 +03:00
|
|
|
add_subdirectory(sdk/core/core)
|
2020-02-22 22:47:17 +03:00
|
|
|
|
|
|
|
add_subdirectory(sdk/platform/http_client/nohttp)
|
2020-02-26 01:44:29 +03:00
|
|
|
# Adding transport implementation for curl
|
2020-04-10 01:29:12 +03:00
|
|
|
# Users can still build Core and SDK client without depending on a HTTP transport implementation
|
2020-05-13 01:03:45 +03:00
|
|
|
if(TRANSPORT_CURL)
|
2020-02-22 22:47:17 +03:00
|
|
|
add_subdirectory(sdk/platform/http_client/curl)
|
2020-02-20 02:56:10 +03:00
|
|
|
endif()
|
|
|
|
|
2020-02-26 01:44:29 +03:00
|
|
|
# SDK Clients and tests
|
|
|
|
add_subdirectory(sdk/storage/blobs)
|
2020-05-05 01:01:16 +03:00
|
|
|
add_subdirectory(sdk/iot/common)
|
2020-03-24 00:15:00 +03:00
|
|
|
add_subdirectory(sdk/iot/hub)
|
|
|
|
add_subdirectory(sdk/iot/provisioning)
|
2020-02-26 01:44:29 +03:00
|
|
|
|
|
|
|
# PAL
|
2020-02-22 22:47:17 +03:00
|
|
|
add_subdirectory(sdk/platform/noplatform)
|
|
|
|
add_subdirectory(sdk/platform/posix)
|
|
|
|
add_subdirectory(sdk/platform/win32)
|
2020-02-13 22:42:12 +03:00
|
|
|
|
2020-02-26 01:44:29 +03:00
|
|
|
# User can disable samples generation by setting env variable AZ_SDK_C_NO_SAMPLES
|
2020-02-13 22:42:12 +03:00
|
|
|
if(NOT DEFINED ENV{AZ_SDK_C_NO_SAMPLES})
|
2020-03-10 21:44:11 +03:00
|
|
|
add_subdirectory(sdk/samples/keyvault/keyvault)
|
|
|
|
add_subdirectory(sdk/samples/keyvault/keyvault/samples)
|
2020-02-26 01:44:29 +03:00
|
|
|
add_subdirectory(sdk/storage/blobs/samples)
|
2020-05-13 01:58:31 +03:00
|
|
|
if(TRANSPORT_PAHO)
|
2020-04-10 01:29:12 +03:00
|
|
|
add_subdirectory(sdk/iot/provisioning/samples)
|
2020-05-02 04:01:29 +03:00
|
|
|
add_subdirectory(sdk/iot/hub/samples)
|
2020-04-10 01:29:12 +03:00
|
|
|
endif()
|
2020-02-13 22:42:12 +03:00
|
|
|
endif()
|
2020-02-26 02:48:50 +03:00
|
|
|
|
2020-02-28 02:59:10 +03:00
|
|
|
# default for Unit testing with cmocka is OFF, however, this will be ON on CI and tests must
|
2020-04-30 01:26:50 +03:00
|
|
|
# pass before commiting changes
|
2020-02-28 02:59:10 +03:00
|
|
|
if (UNIT_TESTING)
|
|
|
|
add_subdirectory(sdk/core/core/test/cmocka)
|
2020-02-29 02:46:46 +03:00
|
|
|
add_subdirectory(sdk/storage/blobs/test/cmocka)
|
2020-05-05 01:01:16 +03:00
|
|
|
add_subdirectory(sdk/iot/common/tests/cmocka)
|
2020-03-24 00:15:00 +03:00
|
|
|
add_subdirectory(sdk/iot/hub/tests/cmocka)
|
|
|
|
add_subdirectory(sdk/iot/provisioning/tests/cmocka)
|
2020-03-10 21:44:11 +03:00
|
|
|
|
|
|
|
if(NOT DEFINED ENV{AZ_SDK_C_NO_SAMPLES})
|
|
|
|
add_subdirectory(sdk/samples/keyvault/keyvault/test/cmocka)
|
|
|
|
endif()
|
2020-02-28 02:59:10 +03:00
|
|
|
endif()
|