root / cmake / Modules / CMakeMacroLibtoolFile.cmake @ 8ee7c96f
History | View | Annotate | Download (3.9 kB)
| 1 | faf7dea0 | Josh Blum | #http://www.vtk.org/Wiki/CMakeMacroLibtoolFile |
|---|---|---|---|
| 2 | faf7dea0 | Josh Blum | #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: |
| 3 | faf7dea0 | Josh Blum | |
| 4 | faf7dea0 | Josh Blum | #The macro GET_TARGET_PROPERTY_WITH_DEFAULT is helpful to handle properties with default values. |
| 5 | faf7dea0 | Josh Blum | |
| 6 | faf7dea0 | Josh Blum | #ADD_LIBRARY(foo SHARED kfoo1.cpp kfoo2.cpp) |
| 7 | faf7dea0 | Josh Blum | #CREATE_LIBTOOL_FILE(foo /lib/kde3) |
| 8 | faf7dea0 | Josh Blum | |
| 9 | 112a6d92 | Josh Blum | if(DEFINED __INCLUDED_CREATE_LIBTOOL_FILE) |
| 10 | 112a6d92 | Josh Blum | return() |
| 11 | 112a6d92 | Josh Blum | endif() |
| 12 | 112a6d92 | Josh Blum | set(__INCLUDED_CREATE_LIBTOOL_FILE TRUE) |
| 13 | 112a6d92 | Josh Blum | |
| 14 | faf7dea0 | Josh Blum | MACRO(GET_TARGET_PROPERTY_WITH_DEFAULT _variable _target _property _default_value) |
| 15 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY (${_variable} ${_target} ${_property})
|
| 16 | faf7dea0 | Josh Blum | IF (${_variable} MATCHES NOTFOUND)
|
| 17 | faf7dea0 | Josh Blum | SET (${_variable} ${_default_value})
|
| 18 | faf7dea0 | Josh Blum | ENDIF (${_variable} MATCHES NOTFOUND)
|
| 19 | faf7dea0 | Josh Blum | ENDMACRO (GET_TARGET_PROPERTY_WITH_DEFAULT) |
| 20 | faf7dea0 | Josh Blum | |
| 21 | faf7dea0 | Josh Blum | MACRO(CREATE_LIBTOOL_FILE _target _install_DIR) |
| 22 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY(_target_location ${_target} LOCATION)
|
| 23 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_static_lib ${_target} STATIC_LIB "")
|
| 24 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_dependency_libs ${_target} LT_DEPENDENCY_LIBS "")
|
| 25 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_current ${_target} LT_VERSION_CURRENT 0)
|
| 26 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_age ${_target} LT_VERSION_AGE 0)
|
| 27 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_revision ${_target} LT_VERSION_REVISION 0)
|
| 28 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_installed ${_target} LT_INSTALLED yes)
|
| 29 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_shouldnotlink ${_target} LT_SHOULDNOTLINK yes)
|
| 30 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_dlopen ${_target} LT_DLOPEN "")
|
| 31 | faf7dea0 | Josh Blum | GET_TARGET_PROPERTY_WITH_DEFAULT(_target_dlpreopen ${_target} LT_DLPREOPEN "")
|
| 32 | faf7dea0 | Josh Blum | GET_FILENAME_COMPONENT(_laname ${_target_location} NAME_WE)
|
| 33 | faf7dea0 | Josh Blum | GET_FILENAME_COMPONENT(_soname ${_target_location} NAME)
|
| 34 | faf7dea0 | Josh Blum | SET(_laname ${CMAKE_CURRENT_BINARY_DIR}/${_laname}.la)
|
| 35 | faf7dea0 | Josh Blum | FILE(WRITE ${_laname} "# ${_laname} - a libtool library file\n")
|
| 36 | faf7dea0 | Josh Blum | FILE(WRITE ${_laname} "# Generated by CMake ${CMAKE_VERSION} (like GNU libtool)\n")
|
| 37 | faf7dea0 | Josh Blum | FILE(WRITE ${_laname} "\n# Please DO NOT delete this file!\n# It is necessary for linking the library with libtool.\n\n" )
|
| 38 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# The name that we can dlopen(3).\n")
|
| 39 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "dlname='${_soname}'\n\n")
|
| 40 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# Names of this library.\n")
|
| 41 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "library_names='${_soname}.${_target_current}.${_target_age}.${_target_revision} ${_soname}.${_target_current} ${_soname}'\n\n")
|
| 42 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# The name of the static archive.\n")
|
| 43 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "old_library='${_target_static_lib}'\n\n")
|
| 44 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# Libraries that this one depends upon.\n")
|
| 45 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "dependency_libs='${_target_dependency_libs}'\n\n")
|
| 46 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# Names of additional weak libraries provided by this library\n")
|
| 47 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "weak_library_names=\n\n")
|
| 48 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# Version information for ${_laname}.\n")
|
| 49 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "current=${_target_current}\n")
|
| 50 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "age=${_target_age}\n")
|
| 51 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "revision=${_target_revision}\n\n")
|
| 52 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# Is this an already installed library?\n")
|
| 53 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "installed=${_target_installed}\n\n")
|
| 54 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# Should we warn about portability when linking against -modules?\n")
|
| 55 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "shouldnotlink=${_target_shouldnotlink}\n\n")
|
| 56 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# Files to dlopen/dlpreopen\n")
|
| 57 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "dlopen='${_target_dlopen}'\n")
|
| 58 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "dlpreopen='${_target_dlpreopen}'\n\n")
|
| 59 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "# Directory that this library needs to be installed in:\n")
|
| 60 | faf7dea0 | Josh Blum | FILE(APPEND ${_laname} "libdir='${CMAKE_INSTALL_PREFIX}${_install_DIR}'\n")
|
| 61 | faf7dea0 | Josh Blum | INSTALL( FILES ${_laname} DESTINATION ${CMAKE_INSTALL_PREFIX}${_install_DIR})
|
| 62 | faf7dea0 | Josh Blum | ENDMACRO(CREATE_LIBTOOL_FILE) |