On 04/24/2011 04:06 PM, Paul Baumer wrote: > Thanks for your help. I have just tried this. But there is a cyclic > dependency issue. > > install_after_all calls "install" which depends on "ALL_BUILD" and tries to > build "install_after_all". > > Possible solutions: > a. break the "install" - "ALL_BUILD" dependency. This sounds kind of > unhealthy.
This would also be highly inconvenient as one usually expects that the "install" target depends on the "all" target, so a "make install" will ensure that the installed package is up-to-date, i.e. completely built. > b. remove "install_after_all" from ALL_BUILD. What would be the appropriate > way of doing this? Drop the ALL clause in the ADD_CUSTOM_TARGET() command, but if I understand correctly, this contradicts your actual intention since you would need to trigger the "install_after_all" target explicitly. Alternatively, you might try to call the "cmake_install.cmake" script by the custom command instead of triggering the "install" target; it should be quite the same, but doesn't retrigger the "all" target. On *nix, I can see the following CMakeLists.txt work and do what you probably want, in particular without any dependency cycles: CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(INSTALL_AFTER_ALL C) SET(CMAKE_VERBOSE_MAKEFILE ON) FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n") ADD_EXECUTABLE(main main.c) INSTALL(TARGETS main RUNTIME DESTINATION bin) ADD_CUSTOM_TARGET(install_after_all ALL COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_install.cmake) ADD_DEPENDENCIES(install_after_all main) However, ATM, I can't check if this works with Visual Studio, too. Regards, Michael > Again, thanks for your help!. > > Paul > > > On Mon, Mar 14, 2011 at 5:07 PM, David Cole <david.c...@kitware.com> wrote: > >> On Mon, Mar 14, 2011 at 10:16 AM, Paul Baumer >> <paul.baum...@googlemail.com> wrote: >>> Sorry for not being clear enough. I meant (2). >>> >>>> (2) included in the "Build Solution" command, executing after all >>>> other targets have been built, so that "F7" or "Build All" will >>>> actually build the INSTALL target? >>>> >>> >>> >> >> In CMake's C++ code, in the >> cmGlobalGenerator::CreateDefaultGlobalTargets method, the "install" >> target depends on the "all" target. (i.e. -- all has to be up-to-date >> before the install rules can be run...) >> >> The net result of this is that: >> >> make install >> >> ...will build things first, if necessary, before executing the install >> scripts to copy files around. >> >> What you are asking for is for "install" to be *included* in "all" -- >> which is difficult to do, since, traditionally, people are used to >> install depending on all. >> >> One way you could nearly achieve this, without any sort of CMake C++ >> changes at all, would be to add a custom target at the bottom of the >> top level CMakeLists.txt file, which would execute "make install" >> *after* all other targets are built. You could even do it generically, >> regardless of the underlying build system being used, by using >> something like this in a custom target or custom command call: >> >> add_executable(exe1 ...) >> add_executable(exe2 ...) >> install( ... install rules for all libs and exes here ...) >> ... >> add_custom_target(install_after_all ALL >> COMMAND ${CMAKE_COMMAND} --build . --target install --config >> ${CMAKE_CFG_INTDIR} >> ) >> add_dependencies(install_after_all exe1 exe2 ... any other >> "important" target names here, too ... ) _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake