Skip to content

Commit

Permalink
perf: optimize auto triplet detection (#198)
Browse files Browse the repository at this point in the history
- optimize auto triplet detection.
- remove redundant preset.
- use compact mode for vscode cmake plugin.
- rename check-on-macos step name.

---------

Signed-off-by: msclock <[email protected]>
  • Loading branch information
msclock authored Apr 11, 2024
1 parent 0ecd63e commit fb7ea55
Show file tree
Hide file tree
Showing 30 changed files with 36 additions and 490 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
ccache: true
cppcheck: true

- name: Install ${{ matrix.compiler }} through brew
- name: Install llvm through brew
if: contains(matrix.compiler, 'llvm')
run: |
brew install ${{ matrix.compiler }}
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"cmake.useCMakePresets": "always",
"cmake.options.statusBarVisibility": "icon",
"cmake.options.statusBarVisibility": "compact",
"files.exclude": {
"**/.clangd/**": true
},
Expand Down
4 changes: 0 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
"cmake/presets/x64-linux-llvm.json",
"cmake/presets/x64-linux-gcc.json",
"cmake/presets/x64-mingw-dynamic-windows-mingw.json",
"cmake/presets/x64-mingw-dynamic-darwin-mingw.json",
"cmake/presets/x64-mingw-dynamic-linux-mingw.json",
"cmake/presets/x64-mingw-static-windows-mingw.json",
"cmake/presets/x64-mingw-static-darwin-mingw.json",
"cmake/presets/x64-mingw-static-linux-mingw.json",
"cmake/presets/x64-osx-gcc.json",
"cmake/presets/x64-osx-llvm.json",
"cmake/presets/x64-windows-llvm.json",
Expand Down
2 changes: 0 additions & 2 deletions cmake/presets/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"version": 6,
"include": [
"base.json",
"arch/x64.json",
"generators/ninja.json"
],
"configurePresets": [
{
"name": "default",
"inherits": [
"base",
"x64",
"ninja"
]
}
Expand Down
3 changes: 1 addition & 2 deletions cmake/presets/triplets/x64-linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"x64"
],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-linux",
"VCPKG_HOST_TRIPLET": "x64-linux"
"VCPKG_TARGET_TRIPLET": "x64-linux"
}
}
]
Expand Down
1 change: 0 additions & 1 deletion cmake/presets/triplets/x64-mingw-dynamic.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-mingw-dynamic",
"VCPKG_HOST_TRIPLET": "x64-mingw-dynamic",
"USE_SANITIZER": "OFF"
}
}
Expand Down
1 change: 0 additions & 1 deletion cmake/presets/triplets/x64-mingw-static.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-mingw-static",
"VCPKG_HOST_TRIPLET": "x64-mingw-static",
"USE_SANITIZER": "OFF"
}
}
Expand Down
3 changes: 1 addition & 2 deletions cmake/presets/triplets/x64-osx.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"x64"
],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-osx",
"VCPKG_HOST_TRIPLET": "x64-osx"
"VCPKG_TARGET_TRIPLET": "x64-osx"
}
}
]
Expand Down
3 changes: 1 addition & 2 deletions cmake/presets/triplets/x64-windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"x64"
],
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows",
"VCPKG_HOST_TRIPLET": "x64-windows"
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
}
]
Expand Down
53 changes: 0 additions & 53 deletions cmake/presets/x64-mingw-dynamic-darwin-mingw.json

This file was deleted.

53 changes: 0 additions & 53 deletions cmake/presets/x64-mingw-dynamic-linux-mingw.json

This file was deleted.

53 changes: 0 additions & 53 deletions cmake/presets/x64-mingw-static-darwin-mingw.json

This file was deleted.

53 changes: 0 additions & 53 deletions cmake/presets/x64-mingw-static-linux-mingw.json

This file was deleted.

2 changes: 2 additions & 0 deletions cmake/vcpkg/bootstrap/vcpkg_chainload_toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function(_vcpkg_chainload_toolchain)
)
endif()

# Load toolchain variables from triplet and architecture

string(LENGTH "${VCPKG_TARGET_ARCHITECTURE}-" _prefix_len)
string(SUBSTRING ${VCPKG_TARGET_TRIPLET} ${_prefix_len} -1 _stripped_string)
string(REPLACE "-" ";" _triplet_parts "${_stripped_string}")
Expand Down
28 changes: 11 additions & 17 deletions cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ function(_vcpkg_detect_host_triplet)
return()
endif()
else()
find_program(Z_VCPKG_CL cl)
if(Z_VCPKG_CL MATCHES "amd64/cl.exe$" OR Z_VCPKG_CL MATCHES "x64/cl.exe$")
find_program(_vcpkg_cl cl)
if(_vcpkg_cl MATCHES "amd64/cl.exe$" OR _vcpkg_cl MATCHES "x64/cl.exe$")
set(_detect_target_triplet_arch x64)
elseif(Z_VCPKG_CL MATCHES "arm/cl.exe$")
elseif(_vcpkg_cl MATCHES "arm/cl.exe$")
set(_detect_target_triplet_arch arm)
elseif(Z_VCPKG_CL MATCHES "arm64/cl.exe$")
elseif(_vcpkg_cl MATCHES "arm64/cl.exe$")
set(_detect_target_triplet_arch arm64)
elseif(Z_VCPKG_CL MATCHES "bin/cl.exe$" OR Z_VCPKG_CL MATCHES
"x86/cl.exe$")
elseif(_vcpkg_cl MATCHES "bin/cl.exe$" OR _vcpkg_cl MATCHES "x86/cl.exe$")
set(_detect_target_triplet_arch x86)
elseif(
CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64"
Expand All @@ -114,17 +113,10 @@ function(_vcpkg_detect_host_triplet)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "loongarch64")
set(_detect_target_triplet_arch loongarch64)
else()
if(Z_VCPKG_CMAKE_IN_TRY_COMPILE)
message(
STATUS
"Unable to determine target architecture, continuing without vcpkg."
)
else()
message(
WARNING
"Unable to determine target architecture, continuing without vcpkg."
)
endif()
message(
WARNING
"Unable to determine target architecture, continuing without vcpkg."
)
set(VCPKG_TOOLCHAIN ON)
cmake_policy(POP)
return()
Expand Down Expand Up @@ -200,6 +192,8 @@ macro(_vcpkg_load_triplet)
endif()
endif()

# Load triplet variables from VCPKG_TARGET_TRIPLET triplet file

set(_triplet "triplets/${VCPKG_TARGET_TRIPLET}.cmake")
set(_community_triplet "triplets/community/${VCPKG_TARGET_TRIPLET}.cmake")

Expand Down
2 changes: 1 addition & 1 deletion template/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"cmake.useCMakePresets": "always",
"cmake.options.statusBarVisibility": "icon",
"cmake.options.statusBarVisibility": "compact",
"files.exclude": {
"**/.clangd/**": true
},
Expand Down
4 changes: 0 additions & 4 deletions template/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
"cmake/presets/x64-linux-llvm.json",
"cmake/presets/x64-linux-gcc.json",
"cmake/presets/x64-mingw-dynamic-windows-mingw.json",
"cmake/presets/x64-mingw-dynamic-darwin-mingw.json",
"cmake/presets/x64-mingw-dynamic-linux-mingw.json",
"cmake/presets/x64-mingw-static-windows-mingw.json",
"cmake/presets/x64-mingw-static-darwin-mingw.json",
"cmake/presets/x64-mingw-static-linux-mingw.json",
"cmake/presets/x64-osx-gcc.json",
"cmake/presets/x64-osx-llvm.json",
"cmake/presets/x64-windows-llvm.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ jobs:
ccache: true
cppcheck: true

- name: Install {{ '${{ matrix.compiler }}' }} through brew
- name: Install llvm through brew
if: contains(matrix.compiler, 'llvm')
run: |
brew install {{ '${{ matrix.compiler }}' }}
Expand Down
Loading

0 comments on commit fb7ea55

Please sign in to comment.