I have try this: # Options for debug level if(NOT DEFINED ${DEBUG_LEVEL}) add_definitions(-DDEBUG=0) else(NOT DEFINED ${DEBUG_LEVEL}) add_definitions(-DDEBUG=${DEBUG_LEVEL}) endif(NOT DEFINED ${DEBUG_LEVEL}) With the command line: cmake -DDEBUG_LEVEL=50 ./ That's not work, why?