Prevent invocation of makefile and force use of cmake --build


I’m using a Cmake project with vcpkg integration for dependency management. Since the makefile can invoke Cmake at any point if a file like a CmakeLists.txt changes, and the user is running make from the build directory, the missing vcpkg variables feed by the profile cause compilation issues. So I’m recommending our users to build using cmake --build --preset <preset>, but I want to add some sort of big warning message in the makefile so if is invoked outside of the cmake build command it warns the user. Any recommendation about how to add a custom code snipped in the generated Makefile? Or any other approach that can be suggested?

Try an approach using a sentinel environment variable: CMake force use of presets · GitHub

1 Like