I tried to port a package (cmake based) to OpenWRT. However, its CMakeLists.txt file includes the following scripts to disable the in-source build. I can create a simple patch to remove the scripts and be done with it. However, there are a whole lot more cmake based packages out there that implement such an out-of-source build. Therefore, it certainly will make more sense to learn how to taylor an OpenWRT Makefile for the package to comply with the out-of-source build. If any cmake experts here can lend some hands, I certainly will appreciate that.

#
# Prevent in-source builds
# If an in-source build is attempted, you will still need to clean up a few
# files manually.
#
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
  message(FATAL_ERROR "In-source builds in ${CMAKE_BINARY_DIR} are not "
   "allowed, please remove ./CMakeCache.txt and ./CMakeFiles/, create a "
   "separate build directory and run cmake from there.")
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")