Cleanup build installation directories
[oonf.git] / cmake / declare_library.cmake
1 # generic oonf library creation
2
3 function (oonf_create_library libname source include link_internal linkto_external)
4     # create static and dynamic library
5     add_library(oonf_${libname} SHARED ${source})
6     add_library(oonf_static_${libname} OBJECT ${source})
7     
8     # add libraries to global static/dynamic target
9     add_dependencies(dynamic oonf_${libname})
10     add_dependencies(static oonf_static_${libname})
11
12     # and link their dependencies
13     if(WIN32)
14         target_link_libraries(oonf_${libname} ws2_32 iphlpapi)
15     endif(WIN32)
16
17     set_target_properties(oonf_${libname} PROPERTIES SOVERSION "${OONF_VERSION}")
18
19     if (linkto_internal)
20         target_link_libraries(oonf_${libname} ${linkto_internal})
21     endif (linkto_internal)
22     if (linkto_external)
23         target_link_libraries(oonf_${libname} ${linkto_external})
24     endif (linkto_external)
25     
26     install(TARGETS oonf_${libname} LIBRARY
27                                     DESTINATION ${INSTALL_LIB_DIR}
28                                     COMPONENT component_oonf_${libname})
29     
30     ADD_CUSTOM_TARGET(install_oonf_${libname}
31                       COMMAND ${CMAKE_COMMAND} 
32                       -DBUILD_TYPE=${CMAKE_BUILD_TYPE}
33                       -DCOMPONENT=component_oonf_${libname}
34                       -P ${CMAKE_BINARY_DIR}/cmake_install.cmake)
35     ADD_DEPENDENCIES(install_oonf_${libname}   oonf_${libname})
36     
37     if (linkto_internal)
38         FOREACH(lib ${linkto_internal})
39             ADD_DEPENDENCIES(install_oonf_${libname} ${lib})
40             ADD_DEPENDENCIES(install_oonf_${libname} install_${lib})
41         ENDFOREACH(lib)
42     endif (linkto_internal)
43 endfunction (oonf_create_library)
44
45 function (oonf_create_plugin libname source include linkto_external)
46     SET (linkto_internal oonf_libcore oonf_libconfig oonf_libcommon)
47     
48     oonf_create_library("${libname}" "${source}" "${include}" "${linkto_internal}" "${linkto_external}")
49 endfunction (oonf_create_plugin)