mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-25 07:58:59 -06:00
Merge topic 'emscripten-try_run'
a308ea38f3Emscripten: Fix try_run to run the `.js` file and not the adjacent `.wasm`ad91bc558aci: Make node available to Emscripten tests27cc5d58bfTests/RunCMake/Emscripten: Add tests covering try_compile COPY_FILE Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !11451
This commit is contained in:
@@ -1232,8 +1232,20 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
||||
|
||||
if ((res == 0) && arguments.CopyFileTo) {
|
||||
std::string const& copyFile = *arguments.CopyFileTo;
|
||||
std::string outputFile = this->OutputFile;
|
||||
|
||||
// Emscripten `.js` executables have an adjacent `.wasm` file with the
|
||||
// actual compiled binary. Our COPY_FILE clients need the latter.
|
||||
if (cmHasLiteralSuffix(outputFile, ".js")) {
|
||||
std::string wasmOutput =
|
||||
cmStrCat(outputFile.substr(0, outputFile.length() - 3), ".wasm");
|
||||
if (cmSystemTools::FileExists(wasmOutput)) {
|
||||
outputFile = std::move(wasmOutput);
|
||||
}
|
||||
}
|
||||
|
||||
cmsys::SystemTools::CopyStatus status =
|
||||
cmSystemTools::CopyFileAlways(this->OutputFile, copyFile);
|
||||
cmSystemTools::CopyFileAlways(outputFile, copyFile);
|
||||
if (!status) {
|
||||
std::string err = status.GetString();
|
||||
switch (status.Path) {
|
||||
@@ -1249,7 +1261,7 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
||||
/* clang-format off */
|
||||
err = cmStrCat(
|
||||
"Cannot copy output executable\n"
|
||||
" '", this->OutputFile, "'\n"
|
||||
" '", outputFile, "'\n"
|
||||
"to destination specified by COPY_FILE:\n"
|
||||
" '", copyFile, "'\n"
|
||||
"because:\n"
|
||||
@@ -1388,14 +1400,6 @@ void cmCoreTryCompile::FindOutputFile(std::string const& targetName)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmHasLiteralSuffix(outputFileLocation, ".js")) {
|
||||
std::string wasmOutputLocation = cmStrCat(
|
||||
outputFileLocation.substr(0, outputFileLocation.length() - 3), ".wasm");
|
||||
if (cmSystemTools::FileExists(wasmOutputLocation)) {
|
||||
outputFileLocation = wasmOutputLocation;
|
||||
}
|
||||
}
|
||||
|
||||
this->OutputFile = cmSystemTools::CollapseFullPath(outputFileLocation);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user