[CMake] add_test and $(Configuration) with Visual Studio Generator

Kelly Thompson kgt at lanl.gov
Tue Jul 20 15:39:06 EDT 2010


Hi,

 

I am having trouble with add_test and the MSVC macro $(Configuration) when I
generate project files for Visual Studio.  I am hoping someone on this list
can provide a solution.

 

Scenario:  (This is an outline of what I want to do.)

 

1.     Ceating a unit test via 'add_executable(unittest unittest.cc)'.

2.     Add a the test so that it runs under a script that takes the unit
test's fully qualified path as an argument.  That is, I use 'add_test(
myunittest c:\bin\mytestscript ${path_to_unittest}/unittest.exe )'

 

So the question is: how do I define ${path_to_unittest}.  I was trying to
use 'get_target_property( unittest_loc unitttest LOCATION ),' but this
provides a path that contains the Visual Studio Macro $(Configuration) which
is not converted into 'Debug/Release/.' when I run the unit tests inside of
visual studio.  Instead I get an error about the path not being found (i.e:
'c:\myproj\test\$(Configuration)\unittest.exe not found').

 

Does anyone have an example of how to use add_test in the way that I am
trying to use it?  I suppose I could create a custom command that runs a
build time and does a find_file(.) but I think there must be a better way.

 

Thanks in advance,

 

-kt

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100720/2f7f2040/attachment.htm>


More information about the CMake mailing list