On Fri, Apr 12, 2013 at 11:58 AM, Rolf Eike Beer <e...@sf-mail.de> wrote:
> Lloyd wrote: > > Hi, > > > > I am new to Cmake and at present exploring its features for migrating our > > projects build system to use it. > > > > I have main source folder inside that another folder contains the source > > for our custom library. > > > > I understand that the problem is with my cmake file. Through that the > > generated project cannot locate the location of my library build > location. > > What is the right way to solve this kind of problem? > > > > Thanks, > > Lloyd > > > > As a sample I am including my Cmake code > > > > #Cmake file of library source code > > #Path-> Myproject/src/lib/reverse > > > > cmake_minimum_required (VERSION 2.6) > > > > if(WIN32) > > SET (REV_SRC reverse.cpp reverse.h) > > else(WIN32) > > SET (REV_SRC reverse.cpp) > > endif(WIN32) > > There is no reason for this. CMake knows that it does not have to compile > header files, so it wont add compile rules for them e.g. in Makefiles. Just > always add them to the project, this has some additional benefits for > generated headers and the like. > 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. > > > ADD_DEFINITIONS(-DREVERSE_EXPORTS) > > > > ADD_LIBRARY(Reverse SHARED ${REV_SRC}) > > > > > > > > This is my CMake file inside the Src folder > > > > #Cmake file of main source code > > #Path-> Myproject/src/ > > cmake_minimum_required (VERSION 2.6) > > > > FIND_PACKAGE(Qt4 REQUIRED) > > INCLUDE(${QT_USE_FILE}) > > INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib/reverse) > > > > ADD_SUBDIRECTORY(lib/reverse) > > > > ADD_EXECUTABLE(Tutorial main.cpp) > > > > TARGET_LINK_LIBRARIES(Tutorial ${QT_LIBRARIES}) > > ############################################################# > > #I understand that the problem is here, because it cant locate my > library. > > TARGET_LINK_LIBRARIES(Tutorial reverse) > > ############################################################# > > You just need to make sure that it goes into the lib folder first, before > going into src. So the top level CMakeLists.txt should have > > add_subdirectory(lib) > # or lib/reverse above, depending if you have something in lib/ > add_subdirectory(src) > 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 #Root cmake file cmake_minimum_required (VERSION 2.6) PROJECT (Tutorial) ADD_SUBDIRECTORY(src/lib/reverse) ADD_SUBDIRECTORY(src) SET (DO_TEST false CACHE BOOL "Enable Testing?") if(DO_TEST) ENABLE_TESTING() ADD_SUBDIRECTORY(tests) endif(DO_TEST) Thank you very much, Lloyd > > Eike > -- > > -- > > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake >
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake