Debian Codegraph @

cmake/support/compiler_setup.cmake

raw
1 set(CMAKE_CXX_STANDARD 11)
2
3 option(USE_ADDRESS_SANITIZER "Use GCC Address Sanitizer" OFF)
4 if(USE_ADDRESS_SANITIZER)
5 set(CMAKE_CXX_FLAGS
6 "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
7 set(CMAKE_EXE_LINKER_FLAGS
8 "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
9 endif()
10
11 set(CMAKE_REQUIRED_QUIET $<NOT:${VERBOSE}>)
12
13 include(CheckCXXCompilerFlag)
14
15 set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
16 check_cxx_compiler_flag(-Werror HAS_WERROR)
17
18 if(HAS_WERROR)
19 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
20 endif()
21
22 check_cxx_source_compiles("int main(void) { static __thread int x; (void)x; return 0;}" HAS_ATTR_THREAD)
23
24 if(NOT HAS_ATTR_THREAD)
25 check_cxx_source_compiles("int main(void) { __declspec(thread) static int x; (void)x; return 0;}" HAS_DECLSPEC_THREAD)
26 endif()
27
28 check_cxx_source_compiles("#include <cstdlib>
29 int main(void) { long long int x = atoll(\"123\"); (void)x; }" HAS_ATOLL)
30 check_cxx_source_compiles("
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <errno.h>
35 #include <libproc.h>
36 #include <unistd.h>
37
38 int main (int argc, char* argv[])
39 {
40 pid_t pid = getpid();
41 char path[PROC_PIDPATHINFO_MAXSIZE];
42 (void) proc_pidpath (pid, path, sizeof(path));
43 return 0;
44 }
45 " HAS_PIDPATH)
46
47 check_cxx_source_compiles("
48 #include <windows.h>
49 int main (int argc, char* argv[]) {
50 char path[MAX_PATH];
51 (void) GetModuleFileName(NULL, path, MAX_PATH);
52 return 0;
53 }" HAS_GETMODULEFILENAME)
54
55 check_cxx_source_compiles("
56 #include <windows.h>
57 int main (int argc, char* argv[]) {
58 (void) GetFileAttributes(NULL);
59 return 0;
60 }" HAS_GETFILEATTRIBUTES)
61
62 check_cxx_source_compiles("
63 #include <string.h>
64 int main (int argc, char* argv[]) {
65 (void) memcpy_s(NULL,0,NULL,0);
66 return 0;
67 }" HAS_MEMCPY_S)