[CMake] CMake:question of the time when the command will happen in add_custom_command(...)

Chaos Zhang zcsd2012 at gmail.com
Fri Apr 22 01:25:22 EDT 2016


Hi all,

I have some trouble when i use PRE_BUILD | PRE_LINK | POST_BUILD in command
"add_custom_command(...)". When i use POST_BUILD, i found the command will
execute before target had been built, like this:

1 [root at VM_33_35_centos build]# make
2 Scanning dependencies of target main
3 [100%] Building C object CMakeFiles/main.dir/main.c.o
4 Linking C executable main
5 This is pre build 
6 This is post build
7 [100%] Built target main

In my CMakeLists.txt, the content is:
 1 cmake_minimum_required(VERSION 2.8)
 2 add_executable(main main.c)
 3 add_custom_command(TARGET main
 4                     PRE_BUILD
 5                     COMMAND echo "This is pre build "
 6         )
 7 add_custom_command(TARGET main
 8                     POST_BUILD
 9                     COMMAND echo "This is post build"
 10         )

Why the command echo "This is post build" in 8 line(CMakeLists.txt) did not
execute after [100%] Built target main in 7 line(Linux command)?




--
View this message in context: http://cmake.3232098.n2.nabble.com/CMake-question-of-the-time-when-the-command-will-happen-in-add-custom-command-tp7593314.html
Sent from the CMake mailing list archive at Nabble.com.


More information about the CMake mailing list