CMake: reuse object files built for a lib into another lib target -


i'm trying move project cmake, , @ same time have optimization on compilation process.

here's deal:

  • i have several subdirs (have be) each compiled static library (this works).
  • i want gather object files each subdir bigger, complete, static library.

it looks this:

. libbig.a  # made object subdir1 , subdir2 subdir1/    src/    libsubdir1.a subdir2/    src/    libsubdir2.a 

today, managed use global variable in every subdir cmakelists.txt append own source files. use variable "source" input in big library:

# big library depends on source files # ${all_src} automatically filled each subdir's cpp file get_property( biglib_src global property all_src) add_library( big static ${biglib_src}) # recompiles sources 

now, works, not bad, thing is, all source files compiled twice: once subdir library, , once big library.

cmake seems forget has built them.

i have keep subdir libraries , ar can't merge 2 static libraries.

do know how that?

you can use new object library feature introduced in cmake 2.8.8. idea explained here. basically, object library similar concept convenience library known autotools group object files.

check complete cmake object library tutorial.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -