1 # CMake file for crosscompiling Maxima/wxMaxima for Windows
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (C) by Wolfgang Dautermann
4 # License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
5 # This is free software: you are free to change and redistribute it.
6 # There is NO WARRANTY, to the extent permitted by law.
8 set(CMAKE_SYSTEM_NAME Windows)
10 option(BUILD_64BIT "Build a 64 bit installer." YES)
13 set(HOST x86_64-w64-mingw32)
14 set(INSTALLERSUFFIX "win64")
16 set(HOST i686-w64-mingw32)
17 set(INSTALLERSUFFIX "win32")
20 set(CMAKE_C_COMPILER ${HOST}-gcc)
21 set(CMAKE_CXX_COMPILER ${HOST}-g++)
22 set(CMAKE_RC_COMPILER ${HOST}-windres)
24 cmake_minimum_required(VERSION 3.10)
26 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/ ${CMAKE_BINARY_DIR}/)
29 # On which windows drive (C:, D:, ...) will be the default installation path?
30 set(WINDOWS_DRIVELETTER "C")
33 # What is the build system?
34 execute_process(COMMAND gcc -dumpmachine OUTPUT_VARIABLE BUILDHOST OUTPUT_STRIP_TRAILING_WHITESPACE)
35 message(STATUS "Build system: ${BUILDHOST}")
37 # Output the host system, for which we are compiling
38 message(STATUS "Host system: ${HOST}")
40 find_file(NSISTEMPLATE_IN NAMES "NSIS.template.in"
41 PATHS "${CMAKE_ROOT}/Modules/" "${CMAKE_ROOT}/Modules/Internal/CPack")
42 file(READ "${NSISTEMPLATE_IN}" MYNSISTEMPLATE)
43 string(REPLACE "RequestExecutionLevel admin" "RequestExecutionLevel admin
46 " MYNSISTEMPLATE "${MYNSISTEMPLATE}")
48 string(REPLACE "Function .onInit" "Function .onInit
50 \${GetOptions} \$0 \"/no_vtk\" \$1
52 !insertmacro UnselectSection \${vtk}
54 \${GetOptions} \$0 \"/no_gnuplot\" \$1
56 !insertmacro UnselectSection \${gnuplot}
58 \${GetOptions} \$0 \"/no_wxmaxima\" \$1
60 !insertmacro UnselectSection \${wxmaxima}
62 \${GetOptions} \$0 \"/?\" \$1
64 MessageBox MB_OK \"Installer for Maxima\$\\n\$\\nThis installer allows the following command line options:\$\\n /S - silent install\$\\n /D=<path> - select the install path\$\\n /no_vtk - do not select VTK\$\\n /no_gnuplot - do not select Gnuplot\$\\n /no_wxmaxima - do not select wxMaxima\$\\n /? - this help message\$\\n\$\\nMaxima Website: https://maxima.sourceforge.io\"
68 " MYNSISTEMPLATE "${MYNSISTEMPLATE}")
69 file(WRITE ${CMAKE_BINARY_DIR}/NSIS.template.in "${MYNSISTEMPLATE}")
70 message(STATUS "Copied and patched ${CMAKE_ROOT}/Modules/NSIS.template.in to ${CMAKE_BINARY_DIR}/NSIS.template.in")
72 option(USE_WXMAXIMA_GIT "Use wxMaxima development snapshot." NO)
73 option(USE_VTK "Use VTK." YES)
74 # the following option is used for nightly builds of the installer.
75 # it builds the current Maxima/wxMaxima Git versions and also
76 # sets the installation directory to ${WINDOWS_DRIVELETTER}:\maxima-current
77 option(BUILD_CURRENT "Build a installer for current Maxima/wxMaxima." NO)
79 option(WITH_ABCL "Include ABCL in the installer." NO)
81 # SBCL and CLISP have both advantages and disadvantages:
82 # - SBCL is fast, but sometimes runs out of memory in places it really shouldn't
83 # (Loading LAPACK on IA32, for example) and isn't too happy with changing to
84 # non-ascii-non-unicode pathnames (which wxMaxima works around by now, though,
85 # and which Xmaxima doesn't evven try to do)
86 # - CLISP is slow. And version 2.49 only sends valid output over the network
87 # if the front-end is slow enough. Test cases: Running a demo, all commands
88 # with loads of compiler output (load("draw"); for the first time) or just
89 # receiving a batch of new autocompletion symbols. Since the libraries the
90 # front-ends use have evolved in the last years it has become easy to
91 # trigger this => Setting SBCL to be the default.
92 # - ABCL (optional) is a Java based Lisp.
94 set(WITH_DEFAULT_LISP "sbcl" CACHE STRING "Which Lisp should be used by default (clisp/sbcl/abcl)?")
95 set_property(CACHE WITH_DEFAULT_LISP PROPERTY STRINGS "clisp" "sbcl" "abcl")
99 set(WITH_DEFAULT_LISP "sbcl" CACHE STRING "Which Lisp should be used by default (clisp/sbcl)?")
100 set_property(CACHE WITH_DEFAULT_LISP PROPERTY STRINGS "clisp" "sbcl")
101 set(ABCL_STYLE "display: none;")
105 # If you want to use a updated version of a program,
106 # update the version number and the checksum.
107 # If no further patches are needed, you should get a
108 # updated setup-file automatically.
110 # current program versions
111 set(CLISPVERSION 2.49)
114 # MD5 checksums for the current program versions.
115 set(CLISP_MD5 "8d58d64f83dd7ad01c054aecc16c1f52")
118 set(USE_WXMAXIMA_GIT YES)
119 set(MAXIMAVERSION "current")
121 # Get Maxima version from configure.ac
122 file(STRINGS "${CMAKE_SOURCE_DIR}/../configure.ac" CONFIGUREAC REGEX "AC_INIT\\(.*\\)")
123 string(REGEX REPLACE "AC_INIT\\(\\[maxima\\],[ \t\r\n]*\\[(.*)\\]\\)" "\\1" MAXIMAVERSION ${CONFIGUREAC})
124 message(STATUS "Maxima version (from configure.ac): ${MAXIMAVERSION}")
127 # The HTML documentation is installed in a directory depending on "git describe",
128 # when building from Git, e.g.:
129 # share/maxima/branch_5_45_base_99_g0b3357e40_dirty/doc/html/maxima_singlepage.html
130 # Otherwise the version number is included, e.g something like:
131 # share/maxima/5.45.1/doc/html/maxima_singlepage.html
132 # Set it first to the second variant, if Git is found and we are building
133 # from a Git tree use the result of "git describe --dirty" in the path instead - where
134 # "-" are changed to "_" (see commit d5d04f2 and the file '../configure.ac').
135 set(MAXIMA_SINGLEPAGE_HTML "share/maxima/${MAXIMAVERSION}/doc/html/maxima_singlepage.html")
138 execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty
139 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
140 OUTPUT_VARIABLE GIT_DESCRIBE
142 OUTPUT_STRIP_TRAILING_WHITESPACE)
144 string(REPLACE "-" "_" GIT_DESCRIBE ${GIT_DESCRIBE})
145 set(MAXIMA_SINGLEPAGE_HTML "share/maxima/${GIT_DESCRIBE}/doc/html/maxima_singlepage.html")
150 set(CLISP_URL "http://downloads.sourceforge.net/project/clisp/clisp/${CLISPVERSION}/clisp-${CLISPVERSION}-win32-mingw-big.zip")
153 # Where are libgcc and libstdc++?
155 execute_process(COMMAND "${CMAKE_CXX_COMPILER}" -print-file-name=libgcc_s_seh-1.dll OUTPUT_VARIABLE MINGW_LIBGCC OUTPUT_STRIP_TRAILING_WHITESPACE)
157 execute_process(COMMAND "${CMAKE_CXX_COMPILER}" -print-file-name=libgcc_s_sjlj-1.dll OUTPUT_VARIABLE MINGW_LIBGCC OUTPUT_STRIP_TRAILING_WHITESPACE)
160 execute_process(COMMAND "${CMAKE_CXX_COMPILER}" -print-file-name=libstdc++-6.dll OUTPUT_VARIABLE MINGW_LIBSTDCPP OUTPUT_STRIP_TRAILING_WHITESPACE)
162 message(STATUS "Found libstdc++ at ${MINGW_LIBSTDCPP}")
164 message(STATUS "Found libgcc at ${MINGW_LIBGCC}")
166 add_subdirectory("wine/")
168 find_program(SEVENZIP_EXE NAMES 7z)
171 message(STATUS "Found 7z at ${SEVENZIP_EXE}")
173 message(FATAL_ERROR "7z not found. It is required for crosscompiling Maxima.")
176 include(ExternalProject)
179 # Clisp (already a binary package just extract it...)
181 # What is the difference between clisp-2.49-win32-mingw-big.zip and clisp-2.49-win32-mingw-small.zip?
182 # What should be used for running Maxima?
183 externalproject_add(clisp
185 DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/downloads
191 install(DIRECTORY ${CMAKE_BINARY_DIR}/clisp-prefix/src/clisp/ DESTINATION clisp-${CLISPVERSION} COMPONENT Clisp)
193 add_subdirectory("sbcl/")
195 add_subdirectory("gnuplot/")
197 add_subdirectory("tcltk/")
199 add_subdirectory("wxwidgets/")
201 add_subdirectory("wxmaxima/")
204 add_subdirectory("vtk/")
207 set(VTK_STYLE "display: none;")
211 add_subdirectory("abcl/")
212 set(ABCL_ENABLE "--enable-abcl")
213 set(ABCL_DEPENDS "abcl")
214 set(ABCL_JAR "--with-abcl-jar=${CMAKE_BINARY_DIR}/abcl/abcl-prefix/src/abcl/abcl.jar")
221 configure_file("${CMAKE_SOURCE_DIR}/wine-clisp.sh.tmpl" "${CMAKE_BINARY_DIR}/wine-clisp.sh")
222 configure_file("${CMAKE_SOURCE_DIR}/wine-lisp.sh.tmpl" "${CMAKE_BINARY_DIR}/wine-lisp.sh")
223 configure_file("${CMAKE_SOURCE_DIR}/wine-sbcl.sh.tmpl" "${CMAKE_BINARY_DIR}/wine-sbcl.sh")
225 externalproject_add(maxima
226 # first copy the maxima source to a build directory, since out-of-source-builds do not work
227 DOWNLOAD_COMMAND rsync -a --exclude=crosscompile-windows/build/ "${CMAKE_SOURCE_DIR}/../" "${CMAKE_BINARY_DIR}/maxima-prefix/src/maxima"
228 DEPENDS clisp sbcl tcl tk ${ABCL_DEPENDS}
230 CONFIGURE_COMMAND sh -c "test -x ./bootstrap && ./bootstrap || return 0"
231 COMMAND ./configure --host=${HOST} --enable-clisp --with-clisp=${CMAKE_BINARY_DIR}/wine-clisp.sh --with-clisp-runtime=${CMAKE_BINARY_DIR}/wine-lisp.sh --enable-sbcl --with-sbcl=${CMAKE_BINARY_DIR}/wine-sbcl.sh ${ABCL_ENABLE} "${ABCL_JAR}" --with-default-lisp=${WITH_DEFAULT_LISP} --prefix=${WINDOWS_DRIVELETTER}:/maxima-${MAXIMAVERSION}
232 # clisp-depends.mk is generated with "\" as path separator, not "/" - correct that...
233 BUILD_COMMAND LANG=C $(MAKE) -C src clisp-depends.mk
234 COMMAND sed -i s+\\\\+/+g src/clisp-depends.mk
235 COMMAND LANG=C $(MAKE)
236 COMMAND LANG=C $(MAKE) pdf
237 INSTALL_COMMAND LANG=C $(MAKE) install DESTDIR=${CMAKE_BINARY_DIR}/maxima-installroot/
238 COMMAND LANG=C $(MAKE) extradocinstall DESTDIR=${CMAKE_BINARY_DIR}/maxima-installroot/
241 option(STRIP_HELPERPROGRAMS "Strip the included helper programs (winkill, winkill_lib, maxima_longnames)." YES)
243 # crosscompiling winkill with autoconf does not work, compile it using CMake.
244 add_library(winkill_lib SHARED ${CMAKE_SOURCE_DIR}/../interfaces/xmaxima/win32/winkill_lib.c)
245 add_executable(winkill ${CMAKE_SOURCE_DIR}/../interfaces/xmaxima/win32/winkill.c)
246 set_target_properties(winkill_lib PROPERTIES PREFIX "") # remove 'lib' prefix from libwinkill_lib.dll
247 target_link_libraries(winkill winkill_lib)
249 # convert windows short names to long names (e.g.
250 # "C:/Users/TESTTE~1/AppData/Local/Temp" to "C:/Users/test test/AppData/Local/Temp")
251 # CLISP can (currently not handle short names.
252 add_executable(maxima_longnames maxima_longnames.c)
253 if(STRIP_HELPERPROGRAMS)
254 add_custom_command(TARGET winkill POST_BUILD COMMAND ${CMAKE_STRIP} winkill.exe)
255 add_custom_command(TARGET winkill_lib POST_BUILD COMMAND ${CMAKE_STRIP} winkill_lib.dll)
256 add_custom_command(TARGET maxima_longnames POST_BUILD COMMAND ${CMAKE_STRIP} maxima_longnames.exe)
258 install(TARGETS winkill winkill_lib maxima_longnames COMPONENT Maxima RUNTIME DESTINATION bin LIBRARY DESTINATION bin/)
259 install(FILES "${CMAKE_SOURCE_DIR}/../interfaces/xmaxima/win32/win_signals.lisp" DESTINATION bin/ COMPONENT Maxima)
262 install(DIRECTORY ${CMAKE_BINARY_DIR}/maxima-installroot/${WINDOWS_DRIVELETTER}:/maxima-${MAXIMAVERSION}/
263 DESTINATION . COMPONENT Maxima PATTERN "binary-abcl" EXCLUDE)
265 install(DIRECTORY ${CMAKE_BINARY_DIR}/maxima-installroot/${WINDOWS_DRIVELETTER}:/maxima-${MAXIMAVERSION}/
266 DESTINATION . COMPONENT ABCL PATTERN "binary-abcl")
269 install(FILES "${CMAKE_SOURCE_DIR}/xmaxima.bat" DESTINATION bin/ COMPONENT Maxima)
270 install(FILES "${CMAKE_BINARY_DIR}/maxima-prefix/src/maxima/doc/info/maxima.pdf" DESTINATION share/doc/ COMPONENT Maxima)
271 configure_file("${CMAKE_SOURCE_DIR}/lispselector.tcl" "${CMAKE_BINARY_DIR}/lispselector.tcl")
272 install(FILES "${CMAKE_BINARY_DIR}/lispselector.tcl" DESTINATION bin/ COMPONENT Maxima)
273 install(FILES "${CMAKE_SOURCE_DIR}/lispselector.bat" DESTINATION bin/ COMPONENT Maxima)
277 # Include DLLs from the current Mingw environment.
278 install(FILES "${MINGW_LIBSTDCPP}" "${MINGW_LIBGCC}" DESTINATION bin/ COMPONENT Maxima)
280 configure_file("${CMAKE_SOURCE_DIR}/licenses.html" "${CMAKE_BINARY_DIR}/licenses.html")
281 install(FILES "${CMAKE_BINARY_DIR}/licenses.html" DESTINATION share/doc/ COMPONENT Maxima)
283 file(COPY "${CMAKE_SOURCE_DIR}/../COPYING" DESTINATION "${CMAKE_BINARY_DIR}")
284 file(READ "${CMAKE_SOURCE_DIR}/LICENSE_APPENDIX.txt" LICENSE_APPENDIX)
285 file(APPEND "${CMAKE_BINARY_DIR}/COPYING" "${LICENSE_APPENDIX}")
287 set(CPACK_GENERATOR "NSIS;ZIP")
288 set(CPACK_PACKAGE_VERSION "${MAXIMAVERSION}")
289 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Maxima")
290 set(CPACK_PACKAGE_VENDOR "Maxima Team")
291 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/../README")
292 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/COPYING")
293 set(CPACK_PACKAGE_INSTALL_DIRECTORY "maxima-${CPACK_PACKAGE_VERSION}")
294 set(CPACK_NSIS_INSTALL_ROOT "${WINDOWS_DRIVELETTER}:")
295 set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
296 set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/maxima-icon.bmp")
297 set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/../interfaces/xmaxima\\\\maxima-icon.ico")
298 set(CPACK_NSIS_MUI_UNIICON "${CPACK_NSIS_MUI_ICON}")
299 set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\maxima-command.ico")
300 set(CPACK_NSIS_DISPLAY_NAME "Maxima computer algebra system")
301 set(CPACK_PACKAGE_EXECUTABLES "..\\\\bin\\\\wxmaxima" "wxMaxima (GUI for Maxima)")
302 set(CPACK_NSIS_URL_INFO_ABOUT "https://maxima.sourceforge.io")
303 set(CPACK_NSIS_MENU_LINKS "bin/maxima.bat" "Maxima (command line)" "bin/xmaxima.bat" "XMaxima (simple GUI)" "https://maxima.sourceforge.io" "About Maxima" "https://wxmaxima-developers.github.io/wxmaxima/" "About wxMaxima" "${MAXIMA_SINGLEPAGE_HTML}" "Maxima documentation" "share/doc/licenses.html" "Maxima and included software licenses" "bin/lispselector.bat" "Configure default LISP for Maxima")
304 set(CPACK_PACKAGE_FILE_NAME "maxima-${CPACK_PACKAGE_VERSION}-${INSTALLERSUFFIX}")
305 set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
308 set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "${CMAKE_SOURCE_DIR}/maxima-installerimage.bmp")
311 cpack_add_component(Maxima
312 DESCRIPTION "The Maxima computer algebra system.\nRequired."
316 cpack_add_component(VTK
317 DESCRIPTION "VTK is an advanced graphic toolkit for draw().\nOptional.")
320 cpack_add_component(Gnuplot
321 DESCRIPTION "Gnuplot is the main graphic toolkit.\nInstallation is strongly recommended.")
323 cpack_add_component(wxMaxima
324 DESCRIPTION "wxMaxima is an advanced GUI for Maxima based on wxWidgets.\nInstallation is strongly recommended.")
326 cpack_add_component(Clisp
327 DESCRIPTION "The CLISP Lisp compiler.\nRequired."
330 cpack_add_component(SBCL
331 DESCRIPTION "The SBCL Lisp compiler.\nRequired."
334 cpack_add_component(TclTk
335 DISPLAY_NAME "Tcl/Tk"
336 DESCRIPTION "The TCL/TK scripting language.\nRequired."
339 cpack_add_component(ABCL
340 DESCRIPTION "The ABCL Lisp compiler.\nA Java installation is required.\nOptional.")