[CMake] comparing program output / getting path to current build of executable.

Philip Lowman philip at yhbt.com
Tue Jul 7 07:51:02 EDT 2009


I believe the way we do this is to use variables like CMAKE_BINARY_DIR to
identify the build tree and then append "/bin" and the name of the binary in
order to run the test.  I don't recall doing anything VS specific within the
CMake scripts to make it work.  IIRC Visual Studio's generator appends the
build type itself or CTest guesses it.

If you're not using a single directory for all of your executables I think
CMAKE_CURRENT_BINARY_DIR might be helpful.

http://www.cmake.org/Wiki/CMake_Useful_Variables

On Fri, Jul 3, 2009 at 4:26 PM, Rupert Brooks <rupe.brooks at gmail.com> wrote:

> Hi everyone,
>
> I have a feeling this should be obvious, but i cant figure it out.
> Probably im using the wrong keywords to search the mailing list.
>
> What i want to do is add a test (using ADD_TEST, for ctest) that
> verifies that my program outputs what it was supposed to output.
> CTest, however, expects to use the return value of the program to
> determine if the test passed or not.  So, i wrote a simple program to
> compare the output of a program, and a text file.  If it matches, it
> returns zero, if not, it returns 1.
>
> I end up with an addtest line that would look like this
>
> ADD_TEST(OutputTest  CompareOutput  "PROGRAM  arguments"
> "TextFileOfExpectedOutput")
>
> My problem is the PROGRAM part in the above.  I need the path to the
> executable that is going to be tested.  In particular, i want to
> support build systems like visual studio where theres a subdirectory
> (Debug, Release, etc) depending on build type, and systems where there
> is not such a subdirectory.  In fact, visual studio is probably the
> troublesome one, i think that something like
> ${CMAKE_CURRENT_BUILD_DIR}/program_name would work on linux.  CTest
> has this information internally - since it runs the correct binary
> when it runs the test.  But i cant figure out a way to get this
> information as an argument to the tested program.
>
> Any suggestions would be appreciated - same goes if theres a better
> way to solve the original problem.
>
> Thanks
> Rupert B
>
> --
> --------------------------------------------------------------
> Rupert Brooks, Ph. D.
>
> Attaché de recherches | Research Associate
> Simulation des Matériaux Déformables | Simulation of Deformable Materials
> Institut des matériaux industriels | Industrial Materials Institute
> Conseil national de recherches Canada | National Research Council Canada
> 75, de Mortagne, Boucherville, Québec, Canada, J4B 6Y4
> Gouvernement du Canada | Government of Canada
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090707/d99ad7ad/attachment.htm>


More information about the CMake mailing list