From: Ivan Maidanski Date: Tue, 30 Jul 2019 23:01:57 +0000 (+0300) Subject: Fix passing CFLAGS_EXTRA to compiler in CMake script X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e329ab91b3692fdb87c631f1dc4750559381e67f;p=gc Fix passing CFLAGS_EXTRA to compiler in CMake script (fix of commit b6ac6a5a4) The previous solution does not work for MS VC target. * CMakeLists.txt [CFLAGS_EXTRA] (CMAKE_C_FLAGS, CMAKE_CXX_FLAGS): Do not set. * CMakeLists.txt [CFLAGS_EXTRA]: Pass $(CFLAGS_EXTRA) to add_compile_options. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 758fac79..e017f389 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,10 +310,7 @@ endif() # Extra user-defined flags to pass both to C and C++ compilers. if (DEFINED CFLAGS_EXTRA) - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${CFLAGS_EXTRA}) - if (enable_cplusplus) - set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CFLAGS_EXTRA}) - endif() + add_compile_options(${CFLAGS_EXTRA}) endif() add_library(gc ${SRC})