cmake: Add msbuild integration to the install
authorHans Wennborg <hans@hanshq.net>
Wed, 28 Aug 2013 01:19:26 +0000 (01:19 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 28 Aug 2013 01:19:26 +0000 (01:19 +0000)
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

CMakeLists.txt
tools/msbuild/CMakeLists.txt [new file with mode: 0644]
tools/msbuild/install.bat [new file with mode: 0644]
tools/msbuild/uninstall.bat [new file with mode: 0644]

index 8d38fe5d8a277fa7c5b372336cc87e27d5d48a97..56adcf335d4b8b004ac74e663582c776d5ad5e3a 100644 (file)
@@ -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")
 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)
 
 endif()
 include(CPack)
 
diff --git a/tools/msbuild/CMakeLists.txt b/tools/msbuild/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a1dca8a
--- /dev/null
@@ -0,0 +1,10 @@
+if (WIN32)
+  install(DIRECTORY .
+    DESTINATION tools/msbuild
+    FILES_MATCHING
+    PATTERN "*.targets"
+    PATTERN "*.props"
+    PATTERN "*.bat"
+    PATTERN ".svn" EXCLUDE
+    )
+endif()  
diff --git a/tools/msbuild/install.bat b/tools/msbuild/install.bat
new file mode 100644 (file)
index 0000000..db11c86
--- /dev/null
@@ -0,0 +1,34 @@
+@echo off\r
+\r
+echo Installing MSVC integration...\r
+\r
+REM Change to the directory of this batch file.\r
+cd /d %~dp0\r
+\r
+REM Search for the MSBuild toolsets directory.\r
+SET D="%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets"\r
+IF EXIST %D% GOTO FOUND_MSBUILD\r
+SET D="%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets"\r
+IF EXIST %D% GOTO FOUND_MSBUILD\r
+\r
+echo Failed to find MSBuild toolsets directory.\r
+goto FAILED\r
+\r
+:FOUND_MSBUILD\r
+IF NOT EXIST %D%\llvm mkdir %D%\llvm\r
+IF NOT %ERRORLEVEL% == 0 GOTO FAILED\r
+\r
+copy Microsoft.Cpp.Win32.llvm.props %D%\llvm\r
+IF NOT %ERRORLEVEL% == 0 GOTO FAILED\r
+copy Microsoft.Cpp.Win32.llvm.targets %D%\llvm\r
+IF NOT %ERRORLEVEL% == 0 GOTO FAILED\r
+\r
+echo Done!\r
+goto END\r
+\r
+:FAILED\r
+echo MSVC integration install failed.\r
+pause\r
+goto END\r
+\r
+:END\r
diff --git a/tools/msbuild/uninstall.bat b/tools/msbuild/uninstall.bat
new file mode 100644 (file)
index 0000000..8bc304e
--- /dev/null
@@ -0,0 +1,34 @@
+@echo off\r
+\r
+echo Uninstalling MSVC integration...\r
+\r
+REM CD to the directory of this batch file.\r
+cd /d %~dp0\r
+\r
+REM Search for the MSBuild toolsets directory.\r
+SET D="%ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets"\r
+IF EXIST %D% GOTO FOUND_MSBUILD\r
+SET D="%ProgramFiles(x86)%\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets"\r
+IF EXIST %D% GOTO FOUND_MSBUILD\r
+\r
+echo Failed to find MSBuild toolsets directory.\r
+goto FAILED\r
+\r
+:FOUND_MSBUILD\r
+\r
+del %D%\llvm\Microsoft.Cpp.Win32.llvm.props\r
+IF NOT %ERRORLEVEL% == 0 GOTO FAILED\r
+del %D%\llvm\Microsoft.Cpp.Win32.llvm.targets\r
+IF NOT %ERRORLEVEL% == 0 GOTO FAILED\r
+rmdir %D%\llvm\r
+IF NOT %ERRORLEVEL% == 0 GOTO FAILED\r
+\r
+echo Done!\r
+goto END\r
+\r
+:FAILED\r
+echo MSVC integration uninstall failed.\r
+pause\r
+goto END\r
+\r
+:END\r