@@ -28,8 +28,16 @@ function(vcpkg_cmake_module)
28
28
set (arg_MODULE_PATH "${arg_PACKAGE_NAME} " )
29
29
endif ()
30
30
31
- set (_modules_dir_path "cmake " )
31
+ set (_modules_dir_path "_modules " )
32
32
set (_modules_path "${_modules_dir_path} /${arg_MODULE_PATH} " )
33
+ set (_export_in_vcpkg_cmake_wrapper
34
+ "include_guard(GLOBAL)\n\n list(APPEND CMAKE_MODULE_PATH \$ {CMAKE_CURRENT_LIST_DIR}/${_modules_dir_path} )\n "
35
+ )
36
+ string (
37
+ APPEND
38
+ _export_in_vcpkg_cmake_wrapper
39
+ "list(APPEND CMAKE_PREFIX_PATH \$ {CMAKE_CURRENT_LIST_DIR}/${_modules_path} )\n "
40
+ )
33
41
34
42
if (arg_FILE_LIST )
35
43
foreach (_file ${arg_FILE_LIST} )
@@ -40,18 +48,51 @@ function(vcpkg_cmake_module)
40
48
41
49
if (arg_DIRECTORY_LIST )
42
50
foreach (_dir "${arg_DIRECTORY_LIST} " )
43
- install (
44
- DIRECTORY "${_dir} "
45
- DESTINATION ${CURRENT_PACKAGES_DIR} /share/${PORT}/${_modules_path} )
51
+ if (NOT IS_DIRECTORY ${_dir} )
52
+ message (
53
+ FATAL_ERROR
54
+ "DIRECTORY_LIST must pass with directories, error: ${arg_DIRECTORY_LIST} "
55
+ )
56
+ endif ()
57
+
58
+ get_filename_component (_dir_name ${_dir} NAME_WE )
59
+
60
+ string (
61
+ APPEND
62
+ _export_in_vcpkg_cmake_wrapper
63
+ "list(APPEND CMAKE_PREFIX_PATH \$ {CMAKE_CURRENT_LIST_DIR}/${_modules_path} /${_dir_name} )\n "
64
+ )
65
+
66
+ file (
67
+ GLOB_RECURSE _dir_itmes
68
+ LIST_DIRECTORIES ON
69
+ RELATIVE "${_dir} "
70
+ "${_dir} /*" )
71
+ list (FILTER _dir_itmes EXCLUDE REGEX [[^\.]] )
72
+ message (STATUS ${_dir_itmes} )
73
+ foreach (_item ${_dir_itmes} )
74
+ if (IS_DIRECTORY "${_dir} /${_item} " )
75
+ string (
76
+ APPEND
77
+ _export_in_vcpkg_cmake_wrapper
78
+ "${_export_in_vcpkg_cmake_wrapper} list(APPEND CMAKE_PREFIX_PATH "
79
+ "\$ {CMAKE_CURRENT_LIST_DIR}/${_modules_dir_path} /${_dir_name} /${_item} )\n "
80
+ )
81
+ endif ()
82
+ endforeach ()
83
+
84
+ # Install as subdir
85
+ file (INSTALL ${_dir}
86
+ DESTINATION "${CURRENT_PACKAGES_DIR} /share/${PORT} /${_modules_path} " )
87
+
46
88
endforeach ()
47
89
endif ()
48
90
49
- file (
50
- WRITE ${CURRENT_PACKAGES_DIR} /share/${PORT}/vcpkg-cmake-wrapper.cmake
51
- "include_guard(GLOBAL)\n\n list(APPEND CMAKE_MODULE_PATH \$ {CMAKE_CURRENT_LIST_DIR}/${_modules_dir_path} )\n "
52
- )
91
+ file (WRITE ${CURRENT_PACKAGES_DIR} /share/${PORT}/vcpkg-cmake-wrapper.cmake
92
+ ${_export_in_vcpkg_cmake_wrapper} )
53
93
54
94
unset (_modules_dir_path )
55
95
unset (_modules_path )
96
+ unset (_export_in_vcpkg_cmake_wrapper )
56
97
57
98
endfunction ()
0 commit comments