1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-24 Bradley M. Bell
# ----------------------------------------------------------------------------
# Construct cppad.pc from cppad.pc.in; see
# http://people.freedesktop.org/~dbn/pkg-config-guide.html
# -----------------------------------------------------------------------------
# {xrst_begin pkgconfig}
# {xrst_spell
# builddir
# cflags
# datadir
# includedir
# libdir
# libs
# }
# {xrst_comment_ch #}
#
# CppAD pkg-config Files
# ######################
#
# Purpose
# *******
# The ``pkg-config`` program helps with the used if installed libraries
# and include files; see its
# `guide <https://people.freedesktop.org/~dbn/pkg-config-guide.html>`_
# for more information on writing an using pkg-config files.
#
# cppad.pc
# ********
#
# PKG_CONFIG_PATH
# ===============
# The ``cppad.pc`` file is installed in the following two directories:
#
# | |tab| *prefix* / *libdir* / ``pkgconfig``
# | |tab| *prefix* / *datadir* / ``pkgconfig``
#
# where *prefix* is :ref:`cmake@cppad_prefix` ,
# *libdir* is the first entry in
# :ref:`cmake@cmake_install_libdirs` ,
# and # *datadir* is
# :ref:`cmake@cmake_install_datadir` .
# In order to use ``pkg-config`` ,
# one of these directories must your ``PKG_CONFIG_PATH`` .
#
# Compile Flags
# =============
# The necessary flags for compiling code that includes CppAD can
# be obtained with the command
# ::
#
# pkg-config --cflags cppad
#
# Link Flags
# ==========
# The flags for linking can be obtains with the command
# ::
#
# pkg-config --libs cppad
#
# Extra Definitions
# =================
# The ``cppad.pc`` file contains the text:
#
# | |tab| ``prefix`` = *prefix*
# | |tab| ``exec_prefix`` = *exec_prefix*
# | |tab| ``includedir`` = *includedir*
# | |tab| ``libdir`` = *libdir*
#
# where *prefix* , *exec_prefix* , *includedir* , and
# *libdir* are the
# `gnu installation variables <https://www.gnu.org/prep/standards/html_node/Directory-Variables.html>`_.
#
# cppad-uninstalled.pc
# ********************
#
# PKG_CONFIG_PATH
# ===============
# The ``cppad-uninstalled.pc`` file is located in the following directory:
#
# *builddir* / ``pkgconfig``
#
# where *builddir* is the directory where the :ref:`cmake-name` command
# is executed.
#
# Compile Flags
# =============
# The necessary flags for compiling code that includes CppAD,
# before CppAD is installed, can be obtained with the command
# ::
#
# pkg-config --cflags cppad-uninstalled
#
# Link Flags
# ==========
# The flags for linking can be obtains with the command
# ::
#
# pkg-config --libs cppad-uninstalled
#
# Extra Definitions
# =================
# The ``cppad-uninstalled.pc`` file has the same extra variables
# as the ``cppad.pc`` file.
#
# {xrst_end pkgconfig}
# ----------------------------------------------------------------------------
#
# The following variables are used by cppad.pc.in
# and set in the top source CMakeLists.txt:
# cppad_prefix,
# cppad_description,
# cppad_version,
# cppad_url,
# cppad_lib
# The other variables used by cppad.pc.in are set below
# Note that cppad_SOURCE_DIR is used by cppad-uninstalled.pc
# and is set by cmake to the top source directory.
#
# cppad_includedir
LIST(GET cmake_install_includedirs 0 cppad_includedir)
#
# cppad_libdir
LIST(GET cmake_install_libdirs 0 cppad_libdir)
#
# add_to_set
MACRO(add_to_set variable_name element)
IF( "${${variable_name}}" STREQUAL "" )
SET(${variable_name} ${element} )
ELSE( "${${variable_name}}" STREQUAL "" )
LIST(FIND ${variable_name} ${element} index)
IF( index EQUAL -1 )
SET(${variable_name} "${${variable_name}} ${element}")
ENDIF( index EQUAL -1 )
ENDIF( "${${variable_name}}" STREQUAL "" )
ENDMACRO(add_to_set variable_name element)
# -----------------------------------------------------------------------------
# initialize
SET(cppad_libdir_list "-L${cppad_prefix}/${cppad_libdir}")
SET(cppad_lib_list "-l${cppad_lib}")
SET(cppad_requires "")
SET(cppad_libs_private "")
SET(cppad_requires_private "")
#
# Colpack does not have a pkgconfig file.
SET(colpack_libdir NOTFOUND)
IF( cppad_has_colpack )
FOREACH(dir ${cmake_install_libdirs})
FILE(GLOB file_list "${colpack_prefix}/${dir}/libColPack.*" )
IF( file_list )
SET(colpack_libdir "${colpack_prefix}/${dir}")
ENDIF( file_list )
ENDFOREACH(dir ${cmake_install_libdirs})
IF( NOT colpack_libdir )
MESSAGE(FATAL_ERROR "Cannit find libColPack.* below ${colpack_prefix}")
ENDIF( NOT colpack_libdir )
add_to_set(cppad_libdir_list "-L${colpack_libdir}")
add_to_set(cppad_lib_list "-lColPack")
ENDIF( cppad_has_colpack )
#
# Ipopt and eigen have pkgconfig files.
IF( cppad_has_eigen )
SET(cppad_requires "${cppad_requires} eigen3")
ENDIF( cppad_has_eigen )
IF( cppad_has_ipopt )
SET(cppad_requires "${cppad_requires} ipopt")
add_to_set(cppad_lib_list "-lcppad_ipopt" )
ENDIF( cppad_has_ipopt )
# -----------------------------------------------------------------------------
# cppad.pc
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/cppad.pc.in
${CMAKE_CURRENT_BINARY_DIR}/cppad.pc
@ONLY
)
# cppad-uninstalled.pc
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/cppad-uninstalled.pc.in
${CMAKE_CURRENT_BINARY_DIR}/cppad-uninstalled.pc
@ONLY
)
# During install copy cppad.pc to datadir
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/cppad.pc
DESTINATION ${cppad_abs_datadir}/pkgconfig
)
# During install also copy cppad.pc to libdir
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/cppad.pc
DESTINATION ${cppad_abs_libdir}/pkgconfig
)
|