cmake: added GCC hack to strip absolute path out of the __FILE__ macro
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Wed, 12 Mar 2014 17:55:38 +0000 (13:55 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Wed, 12 Mar 2014 17:55:38 +0000 (13:55 -0400)
CMakeLists.txt

index 8513205..98c208f 100755 (executable)
@@ -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")