Hi Andreas,

I too am new to CMake, but let me take a crack at this... someone correct me if there's a better way.

You shouldn't need a find module. You only need them when you're including libraries that CMake doesn't already know the location of. Since you're building Library_1 in CMake you can just give the library target name directly to target_link_libraries.

Assuming you have:

Source/CMakeLists.txt
    ...
    add_subdirectory(Library_1)
    add_subdirectory(Application_1)

Source/Library_1/CMakeLists.txt
    add_library(Library_1 

then you can simply do this:

Source/Application_1/CMakeLists.txt
    add_executable( Application_1 app1.cpp )
    target_link_libraries( Application_1 Library_1 )
    # That said, I'm not quite sure the nicest way to include_directories of said library.
    # I've been using this:
    include_directories( "${PROJECT_SOURCE_DIR}/Library_1" )

Hope this helps,

-Carl

-----cmake-boun...@cmake.org wrote: -----

To: cmake@cmake.org
From: "m.hergarden" <m.hergar...@euphoria-it.nl>
Sent by: cmake-boun...@cmake.org
Date: 02/29/2012 01:50AM
Subject: Re: [CMake] Question regarding source tree structure and how to find libraries easily within that structure

On 02/26/2012 09:18 AM, Andreas Guther wrote:
Hello,

I'm justing starting to learn/use CMake and I have a question regarding the usage of it in regards of source tree structure and library usage.

I have the following folder structure:

Root
     Bin
          Win32X86Debug
          Win32X86Release
          ...
     Lib
          Win32X86Debug
          Win32X86Release
          ...
     Source
          ace
          Application_1
          Application_2
          boost
          Library_1
          Library_2
          Library_3
          ...
     Tools
         

I'd like to point out the structure within "Source". In the source directory there are libraries that may be used by one or more applications. That means for example that "Application_1" may use "Library_1" and "Library_3" and "Application_2" may use "Library_1" and "Library_2".

I have currently no idea how I should solve this without creating a find module for every library in the tree. Is there any other solution than creating find modules I can use?
If there is really no other (good) solution than creating find modules, is it possible to place the find modules (Library_n.cmake files, right?) within the library folders? I ask this, because I think it would make it much more easy to maintain them.

Kind regards,
Andreas
--

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
Is there a reason you can't use the 'include_directories' and 'link_directories' commands to add the correct linkpaths?

Micha

--

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

Reply via email to