1*4882a593Smuzhiyunset(CMAKE_CXX_FLAGS "-Wall -std=c++11 -fPIC") 2*4882a593Smuzhiyunset(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") 3*4882a593Smuzhiyunset(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") 4*4882a593Smuzhiyunset(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG") 5*4882a593Smuzhiyunset(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") 6*4882a593Smuzhiyun 7*4882a593Smuzhiyunif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") 8*4882a593Smuzhiyun execute_process( 9*4882a593Smuzhiyun COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) 10*4882a593Smuzhiyun if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)) 11*4882a593Smuzhiyun message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.") 12*4882a593Smuzhiyun endif () 13*4882a593Smuzhiyunelseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") 14*4882a593Smuzhiyun set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") 15*4882a593Smuzhiyunelseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 16*4882a593Smuzhiyun set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /stdlib=libc++") 17*4882a593Smuzhiyunelse () 18*4882a593Smuzhiyun message(FATAL_ERROR "Your C++ compiler does not support C++11.") 19*4882a593Smuzhiyunendif () 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun# Workaround Compile Errors 22*4882a593Smuzhiyunif (CMAKE_CXX_COMPILER_ID MATCHES "GNU") 23*4882a593Smuzhiyun set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder -Wno-unused -Wno-misleading-indentation -Wno-format-truncation -fno-strict-aliasing -Wno-address-of-packed-member -Wno-psabi") 24*4882a593Smuzhiyun if(NOT ARCH STREQUAL "fpga") 25*4882a593Smuzhiyun add_compile_options(-fstack-protector-strong -D_FORTIFY_SOURCE=2) 26*4882a593Smuzhiyun endif() 27*4882a593Smuzhiyunelseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 28*4882a593Smuzhiyun add_definitions(-D_CRT_SECURE_NO_WARNINGS) 29*4882a593Smuzhiyunendif() 30*4882a593Smuzhiyun 31*4882a593Smuzhiyunif (RKAIQ_ENABLE_ASAN) 32*4882a593Smuzhiyun set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") 33*4882a593Smuzhiyun set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") 34*4882a593Smuzhiyun set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") 35*4882a593Smuzhiyunendif() 36*4882a593Smuzhiyun 37