[cmake-developers] [CMake 0015059]: CMake custom build step PRE_LINK/PRE_BUILD do not work

Mantis Bug Tracker mantis at public.kitware.com
Tue Aug 5 04:24:52 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15059 
====================================================================== 
Reported By:                k0n3ru
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15059
Category:                   CMake
Reproducibility:            always
Severity:                   feature
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-08-05 04:24 EDT
Last Modified:              2014-08-05 04:24 EDT
====================================================================== 
Summary:                    CMake custom build step PRE_LINK/PRE_BUILD do not
work
Description: 
PRE_LINK and PRE_BUILD do not seem to work in CMake on linux ( generating
MakeFiles ). 

The documentation says that only PRE_BUILD is not supported. But , PRE_LINK does
not work at all.And PRE_BUILD is built *after* the actual target.

>From the documentation :

"Note that the PRE_BUILD option is only supported on Visual Studio 7 or later.
For all other generators PRE_BUILD will be treated as PRE_LINK." 






Steps to Reproduce: 
cmake_minimum_required(VERSION 2.8.5)
project(custom_command_test)

add_custom_target(my_actual_target
    COMMAND echo " I am the actual taget "
    COMMENT "Running actual target"
    )
add_custom_command(
    TARGET my_actual_target
    PRE_LINK
    COMMAND echo "I am prelinked to actual target"
    COMMENT " Running PRELINK action "
    )
add_custom_command(
    TARGET my_actual_target
    PRE_BUILD
    COMMAND echo " I am prebuilt to actual target"
    COMMENT " Running PRE_BUILD action"
    )
add_custom_command(
    TARGET my_actual_target
    POST_BUILD
    COMMAND echo " I postbuild to actual target"
    COMMENT " Running POST BUILD action "
    )


=================================================
On running the above :

> cmake .
-- The C compiler identification is GNU 4.4.2
-- The CXX compiler identification is GNU 4.4.2
-- Check for working C compiler: XXXX/gcc/4.4.2/bin/gcc
-- Check for working C compiler: XXXX/gcc/4.4.2/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: XXXX/gcc/4.4.2/bin/g++
-- Check for working CXX compiler: XXXX/gcc/4.4.2/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: XXXX

 > make my_actual_target
Scanning dependencies of target my_actual_target
[100%] Running actual target
 I am the actual taget 
 Running PRE_BUILD action
 I am prebuilt to actual target
 Running POST BUILD action 
 I postbuild to actual target
[100%] Built target my_actual_target

> cmake --version
cmake version 2.8.10.2

Additional Information: 
Workaround is to add a fake target and POST_BUILD step on it. Then creating
dependency seems to work. But, it has its own issues.For my setup , it creates
problems when parallel make ( -j ) is done.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-08-05 04:24 k0n3ru         New Issue                                    
======================================================================



More information about the cmake-developers mailing list