diff options
| author | MeanSquaredError <[email protected]> | 2025-11-22 13:10:41 +0200 |
|---|---|---|
| committer | MeanSquaredError <[email protected]> | 2025-11-23 18:36:20 +0200 |
| commit | 8b165b81f1ab59188bfbbb14ca94a4ebbf42f998 (patch) | |
| tree | f3cd909b08463a5685a7059fa3ad560b33b5131d | |
| parent | 4c8fd669a52cfa6676052953457ce65ab0b8b89b (diff) | |
cmake find_package: If finding the package fails, return an error, regardless of the allow_empty_package option.
| -rw-r--r-- | xmake/modules/package/manager/cmake/find_package.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/xmake/modules/package/manager/cmake/find_package.lua b/xmake/modules/package/manager/cmake/find_package.lua index fdf9aa608..2683d5e1a 100644 --- a/xmake/modules/package/manager/cmake/find_package.lua +++ b/xmake/modules/package/manager/cmake/find_package.lua @@ -138,7 +138,15 @@ function _find_package(cmake, name, opt) -- run cmake local envs = configs.envs or opt.envs or {} envs.CMAKE_BUILD_TYPE = envs.CMAKE_BUILD_TYPE or _cmake_mode(opt.mode or "release") - try {function() return os.vrunv(cmake.program, {workdir}, {curdir = workdir, envs = envs}) end} + -- If the generated CMakeLists.txt fails to find the REQUIRED package, CMake will exit + -- with code 1, os.vrunv will raise an error and the try{} block will return nil. + local ok = try {function() + os.vrunv(cmake.program, {workdir}, {curdir = workdir, envs = envs}) + return true + end} + if not ok then + return + end -- parse defines and includedirs for macosx/linux local links |
