c++ - cmake: Building multiple versions of a program -


I would like to write a semic script which will compile the same source against several versions of the header file. The aim is to be able to easily create shared libraries that are backwards compatible with previous versions of an API.

I'm looking for examples and hints of the best way to do this.

I'm both c ++ and cmake so any help would be greatly appreciated.

This is the answer. If my head is slightly above, then take a different perspective with you

do this in my source code:

 Version_1_0 #include #ifdef "Header_1_0.h" #endif #ifdef Version_2_0 #include "Header_2_0.h" #endif 

do this in CMakeLists.txt file:

 add_library (Foo_Version_1_0 share Foo.cxx Header_1_0.h) # when you compile Foo_Version_1_0, defined "Version_1_0" set_target_properties (Foo_Version_1_0 attribute COMPILE_FLAGS -DVersion1_0) similar to version_2_0 # ... 

Finishing the building, you must have two libraries called libFoo_Version_1_0.so and libFoo_Version_2_0.so .

Cheers,
-Dan


Comments