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.

> 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)

Eike
-- 

Attachment: signature.asc
Description: This is a digitally signed message part.

--

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

Reply via email to