On 2019-07-29 13:24-0400 Brad King wrote:

On 7/29/19 11:50 AM, Dave Milter wrote:
Only source code are generated, so main.cpp -> main.cpp.o doesn't
depend on anything.
But generated by cmake build.ninja still require link of extern_lib
before starting  main.cpp -> main.cpp.o

If there are any custom commands in any targets on which main.cpp's
target depends then CMake must pessimistically assume that the
custom commands may generate a header needed to compile `main.cpp`.

Hi Brad:

Thanks for that clarification.  Clearly David's test case for an external 
library and my own
recently corrected test case for an internal library are not consistent with 
that assumption which
explains the bad results we get for them.

However, I think there is still a problem when a project is consistent
with that assumption.  See the attached no_custom_add_internal_library.tar.gz
which contains an extremely simple test project with no custom commands at all
(i.e., no wait and headers and source are pre-existing in all cases).

Yet for this project I get the following results with ninja.

irwin@merlin> ninja -j16 -v app
[1/7] /usr/bin/c++  -Dinternal_lib_EXPORTS -I../lib -fPIC -MD -MT 
CMakeFiles/internal_lib.dir/lib/lib4.cpp.o -MF 
CMakeFiles/internal_lib.dir/lib/lib4.cpp.o.d -o 
CMakeFiles/internal_lib.dir/lib/lib4.cpp.o -c ../lib/lib4.cpp
[2/7] /usr/bin/c++  -Dinternal_lib_EXPORTS -I../lib -fPIC -MD -MT 
CMakeFiles/internal_lib.dir/lib/lib1.cpp.o -MF 
CMakeFiles/internal_lib.dir/lib/lib1.cpp.o.d -o 
CMakeFiles/internal_lib.dir/lib/lib1.cpp.o -c ../lib/lib1.cpp
[3/7] /usr/bin/c++  -Dinternal_lib_EXPORTS -I../lib -fPIC -MD -MT 
CMakeFiles/internal_lib.dir/lib/lib2.cpp.o -MF 
CMakeFiles/internal_lib.dir/lib/lib2.cpp.o.d -o 
CMakeFiles/internal_lib.dir/lib/lib2.cpp.o -c ../lib/lib2.cpp
[4/7] /usr/bin/c++  -Dinternal_lib_EXPORTS -I../lib -fPIC -MD -MT 
CMakeFiles/internal_lib.dir/lib/lib3.cpp.o -MF 
CMakeFiles/internal_lib.dir/lib/lib3.cpp.o.d -o 
CMakeFiles/internal_lib.dir/lib/lib3.cpp.o -c ../lib/lib3.cpp
[5/7] : && /usr/bin/c++ -fPIC    -shared -Wl,-soname,libinternal_lib.so -o 
libinternal_lib.so CMakeFiles/internal_lib.dir/lib/lib1.cpp.o 
CMakeFiles/internal_lib.dir/lib/lib2.cpp.o CMakeFiles/internal_lib.dir/lib/lib3.cpp.o 
CMakeFiles/internal_lib.dir/lib/lib4.cpp.o   && :
[6/7] /usr/bin/c++   -I../lib  -MD -MT CMakeFiles/app.dir/main.cpp.o -MF 
CMakeFiles/app.dir/main.cpp.o.d -o CMakeFiles/app.dir/main.cpp.o -c ../main.cpp
[7/7] : && /usr/bin/c++     CMakeFiles/app.dir/main.cpp.o  -o app  
-Wl,-rpath,/home/irwin/David.Milter/20190728/test_ninja/no_gen_add_internal_library/build_dir 
libinternal_lib.so && :

irwin@merlin> grep cmake_object_order_depends_target_app build.ninja build cmake_object_order_depends_target_app: phony || cmake_object_order_depends_target_internal_lib
build CMakeFiles/app.dir/main.cpp.o: CXX_COMPILER__app ../main.cpp || 
cmake_object_order_depends_target_app

Alan
__________________________
Alan W. Irwin

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.org); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
--

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:
https://cmake.org/mailman/listinfo/cmake

Reply via email to