[CMake] ADD_CUSTOM_COMMAND issues
Brandon Van Every
bvanevery at gmail.com
Fri Jul 13 10:16:58 EDT 2007
On 7/13/07, Yegor Yefremov <yegor_sub1 at visionsystems.de> wrote:
> Hello,
>
> I want to use ADD_CUSTOM_COMMAND to create tags when building the
> project. The first problem, ADD_CUSTOM_COMMAND must be placed after the
> target definition. Should it be so?
Yes. And it's reasonable, given that you're doing a POST_BUILD command.
> One can parse the CMakeLists.txt and
> build dependencies so that it doesn't matter where to place
> ADD_CUSTOM_COMMAND.
Kitware could comment on how difficult it would be to change their
implementation, but I anticipate the answer would be "very difficult."
> The second issue is that COMMENT won't be printed at all. A didn't use
> APPEND.
> [Citation from http://www.cmake.org/HTML/Documentation.html]:
>
> The COMMENT, WORKING_DIRECTORY, and MAIN_DEPENDENCY options are
> currently ignored when APPEND is given, but may be used in the future.
>
> But for me it is not the case.
>
> Best regards,
> Yegor Yefremov
>
> project (TEST)
>
> # some parameters
> set (CMAKE_VERBOSE_MAKEFILE OFF)
>
> # sources
> set (SRCS test.c)
>
> add_custom_command (TARGET test POST_BUILD COMMAND ctags -R WORKING_DIRECTORY ${HWTEST_SOURCE_DIR} COMMENT "Creating tags" VERBATIM)
> # executables
> add_executable (test ${SRCS})
>
> #include <stdio.h>
>
> int main(int argc, char *argv)
> {
> printf("Hello world\n");
>
> return 1;
> }
Note to anyone cutting and pasting this code to try it out: first you
have to put the ADD_EXECUTABLE before the ADD_CUSTOM_COMMAND. That
took me a minute to sift through.
I've noted the following weird behavior on the MinGW generator,
executing under a Windows 2000 command prompt. I do not have ctags
installed on my system. Running from a pristine out-of-source build
directory, the 1st time I execute "mingw32-make", I get errors as I
would expect. The 2nd time, I don't. Then if I do "mingw32-make
clean", followed by "mingw32-make", I get errors as I would expect.
Errors only get reported once per build.
So could this explain why your commands seem to be "not working?"
What happens when you first execute in a pristine out-of-source build
directory?
C:\devel\mingw>cd append
C:\devel\mingw\append>mingw32-make
Scanning dependencies of target test
[100%] Building C object CMakeFiles/test.dir/test.obj
Linking C executable test.exe
process_begin: CreateProcess(NULL, ctags -R, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make[2]: *** [test.exe] Error 2
mingw32-make[1]: *** [CMakeFiles/test.dir/all] Error 2
mingw32-make: *** [all] Error 2
C:\devel\mingw\append>mingw32-make
[100%] Built target test
C:\devel\mingw\append>mingw32-make clean
C:\devel\mingw\append>mingw32-make
[100%] Building C object CMakeFiles/test.dir/test.obj
Linking C executable test.exe
process_begin: CreateProcess(NULL, ctags -R, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make[2]: *** [test.exe] Error 2
mingw32-make[1]: *** [CMakeFiles/test.dir/all] Error 2
mingw32-make: *** [all] Error 2
C:\devel\mingw\append>
Cheers,
Brandon Van Every
More information about the CMake
mailing list