Use find modules for libraries with extra processing

Some libraries require more information than what is present in the
xxx-config.cmake file, e.g. the caller must know whether HAVE_TUPLE
is available and probably used when compiling dune-common, and put
this in its own config.h file.

Code to take care of these variables must therefore be in the client
configuration, and this is the same code which is used to handle the
autotools version, namely the find module, so a practical solution
is to just revert to that in both cases.
This commit is contained in:
Roland Kaufmann 2013-03-16 21:30:41 +01:00
parent 6cfa13f136
commit 5401df41b5

View File

@ -51,6 +51,14 @@ foreach (name IN LISTS _opm_proj_vars)
endif (NOT DEFINED ${CMAKE_PROJECT_NAME}_${name})
endforeach (name)
# these dependencies must always be handled by the find module
set (_opm_proj_exemptions
dune-common
dune-istl
dune-grid
dune-geometry
)
# insert this boilerplate whenever we are going to find a new package
macro (find_and_append_package_to prefix name)
# if we have specified a directory, don't revert to searching the
@ -71,6 +79,28 @@ macro (find_and_append_package_to prefix name)
set (${name}_DIR "${${NAME}_ROOT}")
endif (EXISTS ${${NAME}_ROOT}/${name}-config.cmake OR EXISTS ${${NAME}_ROOT}/${name}Config.cmake)
endif (NOT DEFINED ${name}_DIR AND (DEFINED ${name}_ROOT OR DEFINED ${NAME}_ROOT))
# these libraries need special handling which is not provided in
# the -config.cmake file, but which must be provided by this project,
# something which is done in our find module
list (FIND _opm_proj_exemptions "${name}" _${name}_exempted)
if ((NOT (_${name}_exempted EQUAL -1)) AND (DEFINED ${name}_DIR))
# most often we are given the name to the build directory and this
# is a sub-directory of the source tree
if (${name}_DIR MATCHES "build")
get_filename_component (${name}_ROOT "${${name}_DIR}" PATH)
else (${name}_DIR MATCHES "build")
set (${name}_ROOT "${${name}_DIR}")
endif (${name}_DIR MATCHES "build")
# store this for later, in case we reconfigure
set (${name}_ROOT "${${name}_ROOT}" CACHE LOCATION "Path to ${name}")
# clear this to not use config mode
unset (${name}_DIR)
# variables that are given on the command-line is also put in the cache
# removing the local copy only "unshadows" this one
unset (${name}_DIR CACHE)
endif ((NOT (_${name}_exempted EQUAL -1)) AND (DEFINED ${name}_DIR))
# using config mode is better than using module (aka. find) mode
# because then the package has already done all its probes and
# stored them in the config file for us