<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">$ cmake --version<br>cmake version 3.13.2<br></div><div dir="ltr"><br></div><div dir="ltr">$ cmake -S src -B testON<br>ON is ON<br>-- Configuring done<br>-- Generating done<br>-- Build files have been written to:...</div><div dir="ltr"><br></div><div dir="ltr">$ cat src/CMakeLists.txt<br>cmake_minimum_required(VERSION 3.12)<br><br>project(sample C)<br><br>if(ON)<br>  message("ON is ON")<br>endif()<br><br></div><div>What version are you using?<br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 26, 2019 at 10:39 AM Mario Emmenlauer <<a href="mailto:mario@emmenlauer.de">mario@emmenlauer.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Dear All,<br>
<br>
I'm plagued by an issue that I do not understand. An if-statement<br>
(in a package configuration file) evaluates ON to false:<br>
<br>
IF(ON)<br>
    ...some code here<br>
ENDIF()<br>
<br>
The part inside IF is *not* executed. Replacing ON by TRUE does not<br>
help, only replacing it by 1 helps. Is this correct behaviour? I can<br>
not understand this from the documentation. The docs seem to say "ON"<br>
would be a valid token for true: <a href="https://cmake.org/cmake/help/v3.6/command/if.html" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/v3.6/command/if.html</a><br>
<br>
The full user story is that in the package configuration I'd like to<br>
treat shared libraries specially, so I use "IF(@BUILD_SHARED_LIBS@)".<br>
The user configures the build with<br>
<br>
    cmake -DBUILD_SHARED_LIBS=ON .<br>
<br>
so the package configuration gets resolved to "IF(ON)". I have not<br>
too much control about the way users specify the options, so I'd<br>
like to solve this on my end. If options should not keep the value<br>
"ON", how can I cleanly resolve them to the corresponding number 0/1?<br>
<br>
Am I doing something wrong?<br>
<br>
All the best,<br>
<br>
    Mario Emmenlauer<br>
<br>
<br>
--<br>
BioDataAnalysis GmbH, Mario Emmenlauer     Tel. Office: +49-89-74677203<br>
Balanstr. 43                   mailto: memmenlauer * <a href="http://biodataanalysis.de" rel="noreferrer" target="_blank">biodataanalysis.de</a><br>
D-81669 Munich                           <a href="http://www.biodataanalysis.de/" rel="noreferrer" target="_blank">http://www.biodataanalysis.de/</a><br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>