MantisBT - CMake
View Issue Details
0014247CMakeCMakepublic2013-06-26 10:532016-06-10 14:31
res3d 
Philip Lowman 
normalminoralways
closedmoved 
CMake 2.8.11.1 
 
0014247: FindCxxTest: CXXTEST_ADD_TEST compiles source files in Visual Studio 10 even though they shouldn't
The source files containing the actual test sources (i.e. the input files to test generantion) are compiled as though there were actual source files in Visual Studio 10 if they have a .cpp extension.
But since they can't be compiled standalone it would be desireable to have them only show up in the project, but be excluded from actual compilation. This can be done by tagging the test source files as "header files only" (see attached patch).
1. Create a CxxTest with the input files having an .cpp extension:
CXXTEST_ADD_TEST(test_UnicodeStream test_generated.cpp my_test_input.cpp)
2. Generate a Visual Studio 10 project.
3. Compile: my_test_input.cpp is being compiled, which fails.
No tags attached.
patch cmake-cxxtest-sources-headers-only.patch (409) 2013-06-26 10:53
https://public.kitware.com/Bug/file/4803/cmake-cxxtest-sources-headers-only.patch
Issue History
2013-06-26 10:53res3dNew Issue
2013-06-26 10:53res3dFile Added: cmake-cxxtest-sources-headers-only.patch
2013-06-26 11:15Brad KingAssigned To => Philip Lowman
2013-06-26 11:15Brad KingStatusnew => assigned
2013-06-26 11:16Brad KingSummaryCxxTest source files are compiled in Visual Studio 10 though they shouldn't => FindCxxTest: CXXTEST_ADD_TEST compiles source files in Visual Studio 10 even though they shouldn't
2013-07-04 07:50Igor SemenovNote Added: 0033483
2016-06-10 14:29Kitware RobotNote Added: 0042304
2016-06-10 14:29Kitware RobotStatusassigned => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0033483)
Igor Semenov   
2013-07-04 07:50   
Same bug in GCC 4.7.2 on Debian.
If tests are in cpp-file, they are built and linked together with generated file, and it causes multiple definitions.
Patch, proposed by res3d, doesn't work for me, it removes multiple definitions, but causes multiple undefined references.
The only solution for now is to rename tests file from .cpp to .h.
(0042304)
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.