From b8e2897560dc9a6e5ff0da2774e82276b3a2d985 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Mon, 29 Aug 2022 21:20:12 +0200 Subject: [PATCH] fxsdk: add an OTHER_MACROS argument to find_simple_library() --- fxsdk/cmake/FindSimpleLibrary.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fxsdk/cmake/FindSimpleLibrary.cmake b/fxsdk/cmake/FindSimpleLibrary.cmake index 995a45a..19825e3 100644 --- a/fxsdk/cmake/FindSimpleLibrary.cmake +++ b/fxsdk/cmake/FindSimpleLibrary.cmake @@ -1,5 +1,5 @@ function(find_simple_library _library _version_header _version_macro) - cmake_parse_arguments(CLV "" "PATH_VAR;VERSION_VAR" "" ${ARGN}) + cmake_parse_arguments(CLV "" "PATH_VAR;VERSION_VAR" "OTHER_MACROS" ${ARGN}) # Find the library path execute_process( @@ -35,4 +35,13 @@ function(find_simple_library _library _version_header _version_macro) if(DEFINED CLV_VERSION_VAR) set("${CLV_VERSION_VAR}" "${VERSION}" PARENT_SCOPE) endif() + + # Extract other macros from the header + foreach(MACRO_NAME IN LISTS CLV_OTHER_MACROS) + set(SED "s/^\\s*#\\s*define\\s*${MACRO_NAME}\\s*(.+)\\s*$/\\1/p; d") + execute_process( + COMMAND sed -E "${SED}" "${HEADER_PATH}" + OUTPUT_VARIABLE MACRO_VALUE OUTPUT_STRIP_TRAILING_WHITESPACE) + set("${MACRO_NAME}" "${MACRO_VALUE}" PARENT_SCOPE) + endforeach() endfunction()