在makefile中调用了更改编译器

Change compiler called in makefile

本文关键字:编译器 调用 makefile      更新时间:2023-10-16

我有一个make文件,它当前使用cmake编译一组源文件,但我想更改它,使其使用英特尔的c编译器。我可以把所有的cmake都改成icc吗?或者。。。如何做到这一点?

下面是make文件,它来自字节币的加密挖矿守护进程。

all: all-release
cmake-debug:
    mkdir -p build/debug
    cd build/debug && cmake -D CMAKE_BUILD_TYPE=Debug ../..
build-debug: cmake-debug
    cd build/debug && $(MAKE)
test-debug: build-debug
    cd build/debug && $(MAKE) test
all-debug: build-debug
cmake-release:
    mkdir -p build/release
    cd build/release && cmake -D CMAKE_BUILD_TYPE=Release ../..
build-release: cmake-release
    cd build/release && $(MAKE)
test-release: build-release
    cd build/release && $(MAKE) test
all-release: build-release
clean:
    rm -rf build
tags:
    ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest
.PHONY: all cmake-debug build-debug test-debug all-debug cmake-release build-release test-release all-release clean tags

如果有帮助的话,我可以在正常构建后发布它在/build中创建的其他文件,但我想无论我要做什么来更改编译器,每个MAKE文件都是一样的。

否则,其余的源文件可以在这里找到:

https://github.com/amjuarez/bytecoin

我运行的是Ubuntu 14.04。

提前感谢!

在第一次调用CMake时,使用带有-DCMAKE_TOOLCHAIN_FILE=path/to/filetoolchain.txt文件为CMake指定工具链设置,生成makefiles:

cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=<path_to>/toolchain.txt

应该有类似的条目

set(CMAKE_C_COMPILER /<your-toolchain-path>/gcc)
set(CMAKE_CXX_COMPILER /<your-toolchain-path>/g++)

在CCD_ 6中。

通常CXX=<mycompiler> cmake应该执行您想要的操作。或者,您可以修改项目的工具链文件,假设您想永久性地进行更改。

这是我的脚本,它运行cmake来构建带有clang和clang++的llvm/crang:

CC=clang CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_ASSERTIONS=1  -DLLVM_TARGETS_TO_BUILD=X86 ../llvm