added: cmake config mode and pkgconfig
This commit is contained in:
parent
303b9bc885
commit
870cf4514b
111
cmake/Modules/ConfigVars.cmake
Normal file
111
cmake/Modules/ConfigVars.cmake
Normal file
@ -0,0 +1,111 @@
|
||||
# - Create config.h based on a list of variables
|
||||
#
|
||||
# Synopsis:
|
||||
# configure_vars (FILE syntax filename verb varlist)
|
||||
# where
|
||||
# syntax CXX or CMAKE, depending on target
|
||||
# filename Full path (including name) of config.h
|
||||
# verb WRITE or APPEND if truncating or not
|
||||
# varlist List of variable names that has been defined
|
||||
#
|
||||
# In addition, this function will define HAVE_CONFIG_H for the
|
||||
# following compilations, (only) if the filename is "config.h".
|
||||
#
|
||||
# Example:
|
||||
# list (APPEND FOO_CONFIG_VARS
|
||||
# "/* bar library */"
|
||||
# "HAVE_BAR"
|
||||
# "HAVE_BAR_VERSION_2"
|
||||
# )
|
||||
# configure_vars (
|
||||
# FILE CXX ${PROJECT_BINARY_DIR}/config.h
|
||||
# WRITE ${FOO_CONFIG_VARS}
|
||||
# )
|
||||
|
||||
# Copyright (C) 2012 Uni Research AS
|
||||
# This file is licensed under the GNU General Public License v3.0
|
||||
|
||||
function (configure_vars obj syntax filename verb)
|
||||
# this is just to make the syntax look like the build-in commands
|
||||
if (NOT ("${obj}" STREQUAL "FILE" AND
|
||||
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
|
||||
message (FATAL_ERROR "Syntax error in argument list")
|
||||
endif (NOT ("${obj}" STREQUAL "FILE" AND
|
||||
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
|
||||
if (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
|
||||
message (FATAL_ERROR "Invalid target syntax \"${syntax}\"")
|
||||
endif (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
|
||||
|
||||
# truncate the file if the verb was "WRITE"
|
||||
if (verb STREQUAL "WRITE")
|
||||
file (WRITE "${filename}" "")
|
||||
endif (verb STREQUAL "WRITE")
|
||||
|
||||
# whenever we use this, we also signal to the header files that we
|
||||
# have "config.h". add this before any other files (known till now)
|
||||
# to avoid confusion from other configuration files.
|
||||
get_filename_component (_config_path "${filename}" PATH)
|
||||
get_filename_component (_config_file "${filename}" NAME)
|
||||
if ("${_config_file}" MATCHES "config\\.h(\\..+)?")
|
||||
add_definitions (-DHAVE_CONFIG_H=1)
|
||||
include_directories (BEFORE "${_config_path}")
|
||||
endif ("${_config_file}" MATCHES "config\\.h(\\..+)?")
|
||||
|
||||
# only write the current value of each variable once
|
||||
set (_args ${ARGN})
|
||||
if (_args)
|
||||
list (REMOVE_DUPLICATES _args)
|
||||
endif (_args)
|
||||
|
||||
# process each variable
|
||||
set (_prev_verbatim TRUE)
|
||||
foreach (_var IN LISTS _args)
|
||||
|
||||
# massage the name to remove source code formatting
|
||||
string (REGEX REPLACE "^[\\n\\t\\ ]+" "" _var "${_var}")
|
||||
string (REGEX REPLACE "[\\n\\t\\ ]+$" "" _var "${_var}")
|
||||
|
||||
# if the name of a variable has the syntax of a comments, write it
|
||||
# verbatim to the file; this can be used to create headings
|
||||
if ("${_var}" MATCHES "^/[/*]")
|
||||
if (NOT _prev_verbatim)
|
||||
file (APPEND "${filename}" "\n")
|
||||
endif (NOT _prev_verbatim)
|
||||
file (APPEND "${filename}" "${_var}\n")
|
||||
set (_prev_verbatim TRUE)
|
||||
|
||||
else ("${_var}" MATCHES "^/[/*]")
|
||||
|
||||
# write a CMake statements that warns if the value has changed
|
||||
if ("${syntax}" STREQUAL "CMAKE")
|
||||
set (_db "\${") # to avoid parsing problems
|
||||
file (APPEND "${filename}" "if (DEFINED ${_var} AND NOT \"${_db}${_var}}\" STREQUAL \"${${_var}}\")\n")
|
||||
file (APPEND "${filename}" "\tmessage (WARNING \"Incompatible value \\\"${_db}${_var}}\\\" of variable \\\"${_var}\\\"\")\n")
|
||||
file (APPEND "${filename}" "endif ()\n")
|
||||
endif ()
|
||||
|
||||
# check for empty variable; variables that are explicitly set to false
|
||||
# is not included in this clause
|
||||
if ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
|
||||
if ("${syntax}" STREQUAL "CMAKE")
|
||||
file (APPEND "${filename}" "set (${_var})\n")
|
||||
else ("${syntax}" STREQUAL "CMAKE")
|
||||
file (APPEND "${filename}" "/* #undef ${_var} */\n")
|
||||
endif ("${syntax}" STREQUAL "CMAKE")
|
||||
else ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
|
||||
# write to file using the correct syntax
|
||||
if ("${syntax}" STREQUAL "CMAKE")
|
||||
# escape backslash and double quote characters
|
||||
string (REPLACE "\\" "\\\\" _quoted "${${_var}}")
|
||||
string (REPLACE "\"" "\\\"" _quoted "${_quoted}")
|
||||
|
||||
file (APPEND "${filename}" "set (${_var} \"${_quoted}\")\n")
|
||||
else ("${syntax}" STREQUAL "CMAKE")
|
||||
file (APPEND "${filename}" "#define ${_var} ${${_var}}\n")
|
||||
endif ("${syntax}" STREQUAL "CMAKE")
|
||||
|
||||
endif ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
|
||||
set (_prev_verbatim FALSE)
|
||||
endif ("${_var}" MATCHES "^/[/*]")
|
||||
endforeach(_var)
|
||||
endfunction (configure_vars obj syntax filename verb)
|
165
cmake/Modules/LibtoolArchives.cmake
Normal file
165
cmake/Modules/LibtoolArchives.cmake
Normal file
@ -0,0 +1,165 @@
|
||||
# translate a list of libraries into a command-line that can be passed to the
|
||||
# compiler/linker. first parameter is the name of the variable that will
|
||||
# receive this list, the rest is considered the list of libraries
|
||||
function (linker_cmdline what INTO outvar FROM)
|
||||
# if we are going to put these in regexps, we must escape period
|
||||
string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}")
|
||||
string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
string (REPLACE "." "\\." esc_ar_pref "${CMAKE_STATIC_LIBRARY_PREFIX}")
|
||||
string (REPLACE "." "\\." esc_ar_suff "${CMAKE_STATIC_LIBRARY_PREFIX}")
|
||||
|
||||
# CMake loves absolute paths, whereas libtool won't have any of it!
|
||||
# (you get an error message about argument not parsed). translate each
|
||||
# of the libraries into a linker option
|
||||
set (deplib_list "")
|
||||
foreach (deplib IN LISTS ARGN)
|
||||
# starts with a hyphen already? then just add it
|
||||
string (SUBSTRING ${deplib} 0 1 dash)
|
||||
if (${dash} STREQUAL "-")
|
||||
list (APPEND deplib_list ${deplib})
|
||||
else (${dash} STREQUAL "-")
|
||||
# otherwise, parse the name into a directory and a name
|
||||
get_filename_component (deplib_dir ${deplib} PATH)
|
||||
get_filename_component (deplib_orig ${deplib} NAME)
|
||||
string (REGEX REPLACE
|
||||
"^${esc_dl_pref}(.*)${esc_dl_suff}$"
|
||||
"\\1"
|
||||
deplib_name
|
||||
${deplib_orig}
|
||||
)
|
||||
string (REGEX REPLACE
|
||||
"^${esc_ar_pref}(.*)${esc_ar_suff}$"
|
||||
"\\1"
|
||||
deplib_name
|
||||
${deplib_name}
|
||||
)
|
||||
# directory and name each on their own; this is somewhat
|
||||
# unsatisfactory because it may be that a system dir is specified
|
||||
# by an earlier directory and you start picking up libraries from
|
||||
# there instead of the "closest" path here. also, the soversion
|
||||
# is more or less lost. remove system default path, to lessen the
|
||||
# chance that we pick the wrong library
|
||||
if (NOT ((deplib_dir STREQUAL "/usr/lib") OR
|
||||
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
|
||||
list (APPEND deplib_list "-L${deplib_dir}")
|
||||
endif (NOT ((deplib_dir STREQUAL "/usr/lib") OR
|
||||
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
|
||||
# if there was no translation of the name, the library is named
|
||||
# unconventionally (.so.3gf, I'm looking at you), so pass this
|
||||
# name unmodified to the linker switch
|
||||
if (deplib_orig STREQUAL deplib_name)
|
||||
list (APPEND deplib_list "-l:${deplib_orig}")
|
||||
else (deplib_orig STREQUAL deplib_name)
|
||||
list (APPEND deplib_list "-l${deplib_name}")
|
||||
endif (deplib_orig STREQUAL deplib_name)
|
||||
endif (${dash} STREQUAL "-")
|
||||
endforeach (deplib)
|
||||
# caller determines whether we want it returned as a list or a string
|
||||
if ("${what}" STREQUAL "LIST")
|
||||
set (${outvar} ${deplib_list})
|
||||
else ("${what}" STREQUAL "LIST")
|
||||
set (${outvar} "${deplib_list}")
|
||||
string (REPLACE ";" " " ${outvar} "${${outvar}}")
|
||||
endif ("${what}" STREQUAL "LIST")
|
||||
set (${outvar} "${${outvar}}" PARENT_SCOPE)
|
||||
endfunction (linker_cmdline what INTO outvar FROM)
|
||||
|
||||
function (configure_la name target)
|
||||
if (NOT (UNIX OR MSYS OR MINGW))
|
||||
return ()
|
||||
endif (NOT (UNIX OR MSYS OR MINGW))
|
||||
|
||||
# these generic variables are initialized from the project info
|
||||
set (current "${${name}_VERSION_MAJOR}")
|
||||
set (age "${${name}_VERSION_MINOR}")
|
||||
set (inherited_linker_flags "${${name}_LINKER_FLAGS}")
|
||||
set (dependency_libs "${${name}_LIBRARIES}")
|
||||
|
||||
# translate list of libraries to command line
|
||||
linker_cmdline (LIST INTO dependency_libs FROM ${dependency_libs})
|
||||
|
||||
# convert from CMake list (i.e. semi-colon separated)
|
||||
string (REPLACE ";" " " inherited_linker_flags "${inherited_linker_flags}")
|
||||
string (REPLACE ";" " " dependency_libs "${dependency_libs}")
|
||||
|
||||
# this is the preferred installation path
|
||||
set (libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
# ${name}_LIBRARY_TYPE is either SHARED or STATIC
|
||||
if (${name}_LIBRARY_TYPE STREQUAL "SHARED")
|
||||
set (libprefix "${CMAKE_SHARED_LIBRARY_PREFIX}")
|
||||
set (libsuffix "${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
set (libname "${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
# only Unix has soversion in library names
|
||||
if (UNIX)
|
||||
set (dlname "${libname}.${current}")
|
||||
set (library_names "${libname}.${current}.${age} ${libname}.${current} ${libname}")
|
||||
else (UNIX)
|
||||
set (dlname "${libname}")
|
||||
set (library_names "${libname}")
|
||||
endif (UNIX)
|
||||
set (old_library "")
|
||||
else (${name}_LIBRARY_TYPE STREQUAL "SHARED")
|
||||
set (dlname "")
|
||||
set (library_names "")
|
||||
set (old_library "${CMAKE_STATIC_LIBRARY_PREFIX}${target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endif (${name}_LIBRARY_TYPE STREQUAL "SHARED")
|
||||
|
||||
# get the version of libtool installed on the system; this is
|
||||
# necessary because libtool checks that the file contains its own
|
||||
# signature(!)
|
||||
if (NOT libtool_MAIN)
|
||||
find_file (
|
||||
libtool_MAIN
|
||||
ltmain.sh
|
||||
PATHS /usr
|
||||
PATH_SUFFIXES share/libtool/config/
|
||||
DOC "Location of libtool"
|
||||
)
|
||||
mark_as_advanced (libtool_MAIN)
|
||||
# notify the user if it not found after we explicitly searched
|
||||
if (NOT libtool_MAIN)
|
||||
message (STATUS "Libtool not found!")
|
||||
endif (NOT libtool_MAIN)
|
||||
endif (NOT libtool_MAIN)
|
||||
if (libtool_MAIN)
|
||||
file (STRINGS
|
||||
${libtool_MAIN}
|
||||
ltversion_STRING
|
||||
REGEX "^VERSION=\".*\""
|
||||
)
|
||||
endif (libtool_MAIN)
|
||||
if (ltversion_STRING)
|
||||
string (REGEX REPLACE
|
||||
"^VERSION=\"?(.*)\"?"
|
||||
"\\1"
|
||||
ltversion
|
||||
${ltversion_STRING}
|
||||
)
|
||||
endif (ltversion_STRING)
|
||||
|
||||
# assume that we are in cmake/Modules, and that the template have been
|
||||
# put in cmake/Templates. we cannot use CMAKE_CURRENT_LIST_DIR because
|
||||
# this is in a function, and we cannot know who's calling us
|
||||
set (templ_dir "${OPM_MACROS_ROOT}/cmake/Templates")
|
||||
|
||||
|
||||
# only write an .la if libtool is found; otherwise we have no use
|
||||
# for it.
|
||||
if (ltversion)
|
||||
set (la_file "lib${target}.la")
|
||||
message (STATUS "Writing libtool archive for ${target}")
|
||||
configure_file (
|
||||
${templ_dir}/la.in
|
||||
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${la_file}
|
||||
@ONLY@
|
||||
)
|
||||
else (ltversion)
|
||||
set (la_file "")
|
||||
endif (ltversion)
|
||||
|
||||
# return this variable to the caller
|
||||
if (ARGV2)
|
||||
set (${ARGV2} "${la_file}" PARENT_SCOPE)
|
||||
endif (ARGV2)
|
||||
endfunction (configure_la target)
|
152
cmake/Modules/OpmProject.cmake
Normal file
152
cmake/Modules/OpmProject.cmake
Normal file
@ -0,0 +1,152 @@
|
||||
# - Helper routines for opm-core like projects
|
||||
|
||||
include (LibtoolArchives) # linker_cmdline
|
||||
|
||||
# convert a list back to a command-line string
|
||||
function (unseparate_args var_name prefix value)
|
||||
separate_arguments (value)
|
||||
foreach (item IN LISTS value)
|
||||
set (prefixed_item "${prefix}${item}")
|
||||
if (${var_name})
|
||||
set (${var_name} "${${var_name}} ${prefixed_item}")
|
||||
else (${var_name})
|
||||
set (${var_name} "${prefixed_item}")
|
||||
endif (${var_name})
|
||||
endforeach (item)
|
||||
set (${var_name} "${${var_name}}" PARENT_SCOPE)
|
||||
endfunction (unseparate_args var_name prefix value)
|
||||
|
||||
# wrapper to set variables in pkg-config file
|
||||
function (configure_pc_file name source dest prefix libdir includedir)
|
||||
# escape set of standard strings
|
||||
unseparate_args (includes "-I" "${${name}_INCLUDE_DIRS}")
|
||||
unseparate_args (defs "" "${${name}_DEFINITIONS}")
|
||||
linker_cmdline (STRING INTO libs FROM ${${name}_LIBRARIES})
|
||||
|
||||
# necessary to make these variables visible to configure_file
|
||||
set (name "${${name}_NAME}")
|
||||
set (description "${${name}_DESCRIPTION}")
|
||||
set (major "${${name}_VERSION_MAJOR}")
|
||||
set (minor "${${name}_VERSION_MINOR}")
|
||||
set (target "${${name}_LIBRARY}")
|
||||
linker_cmdline (STRING INTO target from ${target})
|
||||
|
||||
configure_file (${source} ${dest} @ONLY)
|
||||
endfunction (configure_pc_file name source dist prefix libdir includedir)
|
||||
|
||||
function (configure_cmake_file name variant version)
|
||||
# declarative list of the variable names that are used in the template
|
||||
# and that must be defined in the project to be exported
|
||||
set (variable_suffices
|
||||
DESCRIPTION
|
||||
VERSION
|
||||
DEFINITIONS
|
||||
INCLUDE_DIRS
|
||||
LIBRARY_DIRS
|
||||
LINKER_FLAGS
|
||||
CONFIG_VARS
|
||||
LIBRARY
|
||||
LIBRARIES
|
||||
TARGET
|
||||
)
|
||||
|
||||
# set these variables temporarily (this is in a function scope) so
|
||||
# they are available to the template (only)
|
||||
foreach (suffix IN LISTS variable_suffices)
|
||||
set (opm-project_${suffix} "${${name}_${suffix}}")
|
||||
endforeach (suffix)
|
||||
set (opm-project_NAME "${${name}_NAME}")
|
||||
|
||||
# make the file substitutions
|
||||
configure_file (
|
||||
${template_dir}/opm-project-config${version}.cmake.in
|
||||
${PROJECT_BINARY_DIR}/${${name}_NAME}-${variant}${version}.cmake
|
||||
@ONLY
|
||||
)
|
||||
endfunction (configure_cmake_file name)
|
||||
|
||||
# installation of CMake modules to help user programs locate the library
|
||||
function (opm_cmake_config name)
|
||||
# assume that the template is located in cmake/Templates (cannot use
|
||||
# the current directory since this is in a function and the directory
|
||||
# at runtime not at definition will be used
|
||||
set (template_dir "${OPM_MACROS_ROOT}/cmake/Templates")
|
||||
|
||||
# write configuration file to locate library
|
||||
configure_cmake_file (${name} "config" "")
|
||||
configure_cmake_file (${name} "config" "-version")
|
||||
configure_vars (
|
||||
FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-config.cmake"
|
||||
APPEND "${${name}_CONFIG_VARS}"
|
||||
)
|
||||
|
||||
# config-mode .pc file; use this to find the build tree
|
||||
configure_pc_file (
|
||||
${name}
|
||||
${template_dir}/opm-project.pc.in
|
||||
${PROJECT_BINARY_DIR}/${${name}_NAME}.pc
|
||||
${PROJECT_BINARY_DIR}
|
||||
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# replace the build directory with the target directory in the
|
||||
# variables that contains build paths
|
||||
string (REPLACE
|
||||
"${PROJECT_SOURCE_DIR}"
|
||||
"${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}"
|
||||
${name}_INCLUDE_DIRS
|
||||
"${${name}_INCLUDE_DIRS}"
|
||||
)
|
||||
string (REPLACE
|
||||
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
|
||||
${name}_LIBRARY
|
||||
"${${name}_LIBRARY}"
|
||||
)
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
|
||||
)
|
||||
# create a config mode file which targets the install directory instead
|
||||
# of the build directory (using the same input template)
|
||||
configure_cmake_file (${name} "install" "")
|
||||
configure_vars (
|
||||
FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake"
|
||||
APPEND "${${name}_CONFIG_VARS}"
|
||||
)
|
||||
# this file gets copied to the final installation directory
|
||||
install (
|
||||
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake
|
||||
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
|
||||
RENAME ${${name}_NAME}-config.cmake
|
||||
)
|
||||
# assume that there exists a version file already
|
||||
install (
|
||||
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-config-version.cmake
|
||||
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
|
||||
)
|
||||
|
||||
# find-mode .pc file; use this to locate system installation
|
||||
configure_pc_file (
|
||||
${name}
|
||||
${template_dir}/opm-project.pc.in
|
||||
${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
|
||||
${CMAKE_INSTALL_PREFIX}
|
||||
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}
|
||||
${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}
|
||||
)
|
||||
|
||||
# put this in the right system location; if we have binaries then it
|
||||
# should go in the arch-specific lib/ directory, otherwise use the
|
||||
# common/noarch lib/ directory (these targets come from UseMultiArch)
|
||||
if (${name}_TARGET)
|
||||
set (_pkg_dir ${CMAKE_INSTALL_LIBDIR})
|
||||
else ()
|
||||
set (_pkg_dir ${LIBDIR_MULTIARCH_UNAWARE})
|
||||
endif ()
|
||||
install (
|
||||
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${_pkg_dir}/pkgconfig${${name}_VER_DIR}/
|
||||
RENAME ${${name}_NAME}.pc
|
||||
)
|
||||
endfunction (opm_cmake_config name)
|
28
cmake/Templates/opm-project-config-version.cmake.in
Normal file
28
cmake/Templates/opm-project-config-version.cmake.in
Normal file
@ -0,0 +1,28 @@
|
||||
# - CMake version file for @opm-project_NAME@
|
||||
#
|
||||
# Determine if requested version matches exactly or is compatible with
|
||||
# the installed package. It sets the following variables:
|
||||
#
|
||||
# PACKAGE_VERSION Full provided version string
|
||||
# PACKAGE_VERSION_COMPATIBLE True if version is compatible
|
||||
# PACKAGE_VERSION_EXACT True if version is exact match
|
||||
|
||||
# This file is used by find_package to see if the installed version of a
|
||||
# package can be used by the client, before the main -config.cmake file
|
||||
# is loaded.
|
||||
# see <http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Package_Version_Files>
|
||||
|
||||
# this is the version that is installed
|
||||
set (PACKAGE_VERSION @opm-project_VERSION@)
|
||||
|
||||
# if we wanted this exact version, then everything's fine
|
||||
if (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
|
||||
set (PACKAGE_VERSION_EXACT TRUE)
|
||||
endif (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
|
||||
|
||||
# in general, we assume that there is going to be API breakage between
|
||||
# released versions; this will hopefully change in the future
|
||||
## compatible versions
|
||||
#if (NOT PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
# set (PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
#endif (NOT PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
66
cmake/Templates/opm-project-config.cmake.in
Normal file
66
cmake/Templates/opm-project-config.cmake.in
Normal file
@ -0,0 +1,66 @@
|
||||
# - @opm-project_DESCRIPTION@ config mode
|
||||
#
|
||||
# Defines the following variables:
|
||||
# @opm-project_NAME@_FOUND - true
|
||||
# @opm-project_NAME@_VERSION - version of the @opm-project_NAME@ library found, e.g. 0.2
|
||||
# @opm-project_NAME@_DEFINITIONS - defines to be made on the command line
|
||||
# @opm-project_NAME@_INCLUDE_DIRS - header directories with which to compile
|
||||
# @opm-project_NAME@_LINKER_FLAGS - flags that must be passed to the linker
|
||||
# @opm-project_NAME@_LIBRARIES - names of the libraries with which to link
|
||||
# @opm-project_NAME@_LIBRARY_DIRS - directories in which the libraries are situated
|
||||
#
|
||||
# You should put lines like this in your CMakeLists.txt
|
||||
# set (@opm-project_NAME@_DIR "${PROJECT_BINARY_DIR}/../@opm-project_NAME@" CACHE LOCATION "Build tree of @opm-project_NAME@")
|
||||
# find_package (@opm-project_NAME@)
|
||||
# configure_vars (
|
||||
# FILE CXX "${PROJECT_BINARY_DIR}/config.h"
|
||||
# WRITE ${@opm-project_NAME@_CONFIG_VARS}
|
||||
# )
|
||||
|
||||
# <http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file>
|
||||
|
||||
# propagate these properties from one build system to the other
|
||||
set (@opm-project_NAME@_VERSION "@opm-project_VERSION@")
|
||||
set (@opm-project_NAME@_DEFINITIONS "@opm-project_DEFINITIONS@")
|
||||
set (@opm-project_NAME@_INCLUDE_DIRS "@opm-project_INCLUDE_DIRS@")
|
||||
set (@opm-project_NAME@_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
|
||||
set (@opm-project_NAME@_LINKER_FLAGS "@opm-project_LINKER_FLAGS@")
|
||||
set (@opm-project_NAME@_CONFIG_VARS "@opm-project_CONFIG_VARS@")
|
||||
|
||||
# libraries come from the build tree where this file was generated
|
||||
set (@opm-project_NAME@_LIBRARY "@opm-project_LIBRARY@")
|
||||
set (@opm-project_NAME@_LIBRARIES ${@opm-project_NAME@_LIBRARY} "@opm-project_LIBRARIES@")
|
||||
mark_as_advanced (@opm-project_NAME@_LIBRARY)
|
||||
|
||||
# not all projects have targets; conditionally add this part
|
||||
if (NOT "@opm-project_TARGET@" STREQUAL "")
|
||||
# add the library as a target, so that other things in the project including
|
||||
# this file may depend on it and get rebuild if this library changes.
|
||||
add_library (@opm-project_TARGET@ UNKNOWN IMPORTED)
|
||||
set_property (TARGET @opm-project_TARGET@ PROPERTY IMPORTED_LOCATION "${@opm-project_NAME@_LIBRARY}")
|
||||
endif (NOT "@opm-project_TARGET@" STREQUAL "")
|
||||
|
||||
# ensure that we build with support for C++11 to preserve ABI
|
||||
string (REPLACE "@CXX_STD0X_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string (REPLACE "@CXX_STDLIB_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
|
||||
set (CMAKE_CXX_FLAGS "@CXX_STD0X_FLAGS@@CXX_SPACE@@CXX_STDLIB_FLAGS@ ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# same as above, but for C99
|
||||
string (REPLACE "@C_STD99_FLAGS@" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string (STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
|
||||
set (CMAKE_C_FLAG "@C_STD99_FLAGS@ ${CMAKE_C_FLAGS}")
|
||||
|
||||
# build with OpenMP if that was found
|
||||
if (NOT "@OpenMP_C_FLAGS@" STREQUAL "")
|
||||
string (REPLACE "@OpenMP_C_FLAGS@" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string (STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
|
||||
set (CMAKE_C_FLAG "@OpenMP_C_FLAGS@ ${CMAKE_C_FLAGS}")
|
||||
endif (NOT "@OpenMP_C_FLAGS@" STREQUAL "")
|
||||
if (NOT "@OpenMP_CXX_FLAGS@" STREQUAL "")
|
||||
string (REPLACE "@OpenMP_CXX_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
|
||||
set (CMAKE_C_FLAG "@OpenMP_CXX_FLAGS@ ${CMAKE_CXX_FLAGS}")
|
||||
endif (NOT "@OpenMP_CXX_FLAGS@" STREQUAL "")
|
||||
|
||||
# this is the contents of config.h as far as our probes can tell:
|
13
cmake/Templates/opm-project.pc.in
Normal file
13
cmake/Templates/opm-project.pc.in
Normal file
@ -0,0 +1,13 @@
|
||||
prefix=@prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
CXX=@CMAKE_CXX_COMPILER@ @CXX_STD0X_FLAGS@@CXX_SPACE@@CXX_STDLIB_FLAGS@ @OpenMP_CXX_FLAGS@
|
||||
CC=@CMAKE_C_COMPILER@ @C_STD99_FLAGS@ @OpenMP_C_FLAGS@
|
||||
DEPENDENCIES=
|
||||
|
||||
Name: @name@
|
||||
Description: @description@ @major@.@minor@
|
||||
Version: @major@.@minor@
|
||||
URL: http://opm-project.org
|
||||
Libs: @target@ @libs@
|
||||
Cflags: @includes@ @defs@
|
Loading…
Reference in New Issue
Block a user