MantisBT - CMake
View Issue Details
0014766CMake(No Category)public2014-02-20 05:322014-10-06 10:32
Mathieu Malaterre 
Mathieu Malaterre 
highmajorhave not tried
closedno change required 
CMake 2.8.12.2 
 
0014766: CTest does not handle executable extension properly
Here is a simple scenarion, toolchain target mingw32 compiler on a linux host.

Steps:

$ more CMakeLists.txt toolchain.cmake zurg.c
::::::::::::::
CMakeLists.txt
::::::::::::::
cmake_minimum_required(VERSION 2.8)
project(wine_test C)

add_executable(zurg zurg.c)

enable_testing()

add_test(zurg zurg)
::::::::::::::
toolchain.cmake
::::::::::::::
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
set(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)
::::::::::::::
zurg.c
::::::::::::::
int main()
{
  return 0;
}


Now build:

$ mkdir bin32
$ cd bin32
$ cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain.cmake ..
$ make
$ make test
Running tests...
Test project /tmp/c/bin32
    Start 1: zurg
Could not find executable zurg
Looked in the following places:
zurg
zurg
Release/zurg
Release/zurg
Debug/zurg
Debug/zurg
MinSizeRel/zurg
MinSizeRel/zurg
RelWithDebInfo/zurg
RelWithDebInfo/zurg
Deployment/zurg
Deployment/zurg
Development/zurg
Development/zurg
Unable to find executable: zurg
1/1 Test #1: zurg .............................***Not Run 0.00 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) = 0.00 sec

The following tests FAILED:
      1 - zurg (Not Run)
Errors while running CTest
make: *** [test] Error 8
No tags attached.
Issue History
2014-02-20 05:32Mathieu MalaterreNew Issue
2014-02-20 05:42Nils GladitzNote Added: 0035157
2014-02-20 05:48Mathieu MalaterreNote Added: 0035158
2014-02-20 05:57Nils GladitzNote Added: 0035159
2014-02-20 08:03Brad KingNote Added: 0035160
2014-02-20 08:03Brad KingStatusnew => resolved
2014-02-20 08:03Brad KingResolutionopen => no change required
2014-02-20 08:22Mathieu MalaterreAssigned To => Mathieu Malaterre
2014-02-20 08:22Mathieu MalaterreNote Added: 0035161
2014-02-20 08:22Mathieu MalaterreStatusresolved => feedback
2014-02-20 08:22Mathieu MalaterreResolutionno change required => reopened
2014-02-20 08:58Brad KingNote Added: 0035162
2014-02-20 08:58Brad KingStatusfeedback => resolved
2014-02-20 08:58Brad KingResolutionreopened => no change required
2014-10-06 10:32Robert MaynardNote Added: 0036912
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0035157)
Nils Gladitz   
2014-02-20 05:42   
Does the following work?

  add_test(NAME zurg COMMAND zurg)
(0035158)
Mathieu Malaterre   
2014-02-20 05:48   
Obviously not, see http://whathaveyoutried.com [^]

The following hack does solve the symptoms:

add_test(zurg zurg.exe)
(0035159)
Nils Gladitz   
2014-02-20 05:57   
I assume you haven't actually tried it then since it does seem to work for me.

The NAME/COMMAND signature allows executable target names and resolves them to the actual output file while the plain signature does not.
(0035160)
Brad King   
2014-02-20 08:03   
Using the NAME/COMMAND mode of add_test is the way to solve this. The plain signature just runs the command-line given with no transformation. The NAME/COMMAND signature recognizes target names in argv[0] and does the right thing.
(0035161)
Mathieu Malaterre   
2014-02-20 08:22   
I admit that I did not know that and i did not even tried even when suggested. appologies for that. However the documentation could be improved in particular this sentence:

[...]
 add_test(testname Exename arg1 arg2 ... )
   [...] Exename can be
       either an executable built by this project or an arbitrary executable
       on the system (like tclsh).
   [...]

thanks and sorry for the noise
(0035162)
Brad King   
2014-02-20 08:58   
Actually the documentation of add_test needed some cleanup anyway. Done:

 Help: Revise and format add_test() command documentation
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8afa5fe8 [^]
(0036912)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.