Skip to content

Commit

Permalink
NSIS windows installer
Browse files Browse the repository at this point in the history
  • Loading branch information
jleben committed Feb 19, 2012
1 parent a51b996 commit 3b61c59
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 16 deletions.
25 changes: 10 additions & 15 deletions CMakeLists.txt
Expand Up @@ -201,6 +201,11 @@ else()
option(SC_PSYCOLLIDER "Build PsyCollider" OFF)
endif()

if(WIN32)
option(SC_WIN_DEP_DIRS
"A list of directories where dependencies will be searched for when packaging.")
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
option(NATIVE "Optimize binary for this architecture (binaries may not run on other machines, requires gcc-4.3 or higher).")
option(LTO "Use GCC's link time optimizer' (experimental).")
Expand Down Expand Up @@ -262,8 +267,8 @@ add_subdirectory(external_libraries)
add_subdirectory(server)
add_subdirectory(lang)
add_subdirectory(bindings)
add_subdirectory(platform)
add_subdirectory(editors)
add_subdirectory(platform)

if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
install(DIRECTORY include/common include/plugin_interface include/server include/lang
Expand Down Expand Up @@ -441,17 +446,6 @@ set_directory_properties(
#
add_subdirectory(testsuite)

#############################################
# win32 install support

if(WIN32)
install(FILES
${FFTW3F_LIBRARY} ${SNDFILE_LIBRARY} ${PTHREADS_LIBRARY}
${PORTAUDIO_LIBRARIES} ${READLINE_LIBRARY}
DESTINATION "SuperCollider"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()

#############################################
# CPack support

Expand All @@ -468,10 +462,11 @@ if(APPLE)
set(CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/package/ds_store")
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/package/background.png")
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/platform/mac/Resources/SCcube.icns")
elseif(WIN32)
set(CPACK_MONOLITHIC_INSTALL 1)
endif()
include(CPack)

if(NOT WIN32) # We define a custom 'package' target in platform/windows/CMakeLists.txt
include(CPack)
endif()

#############################################
# hide advanced variables
Expand Down
4 changes: 3 additions & 1 deletion platform/CMakeLists.txt
@@ -1,8 +1,10 @@
if(APPLE)
add_subdirectory(mac)
elseif(WIN32)
add_subdirectory(windows)
endif()

# NB freebsd currently OK to ride on linux for this subdir. eventually may need separating.
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_subdirectory(linux)
endif()
endif()
17 changes: 17 additions & 0 deletions platform/windows/CMakeLists.txt
@@ -0,0 +1,17 @@
install(FILES ${CMAKE_SOURCE_DIR}/COPYING DESTINATION SuperCollider)

# Add a target that invokes a cmake script that:
# -- invokes fixup_bundle to copy dependencies over
# -- invokes a custom NSIS script, because CPack would
# not create a suitable installer for sced

add_custom_target( package
COMMAND cmake
"-DSC_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
"-DSC_WIN_DEP_DIRS=${SC_WIN_DEP_DIRS}"
"-DSC_ED=${SC_ED}"
"-DNSIS_SCRIPT=${CMAKE_CURRENT_SOURCE_DIR}/supercollider.nsi"
-P "${CMAKE_CURRENT_SOURCE_DIR}/package.cmake"
COMMENT "Building the installer:"
VERBATIM
)
20 changes: 20 additions & 0 deletions platform/windows/package.cmake
@@ -0,0 +1,20 @@
file(TO_NATIVE_PATH ${SC_INSTALL_PREFIX} NATIVE_INSTALL_PREFIX)

if(SC_ED)
set(DEFINE_SC_ED "/DSC_ED")
endif()

include(BundleUtilities)
fixup_bundle(
"${SC_INSTALL_PREFIX}/SuperCollider/sclang.exe"
""
"${SC_WIN_DEP_DIRS}"
)

execute_process( COMMAND makensis
/DSC_SRC_DIR="${NATIVE_INSTALL_PREFIX}"
# FIXME: Does not support spaces in path:
/DSC_DST_DIR=${NATIVE_INSTALL_PREFIX}
${DEFINE_SC_ED}
${NSIS_SCRIPT}
)
102 changes: 102 additions & 0 deletions platform/windows/supercollider.nsi
@@ -0,0 +1,102 @@
!cd ${SC_SRC_DIR}

!include "Sections.nsh"
!include "FileFunc.nsh"
!include "WordFunc.nsh"
!include "MUI2.nsh"
!insertmacro MUI_LANGUAGE "English"

!define VERSION "3.5-rc1"
Name "SuperCollider ${VERSION}"
OutFile ${SC_DST_DIR}\SuperCollider-${VERSION}-win32.exe
InstallDir $PROGRAMFILES\SuperCollider-${VERSION}

!ifdef SC_ED
Var GEDIT_DIR
!endif

; --- PAGES ---

!define MUI_PAGE_HEADER_TEXT "License"
!define MUI_LICENSEPAGE_TEXT_TOP "Please review the license below."
!define MUI_LICENSEPAGE_TEXT_BOTTOM \
"By installing this software you implicitely agree with this license."
!insertmacro MUI_PAGE_LICENSE SuperCollider\COPYING

!define MUI_PAGE_HEADER_TEXT "Installation components"
!insertmacro MUI_PAGE_COMPONENTS

!define MUI_PAGE_HEADER_TEXT "Installation Folder"
!insertmacro MUI_PAGE_DIRECTORY

!ifdef SC_ED
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Gedit Folder"
!define MUI_DIRECTORYPAGE_VARIABLE $GEDIT_DIR
!define MUI_PAGE_HEADER_TEXT "Gedit Folder"
!define MUI_PAGE_CUSTOMFUNCTION_PRE skipIfNoSced
!define MUI_DIRECTORYPAGE_TEXT_TOP \
"Setup will install Sced - a plugin for gedit text editor \
that allows you to interact with SuperCollider from within the editor, \
and adds syntax highlighting for SuperCollider code.$\n$\n\
Please select a folder where gedit is installed:"
!insertmacro MUI_PAGE_DIRECTORY
!endif

!insertmacro MUI_PAGE_INSTFILES

; --- SECTIONS ---

Section "Core" core_sect
SetOutPath $INSTDIR
File /r SuperCollider\*
SectionEnd

!ifdef SC_ED
Section "Sced (gedit integration)" sced_sect
SetOutPath $GEDIT_DIR
File /r gedit\*
FileOpen $0 $APPDATA\sced.config.json w
IfErrors done
${WordReplace} $INSTDIR "\" "\\" "+" $1
FileWrite $0 "{$\"supercollider-dir$\": $\"$1$\"}"
FileClose $0
done:
SectionEnd
!endif

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${core_sect} \
"Language interpreter and sound synthesis server. Command-line only."
!ifdef SC_ED
!insertmacro MUI_DESCRIPTION_TEXT ${sced_sect} \
"Integration with gedit text editor.$\n$\n\
You need to have gedit installed."
!endif
!insertmacro MUI_FUNCTION_DESCRIPTION_END

; --- FUNCTIONS ---

Function .onInit
IntOp $0 ${SF_SELECTED} | ${SF_RO}
SectionSetFlags ${core_sect} $0
FunctionEnd

!ifdef SC_ED
Function skipIfNoSced
SectionGetFlags ${sced_sect} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 0 is0 ok ok
is0:
Abort
ok:
${Locate} $PROGRAMFILES32 "/G=0 /L=D /M=gedit*" geditFound
StrCmp $GEDIT_DIR "" 0 done
${Locate} $PROGRAMFILES64 "/G=0 /L=D /M=gedit*" geditFound
done:
FunctionEnd

Function geditFound
StrCpy $GEDIT_DIR $R9
Push "StopLocate"
FunctionEnd
!endif

0 comments on commit 3b61c59

Please sign in to comment.