From 607231b9e05bd507916478e856bcdd59450a9e83 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Mon, 3 Dec 2012 12:21:47 +0100 Subject: [PATCH] Add found variables to another library's Instead of adding a package's standard variables to the project, it may be desirable to be able to specify the prefix of the variables to add them to, so the macro find_and_append can also be used in find modules. --- cmake/Modules/UseOpmFind.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/UseOpmFind.cmake b/cmake/Modules/UseOpmFind.cmake index e11a853c..dda1adb8 100644 --- a/cmake/Modules/UseOpmFind.cmake +++ b/cmake/Modules/UseOpmFind.cmake @@ -41,15 +41,20 @@ foreach (name IN LISTS _opm_proj_vars) endforeach (name) # insert this boilerplate whenever we are going to find a new package -macro (find_and_append_package name) +macro (find_and_append_package_to prefix name) find_package (${name} ${ARGN}) if (${name}_FOUND) foreach (var IN LISTS _opm_proj_vars) if (DEFINED ${name}_${var}) - list (APPEND ${CMAKE_PROJECT_NAME}_${var} ${${name}_${var}}) + list (APPEND ${prefix}_${var} ${${name}_${var}}) endif (DEFINED ${name}_${var}) endforeach (var) endif (${name}_FOUND) +endmacro (find_and_append_package_to prefix name) + +# append to the list of variables associated with the project +macro (find_and_append_package name) + find_and_append_package_to (${CMAKE_PROJECT_NAME} ${name} ${ARGN}) endmacro (find_and_append_package name) # libraries should always be trimmed from the beginning, so that also