[CMake] Possible set_tests_properties(ENVIRONMENT) bug?

Scott Gray sgray at inventa.com
Tue May 12 17:42:45 EDT 2009


David,

Awesome! That did the trick!

Thanks for the advice.

-scott

David Cole wrote:
> I think it's just a semicolon problem. Unfortunately for all of us 
> Windows PATH and CMake both use ";" as their list separator character.
>
> And the set_test_properties ENVIRONMENT property is a semicolon 
> delimited list of name1=value1;name2=value2;name3=value3;...etc...
>
> To embed ; characters inside of a value, try this after setting 
> NEWPATH and before calling set_test_properties:
> STRING(REPLACE ";" "\\;" NEWPATH "${NEWPATH}")
>
> Let us know if it works for you...
>
> Thanks,
> David
>
>
> On Tue, May 12, 2009 at 2:34 PM, Scott Gray <sgray at inventa.com 
> <mailto:sgray at inventa.com>> wrote:
>
>
>     While trying to research the answer to my question about how to
>     make your test program locate its dependent DLL's (see my previous
>     posting entitled "add_test and locating dependent DLL's on
>     Windows"), I decided to try the recently added ENVIRONMENT
>     property of set_tests_properties to set the PATH for the test
>     program. I *think* I have found an issue with it, but before I
>     open a bug, I wanted to check to see if this isn't operator error.
>
>     First, I created a very simple test program:
>
>     ===== BEGIN: Env_test.cpp ======
>     #include <stdio.h>
>     #include <stdlib.h>
>
>     void main (int argc, char *argv[])
>     {
>       char *p = getenv("PATH");
>       fprintf(stdout, "PATH = %s\n", p);
>     }
>     ===== END: Env_test.cpp ======
>     And then the CMakeLists.txt
>
>     ===== BEGIN: CMakeLists.txt ======
>     cmake_minimum_required(VERSION 2.7)
>     enable_testing()
>
>     add_executable (Env_test Env_test.cpp)
>     add_test (Env_test Env_test)
>
>     if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
>           set (NEWPATH "C:\\some_dir1;C:\\some_dir2;$ENV{PATH}")
>           message("NEWPATH = ${NEWPATH}")
>           set_tests_properties(Env_test PROPERTIES ENVIRONMENT
>     "PATH=${NEWPATH}")
>     endif()
>     ===== END: CMakeLists.txt ======
>
>     When I run 'cmake -G "Visual Studio 8 2005"', I get the message:
>
>       NEWPATH = C:\some_dir1;C:\some_dir2;C:\Program Files\CollabNet...
>
>     And if I run Env_test.exe by hand, it properly prints out whatever
>     my current PATH is.
>
>     However, when I run ctest, the output contained in the
>     LastTest.log shows:
>
>     Start testing: May 12 14:03 Eastern Daylight Time
>     ----------------------------------------------------------
>     Changing directory into: C:/cmake_bug
>     1/1 Testing: Env_test
>     1/1 Test: Env_test
>     Command: "C:/cmake_bug/debug/Env_test.exe"
>     Directory: C:/cmake_bug
>     "Env_test" start time: May 12 14:03 Eastern Daylight Time
>     Output:
>     ----------------------------------------------------------
>     PATH = C:\some_dir1^M
>     ----------------------------------------------------------
>     Test Passed.
>     "Env_test" end time: May 12 14:03 Eastern Daylight Time
>     "Env_test" time elapsed: 00:00:00
>     ----------------------------------------------------------
>
>     End testing: May 12 14:03 Eastern Daylight Time
>
>
>     No matter what I set the PATH to in my CMakeLists.txt, the test
>     program always dumps on the first component of the path leading up
>     to the first semicolon in the path.
>
>     So, is this operator error or a bug in the new feature?  Oh, I'm
>     running on last night's build of cmake (version 2.7.20090512).
>
>
>     Thanks,
>     -scott
>
>     -- 
>     Scott C. Gray
>     Chief Technologist
>     ANTs Software, Inc.
>     Inventa Technologies, Inc.
>     (W) 856-914-5212
>     (C) 609-304-3429
>
>     _______________________________________________
>     Powered by www.kitware.com <http://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
>
>

-- 
Scott C. Gray
Chief Technologist
ANTs Software, Inc.
Inventa Technologies, Inc.
(W) 856-914-5212
(C) 609-304-3429

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090512/13053348/attachment-0001.htm>


More information about the CMake mailing list