Hello list,
I came across this problem when I tried to write a CMakeLists.txt that
prevents building in the source tree. So I would try something like this:
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _is_in_src)
if(_is_in_src)
file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/CMakeFiles $
{CMAKE_SOURCE_DIR}/CMakeCache.txt)
message(FATAL_ERROR "Aborting...in-source builds are forbidden")
endif(_is_in_src)
When running "cmake ." the error is given as expected. However, the source
directory is polluted with CMakeFiles and CMakeCache.txt. I expect they
can't be removed while the CMakeLists.txt is being interpreted (perhaps
they are but are just created before exit again).
Is there a better way to do this? Perhaps some function/macro that aborts
the process abnormally, cleaning up as if nothing ever happened exists?
Thank you for your time.
Ben
--
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