-
Notifications
You must be signed in to change notification settings - Fork 36
/
dbms_glob_sources.cmake
35 lines (30 loc) · 1.35 KB
/
dbms_glob_sources.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
macro(add_glob cur_list)
file(GLOB __tmp CONFIGURE_DEPENDS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${ARGN})
list(APPEND ${cur_list} ${__tmp})
endmacro()
macro(add_headers_and_sources prefix common_path)
add_glob(${prefix}_headers ${CMAKE_CURRENT_SOURCE_DIR} ${common_path}/*.h)
add_glob(${prefix}_sources ${common_path}/*.cpp ${common_path}/*.c ${common_path}/*.h)
endmacro()
macro(add_headers_only prefix common_path)
add_glob(${prefix}_headers ${CMAKE_CURRENT_SOURCE_DIR} ${common_path}/*.h)
endmacro()
function(remove_specific_headers_and_sources prefix)
set(files_to_remove ${ARGN})
set(root_path "${CMAKE_CURRENT_SOURCE_DIR}")
foreach(file IN LISTS files_to_remove)
get_filename_component(full_path "${file}" ABSOLUTE)
if("${full_path}" MATCHES "^${root_path}")
file(RELATIVE_PATH relative_path "${root_path}" "${full_path}")
set(file_to_remove "${relative_path}")
else()
set(file_to_remove "${file}")
endif()
# remove files from headers and sources
list(REMOVE_ITEM ${prefix}_headers "${file_to_remove}")
list(REMOVE_ITEM ${prefix}_sources "${file_to_remove}")
endforeach()
# update headers and sources
set(${prefix}_headers ${${prefix}_headers} PARENT_SCOPE)
set(${prefix}_sources ${${prefix}_sources} PARENT_SCOPE)
endfunction()