From f2ddb60e33d54fb1a0a888cb1d5d124b5e6c04b4 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 15 Oct 2025 19:48:11 +0100 Subject: [PATCH] Use cmake CMAKE__COMPILER_LAUNCHER variables --- CMakeLists.txt | 7 ++++--- CMakeToolChainRPiClang.txt | 24 ++++++++++++++++-------- CMakeToolChainRPiGCC.txt | 23 +++++++++++++++++------ cmake.config.sample | 3 +++ 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b06dbe..97edaf4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,10 @@ if(CONFIG_CROSS_COMPILE) endif() endif() - +if(CONFIG_COMPILER_LAUNCHER) + set(CMAKE_C_COMPILER_LAUNCHER ${CONFIG_COMPILER_LAUNCHER}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CONFIG_COMPILER_LAUNCHER}) +endif() set (VOMP_OBJ_COMMON src/gitinfo.cc @@ -189,8 +192,6 @@ set (PNG_FILES project(vomp) add_executable(vomp ${VOMP_OBJ_COMMON} ${VOMP_OBJ_RASPBERRY} pngs.o) -# set(CMAKE_CXX_COMPILER_LAUNCHER "distcc") - not until cmake 3.17! - list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) include(gitinfo) GitInfo(${CMAKE_SOURCE_DIR}) diff --git a/CMakeToolChainRPiClang.txt b/CMakeToolChainRPiClang.txt index 733904e..ff6e441 100644 --- a/CMakeToolChainRPiClang.txt +++ b/CMakeToolChainRPiClang.txt @@ -1,19 +1,27 @@ set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_FIND_ROOT_PATH /pi-root) -set(CMAKE_SYSROOT /pi-root) +set(CMAKE_FIND_ROOT_PATH /opt/piroot10) +set(CMAKE_SYSROOT /opt/piroot10) # Clang -#set(CMAKE_C_COMPILER "/usr/bin/clang-11") -#set(CMAKE_CXX_COMPILER "/usr/bin/clang++-11") -set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/../compiler") -set(CMAKE_CXX_COMPILER "${CMAKE_BINARY_DIR}/../compiler") + +# System cross compiler +set(CMAKE_C_COMPILER "/usr/bin/clang-11") +set(CMAKE_CXX_COMPILER "/usr/bin/clang++-11") set(CMAKE_LINKER /usr/bin/arm-linux-gnueabihf-ld) -set(CMAKE_C_FLAGS "-target arm-linux-gnueabihf -mfloat-abi=hard -mcpu=cortex-a7") + +# CT-NG cross compiler +#set(CMAKE_C_COMPILER ?) +#set(CMAKE_CXX_COMPILER ?) +#set(CMAKE_LINKER ?) + + +# Pi1: -mtune=arm1176jzf-s Pi2: -mtune=cortex-a7 Pi3: -mtune=cortex-a53 + +set(CMAKE_C_FLAGS "-target arm-linux-gnueabihf -mfloat-abi=hard -mcpu=cortex-a7") set(CMAKE_CXX_FLAGS "-target arm-linux-gnueabihf -mfloat-abi=hard -mcpu=cortex-a7") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/CMakeToolChainRPiGCC.txt b/CMakeToolChainRPiGCC.txt index 4a14672..e13e47e 100644 --- a/CMakeToolChainRPiGCC.txt +++ b/CMakeToolChainRPiGCC.txt @@ -1,16 +1,27 @@ set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_FIND_ROOT_PATH /pi-root) -set(CMAKE_SYSROOT /pi-root) +set(CMAKE_FIND_ROOT_PATH /opt/piroot10) +set(CMAKE_SYSROOT /opt/piroot10) # GCC -set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc) -set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++) -set(CMAKE_C_FLAGS "-Wno-psabi -mtune=cortex-a7 -mfloat-abi=hard -fopenmp") -set(CMAKE_CXX_FLAGS "-Wno-psabi -mtune=cortex-a7 -mfloat-abi=hard -fopenmp") + +# System cross compiler +#set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc) +#set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++) +#set(CMAKE_LINKER /usr/bin/arm-linux-gnueabihf-ld) + +# CT-NG cross compiler +set(CMAKE_C_COMPILER /opt/xcomp-pi3-ros10/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-gcc) +set(CMAKE_CXX_COMPILER /opt/xcomp-pi3-ros10/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-g++) +set(CMAKE_LINKER /opt/xcomp-pi3-ros10/arm-unknown-linux-gnueabihf/bin/arm-unknown-linux-gnueabihf-ld) + # Pi1: -mtune=arm1176jzf-s Pi2: -mtune=cortex-a7 Pi3: -mtune=cortex-a53 +set(CMAKE_C_FLAGS "-Wno-psabi -mtune=cortex-a53 -mfloat-abi=hard -fopenmp") +set(CMAKE_CXX_FLAGS "-Wno-psabi -mtune=cortex-a53 -mfloat-abi=hard -fopenmp") + + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) diff --git a/cmake.config.sample b/cmake.config.sample index 3fd4903..f285c43 100644 --- a/cmake.config.sample +++ b/cmake.config.sample @@ -4,6 +4,9 @@ set(CONFIG_CROSS_COMPILE no) # Set cross compiler. Options: gcc clang set(CONFIG_CROSS_COMPILER gcc) +# Set compiler launcher e.g. for distcc or ccache +# set(CONFIG_COMPILER_LAUNCHER /usr/bin/distcc) + # Use mold for linker? (Only possible if compiler is clang) set(CONFIG_ENABLE_MOLD no) set(CONFIG_MOLD_BIN /opt/mold/bin/mold) -- 2.39.5