How to Fix 're2c Was Not Found' Error in CMake
CMake Warning: 're2c Was Not Found' - A Comprehensive Guide
If you're seeing the warning 're2c was not found' in your CMake build output, don't panic! This guide will walk you through the problem and its solutions.
Understanding the Issue
This warning signals that CMake cannot locate the 're2c' tool on your system. re2c is a powerful lexer generator that produces efficient C/C++ code for lexical analyzers, often used in parsers and compilers.
The warning originates from your CMakeLists.txt file (specifically line 52 in your case). It indicates that without 're2c', modifications to files matching the pattern src/*.in.cc will not be reflected in your build.
Resolving the Warning
Here are three common approaches to address this issue:
1. Install re2c
The most straightforward solution is to install 're2c' on your system. The installation process varies depending on your operating system:
- Linux (Debian/Ubuntu):
sudo apt-get install re2c- Linux (Fedora/CentOS):sudo yum install re2c- macOS (Homebrew):brew install re2c- Windows: You might need to download the re2c source code and build it manually, or use a package manager like Chocolatey or MSYS2.
After installation, CMake should automatically detect 're2c'.
2. Bypass the Dependency
If the src/*.in.cc files aren't critical for your build (e.g., part of an optional feature), you can either:
- Remove: Delete the relevant code sections from your
CMakeLists.txtthat pertain to these files. - Comment Out: Temporarily disable the code by adding#at the beginning of the lines related tosrc/*.in.ccprocessing in yourCMakeLists.txt.
3. Guide CMake to re2c
If 're2c' is installed in a non-standard location, help CMake find it:
-
Locate the line resembling
find_program(RE2C re2c)in yourCMakeLists.txt. 2. Modify it to provide the correct path to the 're2c' executable. For example:cmake find_program(RE2C re2c PATHS /usr/local/bin /opt/re2c/bin)
Back to Building!
Once you've implemented one of these solutions, the 're2c was not found' warning should disappear. Your build process should now properly incorporate changes made to src/*.in.cc files. If you encounter further issues, double-check your 're2c' installation and the paths specified in your CMakeLists.txt.
原文地址: https://www.cveoy.top/t/topic/SWv 著作权归作者所有。请勿转载和采集!