-#-----------------------------------------------------------------------------
-# Building in the source tree is forbidden !
-IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
- MESSAGE(FATAL_ERROR "Building in the source tree is not allowed !! Quit; remove the file 'CMakeCache.txt' and the folder 'CMakeFiles' and build outside the sources")
-ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
-#-----------------------------------------------------------------------------
+IF(NOT ALLOW_IN_SOURCE_BUILD)
+ #---------------------------------------------------------------------------
+ # Building in the source tree is forbidden !
+ # (except if ALLOW_IN_SOURCE_BUILD is set, e.g. for packaging with rpmbuild)
+ IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
+ MESSAGE(FATAL_ERROR "Building in the source tree is not allowed !! Quit; remove the file 'CMakeCache.txt' and the folder 'CMakeFiles' and build outside the sources")
+ ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
+ #---------------------------------------------------------------------------
+ENDIF(NOT ALLOW_IN_SOURCE_BUILD)