相关疑难解决方法(0)

CMake并添加测试程序命令

我通常使用makefile进行项目,但我想开始学习CMake.我使用makefile不仅用于构建我的项目,还用于测试我的项目.这非常有用.我怎么能用CMake做到这一点?

例如,这个makefile:

pathword=words.txt
flags=-std=c++11 -Wall -Wextra -g -Og
#flags=-std=c++11 -O3 -DNDEBUG -s

default: TextMiningCompiler TextMiningApp

TextMiningCompiler: TextMiningCompiler.cpp trie.cpp
    g++ $(flags) TextMiningCompiler.cpp trie.cpp -o TextMiningCompiler

TextMiningApp: TextMiningApp.cpp
    g++ $(flags) TextMiningApp.cpp -o TextMiningApp

run: TextMiningCompiler TextMiningApp
    ./TextMiningCompiler $(pathword) totoro.txt
    cat test.txt | time ./TextMiningApp totoro.txt

clean:
    trash TextMiningCompiler TextMiningApp
Run Code Online (Sandbox Code Playgroud)

我做了这个CMakefile:

cmake_minimum_required(VERSION 2.8.9)
project (TextMining)
add_executable(TextMiningApp TextMiningApp.cpp)
add_executable(TextMiningCompiler TextMiningCompiler.cpp trie.cpp read_words_file.cpp)
set_property(TARGET TextMiningApp PROPERTY CXX_STANDARD 11)
set_property(TARGET TextMiningCompiler PROPERTY CXX_STANDARD 11)
Run Code Online (Sandbox Code Playgroud)

我怎样才能拥有make run功能?或其他自定义功能?

makefile cmake

6
推荐指数
2
解决办法
7679
查看次数

在cmake中集成bash测试脚本

我有一个C++ cmake项目,它使用Boost Test进行单元测试.现在我想向cmake公开一系列bash脚本(用于集成测试).假设每个脚本在PASS或其他情况下返回0 !如果是FAILURE,则返回0 = 0 .我希望每次运行时都会执行每个脚本cmake test.

获得此类行为的最简单,最快捷的方法是什么

c++ bash cmake

3
推荐指数
1
解决办法
2215
查看次数

标签 统计

cmake ×2

bash ×1

c++ ×1

makefile ×1