Does CMake run a script after setting goals?

I am trying to run a script after completing the installation of CMake. I found this thread on SO , but it still does not work, because my script depends on the goals set.

Basically, my script runs before the goals are set. This is because CMake seems to put code that sets the goals of the subdirectories at the end of cmake_install.cmake

Here is an example illustrating the problem; CMake file subdirectory:

 # src/CMakeLists.txt add_executable(foo main.cpp) install(TARGETS foo DESTINATION bin) 

Top Level CMake File:

 # Top-level CMakeLists.txt cmake_minimum_required(VERSION 2.8) add_subdirectory(src) install(CODE "execute_process(COMMAND ls ${CMAKE_INSTALL_PREFIX}/bin/foo)") 

Running make install gives:

 -- Install configuration: "debug" ls: cannot access /tmp/dummy/bin/foo: No such file or directory -- Installing: /tmp/dummy/bin/foo 

Any idea how I can get around this behavior? Thanks!

+4
source share
1 answer

If you find that cmake places the sub-dir installation objects at the end of cmake_install, you can simply add another sub-dir with cmake containing what you need to do after all the other goals.

+3
source