summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-10-06 12:52:31 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-10-06 12:52:31 +0200
commitd03f5ab76b0d0dee199b65fc801236a38830b5fc (patch)
treee26f639d38098fca8a62f64a513287c067a9a7b3
parent337585e3d881c2c2c9099888b09902119dc05bf8 (diff)
Do not override user-defined CMAKE_C[XX]_FLAGS for clang
337585e3d881c2c2c9099888b09902119dc05bf8 unconditionnaly overrides any potential user-defined CMAKE_C[XX]_FLAGS. This for example breaks the GDAL oss-fuzz builds which build Poppler from source (see https://github.com/OSGeo/gdal/blob/master/gdal/fuzzers/build.sh#L54) So do the same as the GCC path where we save input CMAKE_C[XX]_FLAGS and reinject them in custom CMAKE_C{XX}_FLAGS_{build_configuration} The values are identical to GCC, execpt for the _DEBUG configuration where we remove '-O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline' since clang does not support -fno-reorder-blocks and -fno-schedule-insns, so it is likely better to disable any optimization for proper debugging.
-rw-r--r--cmake/modules/PopplerMacros.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/modules/PopplerMacros.cmake b/cmake/modules/PopplerMacros.cmake
index 5ccbc4ef..a9d20948 100644
--- a/cmake/modules/PopplerMacros.cmake
+++ b/cmake/modules/PopplerMacros.cmake
@@ -166,8 +166,23 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(DEFAULT_COMPILE_WARNINGS "${_warn}")
set(DEFAULT_COMPILE_WARNINGS_EXTRA "${_warn} ${_warnx}")
+ set(_save_cxxflags "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-fno-exceptions -fno-check-new -fno-common -D_DEFAULT_SOURCE")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${_save_cxxflags}")
+ set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${_save_cxxflags}")
+ # clang does not support -fno-reorder-blocks -fno-schedule-insns, so do not use -O2
+ set(CMAKE_CXX_FLAGS_DEBUG "-g ${_save_cxxflags}")
+ set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3 -fno-inline ${_save_cxxflags}")
+ set(CMAKE_CXX_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs ${_save_cxxflags}")
+ set(_save_cflags "${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "-std=c99 -D_DEFAULT_SOURCE")
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g ${_save_cflags}")
+ set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG ${_save_cflags}")
+ # clang does not support -fno-reorder-blocks -fno-schedule-insns, so do not use -O2
+ set(CMAKE_C_FLAGS_DEBUG "-g ${_save_cflags}")
+ set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline ${_save_cflags}")
+ set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs ${_save_cflags}")
+
endif()
if(CMAKE_C_COMPILER MATCHES "icc")