| 1 |
#Copyright (c) Microsoft. All rights reserved. |
| 2 |
#Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| 3 |
|
| 4 |
cmake_minimum_required(VERSION 2.8.11) |
| 5 |
|
| 6 |
if(TARGET azure_macro_utils_c) |
| 7 |
return() |
| 8 |
endif() |
| 9 |
|
| 10 |
project(azure_macro_utils_c) |
| 11 |
|
| 12 |
set(AZURE_MACRO_UTILS_C_VERSION 1.1.0) |
| 13 |
|
| 14 |
option(run_int_tests "set run_int_tests to ON to run int tests (default is OFF)" OFF) |
| 15 |
|
| 16 |
#these are the include folders |
| 17 |
#the following "set" statement exports across the project a global variable called MACRO_UTILS_INC_FOLDER that expands to whatever needs to included when using macro_utils |
| 18 |
set(MACRO_UTILS_INC_FOLDER ${CMAKE_CURRENT_LIST_DIR}/inc CACHE INTERNAL "this is what needs to be included if using macro utils" FORCE) |
| 19 |
|
| 20 |
include(CTest) |
| 21 |
include(GNUInstallDirs) |
| 22 |
|
| 23 |
set(macro_utils_files |
| 24 |
inc/azure_macro_utils/macro_utils.h |
| 25 |
inc/azure_macro_utils/macro_utils_generated.h |
| 26 |
) |
| 27 |
|
| 28 |
install(FILES ${macro_utils_files} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/azure_macro_utils") |
| 29 |
|
| 30 |
if("${CMAKE_VERSION}" VERSION_GREATER 3.0.0) |
| 31 |
add_library(azure_macro_utils_c INTERFACE) |
| 32 |
target_include_directories(azure_macro_utils_c |
| 33 |
INTERFACE |
| 34 |
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/inc> |
| 35 |
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> |
| 36 |
) |
| 37 |
install(TARGETS azure_macro_utils_c EXPORT azure_macro_utils_cTargets |
| 38 |
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
| 39 |
) |
| 40 |
|
| 41 |
#Install azure_iot_sdks |
| 42 |
set(package_location "cmake") |
| 43 |
|
| 44 |
include(CMakePackageConfigHelpers) |
| 45 |
|
| 46 |
write_basic_package_version_file( |
| 47 |
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" |
| 48 |
VERSION ${AZURE_MACRO_UTILS_C_VERSION} |
| 49 |
COMPATIBILITY SameMajorVersion |
| 50 |
) |
| 51 |
|
| 52 |
configure_file("configs/${PROJECT_NAME}Config.cmake" |
| 53 |
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" |
| 54 |
COPYONLY |
| 55 |
) |
| 56 |
|
| 57 |
install(EXPORT azure_macro_utils_cTargets |
| 58 |
FILE |
| 59 |
"${PROJECT_NAME}Targets.cmake" |
| 60 |
DESTINATION |
| 61 |
${package_location} |
| 62 |
) |
| 63 |
|
| 64 |
install( |
| 65 |
FILES |
| 66 |
"configs/${PROJECT_NAME}Config.cmake" |
| 67 |
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" |
| 68 |
DESTINATION |
| 69 |
${package_location} |
| 70 |
) |
| 71 |
else() |
| 72 |
message(STATUS "This version of CMake does not support interface targets. Only the Azure Macro Utils header file will be installed. To use Azure Macro Utils, simply add \"MACRO_UTILS_INC_FOLDER\" to your include directories as specified in the instructions on the GitHub README.") |
| 73 |
endif() |
| 74 |
|
| 75 |
if(${run_int_tests}) |
| 76 |
add_subdirectory(tests) |
| 77 |
endif() |