Skip to content

Commit

Permalink
fix: use detect_architecture to set the VS_DEBUGGER_ENVIRONMENT
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed May 3, 2022
1 parent 7c2a497 commit 3172a52
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ words:
- shlib
- suppr
- TOLOWER
- TOUPPER
- ubsan
- vcpkg
- vcvarsall
Expand Down
5 changes: 3 additions & 2 deletions src/Conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ macro(run_conan)

if(CONAN_EXPORTED)
# standard conan installation, in which deps will be defined in conanfile. It is not necessary to call conan again, as it is already running.
if (EXISTS "${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake")
if(EXISTS "${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake")
include(${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake)
else()
message(FATAL_ERROR "Could not set up conan because \"${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake\" does not exist")
message(
FATAL_ERROR "Could not set up conan because \"${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake\" does not exist")
endif()
conan_basic_setup()
else()
Expand Down
2 changes: 1 addition & 1 deletion src/PackageProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function(package_project)
set(_PackageProject_COMPATIBILITY "SameMajorVersion")
endif()

# default to the build_directory/project_name
# default to the build_directory/project_name
if("${_PackageProject_CONFIG_EXPORT_DESTINATION}" STREQUAL "")
set(_PackageProject_CONFIG_EXPORT_DESTINATION "${CMAKE_BINARY_DIR}/${_PackageProject_NAME}")
endif()
Expand Down
11 changes: 7 additions & 4 deletions src/VCEnvironment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ include("${ProjectOptions_SRC_DIR}/Utilities.cmake")

# Run vcvarsall.bat and set CMake environment variables
function(run_vcvarsall)
# detect the architecture
detect_architecture(VCVARSALL_ARCH)

# If MSVC is being used, and ASAN is enabled, we need to set the debugger environment
# so that it behaves well with MSVC's debugger, and we can run the target from visual studio
if(MSVC)
string(TOUPPER "${VCVARSALL_ARCH}" VCVARSALL_ARCH_UPPER)
set(VS_DEBUGGER_ENVIRONMENT "PATH=\$(VC_ExecutablePath_${VCVARSALL_ARCH_UPPER});%PATH%")

get_all_targets(all_targets)
set_target_properties(${all_targets} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=$(VC_ExecutablePath_x64);%PATH%")
set_target_properties(${all_targets} PROPERTIES VS_DEBUGGER_ENVIRONMENT "${VS_DEBUGGER_ENVIRONMENT}")
endif()

# if MSVC but VSCMD_VER is not set, which means vcvarsall has not run
Expand All @@ -27,9 +33,6 @@ function(run_vcvarsall)
PATH_SUFFIXES "VC/Auxiliary/Build" "Common7/Tools" "Tools")

if(EXISTS ${VCVARSALL_FILE})
# detect the architecture
detect_architecture(VCVARSALL_ARCH)

# run vcvarsall and print the environment variables
message(STATUS "Running `${VCVARSALL_FILE} ${VCVARSALL_ARCH}` to set up the MSVC environment")
execute_process(
Expand Down

0 comments on commit 3172a52

Please sign in to comment.