<div dir="ltr">Hi Lloyd, <div><br></div><div>Seems you have a small typo, target name case should be consistent.</div><div><br></div><div style>Try to use:</div><div style>   </div><div style>   <span style="font-family:arial,sans-serif;font-size:12.800000190734863px">TARGET_LINK_LIBRARIES(Tutorial Reverse)</span></div>

<div style><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">instead of </span></div><div style>

<span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">   </span><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">TARGET_LINK_LIBRARIES(Tutorial reverse)</span></div>

<div style><span style="font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Hth</span></div><div style><span style="font-family:arial,sans-serif;font-size:12.800000190734863px">Jc</span></div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 12, 2013 at 2:48 AM, Lloyd <span dir="ltr">&lt;<a href="mailto:lloydkl.tech@gmail.com" target="_blank">lloydkl.tech@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Fri, Apr 12, 2013 at 11:58 AM, Rolf Eike Beer <span dir="ltr">&lt;<a href="mailto:eike@sf-mail.de" target="_blank">eike@sf-mail.de</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Lloyd wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I am new to Cmake and at present exploring its features for migrating our<br>
&gt; projects build system to use it.<br>
&gt;<br>
&gt; I have main source folder inside that another folder contains the source<br>
&gt; for our custom library.<br>
&gt;<br>
&gt; I understand that the problem is with my cmake file. Through that the<br>
&gt; generated project cannot locate the location of my library build location.<br>
&gt; What is the right way to solve this kind of problem?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;   Lloyd<br>
&gt;<br>
&gt; As a sample I am including my Cmake code<br>
&gt;<br>
&gt; #Cmake file of library source code<br>
&gt; #Path-&gt; Myproject/src/lib/reverse<br>
&gt;<br>
&gt; cmake_minimum_required (VERSION 2.6)<br>
&gt;<br>
&gt; if(WIN32)<br>
&gt; SET (REV_SRC reverse.cpp reverse.h)<br>
&gt; else(WIN32)<br>
&gt; SET (REV_SRC reverse.cpp)<br>
&gt; endif(WIN32)<br>
<br>
</div>There is no reason for this. CMake knows that it does not have to compile<br>
header files, so it wont add compile rules for them e.g. in Makefiles. Just<br>
always add them to the project, this has some additional benefits for<br>
generated headers and the like.<br></blockquote><div><br><br></div></div></div><div>You mean the &quot;if(WIN32)&quot; clause and the addition of &quot;reverse.h&quot; in SET (REV_SRC reverse.cpp reverse.h)? Otherwise I think visual studio projects wont add the header file to the solution&#39;s source file hierarchy.<br>


</div><div class="im"><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><br>
&gt; ADD_DEFINITIONS(-DREVERSE_EXPORTS)<br>
&gt;<br>
&gt; ADD_LIBRARY(Reverse SHARED ${REV_SRC})<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; This is my CMake file inside the Src folder<br>
&gt;<br>
&gt; #Cmake file of main source code<br>
&gt; #Path-&gt; Myproject/src/<br>
&gt; cmake_minimum_required (VERSION 2.6)<br>
&gt;<br>
&gt; FIND_PACKAGE(Qt4 REQUIRED)<br>
&gt; INCLUDE(${QT_USE_FILE})<br>
&gt; INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib/reverse)<br>
&gt;<br>
&gt; ADD_SUBDIRECTORY(lib/reverse)<br>
&gt;<br>
&gt; ADD_EXECUTABLE(Tutorial main.cpp)<br>
&gt;<br>
&gt; TARGET_LINK_LIBRARIES(Tutorial ${QT_LIBRARIES})<br>
&gt; #############################################################<br>
&gt; #I understand that the problem is here, because it cant locate my library.<br>
&gt; TARGET_LINK_LIBRARIES(Tutorial reverse)<br>
&gt; #############################################################<br>
<br>
</div>You just need to make sure that it goes into the lib folder first, before<br>
going into src. So the top level CMakeLists.txt should have<br>
<br>
add_subdirectory(lib)<br>
# or lib/reverse above, depending if you have something in lib/<br>
add_subdirectory(src)<br></blockquote><div><br></div></div><div>I tried in the way you have mentioned, but the error persists (fatal error LNK1104: cannot open file &#39;reverse.lib&#39;) . I have also removed the entry for adding subdirectory (the lib/reverse)  in my src folder&#39;s cmake file ( ADD_SUBDIRECTORY(lib/reverse)). The following is my main cmake file<br>


</div><div><br>#Root cmake file<br>cmake_minimum_required (VERSION 2.6)<br>PROJECT (Tutorial)<br><br>ADD_SUBDIRECTORY(src/lib/reverse)<br>ADD_SUBDIRECTORY(src)<br><br>SET (DO_TEST false CACHE BOOL &quot;Enable Testing?&quot;)<br>


if(DO_TEST)<br>ENABLE_TESTING()<br>ADD_SUBDIRECTORY(tests)<br>endif(DO_TEST)<br><br><br></div><div>Thank you very much,<br></div><div>  Lloyd<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<span><font color="#888888"><br>
Eike<span class="HOEnZb"><font color="#888888"><br>
--<br>
</font></span></font></span><span class="HOEnZb"><font color="#888888"><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></font></span></blockquote></div><br></div></div>
<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><br clear="all"><div><br></div>-- <br>+1 919 869 8849<br>
</div>