[CMake] Making with purify

Eric Bolz ebolz at mitre.org
Thu Oct 14 15:57:06 EDT 2004


There is a way to use ADD_CUSTOM_TARGET to do almost what I want.
Here is the command:
ADD_CUSTOM_TARGET(pure purify ${CMAKE_COMPILER} {$COMPILE_FLAGS} 
$CMAKE_C_LINK_FLAGS} ${LINK_FLAGS} ${FLAGS} ${MY_OBJECTS} my_exe.purify 
${MY_LIBRARIES})

With this custom target I can type 'make pure' and it will build 
my_exe.purify
However, this solution is poor because dependencies are not picked up.
But as long as I do a plain old 'make' first it works.

It seems to me it would not be difficult to modify the ADD_EXECUTABLE 
command as follows:
ADD_EXECUTABLE(  executableName 
                            [WIN32]   [MACOSX_BUNDLE]
                            [ NAME   name ]                              
  (Optional parameter)
                            [ OPT  purify | valgrind | quantify | 
other]   (Optional parameter)
                            source1 source2 source3 ... source(n)}
It would build the executable only if you typed 'make name'
The OPT parameter would cause the execuable to be build with any command 
the user wants such as purify, quantiy, or valgard.

 

William A. Hoffman wrote:

>Currently, there is no way to to make a target optionally part of the all build.
>If you are just using make, you might be able to do something like this:
>
>SET(CMAKE_CXX_LINK_EXECUTABLE "$(PURIFY) ${CMAKE_CXX_LINK_EXECUTABLE}")
>ADD_EXECUTABLE(my_exe  etc...)
>
># to build a purified my_exe
>rm my_exe
>make PURIFY=purify 
># to build the regular my_exe
>rm my_exe
>make 
>
>The $(PURIFY) variable will be treated as a make variable, and
>will expand to nothing when you do not define it on the command line.
>
>
>-Bill
>
>
>
>At 03:52 PM 10/13/2004, Eric Bolz wrote:
>  
>
>>In Mastering CMake, page 56, the example for building a purify version works fine but sometimes I want to build with purify and sometimes I don't.  How is that done?  I can do the following:
>>ADD_EXECUTABLE(my_exe  etc...)
>>SET(CMAKE_C_LINK_EXECUTABLE "purify  etc...")  as per the example on page 56
>>ADD_EXECUTABLE(my_exe.purify  etc...)
>>
>>But now my makefile produces both the purify and non-purify executables every time.
>>I just want to type 'make' to build my regular executable and I want to type 'make purify' when I want the purified version.  Can this be done?
>>
>>_______________________________________________
>>CMake mailing list
>>CMake at www.cmake.org
>>http://www.cmake.org/mailman/listinfo/cmake
>>    
>>
>
>  
>



More information about the CMake mailing list