<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<META name=GENERATOR content="MSHTML 8.00.6001.18702"></HEAD>
<BODY>
<DIV><SPAN class=762420521-26052009><FONT color=#0000ff size=2
face=Arial>Thanks, David.</FONT></SPAN></DIV>
<DIV><FONT color=#0000ff size=2 face=Arial></FONT> </DIV>
<DIV><SPAN class=762420521-26052009><FONT color=#0000ff size=2 face=Arial>I put
your ideas into the PowerShell script that sets up and runs my tests. It's
working...</FONT></SPAN></DIV>
<DIV><SPAN class=762420521-26052009><FONT color=#0000ff size=2
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=762420521-26052009><FONT color=#0000ff size=2
face=Arial>-Steve</FONT></SPAN></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
<DIV></DIV>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left><FONT size=2
face=Tahoma>-----Original Message-----<BR><B>From:</B> cmake-bounces@cmake.org
[mailto:cmake-bounces@cmake.org] <B>On Behalf Of </B>David
Cole<BR><B>Sent:</B> Saturday, May 23, 2009 7:38 AM<BR><B>To:</B> Dmitry
Bely<BR><B>Cc:</B> cmake@cmake.org<BR><B>Subject:</B> Re: [CMake] How to get
the evaluated path to a target - MSVC<BR><BR></FONT></DIV>Dmitry, your
suggestion will not work. He's asking how to achieve this from a wrapper
script that he has written where $(OutDir) does not evaluate in the context of
the script...
<DIV><BR></DIV>
<DIV>Steve, here's a technique that I use, but it has some caveats:</DIV>
<DIV>- it requires that the executable exist at the time of the script
call</DIV>
<DIV>- it's a search for the exe in possible locations, so if multiple exist,
it's possible to get the "wrong" one</DIV>
<DIV><BR></DIV>
<DIV>Anyhow, here it is:</DIV>
<DIV>
<DIV><BR></DIV>
<DIV># For an executable named "my"</DIV>
<DIV>#</DIV>
<DIV># If you make this part of a cmake -P script, you will have to pass
in</DIV>
<DIV># CMAKE_BINARY_DIR and CMAKE_CONFIGURATION_TYPES with</DIV>
<DIV># -D *before* the -P...</DIV>
<DIV>#</DIV>
<DIV># If "my" does not exist in "bin" then find the first one that</DIV>
<DIV># does exist in a configuration type subdir of "bin."</DIV>
<DIV># my_CMAKE_CONFIGURATION_TYPES is a list of possible configuration</DIV>
<DIV># types in "recommended" order. First existing one found wins.</DIV>
<DIV>#</DIV>
<DIV>SET(my_BASE_DIR "${CMAKE_BINARY_DIR}")</DIV>
<DIV>SET(my_CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES})</DIV>
<DIV>#</DIV>
<DIV># If you prefer a different search order than what is defined in
CMAKE_CONFIGURATION_TYPES,</DIV>
<DIV># you may reorder them in my_CMAKE_CONFIGURATION_TYPES...</DIV>
<DIV><BR></DIV>
<DIV>IF(NOT my_EXECUTABLE)</DIV>
<DIV> SET(my_EXECUTABLE
"${my_BASE_DIR}/bin/my${CMAKE_EXECUTABLE_SUFFIX}")</DIV>
<DIV>ENDIF(NOT my_EXECUTABLE)</DIV>
<DIV><BR></DIV>
<DIV>IF(NOT EXISTS "${my_EXECUTABLE}")</DIV>
<DIV> FOREACH(my_CONFIGURATION_TYPE
${my_CMAKE_CONFIGURATION_TYPES})</DIV>
<DIV> IF(NOT EXISTS "${my_EXECUTABLE}")</DIV>
<DIV> IF(EXISTS
"${my_BASE_DIR}/bin/${my_CONFIGURATION_TYPE}/my${CMAKE_EXECUTABLE_SUFFIX}")</DIV>
<DIV> SET(my_EXECUTABLE
"${my_BASE_DIR}/bin/${my_CONFIGURATION_TYPE}/my${CMAKE_EXECUTABLE_SUFFIX}")</DIV>
<DIV> ENDIF(EXISTS
"${my_BASE_DIR}/bin/${my_CONFIGURATION_TYPE}/my${CMAKE_EXECUTABLE_SUFFIX}")</DIV>
<DIV> ENDIF(NOT EXISTS "${my_EXECUTABLE}")</DIV>
<DIV> ENDFOREACH(my_CONFIGURATION_TYPE)</DIV>
<DIV>ENDIF(NOT EXISTS "${my_EXECUTABLE}")</DIV>
<DIV><BR></DIV>
<DIV>MESSAGE(STATUS "my_EXECUTABLE='${my_EXECUTABLE}'")</DIV>
<DIV><BR></DIV>
<DIV><BR></DIV>
<DIV>Good luck!</DIV>
<DIV><BR></DIV>
<DIV>Hope this helps,</DIV>
<DIV>David</DIV>
<DIV><BR></DIV>
<DIV><BR></DIV><BR>
<DIV class=gmail_quote>On Sat, May 23, 2009 at 2:35 AM, Dmitry Bely <SPAN
dir=ltr><<A
href="mailto:dmitry.bely@gmail.com">dmitry.bely@gmail.com</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV>
<DIV></DIV>
<DIV class=h5>On Fri, May 22, 2009 at 11:46 PM, Steve Huston <<A
href="mailto:shuston@riverace.com">shuston@riverace.com</A>>
wrote:<BR>> Hi John,<BR>><BR>> Thanks for
replying.<BR>><BR>>> On Fri, May 22, 2009 at 12:18 PM, Steve
Huston<BR>>> <<A
href="mailto:shuston@riverace.com">shuston@riverace.com</A>>
wrote:<BR>>> > I'm using cmake for some cross-platform
Linux/Windows stuff. When<BR>>> > ctest runs my tests, there is
often the need to have a wrapper script<BR>>> > run the test - it
sets up env variables (sometimes by reading the<BR>>> > content of
a file), runs the test, scans log files, runs valgrind,<BR>>> >
etc. So, I'm passing the actual test exe name to the script, and
the<BR>>> > script runs it at the proper time.<BR>>>
><BR>>> > This works fine on Linux. On Windows, however, I'm
having a problem<BR>>> > getting the actual path - when I get the
LOCATION property, it has<BR>>> > $(OutDir) embedded. Visual Studio
can substitute this in if<BR>> ctest/VS<BR>>> > is directly
executing the test. However, if passed to the wrapper<BR>>> >
script, the VS OutDir variable is not available. Is there a
portable<BR>>> > way to get the test executable's path (either
relative or complete) so<BR>>> > I can pass it to the wrapper
script?<BR>>><BR>>> Shouldn't you already know the path in your
CMakeLists.txt?<BR>>><BR>>> It should be somewhere off
of<BR>>> ${PROJECT_BINARY_DIR}<BR>><BR>> "somewhere off of" is
the operative phrase... Exactly where is what I<BR>> need to know. For
example, in a Windows Debug build, it's in<BR>>
${PROJECT_BINARY_DIR}\Debug.<BR><BR></DIV></DIV>Why not to use something
like this:<BR><BR>if(MSVC_IDE)<BR> set(out_dir "$(OutDir)") # expanded
by Visual Studio<BR>else(MSVC_IDE)<BR> set(out_dir
${PROJECT_BINARY_DIR})<BR>endif(MSVC_IDE)<BR><BR>Nmake generator (instead of
Visual Studio one) could be another option.<BR><FONT color=#888888><BR>-
Dmitry Bely<BR></FONT>
<DIV>
<DIV></DIV>
<DIV class=h5>_______________________________________________<BR>Powered by
<A href="http://www.kitware.com"
target=_blank>www.kitware.com</A><BR><BR>Visit other Kitware open-source
projects at <A href="http://www.kitware.com/opensource/opensource.html"
target=_blank>http://www.kitware.com/opensource/opensource.html</A><BR><BR>Please
keep messages on-topic and check the CMake FAQ at: <A
href="http://www.cmake.org/Wiki/CMake_FAQ"
target=_blank>http://www.cmake.org/Wiki/CMake_FAQ</A><BR><BR>Follow this
link to subscribe/unsubscribe:<BR><A
href="http://www.cmake.org/mailman/listinfo/cmake"
target=_blank>http://www.cmake.org/mailman/listinfo/cmake</A><BR></DIV></DIV></BLOCKQUOTE></DIV><BR></DIV></BLOCKQUOTE></BODY></HTML>