Skip to content

Commit

Permalink
[vcpkg] add x86-wasm.cmake to community triplets (#11323)
Browse files Browse the repository at this point in the history
* add x86-wasm.cmake to community triplets

The EMSDK enviroment variable is normally defined when first installing Emscripten.

* Rename x86-wasm.cmake to wasm32-emscripten.cmake

* Update wasm32-emscripten.cmake

* Update wasm32-emscripten.cmake

* Add wasm32 and wasm64 arch to docs

* Create wasm64-emscripten.cmake

* remove wasm64

* Delete wasm64-emscripten.cmake

* Add wasm32 to list of identifiers

* add emscripten VCPKG_CMAKE_SYSTEM_NAME support

* add path check to EMSDK cmake toolchain
  • Loading branch information
MoAlyousef authored Jun 2, 2020
1 parent ad7a227 commit a6257ac
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ __pycache__/
!triplets/community/arm-ios.cmake
!triplets/community/x64-ios.cmake
!triplets/community/x86-ios.cmake
!triplets/community/wasm32-emscripten.cmake
!triplets/arm-uwp.cmake
!triplets/x64-uwp.cmake
!triplets/x64-windows.cmake
Expand Down
2 changes: 2 additions & 0 deletions docs/maintainers/control-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ The predefined expressions are computed from standard triplet settings:
- `osx` - `VCPKG_CMAKE_SYSTEM_NAME` == `"Darwin"`
- `android` - `VCPKG_CMAKE_SYSTEM_NAME` == `"Android"`
- `static` - `VCPKG_LIBRARY_LINKAGE` == `"static"`
- `wasm32` - `VCPKG_TARGET_ARCHITECTURE` == `"wasm32"`
- `emscripten` - `VCPKG_CMAKE_SYSTEM_NAME` == `"Emscripten"`

These predefined expressions can be overridden in the triplet file via the [`VCPKG_DEP_INFO_OVERRIDE_VARS`](../users/triplets.md) option.

Expand Down
3 changes: 2 additions & 1 deletion docs/users/triplets.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Community Triplets are enabled by default, when using a community triplet a mess
### VCPKG_TARGET_ARCHITECTURE
Specifies the target machine architecture.

Valid options are `x86`, `x64`, `arm`, and `arm64`.
Valid options are `x86`, `x64`, `arm`, `arm64` and `wasm32`.

### VCPKG_CRT_LINKAGE
Specifies the desired CRT linkage (for MSVC).
Expand All @@ -49,6 +49,7 @@ Valid options include any CMake system name, such as:
- `WindowsStore` (Universal Windows Platform)
- `Darwin` (Mac OSX)
- `Linux` (Linux)
- `Emscripten` (WebAssembly)

### VCPKG_CMAKE_SYSTEM_VERSION
Specifies the target platform system version.
Expand Down
6 changes: 6 additions & 0 deletions toolsrc/src/vcpkg/logicexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace vcpkg
osx,
uwp,
android,
emscripten,
wasm32,

static_link,
};
Expand Down Expand Up @@ -113,6 +115,8 @@ namespace vcpkg
{"osx", Identifier::osx},
{"uwp", Identifier::uwp},
{"android", Identifier::android},
{"emscripten", Identifier::emscripten},
{"wasm32", Identifier::wasm32},
{"static", Identifier::static_link},
};

Expand Down Expand Up @@ -165,6 +169,8 @@ namespace vcpkg
case Identifier::osx: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "Darwin");
case Identifier::uwp: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore");
case Identifier::android: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "Android");
case Identifier::emscripten: return true_if_exists_and_equal("VCPKG_CMAKE_SYSTEM_NAME", "Emscripten");
case Identifier::wasm32: return true_if_exists_and_equal("VCPKG_TARGET_ARCHITECTURE", "wasm32");
case Identifier::static_link: return true_if_exists_and_equal("VCPKG_LIBRARY_LINKAGE", "static");
}

Expand Down
15 changes: 15 additions & 0 deletions triplets/community/wasm32-emscripten.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(VCPKG_ENV_PASSTHROUGH EMSDK PATH)

if(NOT DEFINED ENV{EMSDK})
message(FATAL_ERROR "The EMSDK environment variable must be defined")
endif()

if(NOT EXISTS $ENV{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake)
message(FATAL_ERROR "Emscripten.cmake toolchain file not found")
endif()

set(VCPKG_TARGET_ARCHITECTURE wasm32)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Emscripten)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE $ENV{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake)

0 comments on commit a6257ac

Please sign in to comment.