diff --git a/CMake/PreventInSourceBuilds.cmake b/CMake/PreventInSourceBuilds.cmake index 60f035f68683f500d71d7485c290bce4e0811b9a..2a402061c3e89b78c2055e2538e15d548d96a9c3 100644 --- a/CMake/PreventInSourceBuilds.cmake +++ b/CMake/PreventInSourceBuilds.cmake @@ -1,9 +1,14 @@ # # This function will prevent in-source builds function(AssureOutOfSourceBuilds) - # make sure the user doesn't play dirty with symlinks - get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) - get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) + if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.6) + # make sure the user doesn't play dirty with symlinks + get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) + get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) + else() + get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" ABSOLUTE) + get_filename_component(bindir "${CMAKE_BINARY_DIR}" ABSOLUTE) + endif() # disallow in-source builds if("${srcdir}" STREQUAL "${bindir}")