[CMake] compilation order dependencies,

Petr Kmoch petr.kmoch at gmail.com
Wed Aug 27 04:58:42 EDT 2014


Hi Lukasz.

I believe you could put `main.cpp` into an object library:

add_library(foo ${foosources})
add_library(bar ${barsources})
add_library...
...
...
add_library(main_sources OBJECT main.cpp)
add_executable(foo_exe $<TARGET_OBJECTS:main_sources>)
target_link_libraries(foo_exe foo bar ... ... ...)

This should make `main.cpp` compilable independently, as only the linking
of foo_exe will wait until the libraries (including the object one) are
finished.

Petr


On Wed, Aug 27, 2014 at 10:30 AM, Łukasz Tasz <lukasz at tasz.eu> wrote:

> Dear experts,
>
> I hit the wall again with order of compilation in generated Makefiles,
>
> Uscase:
>
> add_library(foo ${foosources})
> add_library(bar ${barsources})
> add_library...
> ...
> ...
> add_executable(foo_exe main.cpp)
> target_link_libraries(foo_exe foo bar ... ... ...)
>
> while libs objects will be compiled in parallel, man.cpp.o will be
> compiled after linking of all libs,
> If main.cpp is compiling long then this is overall additional waist of
> time which could be done much earlier.
>
> Do you have some ideas how this situation could be optimised?
>
> with best regards
> Łukasz Tasz
> --
>
> Powered by 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/20140827/09d53e8c/attachment.html>


More information about the CMake mailing list