[cmake] Fix _GNU_SOURCE being added unconditionally
authorAndreas Hollandt <trass3r@gmail.com>
Mon, 14 Nov 2022 20:27:12 +0000 (12:27 -0800)
committerTom Stellard <tstellar@redhat.com>
Mon, 14 Nov 2022 20:28:21 +0000 (12:28 -0800)
Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D137917

clang/CMakeLists.txt
llvm/cmake/config-ix.cmake

index c9f86d4..e6cc6e4 100644 (file)
@@ -414,8 +414,6 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
index 15a7d78..28ca822 100644 (file)
@@ -348,7 +348,7 @@ endif()
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE