Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake.getLaunchTargetFilename is broken #1692

Closed
FelixBenning opened this issue Mar 2, 2021 · 23 comments
Closed

cmake.getLaunchTargetFilename is broken #1692

FelixBenning opened this issue Mar 2, 2021 · 23 comments

Comments

@FelixBenning
Copy link

FelixBenning commented Mar 2, 2021

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
@andreeis
Copy link
Contributor

andreeis commented Mar 2, 2021

Do you have a "Debug" target selected? It may differ from the build target. Use the command "CMake: Set as Launch/Debug target" in the palette.

@FelixBenning
Copy link
Author

FelixBenning commented Mar 2, 2021

image

I already used that, but it did appear to do nothing. It simply closed the palette after pressing enter and nothing appeared to change.

Also what do you mean with

Do you have a "Debug" target selected?

"Debug" is the cmake.BuildType. And with "cmake.buildDirectory":"${workspaceFolder}/${buildType}" it also becomes the buildDirectory

@andreeis
Copy link
Contributor

andreeis commented Mar 2, 2021

Does your project configure successfully?
Any other commands in the palette behave the same?
Maybe you can share a repro?

@FelixBenning
Copy link
Author

  • The project configures successfully
  • not sure, I am not heavily using the palette to be honest. Running tasks seems to work fine though. Anything you would like me to try?
  • https://github.com/eike-fokken/grazer in the new_input_for_gas branch with the build target model_test

@andreeis
Copy link
Contributor

andreeis commented Mar 2, 2021

I cloned your branch and on windows the debug target setting works fine for me. I will try on linux later (I need to re-setup a system).
Maybe something caused by your VSCode installation, or is it out of date...

Thinking what else you can try.... Set "loggingLevel" to "Debug" in your .vscode/settings.json, clean the "CMake/Build" output channel, run the "CMake: Set Debug Target" (maybe use the mouse instead of enter? shouldn't matter but let's try) and hopefully something interesting is logged in the output channel when you do this?

@FelixBenning
Copy link
Author

FelixBenning commented Mar 3, 2021

So this morning I set the cmake.loggingLevel to debug, I deleted the Debug Folder, selected the build variant again to trigger configuration, pressed the Build button and tried the debug button again - this time it worked....

Output from pressing the `Build` Button
[main] Building folder: grazer 
[main] Saving open files before configure/build
[driver] Runnnig pre-configure checks and steps
[build] Starting build
[driver] Start build model_test
[driver] Runnnig pre-configure checks and steps
[proc] Executing command: /usr/bin/cmake --build /home/fbenning/code/grazer/Debug --config Debug --target model_test -- -j 10
[build] [10/61   1% :: 2.249] Building CXX object src/Exception/CMakeFiles/exception.dir/Exception.cpp.o
[build] [11/61   3% :: 3.277] Linking CXX static library src/Exception/libexception.a
[build] [12/61   4% :: 5.150] Building CXX object googletest/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[build] [13/61   6% :: 9.094] Building CXX object src/Model/Network/CMakeFiles/network.dir/Idobject.cpp.o
[build] [14/61   8% :: 10.163] Building CXX object src/Model/Network/CMakeFiles/network.dir/Edge.cpp.o
[build] [15/61   9% :: 10.509] Building CXX object src/Model/Network/CMakeFiles/network.dir/Net.cpp.o
[build] [16/61  11% :: 11.363] Building CXX object googletest/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
[build] [17/61  13% :: 12.688] Building CXX object src/Model/Problemlayer/CMakeFiles/problemlayer.dir/Subproblem.cpp.o
[build] [18/61  14% :: 12.981] Building CXX object src/Model/Network/CMakeFiles/network.dir/Node.cpp.o
[build] [19/61  16% :: 13.104] Building CXX object src/Model/Problemlayer/CMakeFiles/problemlayer.dir/Subproblemchooser.cpp.o
[build] [20/61  18% :: 13.925] Building CXX object src/Model/Problemlayer/CMakeFiles/problemlayer.dir/Timeevolver.cpp.o
[build] [21/61  19% :: 14.408] Linking CXX static library src/Model/Network/libnetwork.a
[build] [22/61  21% :: 17.241] Building CXX object googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[build] [23/61  22% :: 18.529] Building CXX object src/Model/Problemlayer/CMakeFiles/problemlayer.dir/Problem.cpp.o
[build] [24/61  24% :: 18.840] Linking CXX static library lib/libgtestd.a
[build] [25/61  26% :: 19.838] Linking CXX static library lib/libgmockd.a
[build] [26/61  27% :: 20.643] Linking CXX static library lib/libgtest_maind.a
[build] [27/61  29% :: 23.210] Building CXX object src/Model/Networkproblem/Equationcomponent/CMakeFiles/equationcomponent.dir/Equationcomponent.cpp.o
[build] [28/61  31% :: 24.350] Building CXX object src/Model/Networkproblem/CMakeFiles/networkproblem.dir/Networkproblem_helpers.cpp.o
[build] [29/61  32% :: 27.121] Building CXX object src/Model/Networkproblem/Power/CMakeFiles/power.dir/PQnode.cpp.o
[build] [30/61  34% :: 27.953] Building CXX object src/Model/Networkproblem/CMakeFiles/networkproblem.dir/Networkproblem.cpp.o
[build] [31/61  36% :: 28.169] Building CXX object src/Model/Networkproblem/Power/CMakeFiles/power.dir/PVnode.cpp.o
[build] [32/61  37% :: 28.587] Building CXX object src/Model/Networkproblem/Power/CMakeFiles/power.dir/Vphinode.cpp.o
[build] [33/61  39% :: 29.629] Building CXX object src/Model/Networkproblem/Power/CMakeFiles/power.dir/Transmissionline.cpp.o
[build] [34/61  40% :: 29.904] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Gasnode.cpp.o
[build] [35/61  42% :: 31.613] Building CXX object src/Model/Networkproblem/Power/CMakeFiles/power.dir/Powernode.cpp.o
[build] [36/61  44% :: 36.143] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Source.cpp.o
[build] [37/61  45% :: 39.361] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Sink.cpp.o
[build] [38/61  47% :: 39.529] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Pressureboundarynode.cpp.o
[build] [39/61  49% :: 39.701] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Innode.cpp.o
[build] [40/61  50% :: 40.441] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Gasedge.cpp.o
[build] [41/61  52% :: 41.061] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Flowboundarynode.cpp.o
[build] [42/61  54% :: 42.994] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Shortpipe.cpp.o
[build] [43/61  55% :: 43.142] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Compressorstation.cpp.o
[build] [44/61  57% :: 44.248] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Shortcomponent.cpp.o
[build] [45/61  59% :: 45.862] Building CXX object src/Auxillary/Mathfunctions/CMakeFiles/mathfunctions.dir/Mathfunctions.cpp.o
[build] [46/61  60% :: 46.442] Building CXX object src/Auxillary/Misc/CMakeFiles/misc.dir/Misc.cpp.o
[build] [47/61  62% :: 46.699] Linking CXX static library src/Auxillary/Mathfunctions/libmathfunctions.a
[build] [48/61  63% :: 47.050] Linking CXX static library src/Auxillary/Misc/libmisc.a
[build] [49/61  65% :: 47.274] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Controlvalve.cpp.o
[build] [50/61  67% :: 47.534] Linking CXX static library src/Model/Networkproblem/Equationcomponent/libequationcomponent.a
[build] [50/61  68% :: 50.306] Building CXX object src/Auxillary/Matrixhandler/CMakeFiles/matrixhandler.dir/Matrixhandler.cpp.o
[build] [51/61  70% :: 50.826] Building CXX object src/Model/Scheme/CMakeFiles/scheme.dir/Implicitboxscheme.cpp.o
[build] [51/61  72% :: 50.897] Linking CXX static library src/Auxillary/Matrixhandler/libmatrixhandler.a
[build] [52/61  73% :: 52.114] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Gaspowerconnection.cpp.o
[build] [52/61  75% :: 52.134] Linking CXX static library src/Model/Networkproblem/Power/libpower.a
[build] [52/61  77% :: 54.471] Building CXX object src/Model/Balancelaw/CMakeFiles/balancelaw.dir/Isothermaleulerequation.cpp.o
[build] [53/61  78% :: 54.955] Linking CXX static library src/Model/Balancelaw/libbalancelaw.a
[build] [54/61  80% :: 55.268] Linking CXX static library src/Model/Scheme/libscheme.a
[build] [54/61  81% :: 56.134] Building CXX object src/Model/Networkproblem/Componentfactory/CMakeFiles/componentfactory.dir/Componentfactory.cpp.o
[build] [54/61  83% :: 56.581] Building CXX object src/Auxillary/aux_json/CMakeFiles/aux_json.dir/Aux_json.cpp.o
[build] [55/61  85% :: 56.822] Linking CXX static library src/Auxillary/aux_json/libaux_json.a
[build] [55/61  86% :: 57.573] Building CXX object src/Model/Networkproblem/Gas/CMakeFiles/gas.dir/Pipe.cpp.o
[build] [56/61  88% :: 58.962] Linking CXX static library src/Model/Networkproblem/Gas/libgas.a
[build] [57/61  90% :: 59.255] Linking CXX static library src/Model/Networkproblem/Componentfactory/libcomponentfactory.a
[build] [57/61  91% :: 61.622] Building CXX object testingWithGoogle/CMakeFiles/model_test.dir/ModelTest.cpp.o
[build] [57/61  93% :: 62.516] Building CXX object src/Newtonsolver/CMakeFiles/newton.dir/Newtonsolver.cpp.o
[build] [58/61  95% :: 62.838] Linking CXX static library src/Newtonsolver/libnewton.a
[build] [59/61  96% :: 63.152] Linking CXX static library src/Model/Networkproblem/libnetworkproblem.a
[build] [60/61  98% :: 63.520] Linking CXX static library src/Model/Problemlayer/libproblemlayer.a
[build] [61/61 100% :: 64.305] Linking CXX executable testingWithGoogle/model_test
[cmakefileapi-parser] Read reply folder: /home/fbenning/code/grazer/Debug/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-5580ab367d497d988d24.json","codemodel-v2-40e8f566642347e654a7.json","index-2021-03-03T09-09-19-0818.json","target-aux_json-Debug-fad2df248efba36b0eda.json","target-balancelaw-Debug-eb3801866d0fe780583c.json","target-boundaryprettyfy-Debug-84af2451cd3cbe3c993f.json","target-cclean-Debug-20c6107dca651eac352c.json","target-componentfactory-Debug-3040ce38843862774387.json","target-docs-Debug-0e21a3f4e2b9bd815c3f.json","target-equationcomponent-Debug-be4ca00d2be8dafaa2d4.json","target-exception-Debug-bb2524ecf39d7baab476.json","target-gas-Debug-232b245635570882c086.json","target-gas_test-Debug-13fef6f70bd7bbe13728.json","target-gmock-Debug-aae0c9fc88f0ac95e8ec.json","target-gmock_main-Debug-afda1a1bd83032e7539f.json","target-grazer-Debug-ccb2fa2458ba0cdd00a0.json","target-gtest-Debug-c483bb1df46e411e5201.json","target-gtest_main-Debug-3e6b66893d148df28a09.json","target-implicitboxscheme_test-Debug-567bb3ac9b2296e04348.json","target-input_output-Debug-0416249a54f8697a8b8e.json","target-isothermaleulerequation_test-Debug-17fb9f3dab211966b86d.json","target-mathfunctions-Debug-df2f68bd18d132ac46e4.json","target-matrixhandler-Debug-c3d34571ed396043b820.json","target-misc-Debug-711a1a9e7bdca282fb19.json","target-model_test-Debug-53e844fd148c50e7099c.json","target-net_test-Debug-eff14d228fd9093cd665.json","target-network-Debug-1f261446b9580f5cfec9.json","target-networkproblem-Debug-1b0b4f45dc743f259cec.json","target-newton-Debug-ee33706d9e9f449f6180.json","target-newton_test-Debug-1cc476ac8e874c3d01ee.json","target-power-Debug-f15a43fbcd48e132dc7f.json","target-power_test-Debug-e7cf173d6bea365e078b.json","target-problemlayer-Debug-363a3b82dd521265da93.json","target-scheme-Debug-dfdf6a47f16e60baca92.json","target-transform_boundary-Debug-7942bb2f21feee9f0838.json"]
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[build] Build finished with exit code 0
[extension] [6199] cmake.build finished (returned 0)
[cache] Reading CMake cache file /home/fbenning/code/grazer/Debug/CMakeCache.txt
[cache] Parsing CMake cache string

I guess I'll see if the error occurs at some point in the future again.

@andreeis thank you for your help ❤️

@andreeis
Copy link
Contributor

andreeis commented Mar 3, 2021

Glad that you are unblocked now. Reactivate this report if this happens again and when you do copy paste the "Debug" logging from the "CMake/Build" ouput channel after you press debug.

@andreeis andreeis closed this as completed Mar 3, 2021
@hhx0202
Copy link

hhx0202 commented Mar 4, 2021

So this morning I set the cmake.loggingLevel to debug, I deleted the Debug Folder, selected the build variant again to trigger configuration, pressed the Build button and tried the debug button again - this time it worked....

Output from pressing the Build Button
I guess I'll see if the error occurs at some point in the future again.

@andreeis thank you for your help ❤️

Hi, I had the same issue like you. What's the "Debug Folder" ? I wish it work for me too. Tks.
I copyed the task.json from your comment and added "launchTargetPath: ${command:cmake.launchTargetPath}\ngetLaunchTargetDirectory: ${command:cmake.getLaunchTargetDirectory}" to tail of command, it seems the launchTargetPath and getLaunchTargetDirectory were all NULL, because there were no additional output after "buildDirectory:", only empty lines.
And when I replaced launchTargetPath and getLaunchTargetDirectory with the real path in launch.json, then the F5 worked normally.
Besides, I have another project with exactly the same launch.json and CMakelist.txt format, of which F5 worked well, so I guess maybe there are some authority issues I can't figure out
@andreeis any clue?

@andreeis
Copy link
Contributor

andreeis commented Mar 4, 2021

@hhx0202, verify that you have a debug target set. Run the command "CMake: Set Debug Target" in the palette and chose which binary you wish to debug (the one launchTargetPath is supposed to point to). Then the commands should work.

@hhx0202
Copy link

hhx0202 commented Mar 4, 2021

@andreeis My project only has one bin, and I had tried to set the target but it still seemed useless, and every time the drop-down box always let me type the target name(offer no options)
bad

and meanwhile in the well-worked project, I can directly choose [all] or [name] as target, and in fact the default [all] works fine for me
good

@andreeis
Copy link
Contributor

andreeis commented Mar 4, 2021

The default "all" is a build target, not a debug target. There are different buttons to select each but sometimes the button to select the debug target is hidden and so I don't confuse you with it I suggested the command "CMake: Set Debug Target" (notice there is also a command "CMake: Set Build Target").
You say the "Set Debug Target" command opens a quickPick that is empty. Maybe your project did not configure or failed? Run configure again "CMake: Configure" and inspect the status code in the "CMake/Build" output channel.

@andreeis
Copy link
Contributor

andreeis commented Mar 4, 2021

Oh I just noticed, your failing project is localized. Maybe you selected the wrong command when translated (or more probably we translated wrong)? I searched for the text "Enter a target name" that I see in your image. That's not invoked when setting the debug target, but when setting the build target.

@bobbrow
Copy link
Member

bobbrow commented Mar 4, 2021

Yes, the log says cmake.setDefaultTarget started in the broken screenshot. That is selecting a build target. In the working screenshot, there is a cmake.selectLaunchTarget started in the log.

@bobbrow
Copy link
Member

bobbrow commented Mar 4, 2021

It could also be that the in non-working project, you have an older version of CMake (<= 3.7) or cmake.communicationMode set to "legacy" which means that our extension is not aware of any debuggable targets and you have to type in the launch target yourself.

@FelixBenning
Copy link
Author

Hi, I had the same issue like you. What's the "Debug Folder" ? I wish it work for me too. Tks. - @hhx0202

Instead of building every build type in the same build folder I used this "cmake.buildDirectory":"${workspaceFolder}/${buildType}" in the settings. This means that every buildType (Debug, Release,...) gets its own directory. If you did not do something like this, you probably just have to delete the build folder.

(Maybe I also restarted vscode)

@hhx0202
Copy link

hhx0202 commented Mar 5, 2021

@FelixBenning oh, I had deleted the build/ folder and re-build but not woked, thanks anyway

@andreeis
I had restarted the ubuntu and vs code, deleted the entire build/ folder, and re-config, re-build the project, run the command "CMake: Set Debug Target", but it still not worked
bad2
log here:

[main] Configuring folder: CtApStateMonitor 
[main] Saving open files before configure/build
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[driver] Start configure 
[driver] Runnnig pre-configure checks and steps
[driver] Using compilers in GCC 4.8.5 for configure
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[cmakefileapi-driver] Invoking CMake /usr/local/bin/cmake with arguments ["--no-warn-unused-cli","-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","-DCMAKE_BUILD_TYPE:STRING=Debug","-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-4.8","-DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-4.8","-H/home/liuyi/Desktop/CppTst/CtApStateMonitor","-B/home/liuyi/Desktop/CppTst/CtApStateMonitor/build","-G","Unix Makefiles"]
[proc] Executing command: /usr/local/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-4.8 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-4.8 -H/home/liuyi/Desktop/CppTst/CtApStateMonitor -B/home/liuyi/Desktop/CppTst/CtApStateMonitor/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 4.8.5
[cmake] -- The CXX compiler identification is GNU 4.8.5
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: /usr/bin/gcc-4.8 - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /usr/bin/g++-4.8 - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] /home/liuyi/Desktop/CppTst/CtApStateMonitor/Implementation_Templates/CtApStateMonitor.c
[cmake] /home/liuyi/Desktop/CppTst/CtApStateMonitor/Implementation_Templates/FltRec_fun.c
[cmake] /home/liuyi/Desktop/CppTst/CtApStateMonitor/forTest.cpp
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/liuyi/Desktop/CppTst/CtApStateMonitor/build
[cmakefileapi-parser] Read reply folder: /home/liuyi/Desktop/CppTst/CtApStateMonitor/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-f9bc208a6a5259395fc9.json","codemodel-v2-8e7cc81d89fe26b44194.json","index-2021-03-05T01-36-54-0581.json","target-stateMonitor-DEBUG-e9e38f41554290e2f2f5.json"]
[cache] Reading CMake cache file /home/liuyi/Desktop/CppTst/CtApStateMonitor/build/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [4301] cmake.configureAll finished (returned 0)


[main] Building folder: CtApStateMonitor 
[main] Saving open files before configure/build
[driver] Runnnig pre-configure checks and steps
[build] Starting build
[driver] Start build stateMonitor
[driver] Runnnig pre-configure checks and steps
[proc] Executing command: /usr/local/bin/cmake --build /home/liuyi/Desktop/CppTst/CtApStateMonitor/build --config Debug --target stateMonitor -- -j 6
[build] Scanning dependencies of target stateMonitor
[build] [ 50%] Building CXX object CMakeFiles/stateMonitor.dir/forTest.cpp.o
[build] [ 50%] Building C object CMakeFiles/stateMonitor.dir/Implementation_Templates/FltRec_fun.c.o
[build] [ 75%] Building C object CMakeFiles/stateMonitor.dir/Implementation_Templates/CtApStateMonitor.c.o
[build] [100%] Linking CXX executable stateMonitor
[build] [100%] Built target stateMonitor
[cmakefileapi-parser] Read reply folder: /home/liuyi/Desktop/CppTst/CtApStateMonitor/build/.cmake/api/v1/reply
[cmakefileapi-parser] Found index files: ["cache-v2-f9bc208a6a5259395fc9.json","codemodel-v2-8e7cc81d89fe26b44194.json","index-2021-03-05T01-36-54-0581.json","target-stateMonitor-DEBUG-e9e38f41554290e2f2f5.json"]
[driver] Run _refreshExpansions
[driver] Run _refreshExpansions cb
[build] Build finished with exit code 0
[cache] Reading CMake cache file /home/liuyi/Desktop/CppTst/CtApStateMonitor/build/CMakeCache.txt
[cache] Parsing CMake cache string
[extension] [3469] cmake.buildAll finished (returned 0)
[extension] [2907] cmake.selectLaunchTarget started
[extension] [2907] cmake.selectLaunchTarget finished (returned null)

@bobbrow
my cmake.communicationMode keeped the default [automatic],and my versions are
cmake 3.19.3
vs code 1.50.1
cmake-tools 1.6.0
ubuntu 16.04LTS

CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
project(CtApStateMonitor VERSION 0.1.0)

set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
set(CMAKE_C_FLAGS "-std=c99")

#set include files;
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Contract_Header/
                    ${CMAKE_CURRENT_SOURCE_DIR}/Common/)

#set include files: *.h, *.hpp, *.hh;
FILE(GLOB_RECURSE PROJECT_HEADERS *.h *.hpp)
list(FILTER PROJECT_HEADERS EXCLUDE REGEX "${PROJECT_SOURCE_DIR}/build/.*" )

#set source files:*.cpp, *.c, *.cc;
FILE(GLOB_RECURSE PROJECT_SOURCES *.c *.cpp *.cc *.tcc)
list(FILTER PROJECT_SOURCES EXCLUDE REGEX "${PROJECT_SOURCE_DIR}/build/.*" )

add_executable(stateMonitor forTest.cpp ${PROJECT_SOURCES} ${PROJECT_HEADERS} )
target_link_libraries(stateMonitor -lpthread ${PROJECT_LIBRARIES})

@andreeis
Copy link
Contributor

andreeis commented Mar 5, 2021

No idea, everything looks right then. Do you have a repro project that you can easily share? If would be great if we could debug this symptom over here. We can't get into a state where the debug target setting command is broken.
Also, worth checking: can you switch completely to English and try again, just to make sure that localization doesn't have anything to do with this.

@hhx0202
Copy link

hhx0202 commented Mar 5, 2021

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

@andreeis
Copy link
Contributor

andreeis commented Mar 5, 2021

I'm glad that you are unblocked. It might not have anything to do with case sensitivity of CMAKE_BUILD_TYPE (unless you explicitly experimented with setting it to "Debug" value and working) but with the generator. You were using "Ninja" or "Visual Studio"?
These links may shed some light over CMAKE_BUILD_TYPE in the context of single-config and multi-config generators:
https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
https://cmake.org/cmake/help/v3.9/prop_gbl/GENERATOR_IS_MULTI_CONFIG.html

@bobbrow
Copy link
Member

bobbrow commented Mar 5, 2021

You should set the build type in the status bar (bottom left) or with the command CMake: Select Variant.
image

I was thinking we had a bug about not doing the right thing if you change the build type in your CMakeLists.txt, but I can't seem to find the issue right now.

@pauloasherring
Copy link

On my system, I had the same behavior as you, and it is was being cause by defining CMAKE_BUILD_TYPE.

Apparently, some of the tools (CMake? CMake Tools? I don't know) accept "Debug" and not "DEBUG". When checking the CMake Cache, I've found:
image

I've tried some variations:
set(CMAKE_BUILD_TYPE Debug) -- Works!
set(CMAKE_BUILD_TYPE DebuG) -- Does not work :(
set(CMAKE_BUILD_TYPE DEBUG) -- Does not work :(
set(CMAKE_BUILD_TYPE "Debug") -- Works!
set(CMAKE_BUILD_TYPE "DebuG") -- Does not work :(
set(CMAKE_BUILD_TYPE "DEBUG") -- Does not work :(

@hhx0202, @bobbrow , @FelixBenning thanks for the info sharing!

@unnikrishnan-anil
Copy link

unnikrishnan-anil commented Aug 25, 2021

I am facing a similar issue with one of my cmake projects. I am trying to run this on a remote machine. The host machine is OSX 11.4 (Big Sur). The remote is a Ubuntu 20.04.3. The project configures and builds okay. But I am not able to debug any of my unit tests. This is the error I get when I right-click on the test and press 'Debug'

[extension] [1484] cmake.debugTarget started [main] Failed to prepare executable target with name 'core-01_hello_test.cpp' [extension] [1484] cmake.debugTarget finished (returned null)

Does not give me any other information.

This is what my cmake command looks like:

"cmake .. -DCMAKE_BUILD_TYPE=Debug -GNinja"

I have tried Debug, 'Debug', and also 'DEBUG'. Doesn't seem to make a difference.

@bobbrow
Copy link
Member

bobbrow commented Aug 25, 2021

@CatsNipYummy I'm going to create a new issue for yours because it does not seem related and this issue is closed.

@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants