Jonas Hahnfeld | fc473de | 2017-11-30 17:08:31 +0000 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8) |
| 2 | project(DetectTestCompiler C CXX) |
| 3 | |
Jonas Hahnfeld | 6f9e25d | 2018-02-15 08:10:22 +0000 | [diff] [blame] | 4 | include(CheckCCompilerFlag) |
| 5 | include(CheckCXXCompilerFlag) |
| 6 | |
Jonas Hahnfeld | fc473de | 2017-11-30 17:08:31 +0000 | [diff] [blame] | 7 | function(write_compiler_information lang) |
| 8 | set(information "${CMAKE_${lang}_COMPILER}") |
| 9 | set(information "${information}\\;${CMAKE_${lang}_COMPILER_ID}") |
| 10 | set(information "${information}\\;${CMAKE_${lang}_COMPILER_VERSION}") |
Jonas Hahnfeld | 6f9e25d | 2018-02-15 08:10:22 +0000 | [diff] [blame] | 11 | set(information "${information}\\;${${lang}_FLAGS}") |
Jonas Hahnfeld | fc473de | 2017-11-30 17:08:31 +0000 | [diff] [blame] | 12 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${lang}CompilerInformation.txt ${information}) |
| 13 | endfunction(write_compiler_information) |
| 14 | |
| 15 | find_package(OpenMP) |
| 16 | if (NOT OpenMP_Found) |
| 17 | set(OpenMP_C_FLAGS "-fopenmp") |
| 18 | set(OpenMP_CXX_FLAGS "-fopenmp") |
| 19 | endif() |
| 20 | |
Jonas Hahnfeld | 6f9e25d | 2018-02-15 08:10:22 +0000 | [diff] [blame] | 21 | set(C_FLAGS ${flags} ${OpenMP_C_FLAGS}) |
| 22 | set(CXX_FLAGS ${flags} ${OpenMP_CXX_FLAGS}) |
| 23 | |
| 24 | # TODO: Implement blockaddress in GlobalISel and remove this flag! |
| 25 | if (CMAKE_C_COMPILER_ID STREQUAL "Clang") |
| 26 | check_c_compiler_flag("-fno-experimental-isel" C_HAS_EXPERIMENTAL_ISEL_FLAG) |
| 27 | check_cxx_compiler_flag("-fno-experimental-isel" CXX_HAS_EXPERIMENTAL_ISEL_FLAG) |
| 28 | macro(add_experimental_isel_flag lang) |
| 29 | if (${lang}_HAS_EXPERIMENTAL_ISEL_FLAG) |
| 30 | set(${lang}_FLAGS "-fno-experimental-isel ${${lang}_FLAGS}") |
| 31 | endif() |
| 32 | endmacro(add_experimental_isel_flag) |
| 33 | |
| 34 | add_experimental_isel_flag(C) |
| 35 | add_experimental_isel_flag(CXX) |
| 36 | endif() |
| 37 | |
Jonas Hahnfeld | fc473de | 2017-11-30 17:08:31 +0000 | [diff] [blame] | 38 | write_compiler_information(C) |
| 39 | write_compiler_information(CXX) |