<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"><<a href="mailto:lloydkl.tech@gmail.com" target="_blank">lloydkl.tech@gmail.com</a>></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"><<a href="mailto:eike@sf-mail.de" target="_blank">eike@sf-mail.de</a>></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>
> Hi,<br>
><br>
> I am new to Cmake and at present exploring its features for migrating our<br>
> projects build system to use it.<br>
><br>
> I have main source folder inside that another folder contains the source<br>
> for our custom library.<br>
><br>
> I understand that the problem is with my cmake file. Through that the<br>
> generated project cannot locate the location of my library build location.<br>
> What is the right way to solve this kind of problem?<br>
><br>
> Thanks,<br>
> Lloyd<br>
><br>
> As a sample I am including my Cmake code<br>
><br>
> #Cmake file of library source code<br>
> #Path-> Myproject/src/lib/reverse<br>
><br>
> cmake_minimum_required (VERSION 2.6)<br>
><br>
> if(WIN32)<br>
> SET (REV_SRC reverse.cpp reverse.h)<br>
> else(WIN32)<br>
> SET (REV_SRC reverse.cpp)<br>
> 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 "if(WIN32)" clause and the addition of "reverse.h" in SET (REV_SRC reverse.cpp reverse.h)? Otherwise I think visual studio projects wont add the header file to the solution'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>
> ADD_DEFINITIONS(-DREVERSE_EXPORTS)<br>
><br>
> ADD_LIBRARY(Reverse SHARED ${REV_SRC})<br>
><br>
><br>
><br>
> This is my CMake file inside the Src folder<br>
><br>
> #Cmake file of main source code<br>
> #Path-> Myproject/src/<br>
> cmake_minimum_required (VERSION 2.6)<br>
><br>
> FIND_PACKAGE(Qt4 REQUIRED)<br>
> INCLUDE(${QT_USE_FILE})<br>
> INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib/reverse)<br>
><br>
> ADD_SUBDIRECTORY(lib/reverse)<br>
><br>
> ADD_EXECUTABLE(Tutorial main.cpp)<br>
><br>
> TARGET_LINK_LIBRARIES(Tutorial ${QT_LIBRARIES})<br>
> #############################################################<br>
> #I understand that the problem is here, because it cant locate my library.<br>
> TARGET_LINK_LIBRARIES(Tutorial reverse)<br>
> #############################################################<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 'reverse.lib') . I have also removed the entry for adding subdirectory (the lib/reverse) in my src folder'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 "Enable Testing?")<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>