[CMake] Adding install dependency to test-target?
Good day all, Is there any way that I can add 'install' dependency to the 'test'-target? Doing add_dependencies( test install ) does not seem to work: CMake Error at ... (ADD_DEPENDENCIES): add_dependencies Adding dependency to non-existent target: test Apparently neither 'test' nor 'install' counts as "top-level-targets"? Best regards Hugo Heden FOI -- Swedish Defence Research Agency ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
2008/11/20 Hugo Heden <[EMAIL PROTECTED]>: > Good day all, > > > Is there any way that I can add 'install' dependency to the 'test'-target? > > Doing > > add_dependencies( test install ) > > does not seem to work: > CMake Error at ... (ADD_DEPENDENCIES): > add_dependencies Adding dependency to non-existent target: test I don't think it's possible to add dependencies to "built-in" CMake target (which deserve a feature request :-) > Apparently neither 'test' nor 'install' counts as "top-level-targets"? Precisely :=) May be you can try to add a first "fake test" which does it: ADD_TEST(00_Install ${CMAKE_BUILD_TOOL} install) If this ADD_TEST is added in the top-level CMakeLists.txt this should be the first test runned ? However this will _SYSTEMATICALLY_ install before testing and not add a "real dependency". -- Erk ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
Eric Noulard wrote: Good day all, Is there any way that I can add 'install' dependency to the 'test'-target? Doing add_dependencies( test install ) does not seem to work: CMake Error at ... (ADD_DEPENDENCIES): add_dependencies Adding dependency to non-existent target: test May be you can try to add a first "fake test" which does it: ADD_TEST(00_Install ${CMAKE_BUILD_TOOL} install) Aha, I did not think about that, that's very nice, thanks a lot Eric! (But for future reference, see below) I don't think it's possible to add dependencies to "built-in" CMake target (which deserve a feature request :-) Ok, I'll file one (unless prompted not to, pending any future discussion here -- I don't really have a valid use-case!) I realized that I don't really have a valid use-case for letting 'test' depend on 'install', and I think there could never be one. Reasoning: In any context where it would be unsafe to invoke 'test' without 'install', one would want to do something like add_dependencies( test install ) or, as Eric suggested, ENABLE_TESTING() # First test: ADD_TEST(00_Install ${CMAKE_BUILD_TOOL} install) But this will not work: The user (developer..) could always *select* tests using ctest -R from the command line, like $ ctest -R Blabla in which case the 'install' target will *not* be invoked before the tests. For this reason, each and every test must depend on that everything is installed (e.g each test could start with invoking ${CMAKE_MAKE_PROGRAM} install) .. Now, this is unfortunate, because checking that installation is up-to-date takes a bit of time. And when _N_ tests are run, for example by invoking 'make test', this installation-is-up-to-date check is performed _N-1_ times too many. There are probably ways to resolve this.. but I haven't yet. Ok, thanks for reading! Best Regards Hugo Heden ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
Hi Hugo, > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Hugo Heden > Sent: Thursday, November 20, 2008 10:51 AM > Is there any way that I can add 'install' dependency to the 'test'- > target? Maybe it isn't relevant to your specific needs - but I found I could solve a problem where I needed the 'install' phase completed by adding SET (CTEST_BUILD_TARGET "INSTALL") for the actual build in the ctest script driving our nightly builds. Therefore targets get installed before the actual test phase. I've found this in a closed feature request for an explicit CTEST_INSTALL command .. Best regards, -.jan.- ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
2008/11/20 Eric Noulard : > 2008/11/20 Hugo Heden : >> Good day all, >> >> >> Is there any way that I can add 'install' dependency to the 'test'-target? >> >> Doing >> >> add_dependencies( test install ) >> >> does not seem to work: >> CMake Error at ... (ADD_DEPENDENCIES): >> add_dependencies Adding dependency to non-existent target: test > > I don't think it's possible to add dependencies to "built-in" CMake target > (which deserve a feature request :-) > >> Apparently neither 'test' nor 'install' counts as "top-level-targets"? > > Precisely :=) > Feature request added: http://public.kitware.com/Bug/view.php?id=8438 Best regards Hugo Heden ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
On Thu, Jan 29, 2009 at 7:43 AM, Hugo Heden wrote: > 2008/11/20 Eric Noulard : >> 2008/11/20 Hugo Heden : >>> Good day all, >>> >>> >>> Is there any way that I can add 'install' dependency to the 'test'-target? >>> >>> Doing >>> >>> add_dependencies( test install ) >>> >>> does not seem to work: >>> CMake Error at ... (ADD_DEPENDENCIES): >>> add_dependencies Adding dependency to non-existent target: test >> >> I don't think it's possible to add dependencies to "built-in" CMake target >> (which deserve a feature request :-) >> >>> Apparently neither 'test' nor 'install' counts as "top-level-targets"? >> >> Precisely :=) >> > > Feature request added: http://public.kitware.com/Bug/view.php?id=8438 Sorry to hijack the thread, but I believe I'm having the same issue with the target "clean": ADD_CUSTOM_TARGET(clean_libopts COMMAND ${MAKE} clean WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libopts) ADD_DEPENDENCIES(clean clean_libopts) results in: CMake Error at CMakeLists.txt:245 (ADD_DEPENDENCIES): add_dependencies Adding dependency to non-existent target: clean I'm doing the above because libopts is not built via cmake, but via autotools. -- Aaron Turner http://synfin.net/ http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & Windows Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
You probably want to investigate "ADDITIONAL_MAKE_CLEAN_FILES" property. _ Mike Jackson mike.jack...@bluequartz.net BlueQuartz Softwarewww.bluequartz.net Principal Software Engineer Dayton, Ohio On Jan 29, 2009, at 1:28 PM, Aaron Turner wrote: On Thu, Jan 29, 2009 at 9:41 AM, Michael Jackson wrote: The error you are getting is because there is no target named "clean". Granted, when makefiles are created there is a "make" target called "clean" but you have not defined a target within your project named "clean". Ok, make sense. Try putting the name of one of your actual targets (like a library that depends on libopts) in the add_custom_command instead and see if that works. Now you lost me. What add_custom_command are you referring to? Here's my config: IF(USE_AUTOOPTS) ADD_CUSTOM_TARGET(libopts ALL DEPENDS ${CMAKE_SOURCE_DIR}/libopts/.libs/libopts.a) ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_SOURCE_DIR}/libopts/Makefile ${CMAKE_SOURCE_DIR}/libopts/config.h ${CMAKE_SOURCE_DIR}/test/Makefile ${CMAKE_SOURCE_DIR}/docs/Makefile ${CMAKE_SOURCE_DIR}/doxygen.cfg PRE_BUILD COMMAND ${CMAKE_SOURCE_DIR}/configure) ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_SOURCE_DIR}/libopts/.libs/ libopts.a PRE_BUILD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libopts COMMAND ${MAKE} DEPENDS ${CMAKE_SOURCE_DIR}/libopts/Makefile) ADD_CUSTOM_TARGET(clean_libopts COMMAND ${MAKE} clean COMMAND rm -f Makefile WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libopts) # ADD_DEPENDENCIES(clean clean_libopts) ENDIF(USE_AUTOOPTS) # then later on, I do things like: SET(libs ${CMAKE_SOURCE_DIR}/libopts/.libs/libopts.a ) TARGET_LINK_LIBRARIES(tcpreplay ${libs}) -- Aaron Turner http://synfin.net/ http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & Windows Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
On Thursday 29 January 2009, Aaron Turner wrote: > On Thu, Jan 29, 2009 at 7:43 AM, Hugo Heden wrote: > > 2008/11/20 Eric Noulard : > >> 2008/11/20 Hugo Heden : > >>> Good day all, > >>> > >>> > >>> Is there any way that I can add 'install' dependency to the > >>> 'test'-target? > >>> > >>> Doing > >>> > >>> add_dependencies( test install ) > >>> > >>> does not seem to work: > >>> CMake Error at ... (ADD_DEPENDENCIES): > >>> add_dependencies Adding dependency to non-existent target: test > >> > >> I don't think it's possible to add dependencies to "built-in" CMake > >> target (which deserve a feature request :-) > >> > >>> Apparently neither 'test' nor 'install' counts as "top-level-targets"? > >> > >> Precisely :=) > > > > Feature request added: http://public.kitware.com/Bug/view.php?id=8438 > > Sorry to hijack the thread, but I believe I'm having the same issue > with the target "clean": > > ADD_CUSTOM_TARGET(clean_libopts > COMMAND ${MAKE} clean > WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/libopts) > > ADD_DEPENDENCIES(clean clean_libopts) > > results in: > CMake Error at CMakeLists.txt:245 (ADD_DEPENDENCIES): > add_dependencies Adding dependency to non-existent target: clean Yes, that doesn't work. "clean", "all", "install" are a special kind of target in cmake, i.e. they are not really targets, they are only created when the project files/makefiles are written. > I'm doing the above because libopts is not built via cmake, but via > autotools. You could add a second COMMAND to the clean_libopts target, which does a "make clean" for the current cmake project (yes, that's more a workaround). Alex ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
On Thu, Jan 29, 2009 at 12:37 PM, Alexander Neundorf wrote: > Yes, that doesn't work. "clean", "all", "install" are a special kind of target > in cmake, i.e. they are not really targets, they are only created when the > project files/makefiles are written. > > You could add a second COMMAND to the clean_libopts target, which does a "make > clean" for the current cmake project (yes, that's more a workaround). Yeah I may end up having to do that... really annoying. Right now, I'm trying to figure out how to use ADDITIONAL_MAKE_CLEAN_FILES. 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. 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? 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. -- -- Aaron Turner http://synfin.net/ http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & Windows Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
> > 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 ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Adding install dependency to test-target?
On Fri, Jan 30, 2009 at 3:00 AM, Hugo Heden wrote: > Try using quotes: > > SET_DIRECTORY_PROPERTIES(PROPERTIES > ADDITIONAL_MAKE_CLEAN_FILES "${extra_libopts_clean_files}" ) Thanks! That solved my problem. >> 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. Thanks for the warning. In my case my work around of using the path to the directory of the file and placing the cmake commands in the parent directory seems to be working. -- Aaron Turner http://synfin.net/ http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & Windows Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake