<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Agreed, version numbers will never not be set so #define is the
better choice in this case. However this seems like an easy thing
for users to trip-up on, particularly as only #cmakedefine is used
in the configure_file() manual page.<br>
<br>
Perhaps an additional example, or an INFO/WARNING section in the
manual to highlight this 'issue'?<br>
<br>
<br>
<div class="moz-cite-prefix">On 15/08/2018 13:56, J. Caleb Wherry
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAJxY6XoXcKbQUbsgOMt=XkGA9f-Txo+3pz52PibE56oE2UXXDQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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"
moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a
href="http://cmake.org/cmake/help/consulting.html"
rel="noreferrer" target="_blank" moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">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" moz-do-not-send="true">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>
</blockquote>
<br>
</body>
</html>