[CMake] How to build and link Externa Project with exported target
Hi! I'm building a project that require a 3rd party library libqxmpp. Both project uses cmake I want to build libqxmpp with ExternalProject_add, this the code I use: ExternalProject_add( libqxmpp #no download, i'm using git submodule DOWNLOAD_COMMAND "" CMAKE_ARGS -DQT_QMAKE_EXECUTABLE=/devel/BIN/v4.6.1-git-phonon-dbg-release/bin/qmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/3rdparty/qxmpp-read-only-git/source ) The problem arise when I try to import a target from libqxmpp adding this to my project CMakeLists.txt: #Import libQXmppClient include(${CMAKE_BINARY_DIR}/include/QXmppClient/QXmppClient.cmake) Cmake cannot find QXmppClient.cmake because it will be created when I'll build the project. How can I solve this problem? Are there better solution to build and link an external project? This is the libqxmpp snippet that export the target: INSTALL(TARGETS QXmppClient EXPORT QXmppClient DESTINATION lib) INSTALL(EXPORT QXmppClient DESTINATION include/QXmppClient ) Nicola Brisotto vcard ___ 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
Re: [CMake] How to build and link Externa Project with exported target
On 17. Mar, 2010, at 13:17 , Nicola Brisotto wrote: > Hi! > I'm building a project that require a 3rd party library libqxmpp. Both > project uses cmake > I want to build libqxmpp with ExternalProject_add, this the code I use: > > ExternalProject_add( > libqxmpp > #no download, i'm using git submodule > DOWNLOAD_COMMAND "" > CMAKE_ARGS > -DQT_QMAKE_EXECUTABLE=/devel/BIN/v4.6.1-git-phonon-dbg-release/bin/qmake > -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} > SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/3rdparty/qxmpp-read-only-git/source > ) > > The problem arise when I try to import a target from libqxmpp adding this to > my project CMakeLists.txt: > #Import libQXmppClient > include(${CMAKE_BINARY_DIR}/include/QXmppClient/QXmppClient.cmake) > > Cmake cannot find QXmppClient.cmake because it will be created when I'll > build the project. > How can I solve this problem? Are there better solution to build and link an > external project? > > This is the libqxmpp snippet that export the target: > > INSTALL(TARGETS QXmppClient EXPORT QXmppClient DESTINATION lib) > INSTALL(EXPORT QXmppClient DESTINATION include/QXmppClient ) > > Nicola Brisotto > vcard There are two ways of getting around this: 1) create the IMPORTED targets yourself. 2) also build your main project wit a ExternalProject_Add and drive the whole thing from a "master-CMakeLists.txt" The first one is probably easier to set up, but requires you to guess the installation names and paths correctly. The second option requires you to restructure your whole build system and adds considerable complexity due to the communication between your master-project and the external projects. For this communication I'd try the following: - In the master project do all the feature-detection and setting of cache variables (such as options etc) - Write a cache-initializer script to the binary tree - Do all the ExternalProject_Add calls and specify the cache-initializer script with the -C option in CMAKE_ARGS HTH Michael ___ 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
Re: [CMake] How to build and link Externa Project with exported target
Hi Michael and Nicola, I'm in a similar situation as I' m trying to build up a cmake based dependency builder for OpenSceneGraph based projects: So I' m really interested in any "best practice" advice Michael Wild wrote: On 17. Mar, 2010, at 13:17 , Nicola Brisotto wrote: Hi! I'm building a project that require a 3rd party library libqxmpp. Both project uses cmake I want to build libqxmpp with ExternalProject_add, this the code I use: ExternalProject_add( libqxmpp #no download, i'm using git submodule DOWNLOAD_COMMAND "" CMAKE_ARGS -DQT_QMAKE_EXECUTABLE=/devel/BIN/v4.6.1-git-phonon-dbg-release/bin/qmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/3rdparty/qxmpp-read-only-git/source ) Means there is a way to instruct ExternalProject_add to download from GIT repos? I was not aware of and starting to hack it to add... let me know if one is available: I have already added Bazaar download similarly to SVN ... so if there is a way to share hacking on it The problem arise when I try to import a target from libqxmpp adding this to my project CMakeLists.txt: #Import libQXmppClient include(${CMAKE_BINARY_DIR}/include/QXmppClient/QXmppClient.cmake) Cmake cannot find QXmppClient.cmake because it will be created when I'll build the project. How can I solve this problem? Are there better solution to build and link an external project? This is the libqxmpp snippet that export the target: INSTALL(TARGETS QXmppClient EXPORT QXmppClient DESTINATION lib) INSTALL(EXPORT QXmppClient DESTINATION include/QXmppClient ) Sorry my ignorance, this is part of the install step of QXmppClient ? Nicola Brisotto vcard There are two ways of getting around this: 1) create the IMPORTED targets yourself. 2) also build your main project wit a ExternalProject_Add and drive the whole thing from a "master-CMakeLists.txt" The first one is probably easier to set up, but requires you to guess the installation names and paths correctly. The second option requires you to restructure your whole build system and adds considerable complexity due to the communication between your master-project and the external projects. For this communication I'd try the following: - In the master project do all the feature-detection and setting of cache variables (such as options etc) - Write a cache-initializer script to the binary tree - Do all the ExternalProject_Add calls and specify the cache-initializer script with the -C option in CMAKE_ARGS This suggestion is really interesting:the purpouse is to let any config options in the "master" projects to be passed to the "slaves"? Have you any examples? I came up with a schema like 2: any project is built as external, dependencies are resolved by ExternalProject_Add and I have used CMAKE_ARGS to communicate settings: As most of cmake projects were based on FindXXX stuff for finding deps, I have overridden the necessary modules in order to make the projects find the good components at configure time. As I did not yet need a lot of interactive customization, I just passed common parameters using CMAKE_ARGS Would not something similar work for you: keep your project separate from libqxmpp, add to it a find_package(QXmppClient) then build a "master" project where you do: ExternalProject_add( libqxmpp #no download, i'm using git submodule DOWNLOAD_COMMAND "" CMAKE_ARGS -DQT_QMAKE_EXECUTABLE=/devel/BIN/v4.6.1-git-phonon-dbg-release/bin/qmake -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/3rdparty/qxmpp-read-only-git/source ) ExternalProject_Add( DEPENDS libqxmpp DOWNLOAD_COMMAND "" SOURCE_DIR ${CMAKE_SOURCE_DIR}/ INSTALL_DIR ${CMAKE_INSTALL_PREFIX} HTH Luigi ___ 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
Re: [CMake] How to build and link Externa Project with exported target
On 17. Mar, 2010, at 14:37 , Luigi Calori wrote: > Hi Michael and Nicola, > I'm in a similar situation as I' m trying to build up a cmake based > dependency builder for OpenSceneGraph based projects: > So I' m really interested in any "best practice" advice > > Michael Wild wrote: >> On 17. Mar, 2010, at 13:17 , Nicola Brisotto wrote: >> >> >>> Hi! >>> I'm building a project that require a 3rd party library libqxmpp. Both >>> project uses cmake I want to build libqxmpp with ExternalProject_add, this >>> the code I use: >>> >>> ExternalProject_add( >>> libqxmpp >>> #no download, i'm using git submodule >>> DOWNLOAD_COMMAND "" >>> CMAKE_ARGS >>> -DQT_QMAKE_EXECUTABLE=/devel/BIN/v4.6.1-git-phonon-dbg-release/bin/qmake >>> -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} >>> SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/3rdparty/qxmpp-read-only-git/source >>> ) >>> > Means there is a way to instruct > > ExternalProject_add > > to download from GIT repos? I was not aware of and starting to hack it to > add... let me know if one is available: > I have already added Bazaar download similarly to SVN ... so if there is a > way to share hacking on it He's not downloading with CMake, he just told git that in this directory is a submodule. The user has then to fetch it himself with one command: http://git.wiki.kernel.org/index.php/GitSubmoduleTutorial [...] >> >> 2) also build your main project wit a ExternalProject_Add and drive the >> whole thing from a "master-CMakeLists.txt" >> >> The first one is probably easier to set up, but requires you to guess the >> installation names and paths correctly. The second option requires you to >> restructure your whole build system and adds considerable complexity due to >> the communication between your master-project and the external projects. For >> this communication I'd try the following: >> >> - In the master project do all the feature-detection and setting of cache >> variables (such as options etc) >> - Write a cache-initializer script to the binary tree >> - Do all the ExternalProject_Add calls and specify the cache-initializer >> script with the -C option in CMAKE_ARGS >> > This suggestion is really interesting:the purpouse is to let any config > options in the "master" projects to be passed to the "slaves"? > Have you any examples? You could pass every single cache variable using -D in CMAKE_ARGS, but that becomes pretty tedious very soon... Currently I don't have any example, sorry. > > > I came up with a schema like 2: > any project is built as external, dependencies are resolved by > ExternalProject_Add and I have used CMAKE_ARGS to communicate settings: > As most of cmake projects were based on FindXXX stuff for finding deps, I > have overridden the necessary modules in order to make the projects find the > good components at configure time. That's what you could do with the cache-initialization script, no need to override the FindXXX modules. If more than one of the external projects use the same FindXXX module, do it in the master and then communicate the results using the initializer script. This way the user can easily override the results during the configure-step and get consistent results in all the sub-projects. Only thing that has me worried is when the user aborts the build, changes the settings in the master cache and then restarts the build. You'd need to somehow set up correct dependencies... If sub-project B does a FIND_PACKAGE(A REQUIRED) and A is built as another sub-project, then you can specify A_DIR to the B project containing the path to the directory containing its A-config.cmake. Michael ___ 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
Re: [CMake] How to build and link Externa Project with exported target
[...] He's not downloading with CMake, he just told git that in this directory is a submodule. The user has then to fetch it himself with one command: http://git.wiki.kernel.org/index.php/GitSubmoduleTutorial Sorry ... no git expert at all my point was just to hack ExternalProject_add to let specify different download ways, apart from URL, SVN_REPOSITORY and mine BZR_REPOSITORY would like to have also GIT_REPOSITORY and HG_REPOSITORY [...] 2) also build your main project wit a ExternalProject_Add and drive the whole thing from a "master-CMakeLists.txt" The first one is probably easier to set up, but requires you to guess the installation names and paths correctly. The second option requires you to restructure your whole build system and adds considerable complexity due to the communication between your master-project and the external projects. For this communication I'd try the following: - In the master project do all the feature-detection and setting of cache variables (such as options etc) - Write a cache-initializer script to the binary tree - Do all the ExternalProject_Add calls and specify the cache-initializer script with the -C option in CMAKE_ARGS This suggestion is really interesting:the purpouse is to let any config options in the "master" projects to be passed to the "slaves"? Have you any examples? You could pass every single cache variable using -D in CMAKE_ARGS, but that becomes pretty tedious very soon... Currently I don't have any example, sorry. from http://www.cmake.org/cmake/help/cmake-2-8-docs.html#opt:-Cinitial-cache seems that what you are suggesting is not passing the master cache to the slaves, but to build a selection of variables and build a script in a different format Do you suggesto to pass the same script to ALL the subprojects? I' ll try to find some examples of that usage.seems useful I came up with a schema like 2: any project is built as external, dependencies are resolved by ExternalProject_Add and I have used CMAKE_ARGS to communicate settings: As most of cmake projects were based on FindXXX stuff for finding deps, I have overridden the necessary modules in order to make the projects find the good components at configure time. That's what you could do with the cache-initialization script, no need to override the FindXXX modules. If more than one of the external projects use the same FindXXX module, do it in the master and then communicate the results using the initializer script. This way the user can easily override the results during the configure-step and get consistent results in all the sub-projects. Only thing that has me worried is when the user aborts the build, changes the settings in the master cache and then restarts the build. You'd need to somehow set up correct dependencies... If the cache-initialization script is single, then would be good that all the slave projects file_depends on that but do not know how to set a file dependency on the configure step of ExternalProject_Add If sub-project B does a FIND_PACKAGE(A REQUIRED) and A is built as another sub-project, then you can specify A_DIR to the B project containing the path to the directory containing its A-config.cmake. Yes, that would be good unfortunately not so many cmake projects builds xxx-config.cmake in their build-install process It would be nice to have good examples of usages: this could be a "standard" way of building dependencies throug cmake . Is this ExternalProject_Add feature really used/developed? I find it really nice but a little scared of weather it will be really supported and improved. I have done some patching on it but not know if there is a group of user/developer eventually interested to submit mods to Thanks Luigi ___ 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
Re: [CMake] How to build and link Externa Project with exported target
On 17. Mar, 2010, at 15:43 , Luigi Calori wrote: > > [...] >> He's not downloading with CMake, he just told git that in this directory is >> a submodule. The user has then to fetch it himself with one command: >> >> http://git.wiki.kernel.org/index.php/GitSubmoduleTutorial >> > Sorry ... no git expert at all my point was just to hack > ExternalProject_add to let specify different download ways, apart from URL, > SVN_REPOSITORY and mine BZR_REPOSITORY would like to have also > GIT_REPOSITORY and HG_REPOSITORY >> [...] >> 2) also build your main project wit a ExternalProject_Add and drive the whole thing from a "master-CMakeLists.txt" The first one is probably easier to set up, but requires you to guess the installation names and paths correctly. The second option requires you to restructure your whole build system and adds considerable complexity due to the communication between your master-project and the external projects. For this communication I'd try the following: - In the master project do all the feature-detection and setting of cache variables (such as options etc) - Write a cache-initializer script to the binary tree - Do all the ExternalProject_Add calls and specify the cache-initializer script with the -C option in CMAKE_ARGS >>> This suggestion is really interesting:the purpouse is to let any config >>> options in the "master" projects to be passed to the "slaves"? >>> Have you any examples? >>> >> >> You could pass every single cache variable using -D in CMAKE_ARGS, but that >> becomes pretty tedious very soon... Currently I don't have any example, >> sorry. >> > from http://www.cmake.org/cmake/help/cmake-2-8-docs.html#opt:-Cinitial-cache > seems that what you are suggesting is not passing the master cache to the > slaves, but to build a selection of variables and build a script in a > different format > Do you suggesto to pass the same script to ALL the subprojects? I' ll try to > find some examples of that usage.seems useful Yes, you'll have to generate a file containing "set( CACHE )" invocations. Probably I'd create wrappers for OPTION and SET which add such lines to a global property and then I can use this to write the file in one go. >> >>> I came up with a schema like 2: >>> any project is built as external, dependencies are resolved by >>> ExternalProject_Add and I have used CMAKE_ARGS to communicate settings: >>> As most of cmake projects were based on FindXXX stuff for finding deps, I >>> have overridden the necessary modules in order to make the projects find >>> the good components at configure time. >>> >> >> That's what you could do with the cache-initialization script, no need to >> override the FindXXX modules. If more than one of the external projects use >> the same FindXXX module, do it in the master and then communicate the >> results using the initializer script. This way the user can easily override >> the results during the configure-step and get consistent results in all the >> sub-projects. Only thing that has me worried is when the user aborts the >> build, changes the settings in the master cache and then restarts the build. >> You'd need to somehow set up correct dependencies... >> > If the cache-initialization script is single, then would be good that all > the slave projects file_depends on that but do not know how to set a file > dependency on the configure step of ExternalProject_Add >> If sub-project B does a FIND_PACKAGE(A REQUIRED) and A is built as another >> sub-project, then you can specify A_DIR to the B project containing the path >> to the directory containing its A-config.cmake. >> > Yes, that would be good unfortunately not so many cmake projects builds > xxx-config.cmake in their build-install process It would be nice to have > good examples of usages: > this could be a "standard" way of building dependencies throug cmake . Every CMake based project should do that if it is useful as a "development package"... > > Is this ExternalProject_Add feature really used/developed? I find it really > nice but a little scared of weather it will be really supported and improved. > I have done some patching on it but not know if there is a group of > user/developer eventually interested to submit mods to It is actively used and developed, but also relatively new. If you have improvements, it's best to create a tracker item with a patch and description there and post the link to the item on this list. Michael ___ 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
Re: [CMake] How to build and link Externa Project with exported target
On Wednesday 17 March 2010, Michael Wild wrote: > On 17. Mar, 2010, at 15:43 , Luigi Calori wrote: ... > > Is this ExternalProject_Add feature really used/developed? I find it > > really nice but a little scared of weather it will be really supported > > and improved. I have done some patching on it but not know if there is a > > group of user/developer eventually interested to submit mods to > > It is actively used and developed, but also relatively new. If you have > improvements, it's best to create a tracker item with a patch and > description there and post the link to the item on this list. Yes. And git support for it would be a really nice thing to have :-) Alex ___ 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
Re: [CMake] How to build and link Externa Project with exported target
Say your project is called foo, you could do something like this: # Mark variables to be included in the cache-init script # The variables must already exist in the cache. function(foo_add_cache_init_vars) get_property(is_defined GLOBAL PROPERTY FOO_CACHE_INIT_VARIABLES DEFINED) if(NOT is_defined) define_property(GLOBAL PROPERTY FOO_CACHE_INIT_VARIABLES BRIEF_DOCS "Variables to be written to the cache initialization script" FULL_DOCS "The variables will be used to initialize external projects" ) endif() set_property(GLOBAL APPEND PROPERTY FOO_CACHE_INIT_VARIABLES ${ARGN}) endif() # Write the cache initializer script function(foo_write_cache_init_script outfile) get_property(is_set GLOBAL PROPERTY FOO_CACHE_INIT_VARIABLES SET) if(NOT is_set) message(FATAL_ERROR "You must call foo_add_cache_init_var before calling this function") endif() get_property(varnames GLOBAL PROPERTY FOO_CACHE_INIT_VARIABLES) set(text "# Automatically generated, do not edit!\n") foreach(var IN LISTS varnames) get_property(vartype CACHE ${var} PROPERTY TYPE) get_property(varhelp CACHE ${var} PROPERTY HELPSTRING) set(text "${text}set(${var} \"${${var}}\" CACHE ${vartype} \"${varhelp}\")\n") endforeach() file(WRITE "${outfile}" "${text}") endfunction() # here goes the real stuff foo_add_cache_init_vars( CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT CMAKE_VERBOSE_MAKEFILE # ... ) foreach(config "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO) foo_add_cache_init_vars( CMAKE_C_FLAGS${config} CMAKE_CXX_FLAGS${config} CMAKE_MODULE_LINKER_FLAGS${config} CMAKE_SHARED_LINKER_FLAGS${config} # ... ) endforeach() foo_write_cache_init_script("${CMAKE_BINARY_DIR}/ExternalCacheInitScript.cmake") I haven't tested it, but something along these lines should work. HTH Michael On 19. Mar, 2010, at 15:11 , Nicola Brisotto wrote: > Hi, > the solution with a master CMakeLists.txt works well but now I don't > know how to write wrapper for OPTION and SET functions, can you give > me an example? > I'm quite new to cmake so another question is: > what is the diffence between create a xxx-config and the file I create > with INSTALL(EXPORT QXmppClient DESTINATION include/QXmppClient ) ? > They seem to do the same thing but probably I'm missing something > > Nicola Brisotto > > > > On Wed, Mar 17, 2010 at 8:44 PM, Alexander Neundorf > wrote: >> On Wednesday 17 March 2010, Michael Wild wrote: >>> On 17. Mar, 2010, at 15:43 , Luigi Calori wrote: >> ... Is this ExternalProject_Add feature really used/developed? I find it really nice but a little scared of weather it will be really supported and improved. I have done some patching on it but not know if there is a group of user/developer eventually interested to submit mods to >>> >>> It is actively used and developed, but also relatively new. If you have >>> improvements, it's best to create a tracker item with a patch and >>> description there and post the link to the item on this list. >> >> Yes. And git support for it would be a really nice thing to have :-) >> >> Alex >> ___ >> 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
Re: [CMake] How to build and link Externa Project with exported target
Hi, the solution with a master CMakeLists.txt works well but now I don't know how to write wrapper for OPTION and SET functions, can you give me an example? I'm quite new to cmake so another question is: what is the diffence between create a xxx-config and the file I create with INSTALL(EXPORT QXmppClient DESTINATION include/QXmppClient ) ? They seem to do the same thing but probably I'm missing something Nicola Brisotto On Wed, Mar 17, 2010 at 8:44 PM, Alexander Neundorf wrote: > On Wednesday 17 March 2010, Michael Wild wrote: >> On 17. Mar, 2010, at 15:43 , Luigi Calori wrote: > ... >> > Is this ExternalProject_Add feature really used/developed? I find it >> > really nice but a little scared of weather it will be really supported >> > and improved. I have done some patching on it but not know if there is a >> > group of user/developer eventually interested to submit mods to >> >> It is actively used and developed, but also relatively new. If you have >> improvements, it's best to create a tracker item with a patch and >> description there and post the link to the item on this list. > > Yes. And git support for it would be a really nice thing to have :-) > > Alex > ___ > 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
Re: [CMake] How to build and link Externa Project with exported target
Hi Mike, I'm back to this topic because the second solution create some problem with qt-creator parser of cmake project. If I import the project I have no source file loaded so the solution is not ok for me. The first solution, "create the IMPORTED targets myself", means that I have to put something like the code below in my main CMakeList.txt? #QXmppClient.cmake: # Generated by CMake 2.8.0 IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) MESSAGE(FATAL_ERROR "CMake >= 2.6.0 required") ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) CMAKE_POLICY(PUSH) CMAKE_POLICY(VERSION 2.6) # # Generated CMake target import file. # # Commands may need to know the format version. SET(CMAKE_IMPORT_FILE_VERSION 1) # Create imported target QXmppClient ADD_LIBRARY(QXmppClient STATIC IMPORTED) # Load information for each installed configuration. GET_FILENAME_COMPONENT(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) FILE(GLOB CONFIG_FILES "${_DIR}/QXmppClient-*.cmake") FOREACH(f ${CONFIG_FILES}) INCLUDE(${f}) ENDFOREACH(f) # Commands beyond this point should not need to know the version. SET(CMAKE_IMPORT_FILE_VERSION) CMAKE_POLICY(POP) #QXmppClient-release.cmake # # Generated CMake target import file for configuration "Release". # # Commands may need to know the format version. SET(CMAKE_IMPORT_FILE_VERSION 1) # Compute the installation prefix relative to this file. GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) # Import target "QXmppClient" for configuration "Release" SET_PROPERTY(TARGET QXmppClient APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) SET_TARGET_PROPERTIES(QXmppClient PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "/devel/BIN/v4.6.1-git-phonon-dbg-release/lib/QtGui.framework;-framework Carbon;-framework AppKit;/devel/BIN/v4.6.1-git-phonon-dbg-release/lib/QtXml.framework;/devel/BIN/v4.6.1-git-phonon-dbg-release/lib/QtNetwork.framework;/devel/BIN/v4.6.1-git-phonon-dbg-release/lib/QtCore.framework;/usr/lib/libz.dylib;-framework ApplicationServices" IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libQXmppClient.a" ) # Cleanup temporary variables. SET(_IMPORT_PREFIX) # Commands beyond this point should not need to know the version. SET(CMAKE_IMPORT_FILE_VERSION) On Mar 17, 2010, at 13:41 , Michael Wild wrote: > > On 17. Mar, 2010, at 13:17 , Nicola Brisotto wrote: > >> Hi! >> I'm building a project that require a 3rd party library libqxmpp. Both >> project uses cmake >> I want to build libqxmpp with ExternalProject_add, this the code I use: >> >> ExternalProject_add( >> libqxmpp >> #no download, i'm using git submodule >> DOWNLOAD_COMMAND "" >> CMAKE_ARGS >> -DQT_QMAKE_EXECUTABLE=/devel/BIN/v4.6.1-git-phonon-dbg-release/bin/qmake >> -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} >> SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/3rdparty/qxmpp-read-only-git/source >> ) >> >> The problem arise when I try to import a target from libqxmpp adding this to >> my project CMakeLists.txt: >> #Import libQXmppClient >> include(${CMAKE_BINARY_DIR}/include/QXmppClient/QXmppClient.cmake) >> >> Cmake cannot find QXmppClient.cmake because it will be created when I'll >> build the project. >> How can I solve this problem? Are there better solution to build and link an >> external project? >> >> This is the libqxmpp snippet that export the target: >> >> INSTALL(TARGETS QXmppClient EXPORT QXmppClient DESTINATION lib) >> INSTALL(EXPORT QXmppClient DESTINATION include/QXmppClient ) >> >> Nicola Brisotto >> vcard > > There are two ways of getting around this: > > 1) create the IMPORTED targets yourself. > > 2) also build your main project wit a ExternalProject_Add and drive the whole > thing from a "master-CMakeLists.txt" > > The first one is probably easier to set up, but requires you to guess the > installation names and paths correctly. The second option requires you to > restructure your whole build system and adds considerable complexity due to > the communication between your master-project and the external projects. For > this communication I'd try the following: > > - In the master project do all the feature-detection and setting of cache > variables (such as options etc) > - Write a cache-initializer script to the binary tree > - Do all the ExternalProject_Add calls and specify the cache-initializer > script with the -C option in CMAKE_ARGS > > HTH > > Michael Nicola Brisotto vcard ___ Powered by www.kitware.com Visit other Kitware op