diff options
Diffstat (limited to 'eclass/cmake.eclass')
| -rw-r--r-- | eclass/cmake.eclass | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 987c6e4c6ee..e200b39432f 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -250,17 +250,23 @@ _cmake_modify-cmakelists() { grep -qs "<<< Gentoo configuration >>>" "${CMAKE_USE_DIR}"/CMakeLists.txt && return 0 # Comment out all set (<some_should_be_user_defined_variable> value) - find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec sed \ - -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE\([[:space:]].*)\|)\)/I{s/^/#_cmake_modify_IGNORE /g}' \ - -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \ - -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \ - -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \ - -i {} + || die "${LINENO}: failed to disable hardcoded settings" - local x - for x in $(find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec grep -l "^#_cmake_modify_IGNORE" {} +;); do - einfo "Hardcoded definition(s) removed in $(echo "${x}" | cut -c $((${#CMAKE_USE_DIR}+2))-):" - einfo "$(grep -se '^#_cmake_modify_IGNORE' ${x} | cut -c 22-99)" - done + local file + while read -d '' -r file ; do + sed \ + -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE\([[:space:]].*)\|)\)/I{s/^/#_cmake_modify_IGNORE /g}' \ + -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_COLOR_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \ + -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \ + -e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \ + -i ${file} || die "${LINENO}: failed to disable hardcoded settings" + readarray -t mod_lines < <(grep -se "^#_cmake_modify_IGNORE" ${file}) + if [[ ${#mod_lines[*]} -gt 0 ]]; then + einfo "Hardcoded definition(s) removed in ${file/${CMAKE_USE_DIR%\/}\//}:" + local mod_line + for mod_line in "${mod_lines[@]}"; do + einfo "${mod_line:22:99}" + done + fi + done < <(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -print0) # NOTE Append some useful summary here cat >> "${CMAKE_USE_DIR}"/CMakeLists.txt <<- _EOF_ || die |
