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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
if(APPLE)
set(CMAKE_FIND_APPBUNDLE NEVER) # Make sure cmake does not find the Apple gui version of GIT
if(MACOS_UNIVERSAL_BINARY)
set(SWIPL_ARCH fat-darwin)
endif()
if(MACOSX_DEPENDENCIES_FROM STREQUAL "Homebrew")
if(EXISTS /usr/local/bin/brew)
set(MACOSX_DEPENDENCIES_FROM HomebrewLocal)
elseif(EXISTS /opt/homebrew)
set(MACOSX_DEPENDENCIES_FROM HomebrewOpt)
else()
message(FATAL "Could not find Homebrew in /usr/local nor /opt/homebrew)")
endif()
endif()
function(latest_subdir var dir)
FILE(GLOB children RELATIVE "${dir}" "${dir}/*")
set(subdir)
foreach(child ${children})
if(NOT subdir OR child VERSION_GREATER subdir)
set(subdir "${child}")
endif()
endforeach()
set(${var} ${dir}/${subdir} PARENT_SCOPE)
endfunction()
if(NOT MACOSX_DEPENDENCIES_FROM)
if(EXISTS /opt/local/bin/port)
set(MACOSX_DEPENDENCIES_FROM Macports)
elseif(EXISTS /usr/local/bin/brew)
set(MACOSX_DEPENDENCIES_FROM HomebrewLocal)
elseif(EXISTS /opt/homebrew)
set(MACOSX_DEPENDENCIES_FROM HomebrewOpt)
else()
set(MACOSX_DEPENDENCIES_FROM None)
message(WARNING "Could not find Macport or Homebrew to provide dependencies \
trying to configure with default search paths")
endif()
set(MACOSX_DEPENDENCIES_FROM ${MACOSX_DEPENDENCIES_FROM}
CACHE STRING "Get dependencies from Macports or HomeBrew")
endif()
if(MACOSX_DEPENDENCIES_FROM STREQUAL "Macports")
message("-- Using Macports packages from /opt/local")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH}
/opt/local/lib)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}
/opt/local/include)
if(EXISTS /opt/local/libexec/jpeg)
set(JPEG_ROOT /opt/local/libexec/jpeg)
endif()
elseif(MACOSX_DEPENDENCIES_FROM STREQUAL "HomebrewLocal")
message("-- Using Homebrew packages from /usr/local")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH}
/usr/local/lib)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}
/usr/local/include)
if(IS_DIRECTORY /usr/local/opt/openssl)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
elseif(IS_DIRECTORY /usr/local/opt/openssl@1.1)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl@1.1")
else()
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
set(LibArchive_ROOT /usr/local/opt/libarchive)
set(Readline_ROOT /usr/local/opt/readline)
elseif(MACOSX_DEPENDENCIES_FROM STREQUAL "HomebrewOpt")
message("-- Using Homebrew packages from /opt/homebrew")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH}
/opt/homebrew/lib)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}
/opt/homebrew/include)
# JW: Not sure we need to use the Cellar
latest_subdir(OPENSSL_ROOT_DIR /opt/homebrew/Cellar/openssl@3/)
latest_subdir(LibArchive_ROOT /opt/homebrew/Cellar/libarchive)
latest_subdir(Readline_ROOT /opt/homebrew/Cellar/readline)
elseif(MACOSX_DEPENDENCIES_FROM STREQUAL None)
message("-- Trying to build without Macports or Homebrew dependencies")
elseif(MACOSX_DEPENDENCIES_FROM MATCHES "/.*")
message("-- Trying to build with dependencies from ${MACOSX_DEPENDENCIES_FROM}")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH}
"${MACOSX_DEPENDENCIES_FROM}/lib")
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}
"${MACOSX_DEPENDENCIES_FROM}/include")
set(CMAKE_IGNORE_PATH
/opt/local/lib
/opt/local/include
/opt/local/bin
/usr/local/lib
/usr/local/include
/usr/local/bin
/opt/homebrew/lib
/opt/homebrew/include
/opt/homebrew/bin)
else()
message(FATAL_ERROR "Invalid MACOSX_DEPENDENCIES_FROM: ${MACOSX_DEPENDENCIES_FROM}")
endif()
if(BUILD_MACOS_BUNDLE)
set(MACOS_APP "SWI-Prolog")
if(MACOS_UNIVERSAL_BINARY)
set(SWIPL_CPACK_ARCH fat)
endif()
# These definitions must be here rather than in CPack.cmake as that
# file is loaded after attaching packages/swipl-win and thus isn't picked
# up. See URL below for the defined variables.
# https://cmake.org/cmake/help/latest/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
set(MACOSX_BUNDLE_BUNDLE_NAME "SWI-Prolog")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${SWIPL_VERSION_STRING}")
set(X11_ROOT /opt/X11)
set(Freetype_ROOT /opt/X11)
set(FontConfig_ROOT /opt/X11)
find_program(MACOS_DEPLOYQT NAMES macdeployqt)
if(NOT MACOS_DEPLOYQT)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
get_target_property(uic_location Qt5::uic IMPORTED_LOCATION)
get_filename_component( _dir ${uic_location} DIRECTORY)
set(MACOS_DEPLOYQT "${_dir}/macdeployqt")
if(NOT EXISTS ${MACOS_DEPLOYQT})
message(FATAL_ERROR "Failed to locate macdeployqt executable: [${MACOS_DEPLOYQT}]")
endif()
endif()
set(CPACK_GENERATOR "DragNDrop")
function(deployqt)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME ZZRuntime)
install(FILES ${CMAKE_SOURCE_DIR}/man/macosx/SWIapp.html
DESTINATION .
RENAME Readme.html)
install(FILES ${CMAKE_SOURCE_DIR}/man/macosx/License.html
DESTINATION .)
install(CODE "set(deployqt \"${MACOS_DEPLOYQT}\")
set(fixup_script \"${CMAKE_SOURCE_DIR}/scripts/macosx_bundle_fixup.sh\")
")
install(CODE [===[
execute_process(COMMAND ln -sf SWI-Prolog swipl-win
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/SWI-Prolog.app/Contents/MacOS)
message("Deploying Qt to ${CMAKE_INSTALL_PREFIX}/SWI-Prolog.app")
execute_process(COMMAND "${deployqt}"
"${CMAKE_INSTALL_PREFIX}/SWI-Prolog.app")
file(WRITE "${CMAKE_INSTALL_PREFIX}/SWI-Prolog.app/Contents/swipl.home" "swipl\n")
message("Adding dependencies for modules to bundle")
execute_process(COMMAND ${fixup_script} "${CMAKE_INSTALL_PREFIX}/SWI-Prolog.app")
]===])
endfunction()
deployqt()
endif()
set(CMAKE_MACOSX_RPATH ON)
# Prefer sem_open() over deprecated sem_init()
set(USE_SEM_OPEN 1)
set(SO_PATH DYLD_LIBRARY_PATH)
endif(APPLE)
|