Thank you very much for your help.<br><br>The header file is already #included in one of the source files. What I don&#39;t know is how to link it.<br>Can I do it only with target_link_libraries ( ) or how?<br><br>Thanks<br>
<br>Enrique<br><br><div class="gmail_quote">On Mon, Feb 28, 2011 at 5:26 PM, Andreas Pakulat <span dir="ltr">&lt;<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On 28.02.11 16:55:12, Enrique Izaguirre wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt; I am trying to include a windows header file in my build.<br>
&gt; The simplest way I found is to add the following in the main CMakeLists.txt<br>
&gt; file:<br>
&gt;<br>
&gt; include_directories (&quot;${MYPRJ_SOURCE_DIR}/../../../usr/include/w32api&quot;)<br>
&gt; add_library (w32api w32api/winbase.h)<br>
&gt;<br>
&gt; add_executable (myprj ${hostFiles})<br>
&gt; target_link_libraries (myprj w32api)<br>
&gt;<br>
&gt;<br>
&gt; I am working in Cygwin, and my project is in /home/&lt;my-user&gt;/myprj, that&#39;s<br>
&gt; why I am using<br>
&gt;<br>
&gt;  ${MYPRJ_SOURCE_DIR}/../../../usr/include/w32api<br>
&gt;<br>
&gt; since &quot;/&quot; is the root in my cygwin system and the file I want is in<br>
&gt; /usr/include/w32api<br>
&gt;<br>
&gt; but when running cmake I get the following error:<br>
&gt;<br>
&gt; CMake Error in CMakeLists.txt:<br>
&gt;   Cannot find source file &quot;winbase.h&quot;.  Tried extensions .c .C .c++ .cc .cpp<br>
&gt;   .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx<br>
&gt;<br>
&gt; I have not been able to find out what is going on. Could you help please?<br>
<br>
</div></div>There are several errors here:<br>
<br>
1. you already added the w32api directory to the include-dirs, so you<br>
don&#39;t need it in the add_library line<br>
2. you&#39;re trying to build a library from a header file<br>
3. you&#39;re adding files that are not part of your source code to your<br>
targets<br>
4. you&#39;re trying to link an executable against that header file, what<br>
you really want is #include the header file in your sources and link to<br>
whatever library provides the implementation for winbase.h<br>
<br>
If you fix 4. you won&#39;t need to fix 1-3.<br>
<br>
Andreas<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>