[CMake] Making with purify
William A. Hoffman
billlist at nycap.rr.com
Thu Oct 14 16:32:55 EDT 2004
I think a more simple approach would be to add a property to targets:
IN_ALL.
Then you can do this:
# create normal executable part of all build
ADD_EXECUTABLE(my_exe etc...)
# change the rule for linking a c executable to run purify before all the other commands
SET(CMAKE_C_LINK_EXECUTABLE "purify ${CMAKE_C_LINK_EXECUTABLE}") # modified example from p. 56
# add a new executable that is the same as my_exe but with a .purify
ADD_EXECUTABLE(my_exe.purify etc...)
# tell cmake not to build this target every time
SET_TARGET_PROPERTIES(my_exe.purify PROPERTIES IN_ALL FALSE)
I tried it and it seems to work well, I should be able to commit on Monday.
This will allow any target (exe or library) to be optionally built.
-Bill
At 03:57 PM 10/14/2004, Eric Bolz wrote:
>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
>>>
>>
>>
>
>_______________________________________________
>CMake mailing list
>CMake at www.cmake.org
>http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list