[CMake] how to force assign sequence in multi-thread in cmake

Micha Hergarden micha.hergarden at gmail.com
Tue Sep 16 02:55:24 EDT 2014


Hello all,

I do use the ExternalProject to prebuild some binaries, without the
'superproject' setup, and it does seem to work. Using the
add_dependencies, I can make sure some third party libs are prebuild
before I start to build my project. I have seen some issues with
ExternalProject (failing to extract, or build), but they are too rare to
pinpoint and create a bugreport.

What exactly does not work? Is the external project not build at all, or
just not in time?

Regards,
Micha

On 09/16/2014 08:30 AM, Petr Kmoch wrote:
> Hi.
>
> I've never worked with ExternalProject myself, so I can't comment with
> certainty, but from what I understand, the correct way of using
> ExternalProject is to add your own project as an ExternalProject as
> well. Basically, the toplevel CMakeList becomes a superbuild which
> *only* does ExternalProject_Add() calls and does not add any
> libraries/executables directly. After you build the superbuild once to
> get all the dependencies correct, you switch to the "external" project
> of your own code and work with that normally.
>
> Petr
>
> On Mon, Sep 15, 2014 at 4:13 PM, Yu Jing <yujing5b5d at gmail.com
> <mailto:yujing5b5d at gmail.com>> wrote:
>
>     I had asked in http://stackoverflow.com/questions/25841602  ,
>     someone told me maybe here is a better place to ask.
>
>     I am writing a project base on crfpp , a external project. I use
>     cmake to integerate this project as follow .
>
>     firstly , I add a extenal project like this:
>
>     |EXTERNALPROJECT_ADD(
>                 CRFPP_EX_PROJ
>                 GIT_REPOSITORY git at github.com:yujing5b5d/crfpp.git
>                 PREFIX ${CMAKE_CURRENT_BINARY_DIR}
>                 CONFIGURE_COMMAND ./configure
>                 BUILD_COMMAND make -j8
>                 BUILD_IN_SOURCE 1
>                 INSTALL_COMMAND cp .libs/libcrfpp.a ${PROJECT_BINARY_DIR}/lib && cp crfpp.h ${PROJECT_BINARY_DIR}/include 
>         )|
>
>     this will generate some .a file and copy a header
>     file |crfpp.h| to folder |${PROJECT_BINARY_DIR}/include| , which
>     is included in my project.
>
>     and then , use the |${PROJECT_BINARY_DIR}/include| as include path
>     as follow .
>
>     |INCLUDE_DIRECTORIES(
>         ${PROJECT_SOURCE_DIR}/include
>         ${PROJECT_BINARY_DIR}/include
>     )|
>
>     finally , when I compile the main project , code like this :
>
>     |ADD_EXECUTABLE(cmake_sample main.cc)
>     ADD_DEPENDENCIES(cmake_sample CRFPP_EX_PROJ)
>     TARGET_LINK_LIBRARIES(cmake_sample crfpp)|
>
>     In general , if I just build a build folder, compile like this :
>
>     |cmake ..
>     make|
>
>     It may works fine, compile the external project first , and copy
>     the header file to desired place , and then continue compile
>     main.cc <http://main.cc> in my project . But if I use compile
>     command as multi-thread like this :
>
>     |cmake ..
>     make -j8|
>
>     It will not works because my main.cc <http://main.cc> and the
>     external project are processed at same time, so it report a error
>     like this :
>
>     |/Users/yu/Workspace/res/cmake_sample/src/main.cc:3:10: fatal error: 'crfpp.h' file not found
>     #include "crfpp.h" // crfpp
>              ^
>     1 error generated.|
>
>     This |crfpp.h| will generated after |CRFPP_EX_PROJ| , but in
>     multi-thread environment , the sequence is quite different .
>
>     My Question is : Is it possible that force let my project compile
>     after these external projects all finished . BE CAREFUL , I'm not
>     sure is this the problem of my use of |ADD_DEPENDENCIES| , I also
>     wrote
>
>     |ADD_DEPENDENCIES(cmake_sample CRFPP_EX_PROJ)|
>
>     but it seems not works ?
>
>     Thanks for any help.
>
>
>
>     --
>
>     Powered by www.kitware.com <http://www.kitware.com>
>
>     Please keep messages on-topic and check the CMake FAQ at:
>     http://www.cmake.org/Wiki/CMake_FAQ
>
>     Kitware offers various services to support the CMake community.
>     For more information on each offering, please visit:
>
>     CMake Support: http://cmake.org/cmake/help/support.html
>     CMake Consulting: http://cmake.org/cmake/help/consulting.html
>     CMake Training Courses: http://cmake.org/cmake/help/training.html
>
>     Visit other Kitware open-source projects at
>     http://www.kitware.com/opensource/opensource.html
>
>     Follow this link to subscribe/unsubscribe:
>     http://public.kitware.com/mailman/listinfo/cmake
>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140916/48966cc0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140916/48966cc0/attachment-0001.sig>


More information about the CMake mailing list