"In-Source Builds Are Not Allowed" in Cmake

In-source builds are not allowed in cmake

It wants you to create a separate build directory (anywhere), and run cmake there. For example:

mkdir my_build_dir
cd my_build_dir
rm ../CMakeCache.txt
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/jinha/OCV/source

Note the .. in this example telling cmake where to look for the source.

In case you didn't remove CMakeCache.txt before building again, it will still show this error.
So, please remember to delete CMakeCache.txt first before running cmake.

With cmake, how would you disable in-source builds?

I think I like your way. The cmake mailing list does a good job at answering these types of questions.

As a side note: you could create a "cmake" executable file in the directory which fails. Depending on whether or not "." is in their path (on linux). You could even symlink /bin/false.

In windows, I am not sure if a file in your current directory is found first or not.

CMake Error buildir does not appear to contain CMakeLists.txt

You need to run cmake in the build directory with an argument of the source directory.

Example:

$ cd /path/to/example-0.0.1
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_FLAGS=VALUES # etc.

CMake error: ROOT should be built as an out of source build

The error message simply tells you to create an additional build folder e.g. build next to the ROOT project folder root, change to this directory and call cmake ../root from there.

TLDR; To simply call the following sequence starting from the root folder:

cd ..
mkdir build
cd build
cmake ../root


Related Topics



Leave a reply



Submit