On Thu, Nov 18, 2010 at 8:34 AM, Denis Scherbakov <denis_scherba...@yahoo.com> wrote: > Hi! > > What I mean is: > > PROJECT(MYPROJECT) > > ADD_CUSTOM_COMMAND( OUTPUT "${PROJECT_BINARY_DIR}/MyFile.hh" COMMAND > ${CMAKE_COMMAND} -P MyScript.cmake) > > SET_SOURCE_FILE_PROPERTIES("${PROJECT_BINARY_DIR}/MyFile.hh" PROPERTIES > GENERATED TRUE HEADER_FILE_ONLY TRUE) > > SET (MYPROJECT_SRCS > MyFile.hh > MyFile.cc > ) > > ADD_LIBRARY(MYLIB ${MYPROJECT_SRCS}) > ADD_LIBRARY(MYLIBpic ${MYPROJECT_SRCS}) > SET_TARGET_PROPERTIES(MYLIBpic PROPERTIES COMPILE_FLAGS "-FPIC -DPIC") > > $ gmake -j2 all > ... MyFile.hh is written two times > > So far I understand two targets try to generate MyFile.hh at the same time > and there is no way to tell one of them that the file is being built by > someone else already. > > Denis > > --- On Thu, 11/18/10, Eric Noulard <eric.noul...@gmail.com> wrote: > >> From: Eric Noulard <eric.noul...@gmail.com> >> Subject: Re: [CMake] Problems with parallel builds >> To: "Denis Scherbakov" <denis_scherba...@yahoo.com> >> Cc: cmake@cmake.org >> Date: Thursday, November 18, 2010, 5:13 AM >> 2010/11/18 Denis Scherbakov <denis_scherba...@yahoo.com>: >> > Dear All, >> > >> > I am using CMake 2.8.1 on Linux x86. I have a project >> that needs to be built two times. One with -fPIC, the other >> - without. The project depends on header files that need to >> be generated by an external script. >> > >> > When I build this project with several parallel jobs >> (gmake -j5, for example) to my disappointment CMake calls >> external script several times so at the end I get corrupted >> header files. >> >> Could you give us the exact CMake rule/command you use to >> generate >> those headers? >> >> configure_file? >> add_custom_command? >> add_custom_target? >> execute_process? >> ... combination of those ? >> >> > Does anybody know a cross-platform way of implementing >> a mutex (or something like that) to make sure that >> > scripts that generate files are called only once? >> > >> > So far for me parallel builds do not work with CMake >> at all. >> >> I did never had any trouble with parallel building with >> CMake on Linux >> with makefile generator so far. >> For build host ranging from 1 processors to 4 processors >> with various -j values. >> >> -- >> Erk >> Membre de l'April - « promouvoir et défendre le logiciel >> libre » - >> http://www.april.org >> > > > > _______________________________________________ > 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 >
The easiest way to make this work is to have a separate custom target that depends on the output of the custom command, and then to have the two libraries depend on that custom target with add_dependencies... _______________________________________________ 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