Skip to content

Commit

Permalink
Only use _GNU_SOURCE as feature macro
Browse files Browse the repository at this point in the history
  • Loading branch information
roehling committed Aug 8, 2023
1 parent 07b4190 commit a92cf00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
15 changes: 2 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a92cf00

Please sign in to comment.