MantisBT - CMake
View Issue Details
0015782CMakeCMakepublic2015-10-11 20:302016-06-10 14:31
Dario Oliveri 
Kitware Robot 
normalblockalways
closedmoved 
MSVC 19.0.23026.0Windows
CMake 3.1.2 
 
0015782: "--build" a generated test driver for Visual Studio 2015 fail because tests are not linked
After some trial and error I believe the issue is a bug in Cmake where generating a test driver results in a project file (tests.vcxproj) that cannot be built directly with cmake (basically it don't links the tests object files to the generated test driver, so I believe the bug is in the solution/project generator).

The current workaround is using some other frameworks and manually adding test files instead of generating a test driver from a GLOB.


the script I run from project folder are:

- mkdir build
- cd build
- cmake -G "Visual Studio 14 2015" ..

Building a regular target WORKS:

- cmake --build . --target libInfectorpp2 --config Release

Building ALL or test targets DO NOT WORK:
- cmake --build . --target ALL_BUILD --config Release


This is the "CONSOLE LOG" of the above scripts:
https://ci.appveyor.com/project/Darelbi/infectorpp2/build/1.0.38 [^]

this is the github project (where CMakeLists.txt is located):
https://github.com/Darelbi/Infectorpp2 [^]

No need to download the project, the console log already shows the log.
I need to get "TESTS.EXE" executable build from console using Cmake and the "--build" build command because I'm using a Continuos Integration server and hence I need to build the library and the tests executable at each commit, and I also need to run tests at each commit.

Actually there's no valid target for building the tests executable.
No tags attached.
Issue History
2015-10-11 20:30Dario OliveriNew Issue
2015-10-11 23:24Ben BoeckelNote Added: 0039567
2015-10-12 03:52Dario OliveriNote Added: 0039571
2016-06-10 14:29Kitware RobotNote Added: 0042853
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0039567)
Ben Boeckel   
2015-10-11 23:24   
Your test functions have the wrong type:

int mockSharedPtr(int , char** )

but:

unresolved external symbol "int __cdecl mockSharedPtr(int,char * * const)"
(0039571)
Dario Oliveri   
2015-10-12 03:52   
Thanks that's fixing the issue, I'm guessing why wrong signature works with GCC/CLANG and why most tutorials about test drivers do not use "const".

For example fix this documentation where "const" is not mentioned:
https://cmake.org/cmake/help/v3.0/command/create_test_sourcelist.html [^]
(0042853)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.