From 212f015f4705c64a207670c074c3fe30019431d9 Mon Sep 17 00:00:00 2001 From: Aganlengzi Date: Mon, 1 Aug 2022 16:27:04 +0800 Subject: [PATCH] generate_unify_header supports excludes (#44761) --- cmake/phi.cmake | 12 +++++++++++- paddle/phi/CMakeLists.txt | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/phi.cmake b/cmake/phi.cmake index e320473d9b..f156859200 100644 --- a/cmake/phi.cmake +++ b/cmake/phi.cmake @@ -15,7 +15,7 @@ function(generate_unify_header DIR_NAME) set(options "") set(oneValueArgs HEADER_NAME SKIP_SUFFIX) - set(multiValueArgs "") + set(multiValueArgs EXCLUDES) cmake_parse_arguments(generate_unify_header "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -33,6 +33,9 @@ function(generate_unify_header DIR_NAME) set(skip_suffix "${generate_unify_header_SKIP_SUFFIX}") endif() + # exclude files + list(LENGTH generate_unify_header_EXCLUDES generate_unify_header_EXCLUDES_len) + # generate target header file set(header_file ${CMAKE_CURRENT_SOURCE_DIR}/include/${header_name}.h) file( @@ -43,6 +46,13 @@ function(generate_unify_header DIR_NAME) # get all top-level headers and write into header file file(GLOB HEADERS "${CMAKE_CURRENT_SOURCE_DIR}\/${DIR_NAME}\/*.h") foreach(header ${HEADERS}) + if(${generate_unify_header_EXCLUDES_len} GREATER 0) + get_filename_component(header_file_name ${header} NAME) + list(FIND generate_unify_header_EXCLUDES ${header_file_name} _index) + if(NOT ${_index} EQUAL -1) + continue() + endif() + endif() if("${skip_suffix}" STREQUAL "") string(REPLACE "${PADDLE_SOURCE_DIR}\/" "" header "${header}") file(APPEND ${header_file} "#include \"${header}\"\n") diff --git a/paddle/phi/CMakeLists.txt b/paddle/phi/CMakeLists.txt index 438b85cafe..fdcd511fae 100644 --- a/paddle/phi/CMakeLists.txt +++ b/paddle/phi/CMakeLists.txt @@ -58,6 +58,6 @@ file( # generate inner headers include dir for users generate_unify_header(backends) -generate_unify_header(core) +generate_unify_header(core EXCLUDES cuda_stream.h) generate_unify_header(infermeta) generate_unify_header(kernels SKIP_SUFFIX grad_kernel) -- GitLab