Skip to content

Commit

Permalink
cmake: Add msbuild integration to the install
Browse files Browse the repository at this point in the history
This adds the msbuild integration files to the install, provides batch scripts
for (un)installing it in a convenient way, and hooks up the nsis installer to
run those scripts.

Differential Revision: http://llvm-reviews.chandlerc.com/D1537

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189434 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
zmodem committed Aug 28, 2013
1 parent 7f9a887 commit 110b520
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ set(CPACK_RESOURCE_FILE_LICENSE "${LLVM_MAIN_SRC_DIR}/LICENSE.TXT")
if(WIN32 AND NOT UNIX)
set(CPACK_PACKAGE_ICON "${LLVM_MAIN_SRC_DIR}\\\\cmake\\\\nsis_logo.bmp")
set(CPACK_NSIS_MODIFY_PATH "ON")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"ExecWait '$INSTDIR/tools/msbuild/install.bat'")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
"ExecWait '$INSTDIR/tools/msbuild/uninstall.bat'")
endif()
include(CPack)

Expand Down
10 changes: 10 additions & 0 deletions tools/msbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if (WIN32)
install(DIRECTORY .
DESTINATION tools/msbuild
FILES_MATCHING
PATTERN "*.targets"
PATTERN "*.props"
PATTERN "*.bat"
PATTERN ".svn" EXCLUDE
)
endif()
34 changes: 34 additions & 0 deletions tools/msbuild/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@echo off

echo Installing MSVC integration...

REM Change to the directory of this batch file.
cd /d %~dp0

REM Search for the MSBuild toolsets directory.
SET D="%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets"
IF EXIST %D% GOTO FOUND_MSBUILD
SET D="%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets"
IF EXIST %D% GOTO FOUND_MSBUILD

echo Failed to find MSBuild toolsets directory.
goto FAILED

:FOUND_MSBUILD
IF NOT EXIST %D%\llvm mkdir %D%\llvm
IF NOT %ERRORLEVEL% == 0 GOTO FAILED

copy Microsoft.Cpp.Win32.llvm.props %D%\llvm
IF NOT %ERRORLEVEL% == 0 GOTO FAILED
copy Microsoft.Cpp.Win32.llvm.targets %D%\llvm
IF NOT %ERRORLEVEL% == 0 GOTO FAILED

echo Done!
goto END

:FAILED
echo MSVC integration install failed.
pause
goto END

:END
34 changes: 34 additions & 0 deletions tools/msbuild/uninstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@echo off

echo Uninstalling MSVC integration...

REM CD to the directory of this batch file.
cd /d %~dp0

REM Search for the MSBuild toolsets directory.
SET D="%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets"
IF EXIST %D% GOTO FOUND_MSBUILD
SET D="%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets"
IF EXIST %D% GOTO FOUND_MSBUILD

echo Failed to find MSBuild toolsets directory.
goto FAILED

:FOUND_MSBUILD

del %D%\llvm\Microsoft.Cpp.Win32.llvm.props
IF NOT %ERRORLEVEL% == 0 GOTO FAILED
del %D%\llvm\Microsoft.Cpp.Win32.llvm.targets
IF NOT %ERRORLEVEL% == 0 GOTO FAILED
rmdir %D%\llvm
IF NOT %ERRORLEVEL% == 0 GOTO FAILED

echo Done!
goto END

:FAILED
echo MSVC integration uninstall failed.
pause
goto END

:END

0 comments on commit 110b520

Please sign in to comment.