[CMake] Dependency bug in cmake with a custom-command

Brad King brad.king at kitware.com
Tue Aug 17 14:53:02 EDT 2010


On 08/11/2010 07:04 PM, Andreas Pakulat wrote:
> On 11.08.10 16:07:21, Brad King wrote:
>> What source file is it compiling when it fails to find the header?
> 
> reviewpatchdialog.cpp which has #include "ui_reviewpatch.h"
> 
>> In what target is its object file?
> 
> kdevreviewboard is the target with the .cpp:

I reproduced the problem.  It is *not* kdevreviewboard that is
building when the problem occurs, it is reviewboardtest, which
also includes that c++ source file:

Building CXX object plugins/reviewboard/tests/CMakeFiles/reviewboardtest.dir/__/reviewpatchdialog.o
/.../kdevplatform/plugins/reviewboard/reviewpatchdialog.cpp:23:28: error: ui_reviewpatch.h: No such file or directory

The source file is being compiled in a target that does not
wait for the header to be generated before compiling.  We can
add a dependency on the target the does provide the header.
The patch below fixes the problem.

-Brad


diff --git a/plugins/reviewboard/tests/CMakeLists.txt b/plugins/reviewboard/tests/CMakeLists.txt
index e7367d5..1f26237 100644
--- a/plugins/reviewboard/tests/CMakeLists.txt
+++ b/plugins/reviewboard/tests/CMakeLists.txt
@@ -7,6 +7,7 @@ set(reviewboardtest_SRCS
 )

 kde4_add_executable(reviewboardtest ${reviewboardtest_SRCS})
+add_dependencies(reviewboardtest kdevreviewboard)
 target_link_libraries(reviewboardtest ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${QJSON_LIBRARIES})


More information about the CMake mailing list