From 64e95f6ad7e6778e88f03257d6037040c7646f38 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Wed, 27 Nov 2019 14:58:52 +1100 Subject: [PATCH] cmake: add a toolchain file and convenience script for clang builds --- .gitignore | 3 ++- cmake/Toolchain-clang-linux-native.cmake | 16 ++++++++++++++++ gen-clang.sh | 7 +++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 cmake/Toolchain-clang-linux-native.cmake create mode 100755 gen-clang.sh diff --git a/.gitignore b/.gitignore index bc8d847d..240f12d8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,8 @@ demos .idea/ CmakeSettings.json cmake-build-*/ -build +build/ +build-clang/ build-DobieStation-* debug release diff --git a/cmake/Toolchain-clang-linux-native.cmake b/cmake/Toolchain-clang-linux-native.cmake new file mode 100644 index 00000000..44d80748 --- /dev/null +++ b/cmake/Toolchain-clang-linux-native.cmake @@ -0,0 +1,16 @@ +# The name of the target operating system +set(CMAKE_SYSTEM_NAME Linux) + +# Try to find clang for C and C++ +find_program(CMAKE_C_COMPILER clang) +find_program(CMAKE_CXX_COMPILER clang++) + +# Toolchain find root modes +# NEVER - search host system only +# ONLY - search CMAKE_FIND_ROOT_PATH only +# BOTH - search both +# Probably not needed for a native toolchain so commenting these out +#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +#set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/gen-clang.sh b/gen-clang.sh new file mode 100755 index 00000000..3628ea18 --- /dev/null +++ b/gen-clang.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +CMAKE="cmake" +BUILD_DIR="build-clang" +TOOLCHAIN="./cmake/Toolchain-clang-linux-native.cmake" + +exec $CMAKE . -B "$BUILD_DIR" -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" "$@"