开发者

Working with Existing C++ code tested under Google Test and adding Qt

开发者 https://www.devze.com 2023-02-24 12:24 出处:网络
I am working on a program written in C++ using some c++0x features in Linux (Ubuntu).I have written a bunch of tests in Google Test.I am using g++ and plain makefiles which generate dependencies.

I am working on a program written in C++ using some c++0x features in Linux (Ubuntu). I have written a bunch of tests in Google Test. I am using g++ and plain makefiles which generate dependencies.

Now I want to work on a completely separate UI.

I have decided that Qt will be good, but found that it is kind of complicated to build. I see that the easiest thing is to use qmake.

I was wondering how I can build Qt into my application while keeping all the underlying classes independent of Qt. I understand how to do that by writing good code, but I want a good build system.

I d开发者_StackOverflow社区on't want to switch to using Qt's unit testing framework because I only want to use Qt for the UI and I don't see the point of rewriting my tests.

Should I use qmake and modify it to produce my google test runner as well as the Qt app? Should I keep my makefile and use qmake to build and link only the UI parts of the code which will depend on the .o files produced in the original makefile? Should I do something else?

Finally, how would I do any of those above options?


CMake seems to work well with Qt (based on my experiences with my current project). There are a good set of macros to do all the standard Qt things, plus it integrates reasonably well with other tools. Your initial project may be a bit confusing to setup, but I'm sure there are numerous Qt examples available on the net.

You should not need to switch your testing framework to use CMake. I use the boost test framework, but as far as CMake is concerned any program which uses return codes will work just fine.

There is no reason to even partially use qmake if you use cmake.

Cmake is also cross-platform if that is a concern.


BTW, there is also no reason you have to stop using makefiles. Qt's qmake just calls a bunch of command-line tools which you can also do in make.

0

精彩评论

暂无评论...
验证码 换一张
取 消