]> granicus.if.org Git - graphviz/commitdiff
Add Windows installer using NSIS and CPack
authorErwin Janssen <erwinjanssen@outlook.com>
Fri, 31 Mar 2017 07:27:56 +0000 (09:27 +0200)
committerErwin Janssen <erwinjanssen@outlook.com>
Thu, 6 Apr 2017 19:38:03 +0000 (21:38 +0200)
Create a Windows Installer using CPack and the NSIS generator. The CMake
build on Appveyor now installs Graphviz using this installer and runs the
tests using ctest. The installer is added as an artifact to the Release
build.
Also switched the order of cmake and msbuild in Appveyor and added
`clone_depth: 25` for faster cloning.

appveyor.yml
cmake/FindNSIS.cmake [new file with mode: 0644]
cmake/package_info.cmake

index cc533051106fe9b275247b0805713e3f573ff2b4..068a0525b5fb4647478484c11ff425fe262f6198 100644 (file)
@@ -1,11 +1,14 @@
 version: 2.41.{build}
+clone_depth: 25
 
 image: Visual Studio 2015
 
 environment:
+  CTEST_OUTPUT_ON_FAILURE: TRUE
+  graphviz_install_dir: C:\Graphviz
   matrix:
-    - build_system: msbuild
     - build_system: cmake
+    - build_system: msbuild
 
 configuration:
   - Debug
@@ -52,8 +55,16 @@ build_script:
 
   # Test
   - ps: >-
-      if($env:build_system -eq "cmake") {
-        # No tests yet
+      if($env:build_system -eq "cmake" -and $env:configuration -eq "Release") {
+        mv Graphviz-*.exe Graphviz-install.exe;
+        # Install using installer and add bin directory to path.
+        # Piping the output of the installer to Out-Null, makes the script wait
+        # for the .exe to exit, instead continuing to the next command (which
+        # will then fail because the install hasn't finished)
+        ./Graphviz-install.exe /S /D=$env:graphviz_install_dir | Out-Null;
+        $env:Path += ";" + $env:graphviz_install_dir + "\bin"
+        dot -c;
+        ctest -C $env:configuration;
       }
       elseif($env:build_system -eq "msbuild") {
         # Append build destination to the PATH, configure dot and execute regression tests
@@ -68,3 +79,5 @@ artifacts:
     name: graphviz-windows
   - path: Debug
     name: graphviz-windows-debug
+  - path: build/Graphviz-install.exe
+    name: Graphviz-Windows-install
diff --git a/cmake/FindNSIS.cmake b/cmake/FindNSIS.cmake
new file mode 100644 (file)
index 0000000..d5600d2
--- /dev/null
@@ -0,0 +1,10 @@
+# CMake does not allow for braces in $ENV{}, so a temporary variable must be used.
+set(PROGRAMFILES_X86 "ProgramFiles(x86)")
+
+find_program(NSIS_MAKE
+    NAMES makensis
+    PATHS $ENV{PROGRAMFILES}/NSIS $ENV{${PROGRAMFILES_X86}}/NSIS
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(NSIS DEFAULT_MSG NSIS_MAKE)
index 8260abd73f9e547ab8963ce16d5c0e8cc3f45ef9..c415ca2c8f5051e9fe8cdab408bdbf0737dd0696 100644 (file)
@@ -9,3 +9,14 @@ set(CPACK_RESOURCE_FILE_LICENSE         "${TOP_SOURCE_DIR}/LICENSE"     )
 set(CPACK_RESOURCE_FILE_README          "${TOP_SOURCE_DIR}/README.md"   )
 
 set(CPACK_GENERATOR ZIP)
+
+find_package(NSIS)
+if(NSIS_FOUND)
+    set(CPACK_NSIS_MUI_ICON                 "${TOP_SOURCE_DIR}/windows/build/Graphviz.ico"  )
+    set(CPACK_NSIS_MUI_UNIICON              "${TOP_SOURCE_DIR}/windows/build/Graphviz.ico"  )
+    set(CPACK_NSIS_INSTALLED_ICON_NAME      "Uninstall.exe"                                 )
+    set(CPACK_NSIS_HELP_LINK                "http://www.graphviz.org"                       )
+    set(CPACK_NSIS_URL_INFO_ABOUT           "http://www.graphviz.org"                       )
+    set(CPACK_NSIS_MODIFY_PATH              ON                                              )
+    LIST(APPEND CPACK_GENERATOR NSIS)
+endif()