Missing static library breaks CMake config file
Task Info (Flyspray) | |
---|---|
Opened By | Tobias Markus (netcrusher) |
Task ID | 72726 |
Type | Bug Report |
Project | Community Packages |
Category | Packages |
Version | None |
OS | All |
Opened | 2021-11-12 15:16:50 UTC |
Status | Assigned |
Assignee | Christian Hesse (eworm) |
Assignee | Konstantin Gizdov (kgizdov) |
Details
Description: The antlr4-runtime CMake build system defaults to building and installing both a static and a shared version of the runtime (targets antlr4-shared and antlr4-static in CMake). The exported CMake config files (antlr4-targets.cmake and antlr4-targets-release.cmake in /usr/lib/cmake/antlr4-runtime) also include the static target antlr4-static. However, makepkg automatically removes static libraries, resulting in a package that mentions the static version in the CMake config script while the static library does not actually exist in the final package.
This situation in turn breaks the CMake scripts since they check whether the exported targets are actually present. Example output:
CMake Error at /usr/lib64/cmake/antlr4-runtime/antlr4-targets.cmake:82 (message): The imported target "antlr4_static" references the file
"/usr/lib/libantlr4-runtime.a"
but this file does not exist. Possible reasons include:
-
The file was deleted, renamed, or moved to another location.
-
An install or uninstall procedure did not complete successfully.
-
The installation package was faulty and contained
"/usr/lib64/cmake/antlr4-runtime/antlr4-targets.cmake"
but not all the files it references.
Call Stack (most recent call first): /usr/lib64/cmake/antlr4-runtime/antlr4-runtime-config.cmake:42 (include) CMakeLists.txt:34 (find_package)
-- Configuring incomplete, errors occurred!
In this case, reason number 3 obviously applies.
I could also reproduce the cause of the issue by building the PKGBUILD locally and observing that CMake installs libantlr4-runtime.a to the pkg directory, but makepkg removes it.
Additional info:
- Package Version: antlr4-runtime 4.9.3
Steps to reproduce:
- Install antlr4-runtime
- Observe that /usr/lib/libantlr4-runtime.a does not exist:
$ ls /usr/lib/libantlr4-runtime.a ls: cannot access '/usr/lib/libantlr4-runtime.a': No such file or directory
- Observe that antlr4_static (/usr/lib/libantlr4-runtime.a) is mentioned in CMake target export files:
$ grep -rn antlr4_static /usr/lib/cmake/antlr4-runtime /usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:19:# Import target "antlr4_static" for configuration "Release" /usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:20:set_property(TARGET antlr4_static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) /usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:21:set_target_properties(antlr4_static PROPERTIES /usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:27:list(APPEND _IMPORT_CHECK_TARGETS antlr4_static ) /usr/lib/cmake/antlr4-runtime/antlr4-targets-release.cmake:28:list(APPEND _IMPORT_CHECK_FILES_FOR_antlr4_static "${_IMPORT_PREFIX}/lib/libantlr4-runtime.a" ) /usr/lib/cmake/antlr4-runtime/antlr4-targets.cmake:19:foreach(_expectedTarget antlr4_shared antlr4_static) /usr/lib/cmake/antlr4-runtime/antlr4-targets.cmake:65:# Create imported target antlr4_static /usr/lib/cmake/antlr4-runtime/antlr4-targets.cmake:66:add_library(antlr4_static STATIC IMPORTED)
- Observe that "find_package(antlr4-runtime)" in CMake scripts fails (see example above)