[CMake] Recursive custom target

Boris Boesler baembel at gmx.de
Fri Jul 25 06:12:41 EDT 2008


This seems to be a FAQ (http://www.cmake.org/pipermail/cmake/2003-May/003799.html 
) but I can't find a proper solution for cmake 2.6-patch 0. In cmake  
2.4 I used ADD_CUSTOM_TARGET() in each CMakeLists.txt file in every  
subdirectory where this target should exist - no problem so far.

In cmake 2.6-patch 0 all targets have to be globally unique. So I  
tried to rename the targets name with SET_TARGET_PROPERTIES( ..  
OUTPUT_NAME ..):

# works on something ala *x only
STRING(REPLACE "/" "_" LOCAL_TARGET_PREFIX ${CMAKE_CURRENT_SOURCE_DIR})
MESSAGE(STATUS "new target:" ${LOCAL_TARGET_PREFIX})
SET(LOCAL_TARGET ${LOCAL_TARGET_PREFIX}-foo)

# create globally unique target
ADD_CUSTOM_TARGET(${LOCAL_TARGET}
   COMMAND ${SVN} ls
   COMMENT using "ls" as command is just a poor example)
# rename target
SET_TARGET_PROPERTIES(${LOCAL_TARGET} PROPERTIES
   OUTPUT_NAME foo)

  Now I get the targets "path1-foo", "path2-foo" and so on but not the  
"foo" target. How can I get it?

Thanks in advance,
Boris



More information about the CMake mailing list