diff --git a/CMakeLists.txt b/CMakeLists.txt index da99b6ea7..d2be523bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,11 +46,6 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug") include(CTest) endif() -# fixup __FILE__ absolute paths in logging module -# see: https://cmake.org/pipermail/cmake-developers/2015-January/024202.html -string(LENGTH "${CMAKE_SOURCE_DIR}/" CMAKE_SOURCE_DIR_LENGTH) -add_definitions(-DCMAKE_SOURCE_DIR_LENGTH=${CMAKE_SOURCE_DIR_LENGTH}) - set(STLINK_HEADERS include/stlink.h include/stlink/usb.h diff --git a/include/stlink/logging.h b/include/stlink/logging.h index 9a98a6bc5..a6632a730 100644 --- a/include/stlink/logging.h +++ b/include/stlink/logging.h @@ -20,10 +20,8 @@ enum ugly_loglevel { int ugly_init(int maximum_threshold); int ugly_log(int level, const char *tag, const char *format, ...); -#ifndef CMAKE_SOURCE_DIR_LENGTH -#define CMAKE_SOURCE_DIR_LENGTH 0 -#endif -#define UGLY_LOG_FILE (__FILE__+CMAKE_SOURCE_DIR_LENGTH) +#define UGLY_LOG_FILE (strstr(__FILE__, "/") != NULL ? \ + strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') + 1) /** @todo we need to write this in a more generic way, for now this should compile on visual studio (See http://stackoverflow.com/a/8673872/1836746) */