[CMake] How to use Purify with CMake.

william.crocker at analog.com william.crocker at analog.com
Thu Oct 14 07:33:38 EDT 2010


Hello:

I needed to build a purified version of my test program.
A search of the mailing list archives produced a number of
options, but they all had drawbacks.

I came upon the solution below which seems to work well.
I introduce a new language "PURIFY" for the purposes
of linking the purified executable.

Any comments?

Bill


---------- In a shared, included definitions file.

set( PURIFY_CACHE_DIR /tmp )
set( PURIFY_COMMAND "purify -always-use-cache-dir=yes -cache-dir=${PURIFY_CACHE_DIR}" )
set( CMAKE_PURIFY_LINK_EXECUTABLE "${PURIFY_COMMAND} ${CMAKE_CXX_LINK_EXECUTABLE}" )
set( CMAKE_PURIFY_FLAGS         ${CMAKE_CXX_FLAGS}         )
set( CMAKE_PURIFY_FLAGS_DEBUG   ${CMAKE_CXX_FLAGS_DEBUG}   )
set( CMAKE_PURIFY_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )


---------- In the CMakeList.txt file for a specific component.

# Build the regular test program.
#
add_executable( xyz_test EXCLUDE_FROM_ALL test.cc )
target_link_libraries( xyz_test xyz )

# Build a purified version of the test program.
#
add_executable( xyz_test_pure EXCLUDE_FROM_ALL test.cc )
target_link_libraries( xyz_test_pure xyz )
set_target_properties( xyz_test_pure PROPERTIES LINKER_LANGUAGE PURIFY )


More information about the CMake mailing list