Skip to content

Commit

Permalink
examples: Suffix package exe with .exe on Windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ben-clayton committed Jan 17, 2020
1 parent cdc19ac commit 93b8610
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

###########################################################
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"debuggers": [
{
"type": "@target@",
"program": "@target@",
"program": "@target@@CPPDAP_OS_EXE_EXT@",
"label": "cppdap example: @target@",
"configurationAttributes": {}
}
Expand Down

0 comments on commit 93b8610

Please sign in to comment.