File: FindCompilerFlag.cmake

package info (click to toggle)
bpfcc 0.18.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,368 kB
  • sloc: ansic: 132,727; python: 36,226; cpp: 26,973; sh: 710; yacc: 525; makefile: 141; lex: 94
file content (30 lines) | stat: -rw-r--r-- 779 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright (c) 2017 Facebook, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")

if (CMAKE_C_COMPILER_ID MATCHES "Clang")
	set(COMPILER_NOPIE_FLAG "-nopie")
else()
	set(_backup_c_flags "${CMAKE_REQUIRED_FLAGS}")
	set(CMAKE_REQUIRED_FLAGS "-no-pie")
	CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}"
				  HAVE_NO_PIE_FLAG)
	if (HAVE_NO_PIE_FLAG)
		set(COMPILER_NOPIE_FLAG "-no-pie")
	else()
		set(COMPILER_NOPIE_FLAG "")
	endif()
	set(CMAKE_REQUIRED_FLAGS "${_backup_c_flags}")
endif()

# check whether reallocarray availability
# this is used to satisfy reallocarray usage under src/cc/libbpf/
CHECK_CXX_SOURCE_COMPILES(
"
#define _GNU_SOURCE
#include <stdlib.h>

int main(void)
{
        return !!reallocarray(NULL, 1, 1);
}
" HAVE_REALLOCARRAY_SUPPORT)