Issue
Problem
I have a project with a CMakeLists.txt
at the top level which looks like the following:
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
...
set(PACKAGE_NAME "foo")
...
project(${PACKAGE_NAME} C CXX Rust)
When I run cmake3 -B build .
from the top level, I get a lot of warnings & errors including:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMakeLists.txt:25 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:26 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:27 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:28 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:29 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:30 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:31 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:32 (install):
install PROGRAMS given no DESTINATION!
CMake Error at CMakeLists.txt:33 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:34 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:36 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:37 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:38 (install):
install FILES given no DESTINATION!
CMake Error at CMakeLists.txt:39 (install):
install PROGRAMS given no DESTINATION!
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.17)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
What I really don't understand is that the line numbers (e.g. 39) in the errors like CMake Error at CMakeLists.txt:39
don't seem to correspond to the lines in the CMakeLists.txt I've created (several are just blank lines).
Question:
- Why am I getting error output that doesn't seem to correspond to the
CMakeLists.txt
that I have created?
Solution
If you get unexpected errors with error output that doesn't correspond to the CMakeLists.txt
file you are looking at, it is likely because CMake has cached some build information from a previous build attempt.
You may be able to resolve this error by removing any CMakeCache.txt
(not CMakeLists.txt
) files from your project and building again.
Answered By - karobar Answer Checked By - Clifford M. (WPSolving Volunteer)