Skip to content

Commit

Permalink
Use strict XCode build rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Sprowl authored and JetstreamRoySprowl committed Mar 14, 2018
1 parent 76e5700 commit 0fb7d2e
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ option(build_network_e2e "build network E2E tests" OFF)
option(use_prov_client "Enable provisioning client" OFF)
option(use_tpm_simulator "tpm simulator type of hsm used with the provisioning client" OFF)

message(STATUS "Provisioning client ${use_prov_client}")
if(XCODE AND ${use_prov_client})
# The TPM module is not available on Mac, and Mac's <string.h> and <unistd.h> files collide as well
message(FATAL_ERROR "Provisioning client is not supported on Mac")
endif()

if(WIN32 OR MACOSX)
option(use_openssl "set use_openssl to ON to use OpenSSL." OFF)
else()
Expand Down Expand Up @@ -257,7 +263,6 @@ if (${use_prov_client})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_PROV_MODULE")

add_subdirectory(provisioning_client)

if(${build_provisioning_service_client})
add_subdirectory(provisioning_service_client)
endif()
Expand Down
2 changes: 1 addition & 1 deletion c-utility
30 changes: 30 additions & 0 deletions configs/azure_iot_sdksFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,33 @@ function(add_longhaul_test_directory test_directory)
add_subdirectory(${test_directory})
endif()
endfunction()

# For targets which set warning switches as project properties (e.g. XCode)
function(setSdkTargetBuildProperties stbp_target)
if(XCODE)
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_COMMA "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_INFINITE_RECURSION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_NON_LITERAL_NULL_CONVERSION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_OBJC_LITERAL_CONVERSION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_OBJC_ROOT_CLASS "YES_ERROR")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_RANGE_LOOP_ANALYSIS "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_STRICT_PROTOTYPES "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_SUSPICIOUS_MOVE "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN_UNREACHABLE_CODE "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_CLANG_WARN__DUPLICATE_METHOD_MATCH "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_UNDECLARED_SELECTOR "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS "YES_AGGRESSIVE")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION "YES")
set_target_properties(${stbp_target} PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES")
endif()
endfunction()
2 changes: 1 addition & 1 deletion deps/uhttp
Submodule uhttp updated 2 files
+1 −0 CMakeLists.txt
+1 −1 deps/c-utility
12 changes: 12 additions & 0 deletions iothub_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ if(${use_http})
${iothub_client_http_transport_c_files}
${iothub_client_http_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_http_transport)
linkSharedUtil(iothub_client_http_transport)
set(iothub_client_libs
${iothub_client_libs}
Expand All @@ -289,6 +290,7 @@ if(${use_http})
${iothub_client_http_transport_c_files}
${iothub_client_http_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_http_transport_dll)
linkSharedUtil(iothub_client_http_transport_dll)

if ("${CMAKE_COMPILER_ID}" STREQUAL "GNU")
Expand Down Expand Up @@ -316,6 +318,7 @@ if(${use_amqp})
${iothub_client_amqp_transport_c_files}
${iothub_client_amqp_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_amqp_transport)
linkSharedUtil(iothub_client_amqp_transport)
set(iothub_client_libs
${iothub_client_libs}
Expand All @@ -327,6 +330,7 @@ if(${use_amqp})
${iothub_client_amqp_ws_transport_c_files}
${iothub_client_amqp_ws_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_amqp_ws_transport)
linkSharedUtil(iothub_client_amqp_ws_transport)
set(iothub_client_libs
${iothub_client_libs}
Expand All @@ -338,6 +342,7 @@ if(${use_amqp})
${iothub_client_amqp_transport_c_files}
${iothub_client_amqp_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_amqp_transport_dll)
linkSharedUtil(iothub_client_amqp_transport_dll)
target_link_libraries(iothub_client_amqp_transport_dll uamqp)

Expand All @@ -356,6 +361,7 @@ if(${use_amqp})
${iothub_client_amqp_ws_transport_c_files}
${iothub_client_amqp_ws_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_amqp_ws_transport_dll)
linkSharedUtil(iothub_client_amqp_ws_transport_dll)
target_link_libraries(iothub_client_amqp_transport_dll uamqp)

Expand All @@ -379,6 +385,7 @@ if(${use_mqtt})
${iothub_client_mqtt_transport_c_files}
${iothub_client_mqtt_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_mqtt_transport)
linkSharedUtil(iothub_client_mqtt_transport)
linkMqttLibrary(iothub_client_mqtt_transport)

Expand All @@ -391,6 +398,7 @@ if(${use_mqtt})
${iothub_client_mqtt_ws_transport_c_files}
${iothub_client_mqtt_ws_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_mqtt_ws_transport)
linkSharedUtil(iothub_client_mqtt_ws_transport)
linkMqttLibrary(iothub_client_mqtt_ws_transport)
set(iothub_client_libs
Expand All @@ -403,6 +411,7 @@ if(${use_mqtt})
${iothub_client_mqtt_transport_c_files}
${iothub_client_mqtt_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_mqtt_transport_dll)
linkSharedUtil(iothub_client_mqtt_transport_dll)

# if ("${CMAKE_COMPILER_ID}" STREQUAL "GNU")
Expand All @@ -426,6 +435,7 @@ if(${use_mqtt})
${iothub_client_mqtt_ws_transport_c_files}
${iothub_client_mqtt_ws_transport_h_files}
)
setSdkTargetBuildProperties(iothub_client_mqtt_ws_transport_dll)
linkSharedUtil(iothub_client_mqtt_ws_transport_dll)

# if ("${CMAKE_COMPILER_ID}" STREQUAL "GNU")
Expand Down Expand Up @@ -467,6 +477,7 @@ if (${build_as_dynamic})
${iothub_client_h_files}
${iothub_def_file}
)
setSdkTargetBuildProperties(iothub_client_dll)
target_link_libraries(iothub_client_dll ${iothub_client_libs})
if(NOT WIN32)
set_target_properties(iothub_client_dll PROPERTIES OUTPUT_NAME "iothub_client")
Expand Down Expand Up @@ -494,6 +505,7 @@ add_library(iothub_client
${iothub_client_c_files}
${iothub_client_h_files}
)
setSdkTargetBuildProperties(iothub_client)
target_link_libraries(iothub_client ${iothub_client_libs})

if (${use_prov_client})
Expand Down
1 change: 1 addition & 0 deletions iothub_service_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ if (${build_as_dynamic})
else()
add_library(iothub_service_client ${iothub_service_client_c_files} ${iothub_service_client_h_files})
endif()
setSdkTargetBuildProperties(iothub_service_client)

if(NOT ${nuget_e2e_tests})
target_link_libraries(iothub_service_client uamqp parson)
Expand Down
9 changes: 9 additions & 0 deletions provisioning_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,29 @@ if(WIN32)
ENDIF(WIN32)

add_library(hsm_security_client ${HSM_CLIENT_C_FILES} ${HSM_CLIENT_H_FILES})
setSdkTargetBuildProperties(hsm_security_client)
linkSharedUtil(hsm_security_client)
target_link_libraries(hsm_security_client ${HSM_CLIENT_LIBRARY})
set(provisioning_libs ${provisioning_libs} hsm_security_client)
set(provisioning_headers ${provisioning_headers} ${HSM_CLIENT_H_FILES})


add_library(prov_auth_client ${AUTH_CLIENT_C_FILES} ${AUTH_CLIENT_H_FILES})
setSdkTargetBuildProperties(prov_auth_client)
linkSharedUtil(prov_auth_client)
target_link_libraries(prov_auth_client hsm_security_client)
set(provisioning_libs ${provisioning_libs} prov_auth_client)
set(provisioning_headers ${provisioning_headers} ${AUTH_CLIENT_H_FILES})

add_library(prov_device_ll_client ${PROV_DEVICE_LL_CLIENT_SOURCE_C_FILES} ${PROV_DEVICE_LL_CLEINT_SOURCE_H_FILES})
setSdkTargetBuildProperties(prov_device_ll_client)
linkSharedUtil(prov_device_ll_client)
link_security_client(prov_device_ll_client)
set(provisioning_libs ${provisioning_libs} prov_device_ll_client)
set(provisioning_headers ${provisioning_headers} ${PROV_DEVICE_LL_CLEINT_SOURCE_H_FILES})

add_library(prov_device_client ${PROV_DEVICE_CLIENT_SOURCE_C_FILES} ${PROV_DEVICE_CLIENT_SOURCE_H_FILES})
setSdkTargetBuildProperties(prov_device_client)
target_link_libraries(prov_device_client prov_device_ll_client)
set(provisioning_libs ${provisioning_libs} prov_device_client)
set(provisioning_headers ${provisioning_headers} ${PROV_DEVICE_CLIENT_SOURCE_H_FILES})
Expand All @@ -177,6 +181,7 @@ if (${use_http})

# Provisioning http Transport Client library
add_library(prov_http_transport ${PROV_HTTP_CLIENT_C_FILES} ${PROV_HTTP_CLIENT_H_FILES})
setSdkTargetBuildProperties(prov_http_transport)
linkSharedUtil(prov_http_transport)
set(provisioning_libs ${provisioning_libs} prov_http_transport)
set(provisioning_headers ${provisioning_headers} ${PROV_HTTP_CLIENT_H_FILES})
Expand Down Expand Up @@ -208,13 +213,15 @@ if (${use_amqp})
./src/prov_sasl_tpm.c)

add_library(prov_amqp_ws_transport ${PROV_AMQP_WS_CLIENT_C_FILES} ${PROV_AMQP_WS_CLIENT_H_FILES})
setSdkTargetBuildProperties(prov_amqp_ws_transport)
linkSharedUtil(prov_amqp_ws_transport)
target_link_libraries(prov_amqp_ws_transport uamqp)
set(provisioning_libs ${provisioning_libs} prov_amqp_ws_transport)
set(provisioning_headers ${provisioning_headers} ${PROV_AMQP_WS_CLIENT_H_FILES})

# Provisioning amqp Transport Client library
add_library(prov_amqp_transport ${PROV_AMQP_CLIENT_C_FILES} ${PROV_AMQP_CLIENT_H_FILES})
setSdkTargetBuildProperties(prov_amqp_transport)
linkSharedUtil(prov_amqp_transport)
target_link_libraries(prov_amqp_transport uamqp)
set(provisioning_libs ${provisioning_libs} prov_amqp_transport)
Expand All @@ -241,13 +248,15 @@ if (${use_mqtt})
./src/prov_transport_mqtt_common.c)

add_library(prov_mqtt_ws_transport ${PROV_MQTT_WS_CLIENT_C_FILES} ${PROV_MQTT_WS_CLIENT_H_FILES})
setSdkTargetBuildProperties(prov_mqtt_ws_transport)
linkSharedUtil(prov_mqtt_ws_transport)
target_link_libraries(prov_mqtt_ws_transport umqtt)
set(provisioning_libs ${provisioning_libs} prov_mqtt_ws_transport)
set(provisioning_headers ${provisioning_headers} ${PROV_MQTT_WS_CLIENT_H_FILES})

# Provisioning mqtt Transport Client library
add_library(prov_mqtt_transport ${PROV_MQTT_CLIENT_C_FILES} ${PROV_MQTT_CLIENT_H_FILES})
setSdkTargetBuildProperties(prov_mqtt_transport)
linkSharedUtil(prov_mqtt_transport)
target_link_libraries(prov_mqtt_transport umqtt)
set(provisioning_libs ${provisioning_libs} prov_mqtt_transport)
Expand Down
2 changes: 1 addition & 1 deletion provisioning_client/deps/utpm
Submodule utpm updated 1 files
+1 −1 deps/c-utility
2 changes: 2 additions & 0 deletions provisioning_client/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

cmake_minimum_required(VERSION 2.8.12)

usePermissiveRulesForSdkSamplesAndTests()

#add_unittest_directory(dps_sec_client_ut)
add_unittest_directory(prov_transport_http_client_ut)

Expand Down
1 change: 1 addition & 0 deletions serializer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ else()
serializer ${serializer_c_files} ${serializer_h_files}
)
endif()
setSdkTargetBuildProperties(serializer)

target_link_libraries(serializer
parson
Expand Down
2 changes: 1 addition & 1 deletion uamqp
2 changes: 1 addition & 1 deletion umqtt
Submodule umqtt updated 2 files
+1 −0 CMakeLists.txt
+1 −1 deps/c-utility

0 comments on commit 0fb7d2e

Please sign in to comment.