mirror of
https://github.com/darlinghq/darling.git
synced 2024-11-27 06:10:36 +00:00
Merge pull request #1423 from darlinghq/ubuntu_20.04_adjustments
Fix Building For Ubuntu 20.04. Add Clang Checks.
This commit is contained in:
commit
eb18d733cb
@ -56,6 +56,7 @@ enable_language(ASM)
|
||||
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "core")
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
include(clang_version_check)
|
||||
include(InstallSymlink)
|
||||
include(MacroEnsureOutOfSourceBuild)
|
||||
include(dsym)
|
||||
@ -63,6 +64,10 @@ include(xcproj)
|
||||
include(architecture)
|
||||
include(create_symlink)
|
||||
|
||||
set(CLANG_RECOMMENDED_MINIMUM_VERSION 11)
|
||||
clang_version_check(${CMAKE_C_COMPILER} c ${CLANG_RECOMMENDED_MINIMUM_VERSION})
|
||||
clang_version_check(${CMAKE_CXX_COMPILER} cpp ${CLANG_RECOMMENDED_MINIMUM_VERSION})
|
||||
|
||||
MACRO_ENSURE_OUT_OF_SOURCE_BUILD()
|
||||
|
||||
set(DARLING_TOP_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
42
cmake/clang_version_check.cmake
Normal file
42
cmake/clang_version_check.cmake
Normal file
@ -0,0 +1,42 @@
|
||||
set(MANUALLY_SET_COMPILER_ERROR_MESSAGE
|
||||
"If you already have a supported version of clang installed, you may need to \
|
||||
manually set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER. Refer to the Darling docs \
|
||||
for more details."
|
||||
)
|
||||
|
||||
macro(clang_version_check compiler source_type clang_minimum_version)
|
||||
if (compiler STREQUAL "")
|
||||
message(FATAL_ERROR "Unable to find a compatible compiler")
|
||||
endif (compiler STREQUAL "")
|
||||
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/clang_major.${source_type}" "#include <stdio.h>\n"
|
||||
"#if !__clang__\n" "#error \"Not running on a clang compiler!\"\n" "#endif\n" "int main() { printf(\"%d\", __clang_major__); }")
|
||||
execute_process(COMMAND "${compiler}" "${CMAKE_BINARY_DIR}/clang_major.${source_type}" "-o" "clang_${source_type}_major"
|
||||
RESULT_VARIABLE BUILD_CLANG_TEST_RESULT
|
||||
OUTPUT_VARIABLE BUILD_CLANG_TEST_OUTPUT
|
||||
COMMAND_ECHO NONE
|
||||
)
|
||||
|
||||
if (BUILD_CLANG_TEST_RESULT)
|
||||
message(FATAL_ERROR
|
||||
"Failed to build ${CMAKE_BINARY_DIR}/clang_major.${source_type}\n"
|
||||
"This could indicate that `${compiler}` is either not a clang compiler, "
|
||||
"or the path does not exist. ${MANUALLY_SET_COMPILER_ERROR_MESSAGE}")
|
||||
endif (BUILD_CLANG_TEST_RESULT)
|
||||
|
||||
execute_process(COMMAND "${CMAKE_BINARY_DIR}/clang_${source_type}_major"
|
||||
RESULT_VARIABLE CLANG_MAJOR_VERSION_RESULT
|
||||
OUTPUT_VARIABLE CLANG_MAJOR_VERSION_OUTPUT
|
||||
)
|
||||
|
||||
if (CLANG_MAJOR_VERSION_RESULT)
|
||||
# This should normally never fail...
|
||||
message(FATAL_ERROR "Failed to check clang major version")
|
||||
endif (CLANG_MAJOR_VERSION_RESULT)
|
||||
|
||||
if ("${CLANG_MAJOR_VERSION_OUTPUT}" LESS ${clang_minimum_version})
|
||||
message(FATAL_ERROR
|
||||
"Your clang version (${CLANG_MAJOR_VERSION_OUTPUT}) is below the recommend supported version (${clang_minimum_version})\n"
|
||||
"${MANUALLY_SET_COMPILER_ERROR_MESSAGE}")
|
||||
endif ("${CLANG_MAJOR_VERSION_OUTPUT}" LESS ${clang_minimum_version})
|
||||
endmacro()
|
2
src/external/foundation
vendored
2
src/external/foundation
vendored
@ -1 +1 @@
|
||||
Subproject commit 40b07da5840e61f21f05aa8cfc8ffadc1679cf33
|
||||
Subproject commit 216448718054deaea39ec3d57b891939ca9c824e
|
2
src/external/xnu
vendored
2
src/external/xnu
vendored
@ -1 +1 @@
|
||||
Subproject commit 6d94d59c21eb18d0230a62fcef6a58f98cc46113
|
||||
Subproject commit e4a0b762d0c9e935575a886ec0a349a770582063
|
@ -102,4 +102,5 @@ add_framework(ShazamKit
|
||||
system
|
||||
objc
|
||||
Foundation
|
||||
UniformTypeIdentifiers
|
||||
)
|
||||
|
@ -59,4 +59,5 @@ add_framework(ShazamInsights
|
||||
system
|
||||
objc
|
||||
Foundation
|
||||
CoreLocation
|
||||
)
|
@ -48,4 +48,5 @@ add_framework(ShazamKitUI
|
||||
system
|
||||
objc
|
||||
Foundation
|
||||
ShazamKit
|
||||
)
|
Loading…
Reference in New Issue
Block a user