CMakeMacroLibtoolFile: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
 
(Replace content with link to new CMake community wiki)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[CMake_User_Contributed_Macros|Back]]
{{CMake/Template/Moved}}


This macro creates a libtool .la file for shared libraries or plugins. The first parameter is the target name of the library, the second parameter is the directory where it will be installed to. E.g. for a KDE 3.x module named "kfoo" the usage would be as follows:
This page has moved [https://gitlab.kitware.com/cmake/community/wikis/contrib/macros/LibtoolFile here].
 
 
ADD_LIBRARY(kfoo SHARED kfoo1.cpp kfoo2.cpp)<br>
CREATE_LIBTOOL_FILE(foo /lib/kde3)<br>
 
-----
 
  MACRO(CREATE_LIBTOOL_FILE _target _install_DIR)
      GET_TARGET_PROPERTY(_target_location ${_target} LOCATION)
      GET_FILENAME_COMPONENT(_laname ${_target_location} NAME_WE)
      GET_FILENAME_COMPONENT(_soname ${_target_location} NAME)
      SET(_laname ${_laname}.la)
      FILE(WRITE ${_laname} "# ${_laname} - a libtool library file, generated by cmake \n")
      FILE(APPEND ${_laname} "# The name that we can dlopen(3).\n")
      FILE(APPEND ${_laname} "dlname='${_soname}'\n")
      FILE(APPEND ${_laname} "# Names of this library\n")
      FILE(APPEND ${_laname} "library_names='${_soname} ${_soname} ${_soname}'\n")
      FILE(APPEND ${_laname} "# The name of the static archive\n")
      FILE(APPEND ${_laname} "old_library=''\n")
      FILE(APPEND ${_laname} "# Libraries that this one depends upon.\n")
      FILE(APPEND ${_laname} "dependency_libs=''\n")
      FILE(APPEND ${_laname} "# Version information.\ncurrent=0\nage=0\nrevision=0\n")
      FILE(APPEND ${_laname} "# Is this an already installed library?\ninstalled=yes\n")
      FILE(APPEND ${_laname} "# Should we warn about portability when linking against -modules?\nshouldnotlink=yes\n")
      FILE(APPEND ${_laname} "# Files to dlopen/dlpreopen\ndlopen=''\ndlpreopen=''\n")
      FILE(APPEND ${_laname} "# Directory that this library needs to be installed in:\n")
      FILE(APPEND ${_laname} "libdir='${CMAKE_INSTALL_PREFIX}${_install_DIR}'\n")
      INSTALL_FILES(${_install_DIR} FILES ${_laname})
  ENDMACRO(CREATE_LIBTOOL_FILE)
 
-----
[[CMake_User_Contributed_Macros|Back]]
 
{{CMake/Template/Footer}}

Latest revision as of 15:41, 30 April 2018


The CMake community Wiki has moved to the Kitware GitLab Instance.

This page has moved here.