CMake 不生成 .exe 文件

age*_*nel 6 c++ cmake

我已经构建了一个基于 C++ 的 CERN 的 ROOT 脚本,并且我编写了(编辑一个示例)CMakeList.txt。顺便说一句,我在 CMake 上很菜鸟。当我命令使用 编译时cmake ..,它正确完成 -我认为 - 没有错误。但是没有出现我想要生成的 .exe 文件。我的目录订单

/Project
../TLV.cpp  
../CMakeLists.txt
../build
Run Code Online (Sandbox Code Playgroud)

有我的 CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project(TLV)
#Set CXX flags to compile with c++11 and error warnings quiet
set(CMAKE_CXX_FLAGS "-O3 -fPIC -Wall -Wextra -std=c++11 -m64")

#Load root 
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} $ENV{ROOTSYS}/etc/cmake)
#print conf
message(STATUS "Environmental CMAKE_MODULE_PATH is $ENV{ROOTSYS}")
#find the package with extra libraries needed
find_package(ROOT MODULE REQUIRED Cling TreePlayer Tree Rint Postscript Matrix RIO Core Foam RooStats RooFit RooFitCore Gpad Graf3d Graf Hist Net TMVA  XMLIO MLP)
#include ROOT stuff
include(${ROOT_USE_FILE})
message(STATUS "Environmental ROOTSYS is $ENV{ROOTSYS}")
message(STATUS "found root at: ${ROOT_USE_FILE}")
message(STATUS "ROOT_LIBRARIES=${ROOT_LIBRARIES}")


#produce executables in bin path
set(EXECUTABLE_OUTPUT_PATH bin)
#include_directories(./../Framework Headers)
#${FROM_OTHERS_INCLUDE})
#defines all .cpp support class with corresponding Headers
#file(GLOB SRCS Sources/*.cpp Headers/*.hpp )
#${FROM_OTHERS_HEADER} ${FROM_OTHERS_SOURCE})

#add executable 
add_executable( TLV    TLV.cpp  )

#link the executable with the root libraries
target_link_libraries(TLV ${ROOT_LIBRARIES})
Run Code Online (Sandbox Code Playgroud)

我不明白我错在哪里。

Sco*_*and 7

使用 cmake 的项目的典型场景是

cd src_directory   # for example  cd ~/src/root-6.08.06/
mkdir build        # skip this if dir build already exists
cd build
cmake ..           #  the .. just says your source home dir is up a dir
cmake-gui ..       # (optional) skip this unless you need a GUI alternative to cmake where you can edit settings
cmake --build      # if you have a quad core CPU could use: make -j8 ... or make -j $(nproc) # on linux
Run Code Online (Sandbox Code Playgroud)

然后启动二进制文件并确认其确定然后如果需要使用安装它

sudo make install
Run Code Online (Sandbox Code Playgroud)

  • 除了`make`,也可以建议使用`cmake --build`。后者不依赖于使用的是 ninja 还是 gnu make。 (3认同)
  • 天啊。我有很多关于 linux 和这些东西的东西要学习。谢谢 (2认同)