Skip to content

Commit 4e7349e

Browse files
authored
[fix] Coverity: QPL_VERSION macro is now defined in a CMake-generated file (#1246)
The following warnings appeared in Coverity build log on Windows: ``` "sources/middle-layer/util/library_version.cpp", line 12: warning #7: unrecognized token return QPL_VERSION; ^ ``` The issue is related to the fact that `QPL_VERSION` macro is defined using `/D` command-line option: ``` target_compile_definitions(middle_layer_lib PUBLIC QPL_VERSION="${CMAKE_PROJECT_VERSION}" PUBLIC $<$<C_COMPILER_ID:MSVC>:_ENABLE_EXTENDED_ALIGNED_STORAGE> ``` So it is passed to the compiler command line as... * `-DQPL_VERSION=\"1.8.0\"` (in case of a regular build) * `"-DQPL_VERSION=\"1.8.0\""` (in case of a Coverity build) Since the value of this macro is a string literal, quoting around it requires escaping. It seems that in case of Coverity escaping should be different to achieve the same result. Also it may be [different in case of different shells](https://cmake.org/pipermail/cmake/2007-June/014611.html). So `QPL_VERSION` macro definition was moved from command-line options (using a function `target_compile_definitions` in CMake) to a CMake-generated header file `project_version.h` (using a template file `project_version.h.in` and a function `configure_file()` in CMake) which is a typical approach to organize this functionality. Three new macro definitions were added to this file (besides `QPL_VERSION`): * `QPL_VERSION_MAJOR` * `QPL_VERSION_MINOR` * `QPL_VERSION_PATCH` This generated header file is installed by CMake to the install folder just like other header files in `/include/qpl/c_api`.
1 parent 51bb69d commit 4e7349e

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ qpl-*.tar.*z
1818

1919
# RPM build
2020
qpl*.rpm
21+
22+
# CMake-generated header file containing version information
23+
/include/qpl/c_api/project_version.h
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*******************************************************************************
2+
* Copyright (C) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
******************************************************************************/
6+
7+
/*
8+
* Intel® Query Processing Library (Intel® QPL)
9+
* Job API (public C API)
10+
*/
11+
12+
#ifndef QPL_C_API_VERSIONS_H
13+
#define QPL_C_API_VERSIONS_H
14+
15+
/**
16+
* QPL major version
17+
*/
18+
#define QPL_VERSION_MAJOR @QPL_VERSION_MAJOR@
19+
20+
/**
21+
* QPL minor version
22+
*/
23+
#define QPL_VERSION_MINOR @QPL_VERSION_MINOR@
24+
25+
/**
26+
* QPL patch version
27+
*/
28+
#define QPL_VERSION_PATCH @QPL_VERSION_PATCH@
29+
30+
/**
31+
* QPL version as a string: "major.minor.patch"
32+
*/
33+
#define QPL_VERSION "@QPL_VERSION@"
34+
35+
#endif //QPL_C_API_VERSIONS_H

include/qpl/c_api/version.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#endif
1818

1919
#include "qpl/c_api/defs.h"
20+
#include "qpl/c_api/project_version.h"
2021

2122
#ifdef __cplusplus
2223
extern "C" {

sources/c_api/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ file(GLOB QPL_C_API_SRC
2626

2727
add_library(qpl_c_api OBJECT ${QPL_C_API_SRC})
2828

29+
# Add CMake-generated header file `project_version.h` containing version information (like `QPL_VERSION` macro definition)
30+
set (qpl_versions_header "project_version.h")
31+
set (qpl_versions_header_path "${QPL_PROJECT_DIR}/include/qpl/c_api/${qpl_versions_header}")
32+
configure_file("${qpl_versions_header_path}.in" "${qpl_versions_header_path}" @ONLY)
33+
2934
target_include_directories(qpl_c_api
3035
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
3136
PUBLIC $<BUILD_INTERFACE:${QPL_PROJECT_DIR}/include/> $<INSTALL_INTERFACE:include>

sources/middle-layer/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
5151
endif ()
5252

5353
target_compile_definitions(middle_layer_lib
54-
PUBLIC QPL_VERSION="${CMAKE_PROJECT_VERSION}"
5554
PUBLIC $<$<C_COMPILER_ID:MSVC>:_ENABLE_EXTENDED_ALIGNED_STORAGE>
5655
PUBLIC $<$<BOOL:${LOG_HW_INIT}>:LOG_HW_INIT>
5756
PUBLIC $<$<BOOL:${QPL_EXPERIMENTAL_LOG_IAA}>:QPL_EXPERIMENTAL_LOG_IAA>

sources/middle-layer/dispatcher/hw_dispatcher.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include "hw_dispatcher.hpp"
1313

14+
#include "qpl/c_api/project_version.h"
15+
1416
#if defined(__linux__)
1517

1618
#endif

0 commit comments

Comments
 (0)