我将尝试为您提供帮助:如何检查构建目标?
请考虑以下CMake脚本:
cmake_minimum_required(VERSION 3.5.1)
project(cppTests)
# How to check at this point the target of build
if(TARGET "cppTests")
message(STATUS "Target is cppTests")
else()
message(STATUS "Target is not cppTests")
endif()
message(STATUS "Target is ${TARGET}")
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(cppTests ${SOURCE_FILES})
然后我调用以下内容:
/home/username/Software/clion-2017.1.1/bin/cmake/bin/cmake --build /home/username/Projects/cppTests/cmake-build-debug --target cppTests -- -j 8
如何在CMake脚本中使用 --target 选项后检查目标 cppTests?我想要类似 Makefiles 中的 MAKECMDGOALS 的东西。我找不到任何有用的解决方案...