[CMake] CMake and CTest for Google tests (Chris Hillery)

Neelima Mehdiratta nmehdiratta at decarta.com
Thu Aug 26 18:20:37 EDT 2010


Hi Chris,

Your suggestion to "generate testlist.cmake in your build directory and
then re-run cmake" worked with some tweaking.

Thank you!!

Neelima

Message: 3
Date: Wed, 25 Aug 2010 18:31:46 -0700
From: Chris Hillery <chillery-cmake at lambda.nu>
Subject: Re: [CMake] CMake and CTest for Google tests
To: Neelima Mehdiratta <nmehdiratta at decarta.com>
Cc: cmake at cmake.org
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



More information about the CMake mailing list