Basically, FindBoost.cmake would have to accept a "BOOST_DIR" input that *told* it where Boost was. It would then not do any "finding" at all, but trust the input to tell it where boost things were...<div>
<br></div><div>(Like VTK does.)</div><div><br></div><div>Then, after building Boost with ExternalProject_Add, you could build other things that depend on it with ExternalProject_Add and tell those other things "-D BOOST_DIR= where I built or installed it in the previous ExternalProject_Add"... Then those things in their CMakeLists.txt files, would be able to do a FindBoost call and get correct results because they have the BOOST_DIR defined for them...</div>
<div><br></div><div>Basically, if you use ExternalProject_Add to build *some* components in a project, you should use it to build *all* components in a project. Then, the one at the end of the dependency chain, by the time it gets to do its real configure/build and install, all of its dependencies are built and installed already.</div>
<div><br></div><div>You should NOT try to mix & match ExternalProject_Add and "finding" stuff. You should use ExternalProject_Add to build/install stuff in a known location and then reference it there directly, without any "find" calls.</div>
<div><br></div><div>Does that make sense?</div><div><br></div><div>I know it's complex, ... but it's complex.</div><div><br></div><div><br></div><div>HTH,</div><div>David</div><div><br></div><div><br><div class="gmail_quote">
On Wed, Mar 24, 2010 at 5:10 PM, Michael Jackson <span dir="ltr"><<a href="mailto:mike.jackson@bluequartz.net">mike.jackson@bluequartz.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
What all is needed in a CMake project to make it work correctly/better with ExternalProject_Add(). Here is what I am trying. Project A (Boost) should be built before Project B (MXA). I used to do all this manually but I started looking at ExternalProject_Add() to see if that could help me and others build my project easier.<br>
<br>
I simply have the following in a CMakeLists.txt file<br>
project (Combined)<br>
cmake_minimum_required(VERSION 2.8)<br>
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)<br>
<br>
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin )<br>
<br>
# --------- Setup the Executable output Directory -------------<br>
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin )<br>
<br>
# --------- Setup the Executable output Directory -------------<br>
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin )<br>
<br>
set (EP_BASE "Boost")<br>
ExternalProject_Add(<br>
Boost<br>
TMP_DIR Boost/tmp<br>
STAMP_DIR Boost/stamp<br>
DOWNLOAD_DIR Boost/Download<br>
DOWNLOAD_COMMAND ""<br>
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../MXABoost<br>
CMAKE_ARGS -DBOOST_INCLUDE_INSTALL_DIR=include/boost-1_36 -DBUILD_SOVERSIONED=OFF -DBOOST_LIB_INSTALL_DIR=lib -DENABLE_DEBUG=ON -DENABLE_MULTI_THREADED=ON -DENABLE_RELEASE=ON -DENABLE_SHARED=OFF -DENABLE_SINGLE_THREADED=OFF -DENABLE_STATIC=ON -DINSTALL_VERSIONED=OFF -DWITH_MPI=OFF -DWITH_PYTHON=OFF -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/Boost/Install<br>
BINARY_DIR Boost/Build<br>
BUILD_COMMAND make -j16<br>
INSTALL_DIR Boost/Install<br>
)<br>
<br>
set ($ENV{BOOST_ROOT} "${PROJECT_BINARY_DIR}/Boost/Install")<br>
set (BOOST_ROOT "${PROJECT_BINARY_DIR}/Boost/Install")<br>
# ---------- Find Boost Headers/Libraries -----------------------<br>
SET (Boost_FIND_REQUIRED TRUE)<br>
SET (Boost_FIND_QUIETLY TRUE)<br>
set (Boost_USE_MULTITHREADED TRUE)<br>
set (Boost_USE_STATIC_LIBS TRUE)<br>
SET (Boost_ADDITIONAL_VERSIONS "1.36" "1.36.0" "1.41" "1.41.0" "1.39" "1.39.0")<br>
<br>
# --------------------------------------------------------------------<br>
# MXA_BOOST_HEADERS_ONLY determines if any boost libraries are going to<br>
# be found with the boost headers. For MXADataModel itself NO boost<br>
# libraries are required but if you choose to build the ImportGenerator<br>
# program then you will need the boost program_options library.<br>
if ( NOT MXA_BOOST_HEADERS_ONLY)<br>
set (MXA_BOOST_COMPONENTS program_options )<br>
endif()<br>
<br>
include(${PROJECT_BINARY_DIR}/Boost/Install/share/cmake/boost/BoostConfig.cmake)<br>
#FIND_PACKAGE(Boost COMPONENTS ${MXA_BOOST_COMPONENTS} )<br>
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})<br>
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})<br>
#------ END CMAKELISTS.TXT FILE -------------<br>
<br>
<br>
The problem becomes none of the normal BoostConfig.cmake or anything else is available at cmake time? At least not the first time through because Boost is NOT built yet. This seems like a chicken-and-egg thing going on but I am sure I am just missing something. Or maybe this was not the intent of ExternalProject_Add and we should just use "add_subdirs()" instead?<br>
<br>
Help..<br>
___________________________________________________________<br>
Mike Jackson <a href="http://www.bluequartz.net" target="_blank">www.bluequartz.net</a><br>
Principal Software Engineer <a href="mailto:mike.jackson@bluequartz.net" target="_blank">mike.jackson@bluequartz.net</a><br>
BlueQuartz Software Dayton, Ohio<br>
<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>