I have a very similar problem, but the solution presented here is not really satisfactory.
Like the original poster, I want to run unit tests based on boost::test.
I have multiple test projects, one for each mayor component of our product.
Having to run the install target prior to every test means recompiling the whole thing just to run the tests belonging to a core component. That s what I want to avoid.
如果我改变核心部分,我想汇编这一核心组成部分和相关测试。 然后进行测试。 在试验成功时,我只想汇编和最终安装其余部分。
For running the tests in the debugger, I found some very useful cmake scripts at :
https://github.com/rpavlik/cmake-modules
通过这样做,我可以具体列出所需批量的所有目录,并为新进程设定太平洋建筑工程环境变量:
# for debugging
INCLUDE(CreateLaunchers)
create_target_launcher(PLCoreTests
ARGS "--run-test=Core1"
RUNTIME_LIBRARY_DIRS ${PL_RUNTIME_DIRS_DEBUG} ${PROJECT_BINARY_DIR}/bin/Debug
WORKING_DIRECTORY ${PL_MAIN_DIR}/App/PL/bin
)
如果P-1-PL_RUNTIME_DIRS_DEBUG} 包含有电梯和所有其他图书馆的名录。
现在我看一下我如何能够与捍卫民主力量取得类似的东西。 CUSTOM_COMMAND()
最新情况:
ADD_CUSTOM_COMMAND(ADD)可以有多个指挥系统,把碎打书写成批号。 因此,你可以先把这条道路与所有运行时间的名录连接起来,然后执行可执行的标准。 为了便于人工进行测试,I Letikake在建筑目录中另外添加了批号:
MACRO(RunUnitTest TestTargetName)
IF(RUN_UNIT_TESTS)
SET(TEMP_RUNTIME_DIR ${PROJECT_BINARY_DIR}/bin/Debug)
FOREACH(TmpRuntimeDir ${PL_RUNTIME_DIRS_DEBUG})
SET(TEMP_RUNTIME_DIR ${TEMP_RUNTIME_DIR} ${TmpRuntimeDir})
ENDFOREACH(TmpRuntimeDir)
ADD_CUSTOM_COMMAND(TARGET ${TestTargetName} POST_BUILD
COMMAND echo "PATH=${TEMP_RUNTIME_DIR};%PATH%" > ${TestTargetName}_script.bat
COMMAND echo ${TestTargetName}.exe --result_code=no --report_level=no >> ${TestTargetName}_script.bat
COMMAND ${TestTargetName}_script.bat
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug
)
ENDIF(RUN_UNIT_TESTS)
ENDMACRO()
因此,小组在不必首先汇编全部内容的情况下,尽快对错误进行检测。