From 807ac95e798185aca35d6b2f3bf425a9c8b03744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 8 Dec 2016 02:32:49 +0100 Subject: Use a portable way to get the relative paths into __FILENAME__ --- louloulibs/CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'louloulibs') diff --git a/louloulibs/CMakeLists.txt b/louloulibs/CMakeLists.txt index 908c35f..c5ed7a7 100644 --- a/louloulibs/CMakeLists.txt +++ b/louloulibs/CMakeLists.txt @@ -6,10 +6,6 @@ set(${PROJECT_NAME}_VERSION_SUFFIX "~dev") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pedantic -Wall -Wextra") -# Define a __FILENAME__ macro to get the filename of each file, instead of -# the full path as in __FILE__ -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - # ## Look for external libraries # @@ -143,6 +139,14 @@ if(SYSTEMD_FOUND) target_link_libraries(xmpplib ${SYSTEMD_LIBRARIES}) endif() +# Define a __FILENAME__ macro with the relative path (from the base project directory) +# of each source file +file(GLOB_RECURSE source_all *.[hc]pp) +foreach(file ${source_all}) + file(RELATIVE_PATH shorter_file ${CMAKE_CURRENT_SOURCE_DIR} ${file}) + set_property(SOURCE ${file} APPEND PROPERTY COMPILE_DEFINITIONS __FILENAME__="${shorter_file}") +endforeach() + # ## Check if we have std::get_time # -- cgit v1.2.3