Mon*_*dji 2 ubuntu build cmake
系统:
Linux anon-S 3.19.0-31-generic #36~14.04.1-Ubuntu SMP Thu Oct 8 10:21:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
CMake版本:
anon@anon-S:~/$ cmake --version
cmake version 3.2.2
Run Code Online (Sandbox Code Playgroud)
主要CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 11)
add_subdirectory(${PROJECT_SOURCE_DIR}/src)
add_subdirectory(${PROJECT_SOURCE_DIR}/test)
Run Code Online (Sandbox Code Playgroud)
但
anon@anon-S:/home/anon/project/build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/anon/project/
Run Code Online (Sandbox Code Playgroud)
构建文件已写入:/home/anon/project/代替/home/anon/project/build/
我在使用cmake 3.4.1的Debian jessie上没有这个问题:
anon@anon-S:/home/anon/project/build$ cmake ..
-- The C compiler identification is GNU 5.2.1
-- The CXX compiler identification is GNU 5.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.11")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/anon/project/build/
Run Code Online (Sandbox Code Playgroud)
澄清这里发生的事情:
运行时cmake <directory>它会执行以下两项操作之一:
<directory>是源目录(即其中有一个CMakeLists.txt),它将在该源上运行CMake并使用当前工作目录作为构建目录.<directory>是构建目录(即其中有一个CMakeCache.txt),它将在用于创建构建目录的任何源目录上运行CMake.请注意,后一种情况优先于第一种情况.也就是说,如果您执行以下操作:
cd <src_dir>
cmake .
*oops, wrong directory, i didn't mean that*
cd build
cmake ..
Run Code Online (Sandbox Code Playgroud)
您可能希望这将<src_dir>作为源和build构建目录运行CMake .但是由于第一次意外的CMake运行,<src_dir>现在也是源内构建的构建目录!因此,第二次运行将忽略所有内容,build而是将其src_dir用作源目录和构建目录.
这确实是一个很讨厌的问题,但幸运的是,一旦你意识到发生了什么,可以很快得到解决:只要简单地除去CMakeCache.txt从<src_dir>.
| 归档时间: |
|
| 查看次数: |
1779 次 |
| 最近记录: |