diff --git a/lib/helpers/utils.js b/lib/helpers/utils.js index 053229ae20..83786d6ae0 100644 --- a/lib/helpers/utils.js +++ b/lib/helpers/utils.js @@ -13188,7 +13188,7 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) { let parentVersion = undefined; // In case of meson.build we can find the version number after the word version // thanks to our replaces and splits - const versionIndex = tmpB.findIndex((v) => v === "version"); + const versionIndex = tmpB.findIndex((v) => v?.toLowerCase() === "version"); if (versionIndex > -1 && tmpB.length > versionIndex) { parentVersion = tmpB[versionIndex + 1]; } diff --git a/lib/helpers/utils.test.js b/lib/helpers/utils.test.js index 110f0df082..b5f9fed16f 100644 --- a/lib/helpers/utils.test.js +++ b/lib/helpers/utils.test.js @@ -5734,6 +5734,15 @@ test("parseCmakeLikeFile tests", () => { type: "application", version: "", }); + retMap = parseCmakeLikeFile("./test/data/cmakes/CMakeLists-version.txt", "generic"); + expect(retMap.parentComponent).toEqual({ + "bom-ref": "pkg:generic/MyProject@2.1.3", + group: "", + name: "MyProject", + purl: "pkg:generic/MyProject@2.1.3", + type: "application", + version: "2.1.3", + }); retMap = parseCmakeLikeFile( "./test/data/cmakes/CMakeLists-tpl.txt", "generic", diff --git a/test/data/cmakes/CMakeLists-version.txt b/test/data/cmakes/CMakeLists-version.txt new file mode 100644 index 0000000000..2fa554ab5a --- /dev/null +++ b/test/data/cmakes/CMakeLists-version.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.15) + +project(MyProject VERSION 2.1.3) + +add_executable(myexample example.cpp) \ No newline at end of file