C++ CMake不检测CXX,但检测CPP文件
我正试图从中学习CMake,但在运行简单文件tutorial.cpp的第一步中遇到了麻烦 问题是当我在CMakeLists.txt文件中有这个命令时C++ CMake不检测CXX,但检测CPP文件,c++,cmake,detect,C++,Cmake,Detect,我正试图从中学习CMake,但在运行简单文件tutorial.cpp的第一步中遇到了麻烦 问题是当我在CMakeLists.txt文件中有这个命令时 add_executable(Tutorial tutorial.cpp) 它建造得很好 但是,当我将其更改为 add_executable(Tutorial tutorial.cxx) 它给出了以下错误 -- Configuring done CMake Error at src/CMakeLists.txt:6 (add_executabl
add_executable(Tutorial tutorial.cpp)
它建造得很好
但是,当我将其更改为
add_executable(Tutorial tutorial.cxx)
它给出了以下错误
-- Configuring done
CMake Error at src/CMakeLists.txt:6 (add_executable):
Cannot find source file:
tutorial.cxx
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx
-- Build files have been written to: /home/vaisagh/workspace/Test/build
我的目录结构如下:
.
├── build
├── CMakeLists.txt
└── src
├── CMakeLists.txt
└── tutorial.cpp
2 directories, 3 files
CMakeLists.txt
#Specify the version being used aswell as the language
cmake_minimum_required(VERSION 2.8.11)
#Name your project here
project(Tutorial)
add_subdirectory(src)
#Specify the version being used aswell as the language
cmake_minimum_required(VERSION 2.8.11)
add_executable(Tutorial tutorial.cxx)
src/CMakeLists.txt
#Specify the version being used aswell as the language
cmake_minimum_required(VERSION 2.8.11)
#Name your project here
project(Tutorial)
add_subdirectory(src)
#Specify the version being used aswell as the language
cmake_minimum_required(VERSION 2.8.11)
add_executable(Tutorial tutorial.cxx)
tested extensions.c.c..
表示CMake试图搜索tutorial.cxx.c
,tutorial.cxx.c
等
指定给add_executable
的源文件名必须与光盘上的实际文件名匹配
tutorial.cpp
重命名为tutorial.cxx
-或-添加可执行文件(Tutorial Tutorial.cxx)
更改为添加可执行文件(Tutorial Tutorial.cpp)
谢谢如果使用第三种想法呢?将行更改为添加_可执行文件(教程),这样可以很好地构建项目。但我不确定这是否存在一些问题。我可以想象,如果您意外地在该目录中创建了
tutorial.c
文件,那么您的构建将根据CMake的后缀搜索顺序成功或失败。