summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2016-12-08 02:32:49 +0100
committerlouiz’ <louiz@louiz.org>2016-12-08 02:33:35 +0100
commit807ac95e798185aca35d6b2f3bf425a9c8b03744 (patch)
tree421e0b1fd8c156ecfc3b2bb3496d0d840486dd4f
parent7f577130e7dba8acbdeaa8933c4e5af666dedfce (diff)
downloadbiboumi-807ac95e798185aca35d6b2f3bf425a9c8b03744.tar.gz
biboumi-807ac95e798185aca35d6b2f3bf425a9c8b03744.tar.bz2
biboumi-807ac95e798185aca35d6b2f3bf425a9c8b03744.tar.xz
biboumi-807ac95e798185aca35d6b2f3bf425a9c8b03744.zip
Use a portable way to get the relative paths into __FILENAME__
-rw-r--r--CMakeLists.txt12
-rw-r--r--louloulibs/CMakeLists.txt12
2 files changed, 16 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0faaf12..6a3c3e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,10 +11,6 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage --coverage")
endif()
-# 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
#
@@ -207,6 +203,14 @@ if(USE_DATABASE)
database)
endif()
+# Define a __FILENAME__ macro with the relative path (from the base project directory)
+# of each source file
+file(GLOB_RECURSE source_all src/*.[hc]pp tests/*.[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()
+
include(ExternalProject)
ExternalProject_Add(catch
GIT_REPOSITORY "https://lab.louiz.org/louiz/Catch.git"
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
#