[英]Change compiler called in makefile
I have a make file that currently uses cmake
to compile a collection of source files, but I would like to change it so it uses intel's c compiler. 我有一个make文件,当前使用
cmake
来编译源文件的集合,但是我想对其进行更改,以便它使用intel的c编译器。 Can I just change all the cmake
to icc
or...how would this be done? 我可以将所有
cmake
更改为icc
还是...如何完成?
Below is the make file as-is, it's from a crypto-mining daemon for bytecoin. 以下是按原样制作的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
I can post the other files it creates in /build after a normal build, if that would help, but I imagine whatever process I have to do to change the compiler would be the same for each MAKE file. 如果可以,我可以在正常构建后发布它在/ build中创建的其他文件,但是我想我为每个MAKE文件所做的更改编译器的过程将是相同的。
Otherwise, the rest of the source files can be found here: 否则,可以在这里找到其余的源文件:
https://github.com/amjuarez/bytecoin https://github.com/amjuarez/bytecoin
I am running Ubuntu 14.04. 我正在运行Ubuntu 14.04。
Thanks in advance! 提前致谢!
You specify your toolchain settings for CMake using a toolchain.txt
file with the -DCMAKE_TOOLCHAIN_FILE=path/to/file
on the first call of CMake, that generates the makefiles: 您可以在第一个CMake调用中使用带有
-DCMAKE_TOOLCHAIN_FILE=path/to/file
的toolchain.txt
文件来指定CMake的toolchain.txt
链设置,该文件将生成makefile:
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=<path_to>/toolchain.txt
There should be entries like 应该有像这样的条目
set(CMAKE_C_COMPILER /<your-toolchain-path>/gcc)
set(CMAKE_CXX_COMPILER /<your-toolchain-path>/g++)
in toolchain.txt
. 在
toolchain.txt
。
Typically CXX=<mycompiler> cmake
should do what you want. 通常,
CXX=<mycompiler> cmake
应该可以执行您想要的操作。 Or you can modify the toolchain files of the project, assuming you want to permanently make the change. 或者,假设您要永久进行更改,则可以修改项目的工具链文件。
This is my script that runs cmake to build llvm/clang with clang and clang++: 这是我的脚本,该脚本运行cmake用clang和clang ++构建llvm / clang:
CC=clang CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Release\
-DLLVM_ENABLE_ASSERTIONS=1 -DLLVM_TARGETS_TO_BUILD=X86 ../llvm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.