Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define _GNU_SOURCE for a declaration of vasprintf #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ else()
SET(IS_LOONGARCH_TYPE 0)
endif()

# For vasprintf in deepin-system-monitor-main/3rdparty/include/xalloc.h.
# Also needed by the tests subdirectory.
add_definitions("-D_GNU_SOURCE")

# HAVE_CLOSE_RANGE is used by
# deepin-system-monitor-main/3rdparty/include/fileutils.h to define
# close_range if needed.
try_compile(CLOSE_RANGE_RESULT "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
"${PROJECT_SOURCE_DIR}/cmake/check-close_range.c")
if(CLOSE_RANGE_RESULT)
add_definitions("-DHAVE_CLOSE_RANGE")
endif()

# Likewise, HAVE_DECL_CPU_ALLOC is used in
# deepin-system-monitor-main/3rdparty/include/cpuset.h. Support for
# the <sched.h> macros was added in glibc 2.7, so define it
# unconditionally.
add_definitions("-DHAVE_DECL_CPU_ALLOC")

#系统监视器主应用
ADD_SUBDIRECTORY(deepin-system-monitor-main)
#系统监视器插件
Expand Down
14 changes: 14 additions & 0 deletions cmake/check-close_range.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Check whether <unistd.h> declares close_range, for HAVE_CLOSE_RANGE. */

/* Supplied by the build environment later. */
#define _GNU_SOURCE

#include <unistd.h>

void *volatile p;

int
main(void)
{
p = (void *) close_range;
}