Skip to content

Commit

Permalink
Merge branch 'vsdevcmd'
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuAuahDark committed Mar 21, 2024
2 parents c663769 + a4d8d6f commit 30c0659
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,43 @@ if(MSVC)
if(VSCOMNTOOLS STREQUAL "")
message(WARNING "Environment variable VSCOMNTOOLS not defined and vswhere.exe could not be found. Is Visual Studio properly installed?")
else()
# Find vcvarsall.bat.
get_filename_component(VS_VCVARSALL_BAT ${VSCOMNTOOLS}/../../VC/Auxiliary/Build/vcvarsall.bat ABSOLUTE)

# Find VsDevCmd.bat
get_filename_component(VS_VCVARSALL_BAT ${VSCOMNTOOLS}/VsDevCmd.bat ABSOLUTE)
if(NOT(EXISTS ${VS_VCVARSALL_BAT}))
# older VS versions have it here
get_filename_component(VS_VCVARSALL_BAT ${VSCOMNTOOLS}/../../VC/vcvarsall.bat ABSOLUTE)
# Find vcvarsall.bat.
get_filename_component(VS_VCVARSALL_BAT ${VSCOMNTOOLS}/../../VC/Auxiliary/Build/vcvarsall.bat ABSOLUTE)

if(NOT(EXISTS ${VS_VCVARSALL_BAT}))
# older VS versions have it here
get_filename_component(VS_VCVARSALL_BAT ${VSCOMNTOOLS}/../../VC/vcvarsall.bat ABSOLUTE)
endif()
endif()

if(EXISTS ${VS_VCVARSALL_BAT})
message(STATUS "Found vcvarsall.bat")
set(MEGA_MSVC_VCVARSALL_BAT ${VS_VCVARSALL_BAT})

if(MEGA_X86)
set(MEGA_MSVC_VCVARSALL_BAT_ARG "x86")
elseif(MEGA_ARM64)
set(MEGA_MSVC_VCVARSALL_BAT_ARG "x86_arm64")
if(VS_VCVARSALL_BAT MATCHES "VsDevCmd")
message(STATUS "Found VsDevCmd.bat")
if(MEGA_X86)
set(MEGA_MSVC_VCVARSALL_BAT_ARG "-arch=x86")
else()
set(MEGA_MSVC_VCVARSALL_BAT_ARG "-arch=amd64")
endif()
math(EXPR VS_TOOLCHAIN_VERSION_MAJOR "${VSVERSION} / 10")
math(EXPR VS_TOOLCHAIN_VERSION_MINOR "${VSVERSION} % 10")
set(MEGA_MSVC_VCVARSALL_BAT_ARG "${MEGA_MSVC_VCVARSALL_BAT_ARG} -vcvars_ver=${VS_TOOLCHAIN_VERSION_MAJOR}.${VS_TOOLCHAIN_VERSION_MINOR}")
else()
set(MEGA_MSVC_VCVARSALL_BAT_ARG "x86_amd64")
message(STATUS "Found vcvarsall.bat")
if(MEGA_X86)
set(MEGA_MSVC_VCVARSALL_BAT_ARG "x86")
elseif(MEGA_ARM64)
set(MEGA_MSVC_VCVARSALL_BAT_ARG "x86_arm64")
else()
set(MEGA_MSVC_VCVARSALL_BAT_ARG "x86_amd64")
endif()
endif()
else()
message(WARNING "Could not find vsvarsall.bat")
message(WARNING "Could not find VsDevCmd.bat nor vcvarsall.bat")
endif()
endif()

Expand Down Expand Up @@ -316,6 +332,7 @@ if(MSVC AND NOT MEGA_ARM64)
call \"${MEGA_MSVC_VCVARSALL_BAT}\" ${MEGA_MSVC_VCVARSALL_BAT_ARG}
)
cd \"${MEGA_LUAJIT_SOURCE_DIR}/src\"
cl
msvcbuild.bat debug amalg
")

Expand Down

0 comments on commit 30c0659

Please sign in to comment.