-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix build with samples on linux #3724
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
# Generic Service for Samples | ||
|
||
This is a helper library for samples that provides a generic service client library. | ||
|
||
## How to use | ||
|
||
Include the header from the CMake project using `target_include_directories`. For example, use | ||
|
||
```cmake | ||
# NOTE: Use shared-code only within .cpp files. DO NEVER consume the shared-code from header files. | ||
target_include_directories( | ||
cmake-target-name | ||
PRIVATE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../path/to/samples/inc> | ||
) | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,26 +8,46 @@ set(CMAKE_CXX_STANDARD 14) | |
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
add_executable(chained_token_credential_sample chained_token_credential.cpp) | ||
target_link_libraries(chained_token_credential_sample PRIVATE azure-identity service) | ||
target_link_libraries(chained_token_credential_sample PRIVATE azure-identity) | ||
target_include_directories(chained_token_credential_sample PRIVATE .) | ||
target_include_directories( | ||
chained_token_credential_sample PRIVATE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../../../samples/helpers/service/inc> | ||
) | ||
create_per_service_target_build_for_sample(identity chained_token_credential_sample) | ||
|
||
add_executable(client_certificate_credential_sample client_certificate_credential.cpp) | ||
target_link_libraries(client_certificate_credential_sample PRIVATE azure-identity service get-env-helper) | ||
target_link_libraries(client_certificate_credential_sample PRIVATE azure-identity get-env-helper) | ||
target_include_directories(client_certificate_credential_sample PRIVATE .) | ||
target_include_directories( | ||
client_certificate_credential_sample PRIVATE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../../../samples/helpers/service/inc> | ||
) | ||
create_per_service_target_build_for_sample(identity client_certificate_credential_sample) | ||
|
||
add_executable(client_secret_credential_sample client_secret_credential.cpp) | ||
target_link_libraries(client_secret_credential_sample PRIVATE azure-identity service get-env-helper) | ||
target_link_libraries(client_secret_credential_sample PRIVATE azure-identity get-env-helper) | ||
target_include_directories(client_secret_credential_sample PRIVATE .) | ||
target_include_directories( | ||
client_secret_credential_sample PRIVATE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../../../samples/helpers/service/inc> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of navigating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We decided not to do that for CMake files long time ago, as per Charlie's advice (since we were doing the C SDK) I remember because I used to set all re-usable strings from a CMake file in the top and then I would just use the variables everywhere. So, yeah, I am not against it, but I have been following that advise of keeping the duplication. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @barcharcraz can you please share some guidance and rationale for when and why we should avoid creating reusable string variables within CMake files? |
||
) | ||
create_per_service_target_build_for_sample(identity client_secret_credential_sample) | ||
|
||
add_executable(environment_credential_sample environment_credential.cpp) | ||
target_link_libraries(environment_credential_sample PRIVATE azure-identity service) | ||
target_link_libraries(environment_credential_sample PRIVATE azure-identity) | ||
target_include_directories(environment_credential_sample PRIVATE .) | ||
target_include_directories( | ||
environment_credential_sample PRIVATE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../../../samples/helpers/service/inc> | ||
) | ||
create_per_service_target_build_for_sample(identity environment_credential_sample) | ||
|
||
add_executable(managed_identity_credential_sample managed_identity_credential.cpp) | ||
target_link_libraries(managed_identity_credential_sample PRIVATE azure-identity service) | ||
target_link_libraries(managed_identity_credential_sample PRIVATE azure-identity) | ||
target_include_directories(managed_identity_credential_sample PRIVATE .) | ||
target_include_directories( | ||
managed_identity_credential_sample PRIVATE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../../../samples/helpers/service/inc> | ||
) | ||
create_per_service_target_build_for_sample(identity managed_identity_credential_sample) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to find the other way... Basically, what we have is header-only library, let's fix cmake so that it works on linux too. I would really like to avoid the
..\..\..
, and make it look like any other azure-sdk library. Even at a cost of it having a .cpp file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that
service
is supposed to be a placeholder forazure-anyservice
, I thikn it is better to add a .cpp file. We can make it anOBJECT
library similar toget-env
, consuming it is semantically the same as regular library, unlikeINTERFACE
library (http://www.mariobadr.com/creating-a-header-only-library-with-cmake.html#:~:text=Creating%20a%20Header-Only%20CMake%20Target%20Creating%20an%20interface,is%20not%20meant%20to%20generate%20any%20build%20output.).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vhvb1989, how about this? - #3728