forked from Mirrors/openclonk
Make cross-compiling work with GCC 6+
GCC6 doesn't like getting some of its default include search paths passed with the -isystem flag, and the devs seem unlikely to change whatever they did back to before they broke it. Work around CMake not dealing with it well either by figuring out the paths at configure time and telling CMake about them so it can avoid adding them superfluously.master
parent
3224e2c5cd
commit
8e57c0a9f4
|
@ -178,6 +178,12 @@ endif()
|
|||
############################################################################
|
||||
# Check for compiler quirks and features
|
||||
############################################################################
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CROSSCOMPILING)
|
||||
include(HandleGccCrossIncludePaths)
|
||||
HANDLE_GCC_CROSS_INCLUDE_PATHS(CXX c++)
|
||||
HANDLE_GCC_CROSS_INCLUDE_PATHS(C c)
|
||||
endif()
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(RequireCXXSourceCompiles)
|
||||
include(CheckCXXSymbolExists)
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# OpenClonk, http://www.openclonk.org
|
||||
#
|
||||
# Copyright (c) 2018, The OpenClonk Team and contributors
|
||||
#
|
||||
# Distributed under the terms of the ISC license; see accompanying file
|
||||
# "COPYING" for details.
|
||||
#
|
||||
# "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
||||
# See accompanying file "TRADEMARK" for details.
|
||||
#
|
||||
# To redistribute this file separately, substitute the full license texts
|
||||
# for the above references.
|
||||
|
||||
# GCC6 doesn't work well with CMake while cross-compiling. See bugs:
|
||||
# https://gitlab.kitware.com/cmake/cmake/issues/16291
|
||||
# https://gitlab.kitware.com/cmake/cmake/issues/16919
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129
|
||||
|
||||
function(HANDLE_GCC_CROSS_INCLUDE_PATHS _lang _gcc_lang_flag)
|
||||
set(_compiler "${CMAKE_${_lang}_COMPILER}")
|
||||
set(_compile_flags "${CMAKE_${_lang}_FLAGS}")
|
||||
separate_arguments(_compile_flags UNIX_COMMAND "${_compile_flags}")
|
||||
execute_process(
|
||||
COMMAND ${_compiler} ${_compile_flags} -v -E -x ${_gcc_lang_flag} /dev/null
|
||||
OUTPUT_QUIET
|
||||
ERROR_VARIABLE _compiler_output
|
||||
)
|
||||
if ("${_compiler_output}" MATCHES "#include <\\.\\.\\.> search starts here:\n *(.*)\nEnd of search list\\.")
|
||||
string(REGEX REPLACE "[\n ]+" " " _search_list "${CMAKE_MATCH_1}")
|
||||
separate_arguments(_search_list)
|
||||
foreach(_directory ${_search_list})
|
||||
get_filename_component(_fixed_component "${_directory}" REALPATH)
|
||||
set(_resolved_list ${_resolved_list} "${_fixed_component}")
|
||||
endforeach()
|
||||
set(CMAKE_${_lang}_IMPLICIT_INCLUDE_DIRECTORIES ${CMAKE_${_lang}_IMPLICIT_INCLUDE_DIRECTORIES} ${_resolved_list} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
Loading…
Reference in New Issue