[CMake] checking arguments
Andrea Crotti
andrea.crotti.0 at gmail.com
Wed Feb 22 10:36:56 EST 2012
I find not so nice that CMake doesn't complain at all if some variables
are not defined.
Is there a way to make it complain if a variable used is actually blank?
In the meanwhile I ended up with this:
set(COMPULSORY_ARGUMENTS PSI)
set(OPTIONAL_ARGUMENTS WORKSPACE CONTAINER_PATHS)
macro (check_compulsory_variable var)
if (NOT DEFINED ${var})
message(FATAL_ERROR "variable ${var} is not defined")
endif ()
endmacro ()
macro (check_optional_variable var)
if (NOT DEFINED ${var})
message(WARNING "variable ${var} is not defined")
endif ()
endmacro ()
foreach (arg ${COMPULSORY_ARGUMENTS})
check_compulsory_variable(${arg})
endforeach ()
foreach (arg ${OPTIONAL_ARGUMENTS})
check_optional_variable(${arg})
endforeach ()
which is not great but it does the job.
Any better solutions?
More information about the CMake
mailing list