Search for module in suite directory if specified

Instead of having to specify each and every project in a suite such as
DUNE or OPM, allow a root directory for the entire suite to be specified
and then assume that each module is located in a sub-directory to this.

Each individual project can still have its path explicitly specified, if
a special build of those are required.

The suite variable itself will be written to cache by being specified
on the command line. Each individual project directory will NOT be
written to cache, because then we cannot get rid of it by specifying a
new suite directory.
This commit is contained in:
Roland Kaufmann
2013-03-28 22:12:56 +01:00
parent b254e6c4ed
commit 83fb758b74

View File

@@ -73,6 +73,26 @@ macro (find_and_append_package_to prefix name)
# system default paths afterwards
string (TOUPPER "${name}" NAME)
string (REPLACE "-" "_" NAME "${NAME}")
# only use suite if module-specific variable is not set. this allows
# us to override one dir in a suite
if (NOT (${name}_DIR OR ${name}_ROOT OR ${NAME}_ROOT))
# module is part of a suite if it has name with the pattern xxx-yyy
if (("${name}" MATCHES "[^-]+-.+") OR ${name}_SUITE)
# allow to override if the module doesn't quite fit the convention
# e.g. dune-cornerpoint
if (NOT DEFINED ${name}_SUITE)
# extract suite name from module
string (REGEX REPLACE "([^-]+)-.+" "\\1" ${name}_SUITE "${name}")
endif (NOT DEFINED ${name}_SUITE)
# assume that each module has its own subdir directly under suite dir
string (TOUPPER "${${name}_SUITE}" ${name}_SUITE_UPPER)
if (DEFINED ${${name}_SUITE_UPPER}_ROOT)
set (${NAME}_ROOT ${${${name}_SUITE_UPPER}_ROOT}/${name})
endif (DEFINED ${${name}_SUITE_UPPER}_ROOT)
endif (("${name}" MATCHES "[^-]+-.+") OR ${name}_SUITE)
endif (NOT (${name}_DIR OR ${name}_ROOT OR ${NAME}_ROOT))
# the documentation says that if *-config.cmake files are not found,
# find_package will revert to doing a full search, but that is not
# true, so unconditionally setting ${name}_DIR is not safe. however,