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