<div dir="ltr">I've come across some projects where the source files listed in their add_executable() and add_library() commands do not have file extensions. It seems that CMake still finds the sources by trying some set of file suffixes. This is not documented behaviour, but it does show up in error messages if you give those commands a file name for a non-existent source. For example, if I specify a full filename which doesn't exist, I see an error message similar to the following:<div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">CMake Error at /somepath/CMakeLists.txt:10 (add_library):</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"> Cannot find source file:</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"> ../somethingThatDoesNotExist.h</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"> Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures"> .hxx .in .txx</span></p><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><br></div><div>So my question is whether specifying source file names without extensions is a feature which is simply missing documentation or is it an undocumented feature that projects are not supposed to use? Since there are error messages like the above, it would seem that the latter would be a harder position to justify.</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div></div>