Alexis Winters
Alexis Winters

Reputation: 515

How are CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR set?

When and how are these values set? Does it depend on the location of the CMakeLists.txt? Does it depend on where CMake is ran from?

Upvotes: 2

Views: 2132

Answers (1)

user8197171
user8197171

Reputation:

Here is an example command where I configure a cmake project.

I'll be using the newer cmake style of doing things since it makes thing more clear.

# -S = CMAKE_SOURCE_DIR
# -B = CMAKE_BINARY_DIR
cmake -S C:\foobar -B C:\foobar\binary_dir

As you can see -S specifies the CMAKE_SOURCE_DIR, and -B specifies the CMAKE_BINARY_DIR.

The other ways to configure a build also follow this principle but I think the -S/-B really make things clear.

To summarize:

You are the one who sets the CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR when you configure/generate the build.

EDIT:

If you need I can more in depth. So feel free to comment.

Upvotes: 5

Related Questions