target_link_libraries(test_core gtest gtest_main core)
add_test(NAME test_core COMMAND test_core)
I am essentially trying to solve this problem:
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
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
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe: