[CMake] how to force assign sequence in multi-thread in cmake
Yu Jing
yujing5b5d at gmail.com
Mon Sep 15 10:13:42 EDT 2014
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 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 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140915/d0340e62/attachment-0001.html>
More information about the CMake
mailing list