On 2013-11-10 14:12, Witold E Wolski wrote:
And [<project>_{SOURCE,BINARY}_DIR] are the same as
CMAKE_BINARY_DIR, or CMAKE_SOURCE_DIR.

So why one would use the ${PROJECT}_BINARY_DIR variables?

Not necessarily. Consider:

src/CMakeLists.txt
project(A)

src/b/CMakeLists.txt
project(B)

src/b/tests/CMakeLists.txt

...etc. Now, e.g. B_BINARY_DIR can be different from both CMAKE_BINARY_DIR and CMAKE_CURRENT_BINARY_DIR.

Additionally, your entire project might be included by some other CMakeLists.txt such that (continuing with the above example) A_BINARY_DIR != CMAKE_BINARY_DIR. So it's good practice when defining project-specific macros to use <project>_{SOURCE,BINARY}_DIR where <project> is the project you declare at the top level directory of your project to refer to the top level directory of your project. (And only use CMAKE_{SOURCE,BINARY}_DIR when you really mean the source/build root and don't care if that's your project's top level directory or not.)

Basically, you can be more confident that you know where in your tree <project>_{SOURCE,BINARY}_DIR refers than you can of CMAKE_{SOURCE,BINARY}_DIR.

--
Matthew

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to