You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.4 KiB
72 lines
2.4 KiB
# Detect Clang compiler |
|
if("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang") |
|
set(CMAKE_COMPILER_IS_CLANGXX 1) |
|
endif() |
|
|
|
# Require C++11 |
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) |
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") |
|
if(APPLE) |
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") |
|
endif() |
|
endif() |
|
|
|
# MSVC automatically defines -D_DEBUG when /MTd or /MDd is set, so we |
|
# need to make sure it gets added for other compilers too |
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) |
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") |
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") |
|
endif() |
|
|
|
|
|
# Compile-time type size checks |
|
include(CheckTypeSize) |
|
|
|
if(NOT WCHAR_BYTES) |
|
check_type_size("wchar_t" WCHAR_BYTES) |
|
if(NOT WCHAR_BYTES) |
|
message(FATAL_ERROR "Could not determine sizeof(wchar_t)") |
|
set(WCHAR_BYTES 0) |
|
endif() |
|
endif() |
|
|
|
if(NOT SIZEOF_LONG) |
|
check_type_size("long" SIZEOF_LONG) |
|
if(NOT SIZEOF_LONG) |
|
message(FATAL_ERROR "Could not determine sizeof(long)") |
|
set(SIZEOF_LONG 0) |
|
endif() |
|
endif() |
|
|
|
# Check for CPUID headers |
|
try_compile(HAVE_CPUID ${PROJECT_BINARY_DIR} |
|
${PROJECT_SOURCE_DIR}/cmake/check_cpuid.cpp) |
|
if(HAVE_CPUID) |
|
message("CPUID header found -- using hardware math acceleration when available") |
|
else() |
|
message("CPUID header not found -- using software math") |
|
endif() |
|
|
|
# Look for a supported "deprecated" attribute specifier. |
|
try_compile(HAVE_CXX14_DEPRECATED_ATTR ${PROJECT_BINARY_DIR} |
|
${PROJECT_SOURCE_DIR}/cmake/check_deprecated_attribute.cpp |
|
COMPILE_DEFINITIONS -DTRY_ATTRIBUTE) |
|
try_compile(HAVE_GCC_DEPRECATED_ATTR ${PROJECT_BINARY_DIR} |
|
${PROJECT_SOURCE_DIR}/cmake/check_deprecated_attribute.cpp |
|
COMPILE_DEFINITIONS -DTRY_GCC_ATTR) |
|
|
|
# Look for C++11 constexpr support |
|
try_compile(HAVE_CONSTEXPR ${PROJECT_BINARY_DIR} |
|
${PROJECT_SOURCE_DIR}/cmake/check_constexpr.cpp) |
|
|
|
# Look for C++11 override/final specifiers |
|
try_compile(HAVE_OVERRIDE ${PROJECT_BINARY_DIR} |
|
${PROJECT_SOURCE_DIR}/cmake/check_override.cpp) |
|
|
|
# Look for C++11 noexcept specifier |
|
try_compile(HAVE_NOEXCEPT ${PROJECT_BINARY_DIR} |
|
${PROJECT_SOURCE_DIR}/cmake/check_noexcept.cpp) |
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/cmake/hsCompilerSpecific.h.cmake |
|
${PROJECT_BINARY_DIR}/hsCompilerSpecific.h) |
|
include_directories(${PROJECT_BINARY_DIR})
|
|
|