Skip to content
Snippets Groups Projects
Commit b3494b08 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Make CMake able to cross-build Win32 binaries on FreeBSD

parent 83e7b26f
Branches
No related tags found
No related merge requests found
Pipeline #6772 passed
......@@ -23,7 +23,12 @@ find_package(Curses)
find_package(PkgConfig)
if(NOT WITHOUT_SDL)
find_package(SDL2 CONFIG PATHS /Library/Frameworks)
if(WIN32)
set(SDL2_FOUND ON)
set(SDL2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../3rdp/win32.release/sdl2/include)
else()
find_package(SDL2 CONFIG PATHS /Library/Frameworks)
endif()
endif()
if(NOT WITHOUT_X11)
if(NOT WITHOUT_XRENDER)
......@@ -61,8 +66,14 @@ set(HEADER
if(WIN32)
if(NOT WITHOUT_GDI)
list(APPEND SOURCE win32cio.c)
list(APPEND SOURCE win32gdi.c)
if(WITHOUT_SDL)
list(APPEND SOURCE SDL_win32_main.c)
endif()
set(NEED_BITMAP TRUE)
set(NEED_SCALE TRUE)
endif()
list(APPEND SOURCE win32cio.c)
list(APPEND SOURCE ciolib.rc)
endif()
......@@ -80,7 +91,7 @@ else()
endif()
endif()
if(NOT WITHOUT_X1!)
if(NOT WITHOUT_X11)
if(X11_FOUND)
list(APPEND SOURCE x_events.c x_cio.c)
set(NEED_BITMAP TRUE)
......
......@@ -45,7 +45,9 @@ set(SOURCE
../sbbs3/xmodem.c
)
if(NOT WIN32)
if(WIN32)
set(3RDP_CRYPTLIB_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../../3rdp/win32.release/cryptlib/bin/cl32.lib)
else()
find_program(3RDP_GNU_MAKE
NAMES gmake make
)
......@@ -101,6 +103,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set_source_files_properties(SyncTERM.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
endif()
require_libs(syncterm ciolib comio encode hash sftp uifc xpdev)
target_compile_definitions(syncterm PRIVATE TELNET_NO_DLL)
if(WITHOUT_OOII)
target_compile_definitions(syncterm PRIVATE WITHOUT_OOII=1)
endif()
......
......@@ -51,6 +51,11 @@ gmake CC=mingw32-gcc VERBOSE=please AR=mingw32-ar AS=mingw32-as RANLIB=mingw32-r
32-bit Release builds for Win32 using MinGW-w64 use the following command line:
gmake AR=i686-w64-mingw32-ar AS=i686-w64-mingw32-as CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ RANLIB=i686-w64-mingw32-ranlib WINDRES=i686-w64-mingw32-windres RELEASE=1 VERBOSE=1
32-bit CMake builds for Win32 using MinGW-w64 on my system uses:
cmake -DWITHOUT_ALSA=ON -DWITHOUT_PULSEAUDIO=ON -DCMAKE_TOOLCHAIN_FILE=/synchronet/src/sbbs/src/syncterm/FBSD-mingw64.cmake ..
cmake --build . -j4
This does not rebuild cryptlib, so is suspect.
64-bit Release builds for Win32 using MinGW-w64 use the following command line:
gmake AR=x86_64-w64-mingw32-ar AS=x86_64-w64-mingw32-as CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ RANLIB=x86_64-w64-mingw32-ranlib WINDRES=x86_64-w64-mingw32-windres RELEASE=1 VERBOSE=1
......
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)
# Add search path
list(APPEND CMAKE_PROGRAM_PATH /home/admin/mingw-w32/bin)
# which compilers to use for C and C++
set(CMAKE_C_COMPILER /home/admin/mingw-w32/bin/i686-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER /home/admin/mingw-w32/bin/i686-w64-mingw32-g++)
set(CMAKE_AR /home/admin/mingw-w32/bin/i686-w64-mingw32-ar)
# where is the target environment located
set(CMAKE_FIND_ROOT_PATH /home/admin/mingw-w32)
# adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
......@@ -12,7 +12,12 @@ include(CheckSymbolExists)
include(CheckIncludeFiles)
find_package(Threads)
if(NOT WITHOUT_SDL_AUDIO)
find_package(SDL2 CONFIG PATHS /Library/Frameworks)
if(WIN32)
set(SDL2_FOUND ON)
set(SDL2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../3rdp/win32.release/sdl2/include)
else()
find_package(SDL2 CONFIG PATHS /Library/Frameworks)
endif()
endif()
if(NOT WITHOUT_PULSEAUDIO)
find_package(PulseAudio CONFIG PATHS /usr/local)
......@@ -101,7 +106,9 @@ if(NOT WITHOUT_SDL_AUDIO)
if(SDL2_FOUND)
list(APPEND SOURCE sdlfuncs.c)
if(WIN32)
list(APPEND SOURCE SDL_win32_main.c)
if(WITHOUT_SDL)
list(APPEND SOURCE SDL_win32_main.c)
endif()
endif()
endif()
endif()
......@@ -109,6 +116,7 @@ endif()
check_symbol_exists(strlcpy string.h HAS_STRLCPY)
check_symbol_exists(random stdlib.h HAS_RANDOM_FUNC)
check_symbol_exists(srandomdev stdlib.h HAS_SRANDOMDEV_FUNC)
check_symbol_exists(mkstemp stdlib.h HAS_MKSTEMP_FUNC)
check_include_files(inttypes.h HAS_INTTYPES_H)
check_include_files(stdint.h HAS_STDINT_H)
......@@ -206,6 +214,10 @@ if(HAS_SRANDOMDEV_FUNC)
target_compile_definitions(xpdev PRIVATE HAS_SRANDOMDEV_FUNC)
endif()
if(HAS_MKSTEMP_FUNC)
target_compile_definitions(xpdev PRIVATE DISABLE_MKSTEMP_DEFINE)
endif()
if(NOT WITHOUT_SDL_AUDIO)
if(SDL2_FOUND)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
......
......@@ -233,7 +233,9 @@ extern "C" {
#define snprintf _snprintf
#endif
#define vsnprintf _vsnprintf
#define NEEDS_STRLCPY
#ifndef NEEDS_STRLCPY
#define NEEDS_STRLCPY
#endif
#endif
#if defined(__WATCOMC__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment