File: Ports.cmake

package info (click to toggle)
swi-prolog 8.2.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 78,084 kB
  • sloc: ansic: 362,656; perl: 322,276; java: 5,451; cpp: 4,625; sh: 3,047; ruby: 1,594; javascript: 1,509; yacc: 845; xml: 317; makefile: 156; sed: 12; sql: 6
file content (94 lines) | stat: -rw-r--r-- 3,472 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
if(APPLE)
  include(port/Darwin)
elseif(WIN32)
  include(port/Windows)
elseif(EMSCRIPTEN)
  include(port/Emscripten)
elseif(ANDROID)
  include(port/Android)
endif()

# Architecture id (Prolog flag `arch`, architecture subdirs)
if(NOT SWIPL_ARCH)
  string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR}-${CMAKE_HOST_SYSTEM_NAME}
	 SWIPL_ARCH)
endif()

# Setup cross compiling.  As discussed with _erlanger_ in
# https://github.com/SWI-Prolog/swipl-devel/issues/358#issuecomment-439675854
# we distinguish three scenarios for building:
#
#   1. Native compilation
#   2. Cross compilation with a good emulator (Wine for Windows, Node.js
#      for WASM)
#   3. Cross compilation without a usable emulator.
#
# In case #3 we need to make two builds:
#   1. Compile SWI-Prolog on the build host with a compatible pointer size
#   2. Cross-compile to the final target
#
# The first step is used to produce build artifacts that are needed
# by the cross-compilation step. SWIPL_NATIVE_FRIEND points to the directory
# which contains the build for step #1.
#

# ${SWIPL_NATIVE_FRIEND}, is  either  the  name  of  a  sibling  build
# directory  containing  a compatible native SWI-Prolog or an absolute   path
# pointing at such a directory.  By compatible we mean that the pointer size
# is the same.
#
# The following variables are set, and can be used elsewhere:
#
#   - ${PROG_SWIPL} is a native or friend Prolog executable that can
#                   be used for general Prolog tasks such as generating
#                   the library index or documentation
#
#   - ${PROG_SWIPL_FOR_BOOT} is a native or friend Prolog executable that can
#                            be used for compiling boot.prc and .qlf files.
#                            These used to be platform specific.  Now,
#			     ${PROG_SWIPL} should do. We keep a separate
#			     variable for the time being.
#
# Note: The helper tools mkvmi and  defatoms   (see  src  directory) are built
# using ${CMAKE_HOST_CC} when cross-compiling, and do not need SWIPL_NATIVE_FRIEND.

if(CMAKE_CROSSCOMPILING)
  set(CMAKE_HOST_EXECUTABLE_SUFFIX "" CACHE STRING
      "File name extension for executables for the host")
  set(CMAKE_HOST_CC cc CACHE STRING
      "C compiler used to compile build tools while cross-compiling")

  set(SWIPL_NATIVE_FRIEND "" CACHE STRING
      "CMake binary directory holding a compatible native system")

  if(SWIPL_NATIVE_FRIEND)
    if(IS_ABSOLUTE ${SWIPL_NATIVE_FRIEND})
      set(SWIPL_NATIVE_FRIEND_DIR ${SWIPL_NATIVE_FRIEND})
    else()
      set(SWIPL_NATIVE_FRIEND_DIR ${CMAKE_SOURCE_DIR}/${SWIPL_NATIVE_FRIEND})
    endif()

    set(PROG_SWIPL
	${SWIPL_NATIVE_FRIEND_DIR}/src/swipl${CMAKE_HOST_EXECUTABLE_SUFFIX}
	CACHE STRING "SWI-Prolog executable to perform build tasks")
    set(PROG_SWIPL_FOR_BOOT ${PROG_SWIPL})
  else()
    set(PROG_SWIPL_TARGET_FILE $<TARGET_FILE:swipl>
	CACHE STRING "SWI-Prolog executable to perform build tasks")
    set(PROG_SWIPL ${CMAKE_CROSSCOMPILING_EMULATOR} ${PROG_SWIPL_TARGET_FILE})
    set(PROG_SWIPL_FOR_BOOT ${PROG_SWIPL})
  endif()
else(CMAKE_CROSSCOMPILING)
  set(CMAKE_HOST_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX})
  set(PROG_SWIPL $<TARGET_FILE:swipl>)
  set(PROG_SWIPL_FOR_BOOT ${PROG_SWIPL})
endif(CMAKE_CROSSCOMPILING)

################
# Misc tests

include(CheckFloatingPointFormat)
include(TestBigEndian)

TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
ub_check_floating_point_format(IEEE754_FLOATS FLOAT_BYTES_BIGENDIAN FLOAT_WORDS_BIGENDIAN)