From a92cf006463360cd005cdee2df90238a99e88b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Tue, 8 Aug 2023 15:10:30 +0200 Subject: [PATCH] Only use _GNU_SOURCE as feature macro --- CMakeLists.txt | 15 ++------------- tests/unit/CMakeLists.txt | 3 +-- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d79dacd..da1dba4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,9 +142,7 @@ FetchContent_Declare( ) set(saved_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") -list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_BSD_SOURCE" "-D_DEFAULT_SOURCE" - "-D_POSIX_C_SOURCE=200809L" -) +list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE" "-D_FILE_OFFSET_BITS=64") check_include_file(alloca.h HAVE_ALLOCA_H) check_include_file(errno.h HAVE_ERRNO_H) @@ -175,9 +173,6 @@ check_symbol_exists(_strnicmp string.h HAVE__STRNICMP) check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG) test_big_endian(HAVE_BIG_ENDIAN) -list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") -check_symbol_exists(close_range unistd.h HAVE_CLOSE_RANGE_GNU) - set(CMAKE_REQUIRED_DEFINITIONS "${saved_CMAKE_REQUIRED_DEFINITIONS}") if(CMAKE_SYSTEM_NAME MATCHES "Solaris|SunOS") @@ -322,13 +317,7 @@ add_executable( src/util.c ) -target_compile_definitions( - postsrsd PRIVATE _BSD_SOURCE _DEFAULT_SOURCE _POSIX_C_SOURCE=200809L - _FILE_OFFSET_BITS=64 -) -if(HAVE_CLOSE_RANGE_GNU AND NOT HAVE_CLOSE_RANGE) - target_compile_definitions(postsrsd PRIVATE _GNU_SOURCE) -endif() +target_compile_definitions(postsrsd PRIVATE _GNU_SOURCE _FILE_OFFSET_BITS=64) target_include_directories(postsrsd PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") target_compile_features(postsrsd PRIVATE c_std_99) target_link_libraries( diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 7d7003b..5262eaa 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -20,8 +20,7 @@ macro(add_postsrsd_test name) ${name}_executable PRIVATE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ) target_compile_definitions( - ${name}_executable PRIVATE _BSD_SOURCE _DEFAULT_SOURCE - _POSIX_C_SOURCE=200809L _FILE_OFFSET_BITS=64 + ${name}_executable PRIVATE _GNU_SOURCE _FILE_OFFSET_BITS=64 ) if(HAVE_CLOSE_RANGE_GNU AND NOT HAVE_CLOSE_RANGE) target_compile_definitions(${name}_executable PRIVATE _GNU_SOURCE)