Skip to content

Examples CMake missing support of shared lib #22

@z-vishal

Description

@z-vishal

hi

While building ZenDNN with a shared library and examples, I encountered an issue related to the examples build configuration. The examples build configuration only links the static library (zendnnl_archive) and doesn't handle the case of a shared library

Issue: current code hardcodes linking to static library only

Line: 87

target_link_libraries(examples
PUBLIC OpenMP::OpenMP_CXX
PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,zendnnl::zendnnl_archive>")

Proposed fix:
By adding conditional logic to check for both library

if(TARGET zendnnl::zendnnl_archive)
  target_link_libraries(examples
    PUBLIC  OpenMP::OpenMP_CXX
    PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,zendnnl::zendnnl_archive>")
elseif(TARGET zendnnl::zendnnl)
  target_link_libraries(examples
    PUBLIC  OpenMP::OpenMP_CXX
    PRIVATE zendnnl::zendnnl)
else()
  message(FATAL_ERROR "Neither zendnnl::zendnnl_archive nor zendnnl::zendnnl target found")
endif()

Impact
Examples cannot be built when using shared library

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions