Thank you very much for your help.<br><br>The header file is already #included in one of the source files. What I don'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"><<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>></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>
> Hello,<br>
><br>
> I am trying to include a windows header file in my build.<br>
> The simplest way I found is to add the following in the main CMakeLists.txt<br>
> file:<br>
><br>
> include_directories ("${MYPRJ_SOURCE_DIR}/../../../usr/include/w32api")<br>
> add_library (w32api w32api/winbase.h)<br>
><br>
> add_executable (myprj ${hostFiles})<br>
> target_link_libraries (myprj w32api)<br>
><br>
><br>
> I am working in Cygwin, and my project is in /home/<my-user>/myprj, that's<br>
> why I am using<br>
><br>
> ${MYPRJ_SOURCE_DIR}/../../../usr/include/w32api<br>
><br>
> since "/" is the root in my cygwin system and the file I want is in<br>
> /usr/include/w32api<br>
><br>
> but when running cmake I get the following error:<br>
><br>
> CMake Error in CMakeLists.txt:<br>
> Cannot find source file "winbase.h". Tried extensions .c .C .c++ .cc .cpp<br>
> .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx<br>
><br>
> 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't need it in the add_library line<br>
2. you're trying to build a library from a header file<br>
3. you're adding files that are not part of your source code to your<br>
targets<br>
4. you'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'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>