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
This commit is contained in:
Artur Harasimiuk 2018-03-28 23:55:09 +02:00 committed by sys_ocldev
parent 7f3c4d3d70
commit 7039ababb9
4 changed files with 11 additions and 5 deletions

View File

@ -57,7 +57,7 @@ endif()
# Put Driver version into define
if(NEO_DRIVER_VERSION)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/device_caps.cpp PROPERTIES COMPILE_DEFINITIONS NEO_DRIVER_VERSION="${NEO_DRIVER_VERSION}")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/device_caps.cpp PROPERTIES COMPILE_DEFINITIONS "NEO_DRIVER_VERSION=${NEO_DRIVER_VERSION}")
endif()
if(WIN32)

View File

@ -41,7 +41,9 @@ static std::string vendor = "Intel(R) Corporation";
static std::string profile = "FULL_PROFILE";
static std::string spirVersions = "1.2 ";
static const char *spirvVersion = "SPIR-V_1.0 ";
static std::string driverVersion = NEO_DRIVER_VERSION;
#define QTR(a) #a
#define TOSTR(b) QTR(b)
static std::string driverVersion;
const char *builtInKernels = ""; // the "always available" (extension-independent) builtin kernels
@ -70,7 +72,7 @@ void Device::initializeCaps() {
DEBUG_BREAK_IF(tempName.size() > name.size());
name = tempName;
driverVersion = NEO_DRIVER_VERSION;
driverVersion = TOSTR(NEO_DRIVER_VERSION);
if (driverInfo) {
name.assign(driverInfo.get()->getDeviceName(tempName).c_str());

View File

@ -100,7 +100,7 @@ if(NOT MSVC)
endif()
if(NEO_DRIVER_VERSION)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/device_caps_tests.cpp PROPERTIES COMPILE_DEFINITIONS NEO_DRIVER_VERSION="${NEO_DRIVER_VERSION}")
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/device_caps_tests.cpp PROPERTIES COMPILE_DEFINITIONS "NEO_DRIVER_VERSION=${NEO_DRIVER_VERSION}")
endif()
target_link_libraries(igdrcl_tests ${NEO_MOCKABLE_LIB_NAME})

View File

@ -672,7 +672,11 @@ TEST(Device_GetCaps, givenSystemWithNoDriverInfoWhenGettingNameAndVersionThenRet
tempName += familyName[platformDevices[0]->pPlatform->eRenderCoreFamily];
tempName += " HD Graphics NEO";
const std::string expectedVersion = NEO_DRIVER_VERSION;
#define QTR(a) #a
#define TOSTR(b) QTR(b)
const std::string expectedVersion = TOSTR(NEO_DRIVER_VERSION);
#undef QTR
#undef TOSTR
EXPECT_STREQ(tempName.c_str(), caps.name);
EXPECT_STREQ(expectedVersion.c_str(), caps.driverVersion);