简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM