[CMake] CMake:question of the time when the command will happen in add_custom_command(...)
Chaos Zhang
zcsd2012 at gmail.com
Fri Apr 22 05:53:12 EDT 2016
Sorry for i just know reply by email and thinks for your help again. :-)
Petr Kmoch wrote
> No, it is indeed compiled and linked just fine. What I meant is:
>
> Without any custom commands, the build process conceptually looks like
> this:
>
> buildMain() {
> compile_object_files();
> link_main_binary();
>
> message("Built target main");
> }
>
> With a post-build custom command:
>
> buildMain() {
> compile_object_files();
> link_main_binary();
> post_build_command();
>
> message("Built target main");
> }
>
> The custom command becomes a part of the entire process of "Building
> target," that's why the "Built target" message appears after the command
> runs.
>
> BTW, please keep the mailing list in copy when replying.
>
> Petr
>
> On 22 April 2016 at 10:02, Chaos Zhang <
> zcsd2012@
> > wrote:
>
>> So what you mean is the target have not been complied and linked after i
>> introduce
>> custom commands into this target right? Do i understand right?
>>
>> Thanks a lot for your generous help. :-)
>>
>> 2016-04-22 16:38 GMT+08:00 Petr Kmoch <
> petr.kmoch@
> >:
>>
>>> Hi,
>>>
>>> the reason is that the post-build command is actually a part of building
>>> "main the target." Once you introduce custom commands into a target,
>>> building it includes them all, and not just compiling the object files
>>> and
>>> linking the binary. You will notice that the "Linking C exectuable main"
>>> line came before the post-build message, so it did happen in the correct
>>> order.
>>>
>>> Petr
>>>
>>> On 22 April 2016 at 06:25, Chaos Zhang <
> zcsd2012@
> > wrote:
>>>
>>>> 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.
>>>> --
>>>>
>>>> Powered by www.kitware.com
>>>>
>>>> Please keep messages on-topic and check the CMake FAQ at:
>>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>>
>>>> Kitware offers various services to support the CMake community. For
>>>> more
>>>> information on each offering, please visit:
>>>>
>>>> CMake Support: http://cmake.org/cmake/help/support.html
>>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://public.kitware.com/mailman/listinfo/cmake
>>>>
>>>
>>>
>>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
--
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-tp7593314p7593320.html
Sent from the CMake mailing list archive at Nabble.com.
More information about the CMake
mailing list