+# Warning when build is not an out-of-source build.
+string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" InSourceBuild)
+if(InSourceBuild)
+ message(WARNING "Avoid building inside the source tree!")
+ message(WARNING "Create a separate build directory instead (i.e. 'sgbuild') and call CMake from there: ")
+ message(WARNING " mkdir ../sgbuild && cd ../sgbuild && cmake ${CMAKE_SOURCE_DIR}")
+endif(InSourceBuild)
+