[CMake] custom_command pre_build vs. post_build

Richard Fuchs fuchsrich at se-core.net
Wed Sep 20 12:10:35 EDT 2006


I've added some logging around each of our libraries that we build, but 
I'm getting an unexpected result.  I'm using a custom command with the 
cmake -E echo to print a log out before and after a library is built.  
However, the results are not consistent.  When we have custom targets, 
things work the way I'd expect, but when the target is a library, both 
PRE_BUILD and POST_BUILD options are run at the same time.  I've 
attached cmakelists snips and outputs.

Thanks
Richard


im_generator/CMakelist.txt
ADD_CUSTOM_TARGET(im_generator ALL
    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run_generator.sh
    ${CMAKE_CURRENT_SOURCE_DIR})

# Helpful logging
ADD_CUSTOM_COMMAND(
    TARGET im_generator
    PRE_BUILD
    COMMAND ${CMAKE_COMMAND}
    ARGS -E echo "*****Begin Interest Management Generator *****")

ADD_CUSTOM_COMMAND(
    TARGET im_generator
    POST_BUILD
    COMMAND ${CMAKE_COMMAND}
    ARGS -E echo "***** End Interest Management Generator *****")

daki/CMakeLists.txt
ADD_LIBRARY(${DAKI_CPlusPlus_LIB} SHARED ${SRCS})

# Helpful logging
ADD_CUSTOM_COMMAND(
    TARGET ${DAKI_CPlusPlus_LIB}
    PRE_BUILD
    COMMAND ${CMAKE_COMMAND}
    ARGS -E echo "***** Begin ${DAKI_CPlusPlus_LIB} *****")

ADD_CUSTOM_COMMAND(
    TARGET ${DAKI_CPlusPlus_LIB}
    POST_BUILD
    COMMAND ${CMAKE_COMMAND}
    ARGS -E echo "***** End ${DAKI_CPlusPlus_LIB} *****")


Output:

*****Begin Interest Management Generator *****
path := 
/work/secore-dev/secore/services/distributed_object/src/interest_management/generator/../..
[PARSING]{[imSimpleTypeTest] sdm.phys.StartResume: SimulationTime 
<OPERATOR> time}
[PARSING]{[imComplexTest] sdm.phys.RDMPhysicalEntity: 
MountedOn.SectorOfFire.AngleFromHeading <OPERATOR> someAngle}
[PARSING]{[imCompoundTest] sdm.phys.RDMPhysicalEntity: 
(MountedOn.SectorOfFire.AngleFromHeading <OPERATOR> someAngle) <Compound 
Operator> (SectorOfFire.AngleFromHeading <OPERATOR> angle2) <Compound 
Operator> TentDeployed <OPERATOR> deployed}
[PARSING]{[imSimpleTypeTest] sdm.phys.StartResume: SimulationTime 
<OPERATOR> time}
[PARSING]{[imComplexTest] sdm.phys.RDMPhysicalEntity: 
MountedOn.SectorOfFire.AngleFromHeading <OPERATOR> someAngle}
[PARSING]{[imCompoundTest] sdm.phys.RDMPhysicalEntity: 
(MountedOn.SectorOfFire.AngleFromHeading <OPERATOR> someAngle) <Compound 
Operator> (SectorOfFire.AngleFromHeading <OPERATOR> angle2) <Compound 
Operator> TentDeployed <OPERATOR> deployed}
***** End Interest Management Generator *****
Building CXX object 
services/distributed_object/src/c++/vsasvc/doss/daki/CMakeFiles/daki.dir/daki.o
Linking CXX shared library 
../../../../../../../../lib/services/distributed_object/libdaki.so
***** Begin daki *****
***** End daki *****



More information about the CMake mailing list