including generated cmake-files from a ExternalPackage

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

including generated cmake-files from a ExternalPackage

jens persson
Hello,

I have a problem relating to ExterlalPackage

I have to project (main and lib in this example) that is placed in two
directories next to each other where main needs lib to be able to
link.  I have created a set up so that the main procject uses
ExternalProject to compile lib. This works flawless but since lib is
cmake based I have a export command that creates a include file that I
want to use when configuring main, but since that is not created until
build time I have problems with using it in main/CMakeLists.txt. A
workaround I have used is distributing a empty include file so that
the configure steps goes through but the linking of main fails on the
first run of make, on the second cmake notices that the include file
is updated and reconfigures.


Anyone have any sugestions about how to solve this?

Side note, I don't know if it complicates things but the builds have
to be runnable in tree (no install step).


Thanks in advance
/jp


Example files below:
main/CMakeLists.txt

INCLUDE(ExternalProject)
INCLUDE(../lib/module_toc.cmake)

add_executable(tester
        main.c
)

target_link_libraries(tester
        mylib)

ExternalProject_Add(mylib_a
        DOWNLOAD_COMMAND ""
        SOURCE_DIR ../lib
        CONFIGURE_COMMAND ${CMAKE_COMMAND} .
        BUILD_IN_SOURCE 1
        INSTALL_COMMAND ""


lib/CMakeLists.txt:
PROJECT (lib)
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
CMAKE_POLICY (VERSION 2.6)

add_library(mylib
        bar.c
        foo.c
)

export(
        TARGETS mylib
        FILE module_toc.cmake
        )


--
jens persson
<[hidden email]>
Mäster Olofsväg 24
S-224 66 LUND;SWEDEN
_______________________________________________
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