From 93b861004e522581958a59afb9e8f623dac0ef9c Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Fri, 17 Jan 2020 18:59:05 +0000 Subject: [PATCH] examples: Suffix package exe with .exe on Windows Without this the vscode extension cannot find the example executable, and the example fails. Also use $USERPROFILE instead of $HOME for finding the `.vscode` user directory for installing the extension. Bug: #12 --- CMakeLists.txt | 9 ++++++++- examples/vscode/package.json | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac15424..79ff71f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,10 +85,13 @@ set(CPPDAP_LIST ########################################################### if(CMAKE_SYSTEM_NAME MATCHES "Windows") set(CPPDAP_OS_LIBS WS2_32) + set(CPPDAP_OS_EXE_EXT ".exe") elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") set(CPPDAP_OS_LIBS pthread) + set(CPPDAP_OS_EXE_EXT "") elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") set(CPPDAP_OS_LIBS) + set(CPPDAP_OS_EXE_EXT "") endif() ########################################################### @@ -230,7 +233,11 @@ if(CPPDAP_BUILD_EXAMPLES) target_link_libraries(${target} cppdap "${CPPDAP_OS_LIBS}") if(CPPDAP_INSTALL_VSCODE_EXAMPLES) - set(extroot "$ENV{HOME}/.vscode/extensions") + if(CMAKE_SYSTEM_NAME MATCHES "Windows") + set(extroot "$ENV{USERPROFILE}\\.vscode\\extensions") + else() + set(extroot "$ENV{HOME}/.vscode/extensions") + endif() if(EXISTS ${extroot}) set(extdir "${extroot}/google.cppdap-example-${target}-1.0.0") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/examples/vscode/package.json ${extdir}/package.json) diff --git a/examples/vscode/package.json b/examples/vscode/package.json index bd9e378..9a52413 100644 --- a/examples/vscode/package.json +++ b/examples/vscode/package.json @@ -19,7 +19,7 @@ "debuggers": [ { "type": "@target@", - "program": "@target@", + "program": "@target@@CPPDAP_OS_EXE_EXT@", "label": "cppdap example: @target@", "configurationAttributes": {} }