Skip to content

Support static/shared builds and an ALIAS for the default #784

@misery

Description

@misery

It is currently not possible to build STATIC and SHARED libraries at the same time with CMake.

CMake Error at CMakeLists.txt:106 (add_library):
  add_library cannot create ALIAS target "llhttp::llhttp" because another
  target with the same name already exists.

You have add_library(llhttp::llhttp ALIAS llhttp_shared) twice in CMakeLists.txt.

Also it would be nice if the IMPORTED target in CMake could be llhttp:llhttp as an alias in addition to existing llhttp::llhttp_shared and llhttp::llhttp_static.
Currently we use this to detect it.

find_package(llhttp REQUIRED)

if(TARGET llhttp::llhttp_shared)
	add_library(llhttp::llhttp ALIAS llhttp::llhttp_shared)
elseif(TARGET llhttp::llhttp_static)
	add_library(llhttp::llhttp ALIAS llhttp::llhttp_static)
else()
	message(FATAL_ERROR "TARGET of llhttp not found")
endif()

add_library(OurLibrary)
...
target_link_libraries(OurLibrary llhttp::llhttp)

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