I have this code in cmake:
#mandatory
SET(BOOST_DIR \"$ENV{BOOST_HOME}\")
if (DEFINED ${BOOST_DIR})
#global include directories
include_directories($
You need to avoid dereferencing the variable BOOST_DIR
in the if
statement:
set(BOOST_DIR "$ENV{BOOST_HOME}")
if(BOOST_DIR) # <--- Use 'BOOST_DIR', not 'DEFINED ${BOOST_DIR}'
#global include directories
include_directories(${BOOST_DIR})
else()
message(STATUS "BOOST_HOME at ${BOOST_DIR}")
message(FATAL_ERROR "Undefined BOOST_HOME env var.")
endif()
By dereferencing BOOST_DIR
, you're effectively querying if CMake has a variable called /home/ferran/boost
defined.