2018-06-08 16:00:56 +00:00
|
|
|
# Use Ninja instead of Unix Makefiles by default.
|
2018-06-08 16:07:52 +00:00
|
|
|
# https://stackoverflow.com/questions/11269833/cmake-selecting-a-generator-within-cmakelists-txt
|
|
|
|
#
|
2019-01-17 19:04:21 +00:00
|
|
|
# Reason: it has better startup time than make and it parallelizes jobs more uniformly.
|
2018-06-08 16:07:52 +00:00
|
|
|
# (when comparing to make with Makefiles that was generated by CMake)
|
|
|
|
#
|
|
|
|
# How to install Ninja on Ubuntu:
|
|
|
|
# sudo apt-get install ninja-build
|
2018-06-08 16:00:56 +00:00
|
|
|
|
2018-09-07 00:24:59 +00:00
|
|
|
# CLion does not support Ninja
|
2018-09-07 13:02:52 +00:00
|
|
|
# You can add your vote on CLion task tracker:
|
|
|
|
# https://youtrack.jetbrains.com/issue/CPP-2659
|
|
|
|
# https://youtrack.jetbrains.com/issue/CPP-870
|
|
|
|
|
2021-01-05 23:06:03 +00:00
|
|
|
if (NOT DEFINED ENV{CLION_IDE} AND NOT DEFINED ENV{XCODE_IDE})
|
2018-09-07 00:24:59 +00:00
|
|
|
find_program(NINJA_PATH ninja)
|
|
|
|
if (NINJA_PATH)
|
|
|
|
set(CMAKE_GENERATOR "Ninja" CACHE INTERNAL "" FORCE)
|
|
|
|
endif ()
|
|
|
|
endif()
|
2021-10-12 00:30:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Default toolchain - this is needed to avoid dependency on OS files.
|
|
|
|
execute_process(COMMAND uname -s OUTPUT_VARIABLE OS)
|
|
|
|
execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCH)
|
|
|
|
|
2021-10-12 22:12:50 +00:00
|
|
|
if (OS MATCHES "Linux"
|
|
|
|
AND NOT DEFINED CMAKE_TOOLCHAIN_FILE
|
|
|
|
AND NOT DISABLE_HERMETIC_BUILD
|
2021-12-20 08:59:20 +00:00
|
|
|
AND ($ENV{CC} MATCHES ".*clang.*" OR CMAKE_C_COMPILER MATCHES ".*clang.*"))
|
2021-10-12 22:12:50 +00:00
|
|
|
|
2021-10-12 00:30:08 +00:00
|
|
|
if (ARCH MATCHES "amd64|x86_64")
|
|
|
|
set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-x86_64.cmake" CACHE INTERNAL "" FORCE)
|
|
|
|
elseif (ARCH MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)")
|
|
|
|
set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-aarch64.cmake" CACHE INTERNAL "" FORCE)
|
|
|
|
elseif (ARCH MATCHES "^(ppc64le.*|PPC64LE.*)")
|
|
|
|
set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-ppc64le.cmake" CACHE INTERNAL "" FORCE)
|
|
|
|
else ()
|
|
|
|
message (FATAL_ERROR "Unsupported architecture: ${ARCH}")
|
|
|
|
endif ()
|
2021-10-12 22:12:50 +00:00
|
|
|
|
2021-10-12 00:30:08 +00:00
|
|
|
endif()
|