[cmake-developers] Namespaces
Pau Garcia i Quiles
pgquiles at elpauer.org
Thu Jan 28 17:25:58 EST 2016
On Thu, Jan 28, 2016 at 9:58 PM, Alan W. Irwin <irwin at beluga.phys.uvic.ca>
wrote:
> Your experience is contrary to mine. For example, in my epa_build
> project (where I build all the many prerequisites of PLplot) I build a lot
> of
> different libraries (such as Qt5 and the GTK+ stack of libraries) using
> ExternalProject_Add, and I don't experience any difficulties using
> find_package to find the installed results.
>
> I assume find_package should work well with ExternalProject_Add for
> you as well so long as (a) all your ExternalProject(s) are configured
> to do both a build and install (not just a build), and (b) you are
> being careful in server/CMakeLists.txt to set PATH,
> CMAKE_LIBRARY_PATH, CMAKE_INCLUDE_PATH, and PKG_CONFIG_PATH
> consistently with the install prefix used for the ExternalProject(s).
>
>
It works well for you because you actually have two things there:
- PlPlot
- A superbuild that builds the dependencies required to build PlPlot,
and then, PlPlot itself by way of ExternalProject_Add (using
download_command = copy the source code from some directory to another)
But what I would like to do with ExternalProject_Add (and please note this
is a different topic than what I started the thread for) is to avoid that
superbuild:
CMakeLists.txt
|
\--- 3rdparty
|
\--- server
|
\--- client
|
\--- app
Where the root CMakeLists.txt is something like this:
--8<---
project(myapp)
# ExternalProject used here to build dependencies
add_subdirectory(3rdparty)
# My software is built directly, not through a superbuild
add_subdirectory(server)
add_subdirectory(client)
add_subdirectory(app)
--8<---
and 3rdparty/CMakeLists.txt would be something like this:
--8<---
include(ExternalProject)
# websocketpp
ExternalProject_Add(websocketpp
SOURCE_DIR ${CMAKE_BINARY_DIR}/websocketpp
DOWNLOAD_DIR ${MYAPP_DOWNLOADS_DIR}
INSTALL_DIR ${MYAPP_INSTALL_DIR}
URL ${websocketpp_URL}
URL_MD5 ${websocketpp_MD5}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${MYAPP_INSTALL_DIR} ${CMAKE_BINARY_DIR}/websocketpp
LOG_DOWNLOAD 1
LOG_UPDATE 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_TEST 1
LOG_INSTALL 1
)
# QtZeroConf
ExternalProject_Add(QtZeroConf
SOURCE_DIR ${CMAKE_BINARY_DIR}/QtZeroConf
DOWNLOAD_DIR ${MYAPP_DOWNLOADS_DIR}
INSTALL_DIR ${MYAPP_INSTALL_DIR}
GIT_REPOSITORY ${QtZeroConf_URL}
CONFIGURE_COMMAND ${QT_QMAKE_EXECUTABLE} PREFIX=${MYAPP_INSTALL_DIR}
${CMAKE_BINARY_DIR}/QtZeroConf
LOG_DOWNLOAD 1
LOG_UPDATE 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_TEST 1
LOG_INSTALL 1
)
--8<---
Now I should be able to do:
server/CMakeLists.txt
--8<---
project(server)
find_package(websocketpp REQUIRED)
find_package(Boost REQUIRED COMPONENTS date_time system thread)
set(server_SOURCES main.cpp server.cpp)
add_executable(server ${server_SOURCES})
target_link_libraries(server ${WEBSOCKETPP_LIBRARY} ${Boost_LIBRARIES})
--8<---
That would feel natural, wouldn't it?
But that does not work unless I juggle with add_library(... IMPORTED) or I
use Hunter or alike.
In the end, neither the current behavior of add_subdirectory nor the
current behavior of ExternalProject_Add let me work in the seemingly most
natural way: tell CMake to build my dependencies, then immediately work on
my applications/libraries :-(
I would love to work on this, as Stephen suggested, but I just don't have
the time :-/
--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160128/d73fbb5c/attachment.html>
More information about the cmake-developers
mailing list