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 REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" patch "${version}")
49 string(REGEX REPLACE "^[0-9]+\\.([0-9]).*" "\\1" minor "${version}")
50 string(REGEX REPLACE "^([0-9]).*" "\\1" major "${version}")
51 math(EXPR LT_CURRENT "0${major}+0${minor}")
52 math(EXPR LT_REVISION "0${patch}")
53 math(EXPR LT_AGE "0${minor}")
54 elseif(type MATCHES "STATIC_LIBRARY")
55 set(LT_OLD_LIBRARY $<TARGET_FILE_NAME:${target}>)
56 if(NOT DEFINED LT_DLNAME)
57 set(LT_DLNAME $<TARGET_FILE_NAME:${target}>)
61 file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.la
62 CONTENT "# ${name}.la - a libtool library file
63 # Generated by CMake ${CMAKE_VERSION} (like GNU libtool)\n#
64 # Please DO NOT delete this file!\n# It is necessary for linking the library.\n
65 # The name that we can dlopen(3).\ndlname='${LT_DLNAME}'\n
66 # Names of this library.\nlibrary_names='$<JOIN:${LT_LIBRARY_NAMES}, >'\n
67 # The name of the static archive.\nold_library='${LT_OLD_LIBRARY}'\n
68 # Linker flags that cannot go in dependency_libs.\ninherited_linker_flags='$<JOIN:${LT_INHERITED_LINKER_FLAGS}, >'\n
69 # Libraries that this one depends upon.\ndependency_libs='$<JOIN:${LT_DEPENDENCY_LIBS}, >'\n
70 # Names of additional weak libraries provided by this library\nweak_library_names='$<JOIN:${WEAK_LIBRARY_NAMES}, >'\n
71 # Version information for ${name}.\ncurrent=${LT_CURRENT}\nage=${LT_AGE}\nrevision=${LT_REVISION}\n
72 # Is this an already installed library?\ninstalled=${LT_INSTALLED}\n
73 # Should we warn about portability when linking against -modules?\nshouldnotlink=${LT_SHOULDNOTLINK}\n
74 # Files to dlopen/dlpreopen\ndlopen='${LD_DLOPEN}'\ndlpreopen='${LD_DLPREOPEN}'\n
75 # Directory that this library needs to be installed in:\nlibdir='${CMAKE_INSTALL_PREFIX}/${LT_LIBDIR}'
77 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.la DESTINATION ${LT_LIBDIR})