1 function(install_libtool)
2 set(one_value_keywords "CURRENT;AGE;REVISION;INSTALLED;SHOULDNOTLINK;DLOPEN;DLPREOPEN;LIBDIR")
3 set(multi_value_keywords "TARGETS;DEPENDENCY_LIBS;WEAK_LIBRARY_NAMES;INHERITED_LINKER_FLAGS")
4 cmake_parse_arguments(LT "" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN})
5 list(APPEND LT_TARGETS ${LT_UNPARSED_ARGUMENTS})
6 if(NOT DEFINED LT_INSTALLED OR LT_INSTALLED)
11 if(NOT DEFINED LT_SHOULDNOTLINK OR LT_SHOULDNOTLINK)
12 set(LT_SHOULDNOTLINK yes)
14 set(LT_SHOULDNOTLINK no)
16 if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
17 set(CMAKE_INSTALL_LIBDIR lib)
19 if(NOT DEFINED LT_LIBDIR)
20 set(LT_LIBDIR ${CMAKE_INSTALL_LIBDIR})
21 elseif(IS_ABSOLUTE ${LT_LIBDIR})
22 get_filename_component(LT_LIBDIR ${LT_LIBDIR} NAME)
24 foreach(target ${LT_TARGETS})
25 get_property(name TARGET ${target} PROPERTY OUTPUT_NAME)
27 set(name ${CMAKE_STATIC_LIBRARY_PREFIX}${target})
29 set(name ${CMAKE_STATIC_LIBRARY_PREFIX}${name})
31 get_property(type TARGET ${target} PROPERTY TYPE)
32 if(type MATCHES "(SHARED|MODULE)_LIBRARY")
34 set(LT_DLNAME $<TARGET_FILE_NAME:${target}>)
36 set(LT_DLNAME $<TARGET_LINKER_FILE_NAME:${target}>)
38 list(APPEND LT_LIBRARY_NAMES ${LT_DLNAME})
39 get_property(version TARGET ${target} PROPERTY VERSION)
40 get_property(soversion TARGET ${target} PROPERTY SOVERSION)
41 if(UNIX AND (DEFINED version AND DEFINED soversion))
42 set(LT_DLNAME $<TARGET_SONAME_FILE_NAME:${target}>)
43 list(APPEND LT_LIBRARY_NAMES $<TARGET_SONAME_FILE_NAME:${target}>)
45 if(UNIX AND (DEFINED version OR DEFINED soversion))
46 list(APPEND LT_LIBRARY_NAMES $<TARGET_LINKER_FILE_NAME:${target}>)
48 string(REGEX MATCHALL "[0-9]+" version "${version}.0.0.0")
49 list(GET version 0 major)
50 list(GET version 1 minor)
51 list(GET version 2 patch)
52 math(EXPR LT_CURRENT "${major}+${minor}")
53 math(EXPR LT_REVISION "${patch}")
54 math(EXPR LT_AGE "${minor}")
55 elseif(type MATCHES "STATIC_LIBRARY")
56 set(LT_OLD_LIBRARY $<TARGET_FILE_NAME:${target}>)
57 if(NOT DEFINED LT_DLNAME)
58 set(LT_DLNAME $<TARGET_FILE_NAME:${target}>)
62 file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.la
63 CONTENT "# ${name}.la - a libtool library file
64 # Generated by CMake ${CMAKE_VERSION} (like GNU libtool)\n#
65 # Please DO NOT delete this file!\n# It is necessary for linking the library.\n
66 # The name that we can dlopen(3).\ndlname='${LT_DLNAME}'\n
67 # Names of this library.\nlibrary_names='$<JOIN:${LT_LIBRARY_NAMES}, >'\n
68 # The name of the static archive.\nold_library='${LT_OLD_LIBRARY}'\n
69 # Linker flags that cannot go in dependency_libs.\ninherited_linker_flags='$<JOIN:${LT_INHERITED_LINKER_FLAGS}, >'\n
70 # Libraries that this one depends upon.\ndependency_libs='$<JOIN:${LT_DEPENDENCY_LIBS}, >'\n
71 # Names of additional weak libraries provided by this library\nweak_library_names='$<JOIN:${WEAK_LIBRARY_NAMES}, >'\n
72 # Version information for ${name}.\ncurrent=${LT_CURRENT}\nage=${LT_AGE}\nrevision=${LT_REVISION}\n
73 # Is this an already installed library?\ninstalled=${LT_INSTALLED}\n
74 # Should we warn about portability when linking against -modules?\nshouldnotlink=${LT_SHOULDNOTLINK}\n
75 # Files to dlopen/dlpreopen\ndlopen='${LD_DLOPEN}'\ndlpreopen='${LD_DLPREOPEN}'\n
76 # Directory that this library needs to be installed in:\nlibdir='${CMAKE_INSTALL_PREFIX}/${LT_LIBDIR}'
78 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.la DESTINATION ${LT_LIBDIR})