Skip to content

Commit b124f6c

Browse files
committed
feat: add cmake port module tools
Signed-off-by: msclock <[email protected]>
1 parent 4a58828 commit b124f6c

File tree

7 files changed

+104
-1
lines changed

7 files changed

+104
-1
lines changed

ports/vcpkg-cmake-module/copyright

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Copyright (c) msclock
2+
3+
All rights reserved.
4+
5+
MIT License
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if(NOT TARGET_TRIPLET STREQUAL _HOST_TRIPLET)
2+
message(WARNING "vcpkg-cmake-module is a host-only port; please mark it as a host port in your dependencies.")
3+
endif()
4+
5+
file(INSTALL
6+
"${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_module.cmake"
7+
"${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake"
8+
"${CMAKE_CURRENT_LIST_DIR}/copyright"
9+
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
10+
11+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include_guard(GLOBAL)
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_cmake_module.cmake")

ports/vcpkg-cmake-module/vcpkg.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "vcpkg-cmake-module",
3+
"version-date": "2023-10-10",
4+
"license": "MIT"
5+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
include_guard(GLOBAL)
2+
3+
function(vcpkg_cmake_module)
4+
# Set options
5+
set(_opt)
6+
set(_single_opt)
7+
set(_multi_opt FILE_LIST DIRECTORY_LIST)
8+
cmake_parse_arguments(PARSE_ARGV 0 "arg" "${_opt}" "${_single_opt}"
9+
"${_multi_opt}")
10+
11+
if(DEFINED arg_UNPARSED_ARGUMENTS)
12+
message(
13+
FATAL_ERROR
14+
"${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}"
15+
)
16+
endif()
17+
18+
if(NOT arg_FILE_LIST AND NOT arg_DIRECTORY_LIST)
19+
message(
20+
FATAL_ERROR "Both arg_FILE_LIST and arg_DIRECTORY_LIST cannot be empty")
21+
endif()
22+
23+
set(_modules_path "_modules")
24+
25+
if(arg_FILE_LIST)
26+
foreach(_file ${arg_FILE_LIST})
27+
file(INSTALL "${_file}"
28+
DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}/${_modules_path})
29+
endforeach()
30+
endif()
31+
32+
if(arg_DIRECTORY_LIST)
33+
foreach(_dir "${arg_DIRECTORY_LIST}")
34+
install(
35+
DIRECTORY "${_dir}"
36+
DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}/${_modules_path})
37+
endforeach()
38+
endif()
39+
40+
file(
41+
WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake
42+
"include_guard(GLOBAL)\n\nlist(APPEND CMAKE_MODULE_PATH \${CMAKE_CURRENT_LIST_DIR}/${_modules_path})\n"
43+
)
44+
45+
unset(_modules_path)
46+
47+
endfunction()

versions/baseline.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"default": {}
2+
"default": {
3+
"vcpkg-cmake-module": {
4+
"baseline": "2023-10-10",
5+
"port-version": 0
6+
}
7+
}
38
}

versions/v-/vcpkg-cmake-module.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"versions": [
3+
{
4+
"version-date": "2023-10-10",
5+
"git-tree": "5eb5bf9667874adcdf3c454039ac5d693ca314d4",
6+
"port-version": 0
7+
}
8+
]
9+
}

0 commit comments

Comments
 (0)