How to set CMake variable to include directory - cmake

When trying to build this library with Cmake from the Developer Command Prompt for VS, I get this error
CMake Error at cmake/FindEigen.cmake:77 (MESSAGE):
Failed to find Eigen - Could not find eigen3 include directory, set
EIGEN_INCLUDE_DIR to path to eigen3 include directory, e.g.
/usr/local/include/eigen3.
I'd like find out what was intended of me here: am I to set EIGEN_INCLUDE_DIR with a command line argument or by editing the make file?
I've tried cmake -D EIGEN_INGLUDE_DIR=C:\Users\a\Downloads\eigen-3.3.7\eigen-3.3.7 . but received the same error.

cmake -D EIGEN_INGLUDE_DIR=C:\Users\a\Downloads\eigen-3.3.7\eigen-3.3.7 . failed without creating any files (cmake .. at least started building) and gave me this error
CMake Error: The source "C:/Users/a/Downloads/RpolyPlusPlus-master/RpolyPlusPlus-master/build/CMakeLists.txt" does not match the source "C:/Users/a/Downloads/RpolyPlusPlus-master/RpolyPlusPlus-master/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
So I just ended up adding this to the .cmake file:
# TODO: Add standard Windows search locations for Eigen.
LIST(APPEND EIGEN_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include
C:\\Users\\a\\Downloads\\eigen-3.3.7) <---------------------------------------

Related

project PROJECT called with incorrect number of arguments

when I enter the console:
mkdir build && cd build && cmake .. && make
error occurs:
CMake Error at CMakeLists.txt: 5 (project): project PROJECT called
with incorrect number of arguments
CMake Error at CMakeLists.txt: 19 (find_package): By not providing
"FindQt5Gui.cmake" in CMAKE_MODULE_PATH this project has requested
CMake to find a package configuration file provided by "Qt5Gui", but
CMake did not find one.
Could not find a configuration file provided by "Qt5Gui" with any
of the following names:
Qt5GuiConfig.cmake
qt5gui-config.cmake
Add the installation prefix of "Qt5Gui" to CMAKE_PREFIX_PATH or set
"Qt5Gui_DIR" to a directory containing one of the above files. If
"Qt5Gui" provides a separate development package or SDK, be sure it
has been installed.
on the forums write that this is due to the fact that not installed qt5-defult and gt5-dev-tools, but before the installation and after nothing has changed what to do?

Why does the CMake command show "The source directory "/home/shubham" does not appear to contain CMakeLists.txt."?

I am installing libfreenect2 on Linux.
I am following the steps given in https://github.com/OpenKinect/libfreenect2.
Command
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2"
gives me an error:
"CMake Error: The source directory "/home/shubham" does not appear to contain CMakeLists.txt.
When I searched for "CMakeLists.txt" file, it is in the libfreenect2 folder.

cmake could not find required package TIFF

I'm trying to build an application via cmake 3.9.0. Cmake keeps complaining about the inability to find the tiff library: CMake error at CMakeModules/FindPackageHandleStandardArgs.cmake:51 (Message): Could not find REQUIRED package TIFF). I tried to install the library via sudo apt-get install libtiff5-dev but was still getting the same message. Then I checked-out the source code for libtiff 4 and built it from the source. Now I think we can hint the cmake with the location where to look for the libtiff via setting the variables TIFF_INCLUDE_DIR, TIFF_INCLUDE_DIRS, etc as described here: https://cmake.org/cmake/help/v3.6/module/FindTIFF.html. However I have failed in wiring the right values for the variables. Can somebody show me an example of sample libtiff instalation and the sample values for the configuration variable in order cmake would find the TIFF. Or is here another option how to show CMake where does the TIFF library lie?
cd build
cmake -DTIFF_INCLUDE_DIR=<dir> -DTIFF_LIBRARY=<filename> -GNinja ..
cmake --build .
Alternatively, you can modify the variables in your CMakeLists.txt before calling find_package():
set(TIFF_INCLUDE_DIR "<dir>")
set(TIFF_LIBRARY "<filename>")
find_package(TIFF)
add_executable(myexe TIFF::TIFF)
where <dir> is the include directory path and <filename> is the exact file path to the library.

generate CMakeList.text for OS X

I'm trying to create a plugin for OBS using C, and compiling it using cmake .. && make see - https://github.com/jp9000/obs-studio/wiki/Install-Instructions#mac-osx
when running cmake .. && make from cmd it gives me an error that cmake: command not found and when I run it from the program it gives me an error - CMake Error: The source directory "/Users/gerwin/Desktop/soOBS" does not appear to contain CMakeList.text specify --help for usage, or press the help button on the cmake GUI
How can I generate a CMakeList.Text to compile my soOBS script to a .so file?
One problem is that cmake is not in your path. So, if you type cmake from your command line it cannot be found. The other problem is that you are not specifying correctly your source directory: you have to specify as source directory the location of the main/root CMakeLists.txt.
So, proceed as follow:
Locate your cmake executable, obtaining your <full path to cmake>
Open a shell
Go to your source directory (location of the main/root of obs-studio CMakeLists.txt)
mkdir build
cd build
<full path to cmake> ..The first argument .. is your source directory, location of the main CMakeLists.txt
make

CMake error: For MinGW make to work correctly sh.exe must NOT be in your path

I am trying to built a "Hello World" project with Qt 5 and cmake under MinGW.
This is the CMakeLists.txt file (taken from the on-line doc):
project(Qt5_cmake_test)
cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.1.1/5.1.1/mingw48_32")
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Find the QtWidgets library
find_package(Qt5Widgets)
# Add the source files from the current directory
aux_source_directory(. SRC_LIST)
# Tell CMake to create the executable
add_executable(${PROJECT_NAME} WIN32 ${SRC_LIST})
# Use the Widgets module from Qt5
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
The source code is the one generated automatically when creating a new project (which produces an empty window).
Configuring from the Windows command prompt with: cmake -G "MinGW Makefiles" ..\Qt5_cmake_test
I get these errors:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeMinGWFindMake.cmake:20 (message):
sh.exe was found in your PATH, here:
C:/Program Files (x86)/Git/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles.
Call Stack (most recent call first):
CMakeLists.txt:8 (project)
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:C:/Users/pietro.mele/projects/tests/buildSystem_test/Qt5_cmake_test-build/CMakeFiles/2.8.11.2/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:C:/Users/pietro.mele/projects/tests/buildSystem_test/Qt5_cmake_test-build/CMakeFiles/2.8.11.2/CMakeCXXCompiler.cma
ke
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
So it seems it is not able to find the compiler. Is there a way to let cmake find it on its own, or just giving it the CMAKE_PREFIX_PATH directory?
Do I have to manually specify all those variables in the makefile or as environment variables in Windows?
I tried both from the standard Windows command prompt and from the one provided by Qt, with the same result. Is it OK to build from the Windows command prompt, or should I do it from the MinGW's shell?
Platform:
Qt 5.1
CMake 2.8.11.2
MinGW/GCC 4.8
Windows 7
Get the git path out of your PATH before running cmake.
Here is the magic to do that:
set PATH=%PATH:C:/Program Files (x86)/Git/bin;=%
This CMakeLists.txt file works properly:
project(Qt5_cmake_test)
cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_PREFIX_PATH "C:/Qt/Qt5.1.1/5.1.1/mingw48_32")
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Find the Qt libraries
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
# Add the source files from the current directory
aux_source_directory(. SRC_LIST)
# Tell CMake to create the executable
add_executable(${PROJECT_NAME} WIN32 ${SRC_LIST})
# Use Qt5 modules
target_link_libraries(${PROJECT_NAME}
Qt5::Widgets
Qt5::WinMain)
The changes are:
Added find_package(Qt5Core REQUIRED).
Added Qt5::WinMain to target_link_libraries.
In some of my answer here on SO, I have described. CMake does not like sh.exe.
sh.exe was found in your PATH, here:
C:/Program Files (x86)/Git/bin/sh.exe
Solution : Rename C:/Program Files (x86)/Git/bin/sh.exe shortly.
For example:
C:/Program Files (x86)/Git/bin/shxx.exe
But do not forget when everything is built. rename properly again.