{"id":1097,"date":"2022-08-30T15:12:20","date_gmt":"2022-08-30T15:12:20","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/cmake-defined-does-not-seems-to-recognize-variable-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:12:20","modified_gmt":"2022-08-30T15:12:20","slug":"cmake-defined-does-not-seems-to-recognize-variable-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/cmake-defined-does-not-seems-to-recognize-variable-collection-of-common-programming-errors\/","title":{"rendered":"cmake DEFINED does not seems to recognize variable-Collection of common programming errors"},"content":{"rendered":"<p>I have this code in cmake:<\/p>\n<pre><code>#mandatory\nSET(BOOST_DIR \"$ENV{BOOST_HOME}\")\nif (DEFINED ${BOOST_DIR})\n    #global include directories\n    include_directories(${BOOST_DIR})\nelse(DEFINED ${BOOST_DIR})\n    message( STATUS \"BOOST_HOME at ${BOOST_DIR}\")\n\n    message( FATAL_ERROR \"Undefined BOOST_HOME env var.\")\nendif(DEFINED ${BOOST_DIR})\n<\/code><\/pre>\n<p>The env var BOOST_HOME is defined (\/home\/ferran\/boost). The behavior is very odd because the output is:<\/p>\n<pre><code>-- BOOST_HOME at \/home\/ferran\/boost\nCMake Error at CMakeLists.txt:14 (message):\n  Undefined BOOST_HOME env var.\n\n\n-- Configuring incomplete, errors occurred!\n<\/code><\/pre>\n<p>So, the var exists and prints its contents and at the same time does not exists?<\/p>\n<ol>\n<li>\n<p>You need to avoid dereferencing the variable <code>BOOST_DIR<\/code> in the <code>if<\/code> statement:<\/p>\n<pre><code>set(BOOST_DIR \"$ENV{BOOST_HOME}\")\nif(BOOST_DIR)               #<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:23:10. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have this code in cmake: #mandatory SET(BOOST_DIR &#8220;$ENV{BOOST_HOME}&#8221;) if (DEFINED ${BOOST_DIR}) #global include directories include_directories(${BOOST_DIR}) else(DEFINED ${BOOST_DIR}) message( STATUS &#8220;BOOST_HOME at ${BOOST_DIR}&#8221;) message( FATAL_ERROR &#8220;Undefined BOOST_HOME env var.&#8221;) endif(DEFINED ${BOOST_DIR}) The env var BOOST_HOME is defined (\/home\/ferran\/boost). The behavior is very odd because the output is: &#8212; BOOST_HOME at \/home\/ferran\/boost CMake Error at CMakeLists.txt:14 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1097","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1097"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1097\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}