<div><div dir="auto">I suppose it all depends on if there are situations where you don’t want those variables set? To me, it doesn’t make sense to ever not have version numbers set so I would use #define.</div></div><div dir="auto"><br></div><div dir="auto">-Caleb</div><div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 15, 2018 at 8:32 AM Ian Cullen <<a href="mailto:ian.james.cullen@gmail.com">ian.james.cullen@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm trying to create a header file containing version number details but <br>
am not sure if the following behaviour is expected or a bug.<br>
<br>
Simplified example has 2 files<br>
<br>
==> CMakeLists.txt <==<br>
cmake_minimum_required(VERSION 3.11)<br>
project (<br>
VersionTest<br>
VERSION 1.0.4<br>
)<br>
<br>
configure_file (<br>
"${PROJECT_SOURCE_DIR}/<a href="http://config.h.in" rel="noreferrer" target="_blank">config.h.in</a>"<br>
"${PROJECT_BINARY_DIR}/config.h"<br>
@ONLY<br>
)<br>
<br>
==> <a href="http://config.h.in" rel="noreferrer" target="_blank">config.h.in</a> <==<br>
#cmakedefine VersionTest_VERSION_MAJOR @VersionTest_VERSION_MAJOR@<br>
#cmakedefine VersionTest_VERSION_MINOR @VersionTest_VERSION_MINOR@<br>
#define VersionTest_VERSION_MINOR @VersionTest_VERSION_MINOR@<br>
<br>
<br>
Running cmake creates the output file as required but it has the <br>
following contents<br>
<br>
==> config.h <==<br>
#define VersionTest_VERSION_MAJOR 1<br>
/* #undef VersionTest_VERSION_MINOR */<br>
#define VersionTest_VERSION_MINOR 0<br>
<br>
<br>
Looking at the manual <br>
(<a href="https://cmake.org/cmake/help/v3.12/command/configure_file.html" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/v3.12/command/configure_file.html</a>), this <br>
appears to be because the number '0' is considered false by the if() <br>
command, however '0' is valid within a version number, so perhaps should <br>
not be considered false in this context.<br>
<br>
Is this a known issue? Is it recommended to use #define rather than <br>
#cmakedefine for these types of files?<br>
<br>
Thanks<br>
<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></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Sent from my iPhone 4s</div>