50
50
message (STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++1Y support. Please use a different C++ compiler." )
51
51
endif ()
52
52
53
- # Create a new pre-processor macro __PELOTONFILE__ that has a truncated
53
+ # Create a new pre-processor macro __PELOTONFILE__ that has a truncated
54
54
# path to reduce the size of the debug log messages.
55
55
# Source: http://stackoverflow.com/a/16658858
56
56
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__PELOTONFILE__='\" $(subst ${CMAKE_SOURCE_DIR} /,,$(abspath $<))\" '" )
@@ -62,7 +62,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
62
62
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics" )
63
63
endif ()
64
64
65
- if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" AND
65
+ if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" AND
66
66
(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 ))
67
67
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=auto" )
68
68
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto" )
@@ -79,10 +79,38 @@ if(UNIX OR APPLE)
79
79
endif ()
80
80
endif ()
81
81
82
+ # There is a problem with building on g++5.4 on Ubuntu 17.10 where
83
+ # the compiler will not support a bunch of stuff in std for some reason.
84
+ # For example, it would say that 'to_string' is not part of 'std'.
85
+ # These flags fix these problems. I don't know whether g++5.5 has the same
86
+ # problem, so I am only making this fix target all variants of 5.4.
87
+ #
88
+ # More Info: https://stackoverflow.com/a/38034394
89
+ # https://github.com/opencv/opencv/issues/10032#issuecomment-342347482
90
+ if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" AND
91
+ (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 5.4 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.4 ) AND
92
+ (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.5 ))
93
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GLIBCXX_USE_C99=1 -D_GLIBCXX_USE_C99_MATH=1" )
94
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_C99=1 -D_GLIBCXX_USE_C99_MATH=1" )
95
+ endif ()
96
+
82
97
# ---[ Warnings
83
98
peloton_warnings_disable (CMAKE_CXX_FLAGS -Wno-strict-aliasing -Wno-implicit-fallthrough )
84
99
85
- # Turn on sanitizers if necessary.
100
+ # ---[ Check if we should use the GNU Gold linker
101
+ set (USE_GOLD true CACHE BOOL "Use the GNU Gold linker if available" )
102
+ if (USE_GOLD )
103
+ execute_process (COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION )
104
+ if ("${LD_VERSION} " MATCHES "GNU gold" )
105
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags" )
106
+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags" )
107
+ else ()
108
+ message (WARNING "GNU gold linker isn't available, using the default system linker." )
109
+ set (USE_LD_GOLD OFF )
110
+ endif ()
111
+ endif ()
112
+
113
+ # ---[ Turn on sanitizers if necessary.
86
114
if (USE_SANITIZER )
87
115
if (USE_SANITIZER STREQUAL "Address" )
88
116
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address" )
@@ -102,9 +130,6 @@ if(USE_SANITIZER)
102
130
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-address-use-after-scope" )
103
131
endif ()
104
132
endif ()
105
- if (CMAKE_COMPILER_IS_GNUCC )
106
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold" )
107
- endif ()
108
133
endif ()
109
134
110
135
# -- [ Coverage
0 commit comments