vscode-cmake-tools: cmake.getLaunchTargetFilename is broken

Bug

If I use ${command:getLaunchTargetFilename} in my task.json I get the following error:

[main] =======================================================
[main] No executable target was found to launch. Please check:
[main]  - Have you called add_executable() in your CMake project?
[main]  - Have you executed a successful CMake configure?
[main] No program will be executed

More Detail

This task.json

{
	// See https://go.microsoft.com/fwlink/?LinkId=733558
	// for the documentation about the tasks.json format
	"version": "2.0.0",
	"tasks": [
		{
			"label": "echo",
			"type": "shell",
			"command": "echo 'buildTargetName: ${command:cmake.buildTargetName}\nbuildType: ${command:cmake.buildType}\ntasksBuildCommand: ${command:cmake.tasksBuildCommand}\nbuildDirectory: ${command:cmake.buildDirectory}\n'"
		}
	]
}

has the following output

buildTargetName: model_test
buildType: Debug
tasksBuildCommand: /usr/bin/cmake --build /home/fbenning/code/grazer/Debug --config Debug --target model_test -- -j 10
buildDirectory: /home/fbenning/code/grazer/Debug

pressing the build button works without error, and executing ./Debug/.../model_test manually works as well. (i.e. the file exists!)

additionally the CMakeLists.txt includes add_executable(model_test ModelTest.cpp).

(Possibly) Related Issues

Platform and Versions

  • Operating System: Ubuntu
  • CMake Version: 3.16.3
  • VSCode Version:1.53.2
  • CMake Tools Extension Version:1.6.0
  • Compiler/Toolchain: GCC 9.3.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (13 by maintainers)

Most upvoted comments

After a lot of attempt, I finally located the reason: In CMakeLists.txt, I wrote set(CMAKE_BUILD_TYPE DEBUG) for my project, maybe this command disturbed the parsing of CMakeCache.txt for cmake-tools? after annotating the line and rebuilding, everything worked normally : ) and I realized CMAKE_BUILD_TYPE possible value should be Debug instead of DEBUG…but it looks like DEBUG is acceptable for cmake as I can use gdb with my bin…well @andreeis @FelixBenning thank you for your help