Check for BUILD_TESTING and BUILD_SAMPLES inside Storage's cmakefiles (#1071)

This commit is contained in:
Anton Kolesnyk 2020-12-08 12:34:14 -08:00 committed by GitHub
parent 24c0e72601
commit d20d5eb139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 107 additions and 129 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()