[CMake] Adding install dependency to test-target?

Hugo Heden hugoheden at gmail.com
Fri Jan 30 06:00:13 EST 2009


>
> If I do this:
>
>    LIST(APPEND extra_libopts_clean_files
>        ./libopts/.libs/libopts.o
>        ./libopts/.libs/libopts.la
>        ./libopts/.libs
>        ./libopts/_libs
>        ./libopts/libopts.la
>        ./libopts/so_locations
>        ./libopts/*.o
>        ./libopts/*.lo
>    )
>
>    SET_DIRECTORY_PROPERTIES(PROPERTIES
>        ADDITIONAL_MAKE_CLEAN_FILES ${extra_libopts_clean_files})
>
> I get an error about too many args to SET_DIRECTORY_PROPERTIES.

Try using quotes:

SET_DIRECTORY_PROPERTIES(PROPERTIES
       ADDITIONAL_MAKE_CLEAN_FILES "${extra_libopts_clean_files}" )

> And
> If I specify each file individually, it appears that only the last
> takes effect (basically subsequent calls overwrite the previous
> value).  Surely there is a way to specify multiple files right?
>

In such a case, you could use the APPEND functionality in set_property:
http://www.cmake.org/cmake/help/ctest2.6docs.html#command:set_property

SET_PROPERTY(
  DIRECTORY "${CMAKE_CURRENT_SOURCE_DIRECTORY}"
  APPEND
  ADDITIONAL_MAKE_CLEAN_FILES "./libopts/.libs/libopts.la"
)

But beware of this issue when using ADDITIONAL_MAKE_CLEAN_FILES

http://public.kitware.com/Bug/view.php?id=8164

-- if there is no *target* present in the CMakeLists.txt, then the
directory does not count as a "directory" in the cmake sense, so the
directory property will be ignored.


> Honestly, both of these solutions are just hacks.... it seems like
> cmake really should have a way to add to the 'clean' and 'install'
> pseudo-targets.
>

I agree. This issue is apparently known though, so be patient, see
Brad Kings comment: http://public.kitware.com/Bug/view.php?id=8438 --
thanks Brad!

Best regards
Hugo Heden


More information about the CMake mailing list