Filename clashes of import library for multiple targets
If multiple targets with similar output names are present, it is possible that CMake creates clashes in the filename for the import library.
E.g. here: https://github.com/pybind/pybind11/issues/1915
I have a project exposing the targets
add_library(libvipster ${LIB_SOURCES})
set_target_properties(libvipster PROPERTIES OUTPUT_NAME "vipster")
and
add_executable(vipster WIN32 MACOSX_BUNDLE ${QT_SOURCES} ${ICON_SOURCES})
target_link_libraries(vipster pybind11:embed Qt5::Gui Qt5::Widgets libvipster)
Both for MinGW and clang-cl, CMake created the same TARGET_IMPLIB
.
This has not been a problem until adding pybind11::embed
to the target_link_libraries
which for some reason triggered the creation of the import library also for the executable target.
Given that the reasons for creation of the import library on executable targets is not very transparent, and the resulting error messages even less so, would it be possible to introduce a safer naming scheme?
To come back to my example, the resulting names for a MinGW build are:
libvipster
:
TARGET_FILE = libvipster.dll
TARGET_IMPLIB = libvipster.dll.a
vipster
:
TARGET_FILE = vipster.exe
TARGET_IMPLIB = libvipster.dll.a