[CMake] Find Module, add_library shared and static : standard ?

r2d2leboss at voila.fr r2d2leboss at voila.fr
Mon Apr 13 08:08:40 EDT 2015


Hi,

I need to write a FindModule which search static and shared version of my lib. I need both on my project (there is a diff between static and dynamic lib).

I would like to import my lib using add_library : 

add_library(Foo::MyLib STATIC IMPORTED)
add_library(Foo::MyLib SHARED IMPORTED)

This one will not works (same name) and I will not be able to distinguish static and shared. 
By default, I would like that MyLib point to shared (what find_library find by default). But If I specify something (what ?), I would like to use static lib during link.

target_link_libraries(myProg Foo::MyLib) -> link to shared version

do something()
target_link_libraries(myProg Foo::MyLib) -> link to static version 
restore shared ?

I would like to know what is the standard name, convention to import library static and shared ? (MyLib.a and MyLib.so)
* Two names ? (Foo::MyLib, Foo::MyLibStatic) ? (Foo::MyLib, Foo::Static::MyLib) ?
* Two configurations ? How to use it ?

Thank you,

John


___________________________________________________________
Mode, hifi, maison,… J'achète malin. Je compare les prix avec Voila.fr http://shopping.voila.fr/


More information about the CMake mailing list