[CMake] ADD_CUSTOM_TARGET

Brad Bell bradbell at seanet.com
Tue Jan 15 09:05:55 EST 2013


I am trying to build a project for Red-hat 6 which uses the following 
cmake version
     bradbell at gorst trash]$ cmake --version
     cmake version 2.6-patch 4

While doing so I am having trouble with the ADD_CUSTOM_TARGET. To be 
specifc, after building a custom target, cmake seems to forget it has 
done so.

Below is an example CMakeLists for which
     make check
works with cmake 2.8.9 and fails with 2.6-patch 4:
     CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
     #
     PROJECT(hello)
     #
     ADD_EXECUTABLE(hello_one EXCLUDE_FROM_ALL hello_one.cpp )
     ADD_EXECUTABLE(hello_two EXCLUDE_FROM_ALL hello_two.cpp )
     #
     ADD_CUSTOM_TARGET(check_one hello_one DEPENDS hello_one)
     ADD_CUSTOM_TARGET(check_two hello_two DEPENDS hello_two)
     #
     ADD_CUSTOM_TARGET(check DEPENDS check_one check_two)

I am attaching a bash script that creates the necessary files and runs 
the make check command. The output I get on Red-Hat 6 is

[bradbell at gorst trash]$ ./cmake_target.sh
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /homes/bradbell/trash/build
Scanning dependencies of target hello_two
[ 50%] Building CXX object CMakeFiles/hello_two.dir/hello_two.cpp.o
Linking CXX executable hello_two
[ 50%] Built target hello_two
Scanning dependencies of target check_two
hello_two

[ 50%] Built target check_two
Scanning dependencies of target hello_one
[100%] Building CXX object CMakeFiles/hello_one.dir/hello_one.cpp.o
Linking CXX executable hello_one
[100%] Built target hello_one
Scanning dependencies of target check_one
hello_one

[100%] Built target check_one
Scanning dependencies of target check
make[3]: *** No rule to make target `check_one', needed by 
`CMakeFiles/check'.  Stop.
make[2]: *** [CMakeFiles/check.dir/all] Error 2
make[1]: *** [CMakeFiles/check.dir/rule] Error 2
make: *** [check] Error 2
[bradbell at gorst trash]$




-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake_target.sh
Type: application/x-shellscript
Size: 739 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130115/2f8a4bc7/attachment.bin>


More information about the CMake mailing list