"EXPORT" registers a .lib file for shared managed libraries
Shared managed libraries do not export symbols. Therefore no .lib is created.
However the cmake export mechanism adds a .lib entry to the exported target, causing an error when importing the package.
- Input:
set_target_properties(${TARGET} PROPERTIES
COMMON_LANGUAGE_RUNTIME ""
VS_GLOBAL_CLRSupport "true"
VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.0"
VS_GLOBAL_KEYWORD "ManagedCProj"
)
get_target_property(TARGET_TYPE ${TARGET} TYPE)
if (${TARGET_TYPE} STREQUAL "SHARED_LIBRARY")
set_target_properties(${TARGET} PROPERTIES
LINK_FLAGS /SUBSYSTEM:WINDOWS
)
install(TARGETS ${TARGET} EXPORT ${PROJECT_EXPORT})
endif()
- Exported file:
set_property(TARGET MyTarget APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(MyTarget PROPERTIES
IMPORTED_IMPLIB_DEBUG "C:/.../lib/Debug64/MyTarget.lib" <-- does not exist
IMPORTED_LOCATION_DEBUG "C:/../bin/Debug64/MyTarget.dll"
)
- Result when importing the package:
[cmake] CMake Error at C:/.../install/MyPackage.cmake:205 (message):
[cmake] The imported target "MyPackage::MyTarget" references the file
[cmake]
[cmake] "C:/.../lib/Debug64/MyTarget.lib"
[cmake]
[cmake] but this file does not exist. Possible reasons include:
[cmake]
[cmake] * The file was deleted, renamed, or moved to another location.
[cmake]
[cmake] * An install or uninstall procedure did not complete successfully.
[cmake]
[cmake] * The installation package was faulty and contained
[cmake] -- Configuring incomplete, errors occurred!
Expected behavior: for such targets, no IMPORTED_IMPLIB
property should be added.
Edited by matkara