CMake - syntax error ?
-
I hope this forum will forgive me to ask this, but... CMake wants to have line added cmake_minimum_required(VERSION 3.5) after which opencv.sh complains ./opencv.sh: line 1: syntax error near unexpected token `VERSION' ./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)' I am enclosing my crude log to illustrate some details. And no, I do not know how to change CMake options to remove this version requirement and still would like to know the "syntax" error I made. pre lang="text">
CMake Error at traincascade/CMakeLists.txt:2 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such ascmake_minimum_required(VERSION 3.5)
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".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!
after adding
CMake Error at traincascade/CMakeLists.txt:2 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such ascmake_minimum_required(VERSION 3.5)
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".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!
after addingCmake complains
im-desktop:~$ ./opencv.sh
./opencv.sh: line 1: syntax error near unexpected token `VERSION'
./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)'
jim@jim-desktop:~$Cheers Vaclav
-
I hope this forum will forgive me to ask this, but... CMake wants to have line added cmake_minimum_required(VERSION 3.5) after which opencv.sh complains ./opencv.sh: line 1: syntax error near unexpected token `VERSION' ./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)' I am enclosing my crude log to illustrate some details. And no, I do not know how to change CMake options to remove this version requirement and still would like to know the "syntax" error I made. pre lang="text">
CMake Error at traincascade/CMakeLists.txt:2 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such ascmake_minimum_required(VERSION 3.5)
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".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!
after adding
CMake Error at traincascade/CMakeLists.txt:2 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such ascmake_minimum_required(VERSION 3.5)
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".
This warning is for project developers. Use -Wno-dev to suppress it.
Configuring incomplete, errors occurred!
after addingCmake complains
im-desktop:~$ ./opencv.sh
./opencv.sh: line 1: syntax error near unexpected token `VERSION'
./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)'
jim@jim-desktop:~$Cheers Vaclav
./opencv.sh: line 1: syntax error near unexpected token `VERSION'
./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)'The error ir pretty clear: There is a syntax error in line 1 of the file opencv.sh. The .sh extension indicates that it is a shell script file which is processed by the shell (probably bash) which will off course know nothing about CMake commands.
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such ascmake_minimum_required(VERSION 3.5)
Here CMake complains about a missing command in the file CMakeLists.txt. So you have to add the command to the CMake file CMakeLists.txt.
-
./opencv.sh: line 1: syntax error near unexpected token `VERSION'
./opencv.sh: line 1: `cmake_minimum_required(VERSION 3.5)'The error ir pretty clear: There is a syntax error in line 1 of the file opencv.sh. The .sh extension indicates that it is a shell script file which is processed by the shell (probably bash) which will off course know nothing about CMake commands.
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such ascmake_minimum_required(VERSION 3.5)
Here CMake complains about a missing command in the file CMakeLists.txt. So you have to add the command to the CMake file CMakeLists.txt.
-
It is not about clarity of the error - I am asking WHAT is the syntax error. I have "cut and paste" the required line from the CMake output. Do I need to define "token" VERSION" ? How?
You are missing the point it is complaining about there is no cmake_minimum_required(VERSION 3.5) in CMakeLists.txt You said you cut and paste "cmake_minimum_required(VERSION 3.5)" but did you put it into CMakeLists.txt, you didn't put in the script file per chance?????? I am not being condescending here but I need to check, you do get the script file has nothing to do with cmake. Like you we are a bit perplexed because it's step 1 of any cmake file. Usually the first two lines of CMakeLists.txt are
make_minimum_required (VERSION x.x)
project (_MY_PROJECT_NAME_)_MY_PROJECT_NAME_ being what you want to call the project I am sorry for having to ask and check all these really beginner stuff but there is something strange going on. Whatever the situation I suggest you simply open up a command line window, change to the directory and manually type in the cmake command (so we have any scripts out of the way) and we can see the exact screen spit from cmake itself without the script which is just another source of possible error. Assuming we pass all this basic stuff there is left one other possibility that your first makelist pulls other makelists and those later makelists have version requirements but that is not the sort of error you seem to be getting. The problem is the exact messages change depending on version CMake and exact OS type so I will leave it as a possibility.
In vino veritas
-
It is not about clarity of the error - I am asking WHAT is the syntax error. I have "cut and paste" the required line from the CMake output. Do I need to define "token" VERSION" ? How?
The syntax error is: The program processing the file is not able to parse the command
cmake_minimum_required(VERSION 3.5)
. The reason is: You have pasted the command into the file opencv.sh which is processed by the shell (the Unix command line interpreter; see Unix shell - Wikipedia[^] ). But it should be pasted into the file CMakeLists.txt which is processed by CMake. The solution (see my initial answer):Quote:
So you have to add the command to the CMake file CMakeLists.txt.
instead of opencv.sh.