Brandon Van Every wrote:
On 7/13/07, Yegor Yefremov <[EMAIL PROTECTED]> 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
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake
I'm using Linux and this is my output for the pristine out-of-source build
directory:
[EMAIL PROTECTED]:~/projects/temp/cmake_test_build$ cmake ../cmake_test
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/user/projects/temp/cmake_test_build
[EMAIL PROTECTED]:~/projects/temp/cmake_test_build$ make
Scanning dependencies of target test
[100%] Building C object CMakeFiles/test.dir/test.o
Linking C executable test
[100%] Built target test
I have created two directories:
cmake_test
cmake_test_build
The tags file was successfully created in the ${TEST_SOURCE_DIRECTORY}:
[EMAIL PROTECTED]:~/projects/temp/cmake_test_build$ ls -l ../cmake_test
total 12
-rw-r--r-- 1 user user 272 2007-07-13 16:23 CMakeLists.txt
-rw-r--r-- 1 user user 383 2007-07-13 16:25 tags
-rw-r--r-- 1 user user 95 2007-07-13 09:09 test.c
Below my corrected CMakeLists.txt:
project (TEST)
# some parameters
set (CMAKE_VERBOSE_MAKEFILE OFF)
# sources
set (SRCS test.c)
# executables
add_executable (test ${SRCS})
add_custom_command (TARGET test POST_BUILD COMMAND ctags -R
WORKING_DIRECTORY ${TEST_SOURCE_DIR} COMMENT "Creating tags" VERBATIM)
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake