CMake .. produces output in parent directory

620 Views Asked by At

I'm trying to build BoringSSL by Google. The BUILDING file instructions clearly indicate that the output should go under the build directory.

I have a directory project, and under it I've created build. There is a CMakeLists.txt file under project, and I would like it to build inside the build directory. However, when I run cmake .. from inside build, the makefile is produced in the project directory instead of the current build directory.

Most instructions I found seem to indicate that the output of cmake goes into the current directory, regardless of where CMakeLists.txt is located. What am I doing incorrectly?

2

There are 2 best solutions below

0
On

I made the following files/directory:

.
`-- project
    |-- build
    `-- CMakeLists.txt

With CMakeLists.txt content:

PROJECT(TEST)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

Then I went into the ./project/build folder and ran cmake ..

[~/project/build] cmake ..
-- The C compiler identification is Intel 13.1.0.20130313
-- The CXX compiler identification is Intel 13.1.0.20130313
-- Check for working C compiler: /usr/local/bin/icc
-- Check for working C compiler: /usr/local/bin/icc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/icpc
-- Check for working CXX compiler: /usr/local/bin/icpc -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: ~/project/build

And all the generated files were in the ./project/build folder.

Try opening up your CMakeCache.txt file (it should be generated in the directory you ran CMake from) and check out variables like TEST_BINARY_DIR and CMAKE_CACHEFILE_DIR. They should set to your build directory for example.

0
On

Turns out that since I ran cmake in the top level project directory, running it again from inside build didn't produce a new output. Removing CMakeCache.txt from project should solve the problem.