From 698542cf459e51cd72f7bc46b6979a9d67b33309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 17 Jul 2017 15:22:09 +0200 Subject: [build] make Xcode use the correct compiler when it is installed in a non-standard location --- CMakeLists.txt | 12 +++++++++--- scripts/launch-c-xcode.in | 4 ++++ scripts/launch-c.in | 8 +------- scripts/launch-cxx-xcode.in | 4 ++++ scripts/launch-cxx.in | 8 +------- test/algorithm/update_renderables.test.cpp | 4 ---- 6 files changed, 19 insertions(+), 21 deletions(-) create mode 100644 scripts/launch-c-xcode.in create mode 100644 scripts/launch-cxx-xcode.in diff --git a/CMakeLists.txt b/CMakeLists.txt index d709f1117c..c6758cdacb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,22 +92,28 @@ find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) set(C_LAUNCHER "${CCACHE_PROGRAM}") set(CXX_LAUNCHER "${CCACHE_PROGRAM}") - configure_file(scripts/launch-c.in launch-c) - configure_file(scripts/launch-cxx.in launch-cxx) - execute_process(COMMAND chmod a+rx "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx") if(CMAKE_GENERATOR STREQUAL "Xcode") # Set Xcode project attributes to route compilation and linking through our scripts + # Xcode doesn't include the path to the compiler/linker by default, so we'll have to add it. + configure_file(scripts/launch-c-xcode.in launch-c @ONLY) + configure_file(scripts/launch-cxx-xcode.in launch-cxx @ONLY) + set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c") set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx") set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c") set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx") else() # Support Unix Makefiles and Ninja + configure_file(scripts/launch-c.in launch-c @ONLY) + configure_file(scripts/launch-cxx.in launch-cxx @ONLY) + set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c") set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx") endif() + execute_process(COMMAND chmod a+rx "${CMAKE_BINARY_DIR}/launch-c" "${CMAKE_BINARY_DIR}/launch-cxx") + if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") # ccache splits up the compile steps, so we end up with unused arguments in some steps. # Clang also thinks that ccache isn't interactive, so we explicitly need to enable color. diff --git a/scripts/launch-c-xcode.in b/scripts/launch-c-xcode.in new file mode 100644 index 0000000000..77a0c8aca3 --- /dev/null +++ b/scripts/launch-c-xcode.in @@ -0,0 +1,4 @@ +#!/bin/sh + +export CCACHE_CPP2=true +exec "@C_LAUNCHER@" "${DEVELOPER_DIR}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "$@" diff --git a/scripts/launch-c.in b/scripts/launch-c.in index 6c6c9180bc..94555f32aa 100644 --- a/scripts/launch-c.in +++ b/scripts/launch-c.in @@ -1,10 +1,4 @@ #!/bin/sh -# Xcode generator doesn't include the compiler as the -# first argument, Ninja and Makefiles do. Handle both cases. -if [ "$1" = "${CMAKE_C_COMPILER}" ] ; then - shift -fi - export CCACHE_CPP2=true -exec "${C_LAUNCHER}" "${CMAKE_C_COMPILER}" "$@" +exec "@C_LAUNCHER@" "$@" diff --git a/scripts/launch-cxx-xcode.in b/scripts/launch-cxx-xcode.in new file mode 100644 index 0000000000..7d4639ce6d --- /dev/null +++ b/scripts/launch-cxx-xcode.in @@ -0,0 +1,4 @@ +#!/bin/sh + +export CCACHE_CPP2=true +exec "@CXX_LAUNCHER@" "${DEVELOPER_DIR}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" "$@" diff --git a/scripts/launch-cxx.in b/scripts/launch-cxx.in index 23f107ce48..46671c1c64 100644 --- a/scripts/launch-cxx.in +++ b/scripts/launch-cxx.in @@ -1,10 +1,4 @@ #!/bin/sh -# Xcode generator doesn't include the compiler as the -# first argument, Ninja and Makefiles do. Handle both cases. -if [ "$1" = "${CMAKE_CXX_COMPILER}" ] ; then - shift -fi - export CCACHE_CPP2=true -exec "${CXX_LAUNCHER}" "${CMAKE_CXX_COMPILER}" "$@" \ No newline at end of file +exec "@CXX_LAUNCHER@" "$@" diff --git a/test/algorithm/update_renderables.test.cpp b/test/algorithm/update_renderables.test.cpp index d23e1cc1ac..2d37992579 100644 --- a/test/algorithm/update_renderables.test.cpp +++ b/test/algorithm/update_renderables.test.cpp @@ -100,8 +100,6 @@ auto createTileDataFn(ActionLog& log, T& dataTiles) { }; } -// Unused template argument to fix Clang crash -// See https://github.com/mapbox/mapbox-gl-native/pull/9501 template auto retainTileDataFn(ActionLog& log) { return [&](auto& tileData, Resource::Necessity necessity) { @@ -109,8 +107,6 @@ auto retainTileDataFn(ActionLog& log) { }; } -// Unused template argument to fix Clang crash -// See https://github.com/mapbox/mapbox-gl-native/pull/9501 template auto renderTileFn(ActionLog& log) { return [&](const auto& id, auto& tileData) { -- cgit v1.2.1