Skip to content
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 Windows shared library build for CMake #47621

Merged
merged 4 commits into from Apr 8, 2021

Conversation

xandox
Copy link
Contributor

@xandox xandox commented Mar 7, 2021

MSVC build support with CMake

@google-ml-butler google-ml-butler bot added the size:M CL Change Size: Medium label Mar 7, 2021
@google-cla
Copy link

google-cla bot commented Mar 7, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Mar 7, 2021
@xandox
Copy link
Contributor Author

xandox commented Mar 7, 2021

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Mar 7, 2021
@gbaned gbaned self-assigned this Mar 8, 2021
@gbaned gbaned added the comp:lite TF Lite related issues label Mar 8, 2021
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Mar 8, 2021
@gbaned gbaned requested a review from terryheo March 8, 2021 05:40
tensorflow/lite/CMakeLists.txt Outdated Show resolved Hide resolved
@@ -415,6 +415,11 @@ target_link_libraries(tensorflow-lite
ruy
${TFLITE_TARGET_DEPENDENCIES}
)

if (BUILD_SHARED_LIBS)
list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "TFL_SHARED_LIBRARY_BUILD")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already use TFL_COMPILE_LIBRARY to build windows dll.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFL_COMPILE_LIBRARY switch between dllexport and dllimport. Neither could be applied if static library build

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when BUILD_SHARED_LIBS is used, what's the expected definition of TFL_CAPI_EXPORT?
Do we still need to check TFL_COMPILE_LIBRARY?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. TFL_CAPI_EXPORT resolves to dllexport if TFL_COMPILE_LIBRARY otherwise to dllimport.

tensorflow/lite/delegates/gpu/delegate.cc Show resolved Hide resolved
tensorflow/lite/delegates/gpu/delegate.cc Show resolved Hide resolved
@terryheo
Copy link
Member

terryheo commented Mar 8, 2021

Could you also provide cmake commands you used? Is there anything special?

@xandox
Copy link
Contributor Author

xandox commented Mar 8, 2021

I use lite through add_subdirectory. There are not something special for cmake.

@xandox xandox requested a review from terryheo March 9, 2021 10:47
@gbaned gbaned added the awaiting review Pull request awaiting review label Mar 19, 2021
@terryheo terryheo changed the title windows build Fix Windows shared library build for CMake Mar 22, 2021
@tensorflowbutler tensorflowbutler removed the awaiting review Pull request awaiting review label Mar 24, 2021
@@ -30,6 +30,9 @@ extern "C" {
#ifdef SWIG
#define TFL_CAPI_EXPORT
#else
#ifdef TFL_STATIC_LIBRARY_BUILD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to use #elif defined()

tensorflow/lite/c/c_api_types.h Show resolved Hide resolved
tensorflow/lite/c/c_api_types.h Outdated Show resolved Hide resolved
Copy link
Member

@terryheo terryheo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Apr 1, 2021
PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer Apr 1, 2021
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Apr 1, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Apr 1, 2021
@gbaned gbaned requested a review from terryheo April 1, 2021 14:54
@gbaned gbaned added the awaiting review Pull request awaiting review label Apr 5, 2021
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Apr 7, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Apr 7, 2021
@gbaned gbaned removed the awaiting review Pull request awaiting review label Apr 7, 2021
@copybara-service copybara-service bot merged commit 7065497 into tensorflow:master Apr 8, 2021
PR Queue automation moved this from Approved by Reviewer to Merged Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:lite TF Lite related issues ready to pull PR ready for merge process size:M CL Change Size: Medium
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

5 participants