[C++][CMake] find_package() fails when the C++ runtime is make-install'ed
envgap__antlr__antlr4-2606
01 / FAILURE SIGNATURE
As reported upstream
One solution is to follow CMake's advice in the error message:
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
1177c0b58d07b01bc3eaddaf2cad3780c821e2e1- Manifest
runtime/Cpp/CMakeLists.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
antlr/antlr4 #2606 · read the original issue
I followed [README.md](https://github.com/antlr/antlr4/blob/master/runtime/Cpp/README.md) to compile and install antlr4 on Linux. I turned `ANTLR4_INSTALL` on in the `cmake` step and I left out the `DESTDIR` variable in the `make install` step. This results in the following directory with CMake files: ``` $ ls -l /usr/local/lib/cmake/antlr4 total 24 -rw-r--r-- 1 root root 1607 jul 25 20:27 antlr4-config-version.cmake -rw-r--r-- 1 root root 7632 jul 25 20:27 antlr4-generator-config.cmake -rw-r--r-- 1 root root 1138 jul 25 20:27 antlr4-runtime-config.cmake -rw-r--r-- 1 root root 3235 jul 25 20:27 antlr4-targets.cmake -rw-r--r-- 1 root root 1427 jul 25 20:27 antlr4-targets-release.cmake ``` I then followed [Antlr4Package.md](https://github.com/antlr/antlr4/blob/master/runtime/Cpp/cmake/Antlr4Package.md) to add antlr4 to my project. However, `find_package(antlr4-runtime REQUIRED)` fails: CMake can't find `antlr4-runtime`. This makes sense, given CMake's [Search procedure](https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure) One solution is to follow CMake's advice in the error message: ``` Add the installation prefix of "antlr4-runtime" to CMAKE_PREFIX_PATH or set "antlr4-runtime_DIR" to a directory containing one of the above files. ``` But I'd say it's cleaner to give the `runtime` and `generator` packages each their own directory (or perhaps there's another way that I'm unaware of). Otherwise, could a warning about this issue be added to [Antlr4Package.md](https://github.com/antlr/antlr4/blob/master/runtime/Cpp/cmake/Antlr4Package.md)? It's not much of a problem if you're a seasoned CMake user, but if you barely use it it's quite a hassle to debug (i.e. actually finding the root cause and not simply following CMake's advice).
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]