Skip to content

[Confusion] about ${PROJECT_NAME}_BUILD_SHARED_LIBS #26

@Kiddinglife

Description

@Kiddinglife

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

Metadata

Metadata

Assignees

Labels

acknowledgedThe issue is being worked onbugSomething isn't workingfixedBug has been fixed and the fix testedquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions