From 358d21b2bde53a518f6fd789e0e9a974ae8b6d4c Mon Sep 17 00:00:00 2001 From: yizhi <946185759@qq.com> Date: Mon, 10 Mar 2025 15:08:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DWindows=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E5=BA=93=E7=BC=96=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- thirdpart/install.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/thirdpart/install.js b/thirdpart/install.js index 09882e7..9bb8c46 100644 --- a/thirdpart/install.js +++ b/thirdpart/install.js @@ -44,6 +44,8 @@ const spawnOption = { } }; +function P(path) { return path.replace(/\\/g, "/"); } + function checkFile(...items) { return fs.existsSync(path.resolve(...items)); } @@ -153,9 +155,13 @@ async function main() { "-DMNN_BUILD_CONVERTER=OFF", "-DMNN_WIN_RUNTIME_MT=ON", ], (root) => [ - `set(MNN_INCLUDE_DIR ${JSON.stringify(path.join(root, "include"))})`, - `set(MNN_LIB_DIR ${JSON.stringify(path.join(root, "lib"))})`, - `set(MNN_LIBS MNN)`, + `set(MNN_INCLUDE_DIR ${JSON.stringify(P(path.join(root, "include")))})`, + `set(MNN_LIB_DIR ${JSON.stringify(P(path.join(root, "lib")))})`, + `if(WIN32)` + ` set(MNN_LIBS \${MNN_LIB_DIRMNN}/MNN.lib)`, + `else()` + ` set(MNN_LIBS \${MNN_LIB_DIRMNN}/libMNN.a)`, + `endif()` ].join("\n")); //OpenCV if (buildOptions.withOpenCV) cmakeBuildFromSource("OpenCV", "https://github.com/opencv/opencv.git", "4.11.0", null, [ @@ -229,9 +235,13 @@ async function main() { fs.cpSync(path.join(savedir, dirname), path.join(THIRDPARTY_DIR, "ONNXRuntime"), { recursive: true }); }); fs.writeFileSync(path.join(THIRDPARTY_DIR, "ONNXRuntime/config.cmake"), [ - `set(ONNXRuntime_INCLUDE_DIR ${JSON.stringify(path.join(THIRDPARTY_DIR, "ONNXRuntime/include"))})`, - `set(ONNXRuntime_LIB_DIR ${JSON.stringify(path.join(THIRDPARTY_DIR, "ONNXRuntime/lib"))})`, - `set(ONNXRuntime_LIBS onnxruntime)`, + `set(ONNXRuntime_INCLUDE_DIR ${JSON.stringify(P(path.join(THIRDPARTY_DIR, "ONNXRuntime/include")))})`, + `set(ONNXRuntime_LIB_DIR ${JSON.stringify(P(path.join(THIRDPARTY_DIR, "ONNXRuntime/lib")))})`, + `if(WIN32)`, + ` set(ONNXRuntime_LIBS \${ONNXRuntime_LIB_DIR}/onnxruntime.lib)`, + `else()`, + ` set(ONNXRuntime_LIBS \${ONNXRuntime_LIB_DIR}/libonnxruntime.a)`, + `endif()`, ].join("\n")); } // if (buildOptions.withONNX) cmakeBuildFromSource("ONNXRuntime", "https://github.com/csukuangfj/onnxruntime-build.git", "main", (name, repo, branch) => {