I would like to have the following structure A -> B -> C
, where:
C
is boilerplate code, wrappers for third-party libraries, very
basic code etc.
B
is the common classes, functions and data
structures specific to the project's domain.
A
is the project itself.
I would like to make it easy to reuse C
or B(+C)
in future in my other projects. In addition, I have the following requirements:
- As all three projects are in-progress, I would like to have an ability to build
C
, C+B
and C+B+A
in one shot.
- I would prefer the static linkage over dynamic, so that
C
and C+B
would be static libraries, and C+B+A
would be the executable
- I would like to keep cmake lists and config files simple and clean. Examples which I found in the official wiki and over the internet are pretty big and monstrous.
- It would be great if it won't require changing more than a couple of lines if I'd change the locations of
A
, B
or C
in the filesystem.
- All these three components are using google-test, but I'm not sure if it is important for the project layout.
I am pretty new to cmake and I don't even understand is it better to write XXXConfig.cmake
or FindXXX.cmake
files. Also, I am not sure, how should I pass relative paths from subcomponent to the parent component using X_INCLUDE_DIRS
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…