Skip to content

Commit

Permalink
I am making progress on building the windows version of the minheadle…
Browse files Browse the repository at this point in the history
…ss vm with cmake.
  • Loading branch information
ronsaldo committed May 31, 2019
1 parent b4e09a9 commit 18327e5
Show file tree
Hide file tree
Showing 21 changed files with 287 additions and 71 deletions.
19 changes: 15 additions & 4 deletions CMakeLists.txt
Expand Up @@ -631,9 +631,9 @@ if(NOT ONLY_CONFIG_H)

# Build the VM core library
set(VM_CORE_LIBRARY_TYPE STATIC)
#if(WIN32)
# set(VM_CORE_LIBRARY_TYPE SHARED)
#endif()
if(WIN32)
set(VM_CORE_LIBRARY_TYPE SHARED)
endif()

if("${VM_CORE_LIBRARY_TYPE}" STREQUAL "STATIC")
add_definitions(-DBUILD_OSVM_STATIC)
Expand Down Expand Up @@ -661,7 +661,7 @@ if(NOT ONLY_CONFIG_H)
# Build the VM executable(s)
set(VM_EXECUTABLE_TARGETS ${VM_EXECUTABLE_NAME})
if(WIN32)
set(VM_EXECUTABLE_TARGETS ${VM_EXECUTABLE_TARGETS} ${VM_EXECUTABLE_NAME}Console)
set(VM_EXECUTABLE_TARGETS ${VM_EXECUTABLE_NAME} ${VM_EXECUTABLE_NAME}Console)
add_executable(${VM_EXECUTABLE_NAME}Console platforms/minheadless/common/sqMain.c)
target_link_libraries(${VM_EXECUTABLE_NAME}Console ${VM_LIBRARY_NAME})

Expand Down Expand Up @@ -738,7 +738,18 @@ if(NOT ONLY_CONFIG_H)
LIBRARY DESTINATION ${ProductInstallProgramFolder}
RUNTIME DESTINATION ${ProductInstallProgramFolder}
PUBLIC_HEADER DESTINATION ${ProductInstallBaseFolder}/include
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE
)

# HACK: On cygwin the resulting dlls and exe file are having wrong
# permissions.
if(CYGWIN)
set(FIX_CYGWIN_INSTALL_PERMISSIONS_BASH_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/FixCygwinInstallPermissions.sh")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FixCygwinInstallPermissions.sh.in" "${FIX_CYGWIN_INSTALL_PERMISSIONS_BASH_SCRIPT}" @ONLY)
set(FIX_CYGWIN_INSTALL_PERMISSIONS_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/FixCygwinInstallPermissions.cmake")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FixCygwinInstallPermissions.cmake.in" "${FIX_CYGWIN_INSTALL_PERMISSIONS_SCRIPT}" @ONLY)
install(SCRIPT "${FIX_CYGWIN_INSTALL_PERMISSIONS_SCRIPT}")
endif()
endif()
endif()

Expand Down
Expand Up @@ -11,11 +11,13 @@ SET(CMAKE_CXX_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}-g++)
SET(CMAKE_RC_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}-windres)
SET(CMAKE_SYSTEM_PROCESSOR x86_64)

# where is the target environment
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32/sys-root/mingw/)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SET(CYGWIN TRUE CACHE INTERNAL "Are we running on cygwin?")
Expand Up @@ -11,11 +11,13 @@ SET(CMAKE_CXX_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}-g++)
SET(CMAKE_RC_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}-windres)
SET(CMAKE_SYSTEM_PROCESSOR i686)

# where is the target environment
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32/sys-root/mingw/)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SET(CYGWIN TRUE CACHE INTERNAL "Are we running on cygwin?")
2 changes: 1 addition & 1 deletion cmake/Cairo.cmake
Expand Up @@ -14,5 +14,5 @@ add_thirdparty_with_autoconf(Cairo
MAC_LIBRARIES ${Cairo_Spec_MacLibraries}
MAC_LIBRARIES_SYMLINK_PATTERNS ${Cairo_Spec_MacLibrariesSymlinks}
WINDOWS_DLLS ${Cairo_Spec_WindowsDLLs}
DEPENDENCIES ${Pixman_BuildDep}
DEPENDENCIES ${PkgConfig_BuildDep} ${Pixman_BuildDep} ${FreeType2_BuildDep} ${LibPNG_BuildDep}
)
18 changes: 18 additions & 0 deletions cmake/FT2Plugin.cmake
@@ -0,0 +1,18 @@
# Free type plugin
# Prefer freetype version that we build
if(NOT HAVE_FreeType2)
find_package(Freetype)
if(FREETYPE_FOUND)
include_directories(${FREETYPE_INCLUDE_DIRS})
set(HAVE_FreeType2 TRUE CACHE INTERNAL "Do we have FreeType?")
set(FreeType2_LIBRARIES "${FREETYPE_LIBRARIES}" CACHE STRING "Do we have FreeType?")
endif()
endif()

if(HAVE_FreeType2)
add_vm_plugin_auto(FT2Plugin EXTERNAL)
if(FreeType2_BuildDep)
add_dependencies(FT2Plugin ${FreeType2_BuildDep})
endif()
vm_plugin_link_libraries(FT2Plugin ${FreeType2_LIBRARIES})
endif()
1 change: 1 addition & 0 deletions cmake/FixCygwinInstallPermissions.cmake.in
@@ -0,0 +1 @@
execute_process(COMMAND "@FIX_CYGWIN_INSTALL_PERMISSIONS_BASH_SCRIPT@")
5 changes: 5 additions & 0 deletions cmake/FixCygwinInstallPermissions.sh.in
@@ -0,0 +1,5 @@
#!/bin/sh

InstallPrefix="@CMAKE_INSTALL_PREFIX@"

chmod a+rwx "$InstallPrefix"/*.dll "$InstallPrefix"/*.exe
38 changes: 28 additions & 10 deletions cmake/FreeType2.cmake
Expand Up @@ -6,15 +6,33 @@ set(FreeType2_Spec_MacLibraries libfreetype.6.dylib)
set(FreeType2_Spec_MacLibrariesSymlinks libfreetype*.dylib)
set(FreeType2_Spec_WindowsDLLs libfreetype.dll)

add_thirdparty_with_autoconf(FreeType2
DOWNLOAD_URL ${FreeType2_Spec_URL}
ARCHIVE_NAME ${FreeType2_Spec_ArchiveName}
ARCHIVE_SHA256 ${FreeType2_Spec_ArchiveSha256}
AUTOCONF_EXTRA_ARGS "--without-png"
MAC_LIBRARIES ${FreeType2_Spec_MacLibraries}
MAC_LIBRARIES_SYMLINK_PATTERNS ${FreeType2_Spec_MacLibrariesSymlinks}
WINDOWS_DLLS ${FreeType2_Spec_WindowsDLLs}
DEPENDENCIES ${PkgConfig_BuildDep}
)
set(FreeType2_Spec_Patch "${CMAKE_CURRENT_SOURCE_DIR}/third-party/freetype291.patch")

if(WIN32)
add_thirdparty_with_cmake(FreeType2
DOWNLOAD_URL ${FreeType2_Spec_URL}
ARCHIVE_NAME ${FreeType2_Spec_ArchiveName}
ARCHIVE_SHA256 ${FreeType2_Spec_ArchiveSha256}
PATCH ${FreeType2_Spec_Patch}
CMAKE_EXTRA_ARGS -DWITH_PNG=OFF -DBUILD_SHARED_LIBS=ON
MAC_LIBRARIES ${FreeType2_Spec_MacLibraries}
MAC_LIBRARIES_SYMLINK_PATTERNS ${FreeType2_Spec_MacLibrariesSymlinks}
WINDOWS_DLLS ${FreeType2_Spec_WindowsDLLs}
DEPENDENCIES ${PkgConfig_BuildDep} ${Zlib_BuildDep}
INSTALL_COMMAND make install && cp libfreetype.dll "${ThirdPartyCacheInstallBin}/${FreeType2_Spec_WindowsDLLs}"
)
else()
add_thirdparty_with_autoconf(FreeType2
DOWNLOAD_URL ${FreeType2_Spec_URL}
ARCHIVE_NAME ${FreeType2_Spec_ArchiveName}
ARCHIVE_SHA256 ${FreeType2_Spec_ArchiveSha256}
PATCH ${FreeType2_Spec_Patch}
AUTOCONF_EXTRA_ARGS "--without-png"
MAC_LIBRARIES ${FreeType2_Spec_MacLibraries}
MAC_LIBRARIES_SYMLINK_PATTERNS ${FreeType2_Spec_MacLibrariesSymlinks}
WINDOWS_DLLS ${FreeType2_Spec_WindowsDLLs}
DEPENDENCIES ${PkgConfig_BuildDep} ${Zlib_BuildDep}
)
endif()

include_directories("${ThirdPartyCacheInstallInclude}/freetype2")
2 changes: 1 addition & 1 deletion cmake/LibPNG.cmake
Expand Up @@ -13,5 +13,5 @@ add_thirdparty_with_autoconf(LibPNG
MAC_LIBRARIES ${LibPNG_Spec_MacLibraries}
MAC_LIBRARIES_SYMLINK_PATTERNS ${LibPNG_Spec_MacLibrariesSymlinks}
WINDOWS_DLLS ${LibPNG_Spec_WindowsDLLs}
DEPENDENCIES ${PkgConfig_BuildDep}
DEPENDENCIES ${PkgConfig_BuildDep} ${Zlib_BuildDep}
)
8 changes: 6 additions & 2 deletions cmake/OpenSSL.cmake
Expand Up @@ -31,7 +31,7 @@ else()
set(OpenSSL_ConfigureCommand "./Configure" darwin-i386-cc
"--prefix=${ThirdPartyCacheInstall}" shared )
endif()

set(OpenSSL_BuildCommand
env
"LDFLAGS=-Wl,-rpath,@executable_path:@executable_path/Plugins --sysroot=${CMAKE_OSX_SYSROOT}"
Expand All @@ -44,7 +44,7 @@ else()
foreach(opensslLib ${OpenSSL_Spec_MacLibraries})
set(OpenSSL_LibrariesToAddPermission "${OpenSSL_LibrariesToAddPermission} ${opensslLib}")
endforeach()

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/OpenSSL.mac-install.sh.in"
"${CMAKE_CURRENT_BINARY_DIR}/thirdparty/OpenSSL.mac-install.sh" @ONLY)
set(OpenSSL_InstallCommand "${CMAKE_CURRENT_BINARY_DIR}/thirdparty/OpenSSL.mac-install.sh")
Expand Down Expand Up @@ -84,6 +84,10 @@ else()
if(PkgConfig_BuildDep)
add_dependencies(OpenSSL ${PkgConfig_BuildDep})
endif()

if(Zlib_BuildDep)
add_dependencies(OpenSSL ${Zlib_BuildDep})
endif()
endif()

install_thirdparty_build_artifacts(OpenSSL
Expand Down
4 changes: 4 additions & 0 deletions cmake/PkgConfig.cmake
Expand Up @@ -19,7 +19,11 @@ add_thirdparty_with_autoconf(PkgConfig
ARCHIVE_SHA256 ${PkgConfig_Spec_ArchiveSha256}
EXTRA_BUILD_ARTIFACTS "bin/pkg-config"
CFLAGS "-std=gnu89"
AUTOCONF_EXTRA_ARGS "--with-internal-glib"
)

set(ThirdPartyPkgConfig "${ThirdPartyCacheInstallBin}/pkg-config")
if(WIN32)
set(ThirdPartyPkgConfig "${ThirdPartyCacheInstallBin}/pkg-config.exe")
endif()
set(ThirdPartyPkgConfigPath "${ThirdPartyCacheInstallLib}/pkgconfig")
6 changes: 4 additions & 2 deletions cmake/PluginsCommon.cmake
Expand Up @@ -2,7 +2,7 @@
set(SqueakFFIPrims_Sources
"${CrossPlatformPluginFolder}/SqueakFFIPrims/sqFFI.h"
"${CrossPlatformPluginFolder}/SqueakFFIPrims/sqFFIPlugin.c"
"${CrossPlatformPluginFolder}/SqueakFFIPrims/sqFFITestFuncs.c"
#"${CrossPlatformPluginFolder}/SqueakFFIPrims/sqFFITestFuncs.c" # Clashes with AlienSUnitTestProcedures
"${CrossPlatformPluginFolder}/SqueakFFIPrims/sqManualSurface.c"
"${PluginsSourceFolderName}/SqueakFFIPrims/SqueakFFIPrims.c"
)
Expand Down Expand Up @@ -54,7 +54,7 @@ add_vm_plugin_sources(DropPlugin INTERNAL
add_vm_plugin_auto(ZipPlugin INTERNAL) # Used by Monticello

if(NOT MINIMAL_PLUGIN_SET)

#===============================================================================
# Plugins that are used by both, Squeak and Pharo
#===============================================================================
Expand All @@ -74,7 +74,9 @@ if(NOT DARWIN)
add_vm_plugin_auto(MIDIPlugin INTERNAL)
endif()

add_definitions(-DNO_NULL_SERIAL_PLUGIN_IMPLEMENTATION)
add_vm_plugin_auto(SerialPlugin INTERNAL)

add_vm_plugin_auto(SoundCodecPrims INTERNAL)
add_vm_plugin_auto(SoundGenerationPlugin INTERNAL)
#add_vm_plugin_auto(SoundPlugin INTERNAL)
Expand Down
23 changes: 4 additions & 19 deletions cmake/PluginsPharo.cmake
Expand Up @@ -4,33 +4,18 @@ if(NOT MINIMAL_PLUGIN_SET)

add_vm_plugin_auto(EventsHandlerPlugin EXTERNAL)
allow_plugin_undefined_symbols(EventsHandlerPlugin _ioProcessEventsHandler _setIoProcessEventsHandler _vmIOProcessEvents)

if(HAVE_SDL2)
add_vm_plugin_auto(SDL2DisplayPlugin EXTERNAL)
allow_plugin_undefined_symbols(SDL2DisplayPlugin _setIoProcessEventsHandler)
vm_plugin_link_libraries(SDL2DisplayPlugin ${SDL2_LIBRARIES})
if(SDL2_BuildDep)
if(SDL2_BuildDep AND (NOT WIN32))
add_dependencies(SDL2DisplayPlugin ${SDL2_BuildDep})
endif()
endif()

# Free type plugin
# Prefer freetype version that we build
if(NOT HAVE_FreeType2)
find_package(Freetype)
if(FREETYPE_FOUND)
include_directories(${FREETYPE_INCLUDE_DIRS})
set(HAVE_FreeType2 TRUE CACHE INTERNAL "Do we have FreeType?")
set(FreeType2_LIBRARIES "${FREETYPE_LIBRARIES}" CACHE STRING "Do we have FreeType?")
endif()
endif()

if(HAVE_FreeType2)
add_vm_plugin_auto(FT2Plugin EXTERNAL)
if(FreeType2_BuildDep)
add_dependencies(FT2Plugin ${FreeType2_BuildDep})
endif()
vm_plugin_link_libraries(FT2Plugin ${FreeType2_LIBRARIES})
endif()
# Pharo is not using the FreeType plugin anymore.
#include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FT2Plugin.cmake")

# OSProcess
if(UNIX)
Expand Down
2 changes: 2 additions & 0 deletions cmake/SDL2.cmake
Expand Up @@ -6,6 +6,7 @@ set(LibSDL2_Spec_MacLibraries libSDL2-2.0.0.dylib)
set(LibSDL2_Spec_MacLibrariesSymlinks libSDL2*.dylib)
set(LibSDL2_Spec_LinuxLibraries libSDL2-2.0.so.0.7.0)
set(LibSDL2_Spec_LinuxLibrariesSymlinks libSDL2*so*)
set(LibSDL2_Spec_WindowsLibraries libSDL2.dll.a)
set(LibSDL2_Spec_WindowsDLLs SDL2.dll)

add_thirdparty_with_autoconf(SDL2
Expand All @@ -17,5 +18,6 @@ add_thirdparty_with_autoconf(SDL2
MAC_LIBRARIES_SYMLINK_PATTERNS ${LibSDL2_Spec_MacLibrariesSymlinks}
LINUX_LIBRARIES ${LibSDL2_Spec_LinuxLibraries}
LINUX_LIBRARIES_SYMLINK_PATTERNS ${LibSDL2_Spec_LinuxLibrariesSymlinks}
WINDOWS_LIBRARIES ${LibSDL2_Spec_WindowsLibraries}
WINDOWS_DLLS ${LibSDL2_Spec_WindowsDLLs}
)
4 changes: 4 additions & 0 deletions cmake/ThirdPartyDependenciesCommon.cmake
@@ -1,3 +1,7 @@
if(WIN32)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsRuntimeLibraries.cmake")
endif()

if(PHARO_VM OR (SUPPORT_TRADITIONAL_DISPLAY AND ALLOW_SDL2))
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/SDL2.cmake")
endif()

0 comments on commit 18327e5

Please sign in to comment.