如果我在CMake中使用clang编译器,我想为每个可能的调用添加-cc1
选项(更好:仅针对某个目标)
我尝试使用
set(CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER} -cc1")
但是这会将引用包含在引号中;因此,我的shell中不会将其识别为有效命令。
如果我使用
set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} -cc1)
然后我在clang调用和-cc1
选项之间得到一个分号。这也行不通。
如何让CMake将/path/to/clang
更改为/path/to/clang -cc1
?
答案 0 :(得分:0)
请参阅:cmake CFLAGS CXXFLAGS modification
target_compile_options(target -cc1)
对于单个目标:
private Node insert(Node newNode, String newWord){
if(newNode == null){
newNode = new Node(newWord);
}
else if (newWord.compareToIgnoreCase(newNode.getReservedWord()) < 0){
newNode.setlChild(insert(newNode.getlChild(), newWord));
if(depth(newNode.getlChild()) - depth(newNode.getrChild()) == 2){
if(newWord.compareToIgnoreCase(newNode.getlChild().getReservedWord()) < 0){
newNode = rotateWithLeftChild(newNode);
}
else{
newNode = doubleWithLeftChild(newNode);
}
}
}
else if (newWord.compareToIgnoreCase(newNode.getReservedWord()) > 0){
newNode.setrChild(insert(newNode.getrChild(), newWord));
if(depth(newNode.getrChild()) - depth(newNode.getlChild()) == 2){
if(newWord.compareToIgnoreCase(newNode.getrChild().getReservedWord()) > 0){
newNode = rotateWithRightChild(newNode);
}
else{
newNode = doubleWithRightChild(newNode);
}
}
}
else;
newNode.setDepth(max(depth(newNode.getlChild()), depth(newNode.getrChild()) + 1));
/*if(!this.getAllNodes().contains(newNode)){
this.getAllNodes().add(newNode);
}*/
return newNode;
}
private Node rotateWithLeftChild(Node nodeToRotate){
Node newNode = nodeToRotate.getlChild();
nodeToRotate.setlChild(newNode.getrChild());
newNode.setrChild(nodeToRotate);
nodeToRotate.setDepth(max(depth(nodeToRotate.getlChild()), depth(nodeToRotate.getrChild()) + 1));
newNode.setDepth(max(depth(newNode.getlChild()), nodeToRotate.getDepth() + 1));
return newNode;
}
private Node rotateWithRightChild(Node nodeToRotate){
Node newNode = nodeToRotate.getrChild();
nodeToRotate.setrChild(newNode.getlChild());
newNode.setlChild(nodeToRotate);
nodeToRotate.setDepth(max(depth(nodeToRotate.getlChild()), depth(nodeToRotate.getrChild()) + 1));
newNode.setDepth(max(depth(newNode.getrChild()), nodeToRotate.getDepth() + 1));
return newNode;
}
private Node doubleWithLeftChild(Node nodeToRotate){
nodeToRotate.setlChild(rotateWithRightChild(nodeToRotate.getlChild()));
return rotateWithLeftChild(nodeToRotate);
}
private Node doubleWithRightChild(Node nodeToRotate){
nodeToRotate.setrChild(rotateWithLeftChild(nodeToRotate.getrChild()));
return rotateWithRightChild(nodeToRotate);
}
答案 1 :(得分:0)
针对特定于clang的需求的一种解决方法是使用-Xclang
编译器选项,该选项强制clang驱动程序将其后面的选项传递给clang -cc1
。
例如:
target_compile_options(${target} PUBLIC "-Xclang -include-pch ${output}")