Does cmake
have a mechanism to generate an error when using a undefined variable, a bit like set -u
option in bash
.
I have a big project composed of several CMakeLists.txt
files, representing ~1500 lines, so it is quite difficult to use this construction: if(NOT DEFINED VAR_NAME)
In a ideal world, the following CMakeLists.txt
whould fail.
cmake_minimum_required(VERSION 3.13)
message(STATUS "Will delete ${DIR}/${FILE}")
cmake
documentation is huge, I may have missed it)With version 3.5.x, the new -Werror=dev
combined with --warn-uninitialized
has the behavior I wanted.
So final solution is just to create an alias:
alias cmake="cmake -Werror=dev --warn-uninitialized"