diff --git a/sdk/storage/CMakeLists.txt b/sdk/storage/CMakeLists.txt index 06cbca670..9df7b70d4 100644 --- a/sdk/storage/CMakeLists.txt +++ b/sdk/storage/CMakeLists.txt @@ -10,23 +10,15 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) option(BUILD_STORAGE_SAMPLES "Build storage sample codes" ON) -add_executable(azure-storage-test) if(BUILD_TESTING) - set_target_properties(azure-storage-test PROPERTIES EXCLUDE_FROM_ALL FALSE) - add_gtest(azure-storage-test) -else() - set_target_properties(azure-storage-test PROPERTIES EXCLUDE_FROM_ALL TRUE) + add_executable(azure-storage-test) + add_gtest(azure-storage-test) endif() - -add_executable(azure-storage-sample) if(BUILD_STORAGE_SAMPLES) - set_target_properties(azure-storage-sample PROPERTIES EXCLUDE_FROM_ALL FALSE) -else() - set_target_properties(azure-storage-sample PROPERTIES EXCLUDE_FROM_ALL TRUE) + add_executable(azure-storage-sample) endif() - add_subdirectory(azure-storage-common) add_subdirectory(azure-storage-blobs) add_subdirectory(azure-storage-files-datalake) diff --git a/sdk/storage/azure-storage-blobs/CMakeLists.txt b/sdk/storage/azure-storage-blobs/CMakeLists.txt index c410b5916..09cc1c594 100644 --- a/sdk/storage/azure-storage-blobs/CMakeLists.txt +++ b/sdk/storage/azure-storage-blobs/CMakeLists.txt @@ -30,9 +30,6 @@ set (AZURE_STORAGE_BLOB_SOURCE src/page_blob_client.cpp ) -# CodeCoverage will validate requirements -include(CodeCoverage) - add_library(azure-storage-blobs ${AZURE_STORAGE_BLOB_HEADER} ${AZURE_STORAGE_BLOB_SOURCE}) target_include_directories(azure-storage-blobs PUBLIC inc) target_link_libraries(azure-storage-blobs azure::storage::common) @@ -40,34 +37,32 @@ target_link_libraries(azure-storage-blobs azure::storage::common) get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/blobs/version.hpp") add_library(azure::storage::blobs ALIAS azure-storage-blobs) +generate_documentation(azure-storage-blobs ${AZ_LIBRARY_VERSION}) + +# CodeCoverage will validate requirements +include(CodeCoverage) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF create_code_coverage(storage azure-storage-blobs azure-storage-test) -target_sources( +if(BUILD_TESTING) + target_sources( azure-storage-test - PRIVATE - test/append_blob_client_test.cpp - test/append_blob_client_test.hpp - test/blob_batch_client_test.cpp - test/blob_container_client_test.cpp - test/blob_container_client_test.hpp - test/blob_sas_test.cpp - test/blob_service_client_test.cpp - test/block_blob_client_test.cpp - test/block_blob_client_test.hpp - test/page_blob_client_test.cpp - test/page_blob_client_test.hpp - test/storage_retry_policy_test.cpp -) + PRIVATE + test/append_blob_client_test.cpp + test/blob_batch_client_test.cpp + test/blob_container_client_test.cpp + test/blob_sas_test.cpp + test/blob_service_client_test.cpp + test/block_blob_client_test.cpp + test/page_blob_client_test.cpp + test/storage_retry_policy_test.cpp + ) -target_link_libraries(azure-storage-test PUBLIC azure::storage::blobs) + target_link_libraries(azure-storage-test PRIVATE azure-storage-blobs) +endif() - -target_sources( - azure-storage-sample - PRIVATE - sample/blob_getting_started.cpp -) -target_link_libraries(azure-storage-sample PUBLIC azure::storage::blobs) - -generate_documentation(azure-storage-blobs ${AZ_LIBRARY_VERSION}) +if(BUILD_STORAGE_SAMPLES) + target_sources(azure-storage-sample PRIVATE sample/blob_getting_started.cpp) + target_link_libraries(azure-storage-sample PRIVATE azure-storage-blobs) +endif() diff --git a/sdk/storage/azure-storage-common/CMakeLists.txt b/sdk/storage/azure-storage-common/CMakeLists.txt index 04a63b43d..96549ff02 100644 --- a/sdk/storage/azure-storage-common/CMakeLists.txt +++ b/sdk/storage/azure-storage-common/CMakeLists.txt @@ -35,9 +35,6 @@ set(AZURE_STORAGE_COMMON_SOURCE src/xml_wrapper.cpp ) -# CodeCoverage will validate requirements -include(CodeCoverage) - add_library(azure-storage-common ${AZURE_STORAGE_COMMON_HEADER} ${AZURE_STORAGE_COMMON_SOURCE}) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) @@ -56,38 +53,44 @@ else() target_link_libraries(azure-storage-common OpenSSL::SSL OpenSSL::Crypto) endif() +get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/common/version.hpp") +add_library(azure::storage::common ALIAS azure-storage-common) + +generate_documentation(azure-storage-common ${AZ_LIBRARY_VERSION}) + +# CodeCoverage will validate requirements +include(CodeCoverage) + # coverage. Has no effect if BUILD_CODE_COVERAGE is OFF # excluding json from coverage report create_code_coverage(storage azure-storage-common azure-storage-test "inc/azure/storage/common/json*") -get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/common/version.hpp") -add_library(azure::storage::common ALIAS azure-storage-common) - - -target_sources( +if(BUILD_TESTING) + target_sources( azure-storage-test - PRIVATE - test/bearer_token_test.cpp - test/crypt_functions_test.cpp - test/metadata_test.cpp - test/storage_credential_test.cpp - test/test_base.cpp - test/test_base.hpp -) + PRIVATE + test/bearer_token_test.cpp + test/crypt_functions_test.cpp + test/metadata_test.cpp + test/storage_credential_test.cpp + test/test_base.cpp + ) -target_include_directories(azure-storage-test PUBLIC test) -if (MSVC) + if (MSVC) target_compile_options(azure-storage-test PUBLIC /wd6326 /wd26495 /wd26812) + endif() + + target_link_libraries(azure-storage-test PRIVATE azure-identity) + target_include_directories(azure-storage-test PRIVATE test) endif() - -target_sources( +if(BUILD_STORAGE_SAMPLES) + target_sources( azure-storage-sample - PRIVATE - sample/main.cpp - sample/samples_common.hpp -) + PRIVATE + sample/main.cpp + sample/samples_common.hpp + ) -target_include_directories(azure-storage-sample PUBLIC sample) - -generate_documentation(azure-storage-common ${AZ_LIBRARY_VERSION}) + target_include_directories(azure-storage-sample PRIVATE sample) +endif() diff --git a/sdk/storage/azure-storage-files-datalake/CMakeLists.txt b/sdk/storage/azure-storage-files-datalake/CMakeLists.txt index 511d5f461..13eca6169 100644 --- a/sdk/storage/azure-storage-files-datalake/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-datalake/CMakeLists.txt @@ -29,44 +29,37 @@ set (AZURE_STORAGE_DATALAKE_SOURCE src/datalake_utilities.cpp ) -# CodeCoverage will validate requirements -include(CodeCoverage) - add_library(azure-storage-files-datalake ${AZURE_STORAGE_DATALAKE_HEADER} ${AZURE_STORAGE_DATALAKE_SOURCE}) target_include_directories(azure-storage-files-datalake PUBLIC inc) target_link_libraries(azure-storage-files-datalake azure-storage-blobs) -# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF -create_code_coverage(storage azure-storage-files-datalake azure-storage-test) - get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/files/datalake/version.hpp") add_library(azure::storage::files::datalake ALIAS azure-storage-files-datalake) - -target_sources( - azure-storage-test - PRIVATE - test/datalake_directory_client_test.cpp - test/datalake_directory_client_test.hpp - test/datalake_file_client_test.cpp - test/datalake_file_client_test.hpp - test/datalake_file_system_client_test.cpp - test/datalake_file_system_client_test.hpp - test/datalake_path_client_test.cpp - test/datalake_path_client_test.hpp - test/datalake_sas_test.cpp - test/datalake_service_client_test.cpp - test/datalake_service_client_test.hpp -) - -target_link_libraries(azure-storage-test PUBLIC azure::storage::files::datalake) - - -target_sources( - azure-storage-sample - PRIVATE - sample/datalake_getting_started.cpp -) -target_link_libraries(azure-storage-sample PUBLIC azure::storage::files::datalake) - generate_documentation(azure-storage-files-datalake ${AZ_LIBRARY_VERSION}) + +# CodeCoverage will validate requirements +include(CodeCoverage) + +# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF +create_code_coverage(storage azure-storage-files-datalake azure-storage-test) + +if(BUILD_TESTING) + target_sources( + azure-storage-test + PRIVATE + test/datalake_directory_client_test.cpp + test/datalake_file_client_test.cpp + test/datalake_file_system_client_test.cpp + test/datalake_path_client_test.cpp + test/datalake_sas_test.cpp + test/datalake_service_client_test.cpp + ) + + target_link_libraries(azure-storage-test PRIVATE azure-storage-files-datalake) +endif() + +if(BUILD_STORAGE_SAMPLES) + target_sources(azure-storage-sample PRIVATE sample/datalake_getting_started.cpp) + target_link_libraries(azure-storage-sample PRIVATE azure-storage-files-datalake) +endif() diff --git a/sdk/storage/azure-storage-files-shares/CMakeLists.txt b/sdk/storage/azure-storage-files-shares/CMakeLists.txt index 91c5e8838..6185f096e 100644 --- a/sdk/storage/azure-storage-files-shares/CMakeLists.txt +++ b/sdk/storage/azure-storage-files-shares/CMakeLists.txt @@ -26,41 +26,36 @@ set (AZURE_STORAGE_SHARES_SOURCE src/share_service_client.cpp ) -# CodeCoverage will validate requirements -include(CodeCoverage) - add_library(azure-storage-files-shares ${AZURE_STORAGE_SHARES_HEADER} ${AZURE_STORAGE_SHARES_SOURCE}) target_include_directories(azure-storage-files-shares PUBLIC inc) target_link_libraries(azure-storage-files-shares azure-storage-common) -# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF -create_code_coverage(storage azure-storage-files-shares azure-storage-test) - get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/inc/azure/storage/files/shares/version.hpp") add_library(azure::storage::files::shares ALIAS azure-storage-files-shares) - -target_sources( - azure-storage-test - PRIVATE - test/share_client_test.cpp - test/share_client_test.hpp - test/share_directory_client_test.cpp - test/share_directory_client_test.hpp - test/share_file_client_test.cpp - test/share_file_client_test.hpp - test/share_sas_test.cpp - test/share_service_client_test.cpp - test/share_service_client_test.hpp -) -target_link_libraries(azure-storage-test PUBLIC azure::storage::files::shares) - - -target_sources( - azure-storage-sample - PRIVATE - sample/file_share_getting_started.cpp -) -target_link_libraries(azure-storage-sample PUBLIC azure::storage::files::shares) - generate_documentation(azure-storage-files-shares ${AZ_LIBRARY_VERSION}) + +# CodeCoverage will validate requirements +include(CodeCoverage) + +# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF +create_code_coverage(storage azure-storage-files-shares azure-storage-test) + +if(BUILD_TESTING) + target_sources( + azure-storage-test + PRIVATE + test/share_client_test.cpp + test/share_directory_client_test.cpp + test/share_file_client_test.cpp + test/share_sas_test.cpp + test/share_service_client_test.cpp + ) + + target_link_libraries(azure-storage-test PRIVATE azure-storage-files-shares) +endif() + +if(BUILD_STORAGE_SAMPLES) + target_sources(azure-storage-sample PRIVATE sample/file_share_getting_started.cpp) + target_link_libraries(azure-storage-sample PRIVATE azure-storage-files-shares) +endif()