CMake error that i do not understand - c++

I'm using CMake to compile a project. This is the path to my sources: https://github.com/Ro6afF/Snake . When I type this
cd build && cmake ..
it prints this:
CMake Error: Could not find cmake module file: CMakeDetermineSnakeCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_Snake_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_Snake_COMPILER
CMake Error: Could not find cmake module file: /home/asd/snake/build/CMakeFiles/3.5.0/CMakeSnakeCompiler.cmake
CMake Error at CMakeLists.txt:3 (Project):
No CMAKE_Snake_COMPILER could be found.
Tell CMake where to find the compiler by setting the CMake cache entry
CMAKE_Snake_COMPILER to the full path to the compiler, or to the compiler
name if it is in the PATH.
CMake Error: Could not find cmake module file: CMakeSnakeInformation.cmake
CMake Error: CMAKE_Snake_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "/home/asd/snake/build/CMakeFiles/CMakeOutput.log".
Can you explain me how to fix this error?
Thanks in advance!

You use the project command incorrectly:
PROJECT(OpenGL Snake)
The space acts as a separator. That means project name is OpenGL and language is Snake. CMake knows no such language.
Change the code to something like
PROJECT(OpenGL_Snake)

Related

How to print variables in CMake?

I want to use cmake to build my project, my CMakeLists.txt is very simple:
cmake_minimum_required(VERSION 3.20)
project(YuvParallelProcess)
message("$(PROJECT_SOURCE_DIR)")
include_directories($(PROJECT_SOURCE_DIR)/inc)
link_directories($(PROJECT_SOURCE_DIR)/lib/libyuv)
add_executable(YuvParallelProcess $(PROJECT_SOURCE_DIR)/src/main.cpp)
target_link_libraries(YuvParallelProcess libyuv.a)
my project files are organized as follows:
YuvParallelProcess
build
data
inc
lib
src
CMakeLists.txt
when I run cmake .. in build directory, the shell prints:
$(PROJECT_SOURCE_DIR)
-- Configuring done
CMake Error at CMakeLists.txt:10 (add_executable):
Cannot find source file:
$(PROJECT_SOURCE_DIR)/src/main.cpp
CMake Error at CMakeLists.txt:10 (add_executable):
No SOURCES given to target: YuvParallelProcess
I don't know why the shell just prints $(PROJECT_SOURCE_DIR) other than the value of PROJECT_SOURCE_DIR
How can I print the value of PROJECT_SOURCE_DIR
By the way, I can't figure out why cmake failed to compile my project
Cmake uses curly braces for getting values of variables:
${PROJECT_SOURCE_DIR}
I suggest to dump messages like below to not skip empty messages.
message(PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
Cmake failed to configure your project because it did not recognise variables in parentheses and considered $(PROJECT_SOURCE_DIR) to be a string literal as is.
There is CMakePrintHelpers Cmake module for dumping variables exactly like above.
include(CMakePrintHelpers)
cmake_print_variables(PROJECT_SOURCE_DIR)
Instead of using message, you can also use cmake_print_variables to display variables.
in this case, you must include CMakePrintHelpers
include(CMakePrintHelpers)
cmake_print_variables(PROJECT_SOURCE_DIR)
The ouput will be :
-- PROJECT_SOURCE_DIR="path/to/your/project"
With cmake_print_variables you can also display several variables, like this:
cmake_print_variables(PROJECT_SOURCE_DIR ANOTHER_VARIABLE)
The ouput will be :
-- PROJECT_SOURCE_DIR="path/to/your/project" ; ANOTHER_VARIABLE="other variable"

CMAKE error: TBB variable set to not found

System: Linux
I am getting the following error when trying to run a C++ code. When I run cmake .., I get -
srishti#ubuntu:~/realtimeKCF/build$ cmake ..
FINALLL TBB_LIBRARIES = 'optimized;/usr/lib/x86_64-linux-gnu/libtbb.so;debug;TBB_tbb_LIBRARY_DEBUG-NOTFOUND'
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
TBB_tbb_LIBRARY_DEBUG (ADVANCED)
linked by target "DSKCFcpp" in directory /home/srishti/realtimeKCF
-- Configuring incomplete, errors occurred!
See also "/home/srishti/realtimeKCF/build/CMakeFiles/CMakeOutput.log".
I also searched for:
TBB_tbb_LIBRARY_DEBUG (ADVANCED)
but I can't find this anywhere. Can someone please help me with this? I am just having this error stopping me from running the code.

cmake error "CMake Error: The source directory ".../p4c/build/[-DCMAKE_BUILD_TYPE=RELEASE" does not exist

I'm getting the cmake error when installing p4c. Below is the cmake command to be run
cmake .. [-DCMAKE_BUILD_TYPE=RELEASE|DEBUG] [-DCMAKE_INSTALL_PREFIX=<path>] [-DENABLE_DOCS=ON (default off)] [-DENABLE_P4RUNTIME_TO_PD=OFF (default on)]
I'm getting the below error
CMake Error: The source directory "/home/users/phani/p4c/build/[-DCMAKE_BUILD_TYPE=RELEASE" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
DEBUG]: command not found
source files, CmakeLists.txt are in path "/home/users/phani/p4c", build is done is seperate subdirectory as shown in the link. Please help me to resolve the error
The syntax:
cmake .. [-DCMAKE_BUILD_TYPE=RELEASE|DEBUG] [-DCMAKE_INSTALL_PREFIX=<path>] [-DENABLE_DOCS=ON (default off)] [-DENABLE_P4RUNTIME_TO_PD=OFF (default on)]
is commonly used to quickly describe what options can be added or not to a command line.
To perform a simple build, do
cmake ..
If you want to specify the build type, you do:
cmake .. -DCMAKE_BUILD_TYPE=RELEASE
or
cmake .. -DCMAKE_BUILD_TYPE=DEBUG
etc.
In other words, when you see
command [option] [option=val1|val2]
arguments under [] are optional, and char | means "or". You should not write these characters in the real command line you type in your terminal

cmake: You have called ADD_LIBRARY for library cryptopp without any source files

Windows 64bit using cmake to compile c++ project: github.com/iHateInventNames/synergy-through-usb
I fixed a previous issue in this post: Compile issues: LIBUSB_1 with cmake project on Windows
So when I hit cmake now I get the following error:
> cmake .
-- Found libusb-1.0:
-- - Includes: C:/local/libs/libusbx
-- - Libraries: C:/local/libs/libusbx/libusb-1.0.lib
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
-- Generating done
-- Build files have been written to: C:/local/projects/synergy-usb/synergy-through-usb-master
What does this mean? how can I solve it / move on?
Links to the install instructions
both goto 404 errors...
http://synergy-project.org/projects/synergy/wiki/Readme/?hl=pm
http://synergy-project.org/projects/synergy/wiki/Compiling/?hl=pm
Based on a quick browse through the project's CMakeLists, it would seem you're supposed to unpack tools/cryptopp562.zip into a directory called tools/cryptopp562 before running CMake. This should definitely have been mentioned in the projects' installation instructions, if any.
More precisely, the file tools/CMakeLists.txt contains this code:
set(cpp_dir cryptopp562)
file(GLOB cpp_src ${cpp_dir}/*.cpp)
# ...
add_library(cryptopp STATIC ${cpp_src})
This means that the variable cpp_src is filled with source files taken from directory cryptopp562 (relative to the CMakeList's directory, i.e. tools), and is then used to define the source files of library cryptopp. However, the project's distribution only contains tools/cryptopp562.zip. Unpacking that into directory tools/cryptopp562 should provide the missing files.

CMAKE on (tortoisesvn) SVN project :: Error in configuring process, project files may be invalid

I have checked out a version of project from SVN. Below are the different kinds of errors I got while trying to CMAKE a project from SVN. Could it be that some of the files are not checked out? Please, go through the three kinds of errors and help me out with it.
==================Type 1==================================
CMake Error at CMakeLists.txt:184 (add_subdirectory):
add_subdirectory given source "google/gmock" which is not an existing
directory.
==================Type 2==================================
Subversion executable was not found.
CMake Error at CMakeLists.txt:14 (UpLinqSVN_WC_INFO):
Unknown CMake command "UpLinqSVN_WC_INFO".
Call Stack (most recent call first):
CMakeLists.txt:207 (CreateVersionInfo)
========================TYPE 3==========================================
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
FFMPEG_AVCODEC_LIB
linked by target "UpLinq" in directory C:/Users/Krishna/Desktop/2.5/GUI
FFMPEG_AVCORE_LIB
linked by target "UpLinq" in directory C:/Users/Krishna/Desktop/2.5/GUI
FFMPEG_AVDEVICE_LIB
linked by target "UpLinq" in directory C:/Users/Krishna/Desktop/2.5/GUI
Configuring incomplete, errors occurred!
Error 1 indeed indicates that the CMakeLists.txt expected there to be a directory called google/gmock (relative to the CMakeLists.txt which is calling add_subdirectory at line 184).
Without more info, there's no way to tell if this is an error in the CMakeLists file or in the repository.
The first part of error 2 (can't find Subversion exe) looks like a custom error message. It may be looking for a ".svn" folder in the project root, and assuming that Subversion is available. Presumably it then looks for the Subversion exe and fails to find it (not in path maybe?)
The second part of error2 (unknown CMake command) is saying that at line 14 of CMakeLists.txt, there's a command called UpLinqSVN_WC_INFO being invoked. It doesn't recognise this as a valid command, which probably means that it's defined as a function or macro in another CMake file somewhere. It would need to be defined before it's invoked at line 14. It could be that the CMakeLists.txt you're executing is expected to be run as part of a larger build, which would define this function before starting on your CMakeLists.txt.
Error 3 is saying that there's a CMake target called "UpLinq" (an exe or lib) which has a dependency on ${FFMPEG_AVCODEC_LIB}. At some point, there's probably been a find_library call looking for the avcodec library which has also failed. The result of the search is held in the variable FFMPEG_AVCODEC, and it shows that ${FFMPEG_AVCODEC} has a value of FFMPEG_AVCODEC-NOTFOUND.
If you need more help than this, you'll need to put up a copy of the relevant parts of the CMakeLists files involved, and a bit more info about your environment / directory structures.