Skip to content

Commit 7039aba

Browse files
fix stringification of NEO_DRIVER_VERSION
use preprocessor sequence to convert define value to stirng: #define q(a) #a #define tostr(b) q(b) Change-Id: If0a9ccfcc543523309be4995c05125bf8fbf2081
1 parent 7f3c4d3 commit 7039aba

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ endif()
5757

5858
# Put Driver version into define
5959
if(NEO_DRIVER_VERSION)
60-
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/device_caps.cpp PROPERTIES COMPILE_DEFINITIONS NEO_DRIVER_VERSION="${NEO_DRIVER_VERSION}")
60+
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/device_caps.cpp PROPERTIES COMPILE_DEFINITIONS "NEO_DRIVER_VERSION=${NEO_DRIVER_VERSION}")
6161
endif()
6262

6363
if(WIN32)

runtime/device/device_caps.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ static std::string vendor = "Intel(R) Corporation";
4141
static std::string profile = "FULL_PROFILE";
4242
static std::string spirVersions = "1.2 ";
4343
static const char *spirvVersion = "SPIR-V_1.0 ";
44-
static std::string driverVersion = NEO_DRIVER_VERSION;
44+
#define QTR(a) #a
45+
#define TOSTR(b) QTR(b)
46+
static std::string driverVersion;
4547

4648
const char *builtInKernels = ""; // the "always available" (extension-independent) builtin kernels
4749

@@ -70,7 +72,7 @@ void Device::initializeCaps() {
7072
DEBUG_BREAK_IF(tempName.size() > name.size());
7173
name = tempName;
7274

73-
driverVersion = NEO_DRIVER_VERSION;
75+
driverVersion = TOSTR(NEO_DRIVER_VERSION);
7476

7577
if (driverInfo) {
7678
name.assign(driverInfo.get()->getDeviceName(tempName).c_str());

unit_tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ if(NOT MSVC)
100100
endif()
101101

102102
if(NEO_DRIVER_VERSION)
103-
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/device_caps_tests.cpp PROPERTIES COMPILE_DEFINITIONS NEO_DRIVER_VERSION="${NEO_DRIVER_VERSION}")
103+
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/device_caps_tests.cpp PROPERTIES COMPILE_DEFINITIONS "NEO_DRIVER_VERSION=${NEO_DRIVER_VERSION}")
104104
endif()
105105

106106
target_link_libraries(igdrcl_tests ${NEO_MOCKABLE_LIB_NAME})

unit_tests/device/device_caps_tests.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,11 @@ TEST(Device_GetCaps, givenSystemWithNoDriverInfoWhenGettingNameAndVersionThenRet
672672
tempName += familyName[platformDevices[0]->pPlatform->eRenderCoreFamily];
673673
tempName += " HD Graphics NEO";
674674

675-
const std::string expectedVersion = NEO_DRIVER_VERSION;
675+
#define QTR(a) #a
676+
#define TOSTR(b) QTR(b)
677+
const std::string expectedVersion = TOSTR(NEO_DRIVER_VERSION);
678+
#undef QTR
679+
#undef TOSTR
676680

677681
EXPECT_STREQ(tempName.c_str(), caps.name);
678682
EXPECT_STREQ(expectedVersion.c_str(), caps.driverVersion);

0 commit comments

Comments
 (0)