From ac1d819608baf3ee41af652cba1782698b96cd70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Wed, 12 Mar 2014 13:55:38 -0400 Subject: [PATCH] cmake: added GCC hack to strip absolute path out of the __FILE__ macro --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85132055b..98c208f07 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,6 +133,16 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") + + # Hack to strip absolute paths out of the __FILE__ macro + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILE__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILE__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") + CHECK_C_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefined) + if(Wno-builtin-macro-redefined) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-builtin-macro-redefined") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined") + endif() + CHECK_C_COMPILER_FLAG (-Wno-unused-result Wno-unused-result) if(Wno-unused-result) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result")