[CMake] CMake and CTest for Google tests

Chris Hillery chillery-cmake at lambda.nu
Wed Aug 25 21:31:46 EDT 2010


On Wed, Aug 25, 2010 at 3:17 PM, Neelima Mehdiratta <nmehdiratta at decarta.com
> wrote:

> ADD_CUSTOM_COMMAND(TARGET ${BIN_NAME}
>
>     POST_BUILD
>
>     WORKING_DIRECTORY ${SRC_DIR}
>
>     COMMAND bash ./addtestscrpt
>
>     COMMAND ${CMAKE_COMMAND} ${SRC_DIR}/DDSCommonTests/CMakeLists.txt
>
> )
>
>
I'm not sure, but I think you're very close to the right answer here. The
problem with the above COMMAND is that it doesn't quite make sense - you
can't specify a CMakeLists.txt file as an argument to CMake; it's not a
scripting language in that sense, at least when it's doing build-tree
configuration.

I think what you should do is the following. In your top-level
CMakeLists.txt, have something like

IF (EXISTS ${CMAKE_BINARY_DIR}/testlist.cmake)
  INCLUDE (${CMAKE_BINARY_DIR}/testlist.cmake)
ENDIF (EXISTS ${CMAKE_BINARY_DIR}/testlist.cmake)

and then change your custom to command to generate testlist.cmake in your
build directory and then re-run cmake:

ADD_CUSTOM_COMMAND(TARGET ${CMAKE_BINARY_DIR}/testlist.cmake
  POST_BUILD
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  COMMAND bash addtestscript
  COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}
)

You'll need to tweak the invocation of addtestscript to successfully
generate testlist.cmake in the build directory, and then I think it'll all
work.

Ceej
aka Chris Hillery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100825/10dd0119/attachment.htm>


More information about the CMake mailing list