Checking CMake Variables
I have the following piece of CMake code in my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
message(STATUS "Before setting - ${MY_VARIABLE}")
# first check
if(NOT DEFINED ${MY_VARIABLE})
set(MY_VARIABLE true)
endif(NOT DEFINED ${MY_VARIABLE})
message(STATUS "After setting - ${MY_VARIABLE}")
# second check
if(NOT DEFINED ${MY_VARIABLE})
message(STATUS "What - ${MY_VARIABLE}")
endif(NOT DEFINED ${MY_VARIABLE})
Exiting CMake config:
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/local/bin/cc
-- Check for working C compiler: /usr/local/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Before setting -
-- After setting - true
-- What - true
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/build
Question : Why is the second check of the variable variable definition report not defined even though it is? Surprisingly, the value of the variable is printed correctly as well!
+3
source to share