# Fails the build if any file under Source/Engine includes something from Source/Game. # # cmake -DENGINE_DIR= -P CheckEngineDeps.cmake # # Engine and game share Source/ as their include root, so the compiler would # happily resolve "Game/..." from engine code. This keeps the dependency one-way. file(GLOB_RECURSE engine_files "${ENGINE_DIR}/*.h" "${ENGINE_DIR}/*.hpp" "${ENGINE_DIR}/*.cpp") set(violations "") foreach (file IN LISTS engine_files) file(STRINGS "${file}" lines REGEX "^[ \t]*#[ \t]*include[ \t]*[<\"](\\.\\./)*Game/") foreach (line IN LISTS lines) file(RELATIVE_PATH rel "${ENGINE_DIR}/.." "${file}") string(STRIP "${line}" line) string(APPEND violations "\n ${rel}: ${line}") endforeach () endforeach () if (violations) message(FATAL_ERROR "Engine code must not include Game code:${violations}") endif ()