[CMake] GTest confusion - linking to project being tested
cen
imbacen at gmail.com
Wed Apr 24 17:37:51 EDT 2019
Hi
I am essentially trying to solve this problem:
https://stackoverflow.com/questions/19886397/how-to-solve-the-error-lnk2019-unresolved-external-symbol-function/30667584#30667584
and I have hit a wall.
Using CMake to generate solution with two VC projects, one is a
monolithic .exe the other is a gtest project meant to test a few
functions from the exe.
I am having a problem linking to main project in gtest project because:
1. The project being tested is an exe, not a lib.
2. Ideally I don't want to have all h/cpp files pulled up in the gtest
project, only have the actual test files in there.
3. Adding the main project as a reference to gtest project didn't help
(suggestion from SO thread).
4. Manually adding main project .obj files in gtest as linker input
solves the problem and is essentially the solution I would like to
achieve with CMake.
5. I hit another unpleasant snafu after #4 because main and gtest
project implement a main() method and this fails to build. But I guess
this can be avoided by renaming
the gtest main and changing the entry point of the gtest project.
So if 5 is solvable, what I really need is a CMake solution to #4.. to
automatically build the tested project and link to it's object files in
gtest project.
This seems to me to be a really obvious case for testing so I am not
sure whether it really is that complicated or I am doing things wrong.
Bets regards, cen
More information about the CMake
mailing list