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

[Confusion] about ${PROJECT_NAME}_BUILD_SHARED_LIBS #26

Closed
Kiddinglife opened this issue Aug 19, 2021 · 1 comment
Closed

[Confusion] about ${PROJECT_NAME}_BUILD_SHARED_LIBS #26

Kiddinglife opened this issue Aug 19, 2021 · 1 comment
Assignees
Labels
acknowledged The issue is being worked on bug Something isn't working fixed Bug has been fixed and the fix tested question Further information is requested

Comments

@Kiddinglife
Copy link

Kiddinglife commented Aug 19, 2021

Describe the confusion
I am confused about the below cmake snippets in StandardSettings.cmake:

# Export all symbols when building a shared library
if(${PROJECT_NAME}_BUILD_SHARED_LIBS)
    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
    set(CMAKE_CXX_VISIBILITY_PRESET hidden)
    set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()

As cmake tool will build all the libraries as shared library when BUILD_SHARED_LIBS is ON, my understnading is that we should overwrite the cmake built-in cache variable of BUILD_SHARED_LIBS when ${PROJECT_NAME}_BUILD_SHARED_LIBS is ON. Something looks like this:

# Export all symbols when building a shared library
if(${PROJECT_NAME}_BUILD_SHARED_LIBS)
    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
    set(CMAKE_CXX_VISIBILITY_PRESET hidden)
    set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
    set(BUILD_SHARED_LIBS ON CACHE BOOL "build shared libraries except when explicitely set to static" FORCE)
endif()

Let me know what you think it.

Expected behavior
Overwrite the cmake built-in cache variable of BUILD_SHARED_LIBS when ${PROJECT_NAME}_BUILD_SHARED_LIBS is ON

Desktop (please complete the following information):

  • OS: Windows
  • Version 10
  • Editor: vscode
@filipdutescu filipdutescu self-assigned this Aug 20, 2021
@filipdutescu filipdutescu added acknowledged The issue is being worked on question Further information is requested labels Aug 20, 2021
@filipdutescu
Copy link
Owner

Honestly, I think I should remove the custom macro and just keep the default one, since there is no reason not to. Good catch!

filipdutescu added a commit that referenced this issue Aug 20, 2021
@filipdutescu filipdutescu added bug Something isn't working fixed Bug has been fixed and the fix tested labels Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acknowledged The issue is being worked on bug Something isn't working fixed Bug has been fixed and the fix tested question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants