this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add Basic Checks For Clang Compiler

Thomas A 252d7f75 5d5a364a

+47
+5
CMakeLists.txt
··· 56 56 set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "core") 57 57 58 58 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") 59 + include(clang_version_check) 59 60 include(InstallSymlink) 60 61 include(MacroEnsureOutOfSourceBuild) 61 62 include(dsym) 62 63 include(xcproj) 63 64 include(architecture) 64 65 include(create_symlink) 66 + 67 + set(CLANG_RECOMMENDED_MINIMUM_VERSION 11) 68 + clang_version_check(${CMAKE_C_COMPILER} c ${CLANG_RECOMMENDED_MINIMUM_VERSION}) 69 + clang_version_check(${CMAKE_CXX_COMPILER} cpp ${CLANG_RECOMMENDED_MINIMUM_VERSION}) 65 70 66 71 MACRO_ENSURE_OUT_OF_SOURCE_BUILD() 67 72
+42
cmake/clang_version_check.cmake
··· 1 + set(MANUALLY_SET_COMPILER_ERROR_MESSAGE 2 + "If you already have a supported version of clang installed, you may need to \ 3 + manually set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER. Refer to the Darling docs \ 4 + for more details." 5 + ) 6 + 7 + macro(clang_version_check compiler source_type clang_minimum_version) 8 + if (compiler STREQUAL "") 9 + message(FATAL_ERROR "Unable to find a compatible compiler") 10 + endif (compiler STREQUAL "") 11 + 12 + file(WRITE "${CMAKE_BINARY_DIR}/clang_major.${source_type}" "#include <stdio.h>\n" 13 + "#if !__clang__\n" "#error \"Not running on a clang compiler!\"\n" "#endif\n" "int main() { printf(\"%d\", __clang_major__); }") 14 + execute_process(COMMAND "${compiler}" "${CMAKE_BINARY_DIR}/clang_major.${source_type}" "-o" "clang_${source_type}_major" 15 + RESULT_VARIABLE BUILD_CLANG_TEST_RESULT 16 + OUTPUT_VARIABLE BUILD_CLANG_TEST_OUTPUT 17 + COMMAND_ECHO NONE 18 + ) 19 + 20 + if (BUILD_CLANG_TEST_RESULT) 21 + message(FATAL_ERROR 22 + "Failed to build ${CMAKE_BINARY_DIR}/clang_major.${source_type}\n" 23 + "This could indicate that `${compiler}` is either not a clang compiler, " 24 + "or the path does not exist. ${MANUALLY_SET_COMPILER_ERROR_MESSAGE}") 25 + endif (BUILD_CLANG_TEST_RESULT) 26 + 27 + execute_process(COMMAND "${CMAKE_BINARY_DIR}/clang_${source_type}_major" 28 + RESULT_VARIABLE CLANG_MAJOR_VERSION_RESULT 29 + OUTPUT_VARIABLE CLANG_MAJOR_VERSION_OUTPUT 30 + ) 31 + 32 + if (CLANG_MAJOR_VERSION_RESULT) 33 + # This should normally never fail... 34 + message(FATAL_ERROR "Failed to check clang major version") 35 + endif (CLANG_MAJOR_VERSION_RESULT) 36 + 37 + if ("${CLANG_MAJOR_VERSION_OUTPUT}" LESS ${clang_minimum_version}) 38 + message(FATAL_ERROR 39 + "Your clang version (${CLANG_MAJOR_VERSION_OUTPUT}) is below the recommend supported version (${clang_minimum_version})\n" 40 + "${MANUALLY_SET_COMPILER_ERROR_MESSAGE}") 41 + endif ("${CLANG_MAJOR_VERSION_OUTPUT}" LESS ${clang_minimum_version}) 42 + endmacro()