[Cppunit-devel] Auto registration vs. the linker
Brought to you by:
blep
From: King D. <Ki...@tc...> - 2001-11-09 19:37:01
|
I like and am trying to use auto registration in Visual C++ but the linker keeps defeating me. The example cppunit tests work fine because you are building everything as one project. But that is not how I want to do it. This is for a large system and it would work much nicer to have the tests for individual subsystems be built as their own projects and simply link them together with a small runner program within the overall workspace. So I have a project within the workspace that has the main executable and it just gets its test from the registry. I don't want any file within that project to know about what tests are out there. Each subsystem is built as a shared library that gets linked with the main executable. To add a subsystem to the lists of tests you just add its project to the dependencies of the main executable project to get them to link in. The problem is that it will not work as I described it. The linker is too smart. It will not even include any of the object files for the unit tests unless they are somehow referenced from the main executable. That is of course what the linker is supposed to do. But I don't want to hardcode references to the tests. This requires extra work to add tests, defeats the purpose behind auto registration, and makes it more difficult to change the tests you want to run. If you don't use a shared library and build in one project you don't have this problem. The linker includes all .obj files into the output even if they are not referenced, but will not do that if the same .obj files are packaged as a shared library. I don't want to build everything in one project. Different subsytems need different build options and things, so I want them to be compiled separately with separate configuration. Does anybody have any way to get the linker to do what I want it to do which is to say include all translation units from a shared library whether I reference them or not? -- Dale King |