[CMake] how to specify dependencies out of the source tree?

Michal Turlik michal_tlk at yahoo.com
Wed Jan 26 11:21:12 EST 2011


I thank you so much Eric,
However I managed this thing and obteined the expected result by writing something similar and then including it in my root CMakeLists.txt:

----- util lib dependency -----
# -*- Makefile -*-

IF(BUILD_STANDALONE)

  project( util_lib_pro )

# compatibility issues
  cmake_minimum_required( VERSION 2.6 )
  mark_as_advanced( CMAKE_BACKWARDS_COMPATIBILITY )

  include( "$ENV{CMAKE_ADDITIONAL_MODULES_DIR}/CommonRules.cmake" )
  include( "Project.cmake" )

  set(UTIL_SOURCES ByteArray.cpp command.cpp Config.cpp Logger.cpp
                   StringUtils.cpp Time.cpp Guard.cpp)

ELSE(BUILD_STANDALONE)

  set(_UTIL "$ENV{COMMON_INCDIR}/util")
  #set(CMAKE_SOURCE_DIR ${_UTIL} ${CMAKE_SOURCE_DIR})

  set(UTIL_SOURCES ${_UTIL}/ByteArray.cpp ${_UTIL}/command.cpp ${_UTIL}/Config.cpp
                   ${_UTIL}/Logger.cpp ${_UTIL}/StringUtils.cpp ${_UTIL}/Time.cpp
                   ${_UTIL}/Guard.cpp)

ENDIF(BUILD_STANDALONE)

# target
set(util_LIBRARIES util)
add_library(${util_LIBRARIES} ${UTIL_SOURCES})


--- On Wed, 1/26/11, Eric Noulard <eric.noulard at gmail.com> wrote:

From: Eric Noulard <eric.noulard at gmail.com>
Subject: Re: [CMake] how to specify dependencies out of the source tree?
To: "Michal Turlik" <michal_tlk at yahoo.com>
Cc: cmake at cmake.org
Date: Wednesday, January 26, 2011, 12:44 PM

2011/1/26 Michal Turlik <michal_tlk at yahoo.com>
>
> Hi all
> I am trying to build and link against a dependency out of the source tree.
> I tried to arrange a custom target/command combo but it did not work.
> Could someone help me with this?
> What I really need is how to let cmake and make be correclty launched for such an out of tree dependency before it would be linked with my application.
> thank you so much

Did you have a look at ExternalProject_Add from ExternalProject module?

see:
cmake --help-module ExternalProject


--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110126/1cebe07d/attachment.htm>


More information about the CMake mailing list