syntax error near unexpected token `CMAKE_INSTALL_PREFIX' - cmake

I'm trying to install gflags on openSuse 13.1.
CMake generated the install files OK, but when I try to run cmake_install.cmake, I get the above error.
The line it's referring to is:
set(CMAKE_INSTALL_PREFIX "/usr/local")
Does anyone know what to do to get it to work, and why it has generated a seemingly unusable file?

As far I know, you just can't do this:
set(CMAKE_INSTALL_PREFIX "/usr/local")
To set the prefix and works as you expected..you need to defined before configuration begins, even before cmake begins:
cmake -DCMAKE_INSTALL_PREFIX="/usr/local" ..
Also, you must know that typical build procedure is
cmake [..]
make
make install

Related

CMake Error (configure_file): configure_file error configuring file

I am working on a project on c++ and need to execute a CMakeLists.txt file to run it. I installed cmake, doxygen, cmake-curses-gui and make using sudo. Then I tried running the file.
The following is a part of the cmake code -
if (BUILD_DOC)
find_package(Doxygen)
configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
${PROJECT_SOURCE_DIR}/doc/Doxyfile #ONLY)
add_custom_target(${PROJECT_NAME}_doc ALL ${DOXYGEN_EXECUTABLE}
${PROJECT_SOURCE_DIR}/doc/Doxyfile)
endif ()
Here, it gave me an error message saying that
CMake Error at CMakeLists.txt:77 (configure_file): configure_file
Problem configuring file
Just so that you know, line 77 is configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile.in .
If I add AND DOXYGEN_FOUND to the if condition, it doesn't execute anything at all which means that it couldn't find a doxygen executable. But as I already told, I already installed doxygen.
I am new to cmake. So, could anyone please help me with this
Edit:
The OS I am using is Ubuntu 16.04
After I put if(DOXYGEN_FOUND) after the command find_package(doxygen) it executed, but I got the same cmake error in line 78 instead of line 77
Also, now since I got enough information from the comments, I just realized that my problem is more towards finding where the Doxyfile.in file lies than configuring the file. Could anyonee help me with it?
The error is clear
configure_file Problem configuring file
CMake's configure_file(<input> <output>) command is used to copy input file to ouput and replacing #VARIABLES# in input by the corresponding value.
configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile.in ${PROJECT_SOURCE_DIR}/doc/Doxyfile #ONLY)
You have to find why this process failed:
Make sure ${PROJECT_SOURCE_DIR} contains the correct path to your project, and make sure the file Doxyfile.in is is the right folder (<project dir>/doc)
Make sure content of Doxyfile.in does not contains any syntax error, in particular with #VARIABLES# that needs to be replaced by their CMake value.
Note that this error has nothing to do with Doxygen on your system, and the fact that CMake actually found it or not.

Cmake on msys2 for someone who's unfamiliar with the environment

I'm trying to get cmake working on msys2. I try to compile some code that I've been given for another project and:
CMake Error: Could not create named generator MSYS Makefiles
I've found this thread and this thread and tried to follow the instructions...only to realize that the wiki that the threads eventually link back to never states where msys stores toolchains. Googling around didn't really help.
Even more oddly, the program that I'm trying to use somehow runs and produces valid data despite throwing an error due to the missing cmake. I don't get it.
I've never used msys before; as someone who's brand new to msys2/cygwin and can't even understand the lingo, how do I get cmake installed and working?
Sounds like you are specifying a -G "MSYS Makefiles" as the CMake generator, but CMake doesn't recognize that generator. When I use CMake on msys2 I just use the default Unix Makefiles generator and everything works just fine. Also, on my current msys2 install, CMake doesn't seem to have a MSYS Makefile generator that I can see (running cmake --help will list the available generators). Try running cmake without the -G option. Also, make sure make is installed first via pacman -Sy make.

CMake Error: cmake don't find source directory or CMakeLists.txt (installing Ogre3D)

so I've tried to use the cmake on ogre to install it but every time I use the command in the directory build :
cmake ..
I've got this error which show up :
CMake Error: The source directory "/home/.../TPs/ogre" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
and after doing :
cmake .. -DCMAKE_MODULE_PATH=/usr/share/OGRE/cmake/modules/
the error transformed in :
CMake Error: The source directory "/home/.../TPs/ogre" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
although it got a CMakeLists.txt.
I've got cmake 2.8.XXX version and python 2.7.XXX, I've tried to use cmake-gui but it also gave me an error about the CMakeCache ...
So do you have any advice?
EDIT : Ok it works, moral of the story, even if you strongly want it, don't ever put '\' in folder names !
Be sure you have activated your virtual env. If you are not, then delete previus build folder. Activate virtual env you want. Make new build folder inside opencv. Then execute cmake.

cmake_parse_arguments missing on CMake re-run

I am trying to write a function which uses cmake_parse_arguments to interpret the parameters. This works fine when running cmake in a fresh build directory. However, any time I try to re-run cmake, CMake seems to believe the function does not exist:
CMake Error at CMakeLists.txt:6 (CMAKE_PARSE_ARGUMENTS):
Unknown CMake command "CMAKE_PARSE_ARGUMENTS".
I feel like I'm missing something obvious. I am using CMake 3.3.2 on Arch Linux.
Include CMakeParseArguments with
include(CMakeParseArguments)
Probably it worked the first time because other Find* files included the file already. As the result of the Find* files are cached and not re-run, they no longer included CMakeParseArguments.

Cmake Error: could not load cache

I'm using Cmake to try to build a project for Eclipse. When I try running Cmake, I get the following error:
Error: could not load cache
Error: Batch build stopped due to Eclipse CDT4 - Unix Makefiles error.
---- Time Elapsed: 3 secs ----
Error: could not load cache
Error: Batch build stopped due to Eclipse CDT4 - Unix Makefiles error.
I'm completely stumped on what might be causing this. I know that I'm running Cmake in the correct directory and the CMakeCache.txt file is present. Could someone point me in the right direction to solve this?
If you are using the CLion, you can use File---"Reload CMake Project".
I meet this problem after using git force pull, and Reload CMake Project solves it.
Remove the CMakeCache.txt and try again. You probably had a bad cmake setup.
I have faced the same problem and solved it using the terminal.
Delete the cached/configurations files as we will get them again.
To configure the project run cmake .
Build the project using cmake --build .
run cmake --configure . it should generate required files.
I ran into this recently using JetBrains CLion and the above instructions were helpful but not directly, I was able to reload the project using the "cog" drop down in the CMake tab:
If you are absolutely positive that you are running the build command from the binary directory, this error probably means that you have had an issue during the configuration/generation step that you should have ran before trying the build. You can try to configure again to check (cmake your-build-dir)
I would advise running the Gui and trying to load the cache to see if you get a more explicit error (although I doubt it).
Another possibility would be to try to create a new clean build directory and take it from there.
In your example Eclipse must run something like
cmake --build folder_name --target all
and I opt that the *folder_name* is bad in this case. You probably messed something up in Eclipse.
For me it helps to select CMake tab (next to Run, TODO) in CLion. Then click the Reload CMakeProject button.
I got this error on Windows WSL with ubuntu
~/tmp/cmake$ cmake --build ./build
Error: could not load cache
I was able to fix the above error by running the following cmds in order:
% cmake -S . -B ./build
% cmake --build ./build
The above solution was derived from this post.
If you are using Visual Studio 2019, close Visual Studio, delete .vs and out folders then rebuild your project.
I removed the .cxx and other ide-generated files to the recycle.bin, except app.iml. Then I restarted Android Studio, and eventually it worked fine.
The solution that worked for me using VisualStudio 2017 was choosing:
CMake --> Cache --> Generate (from the top menu)
Apart from the already given answers, it might be due to the wrong commands or in wrong order.
To be precise, for me, it was due to
cmake -B build -G Ninja
cmake --build .
The "cmake --build ." command will throw the Could Not Load Cache error.
The problem is the build directory is given as '.' which doesn't have the cache or whatever files cmake generates, so correct command was 'cmake --build build'... and fixed !
There maybe trillion other ways but my solution was this.
For eg, it happened with the repo -> https://github.com/adi-g15/worldlinesim, though may show the same for other repos too.
For Ubuntu users, provide the source code open-pose path in the CMake-GUI.
P.S I had this issue and my path was not set there.
Most probably the issue is you have not wrote the correct name of the Visual Studio version you have installed during the build file preparation:
cmake .. -G "Visual Studio 16 2019" (note if you have VS 2016 you should change in in there)
The most realistic answer and personal experienced answer is
If you are using Clion and building files with IDE
And getting the error Cmake Error: could not load cache
Because you have accidentally deleted the cache file (like me: permanently and cant get back) or there is other problems or other problems
Then do this:
Run -> Clean
Run -> Build
And your project will be working all fine
cmake -B ./build(dest dir)
cmake --build ./build(