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

**URL:** https://discourse.cmake.org/t/prevent-invocation-of-makefile-and-force-use-of-cmake-build/9968
**Category:** Usage
**Created:** [January 30, 2024, 5:04pm UTC](https://discourse.cmake.org/t/prevent-invocation-of-makefile-and-force-use-of-cmake-build/9968 "2024-01-30T17:04:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ddompe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ddompe/32/4247_2.png) [@ddompe](https://discourse.cmake.org/u/ddompe)
#### Post date: [January 30, 2024, 5:04pm UTC](https://discourse.cmake.org/t/prevent-invocation-of-makefile-and-force-use-of-cmake-build/9968/1 "2024-01-30T17:04:59Z")

</div>

Hello,

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?

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [January 31, 2024, 3:46pm UTC](https://discourse.cmake.org/t/prevent-invocation-of-makefile-and-force-use-of-cmake-build/9968/2 "2024-01-31T15:46:24Z")

</div>

Try an approach using a sentinel environment variable: [CMake force use of presets · GitHub](https://gist.github.com/scivision/8fe5812bcb56ac28e7a1e41f1f9a689d)
