language
stringlengths
0
24
filename
stringlengths
9
214
code
stringlengths
99
9.93M
hhvm/build/fbcode_builder/manifests/python-dulwich
[manifest] name = python-dulwich # The below links point to custom github forks of project dulwich, because the # 0.18.6 version didn't have an official rollout of wheel packages. [download.os=linux] url = https://github.com/lukaspiatkowski/dulwich/releases/download/dulwich-0.18.6-wheel/dulwich-0.18.6-cp36-cp36m-linux_x86_64.whl sha256 = e96f545f3d003e67236785473caaba2c368e531ea85fd508a3bd016ebac3a6d8 [download.os=darwin] url = https://github.com/lukaspiatkowski/dulwich/releases/download/dulwich-0.18.6-wheel/dulwich-0.18.6-cp37-cp37m-macosx_10_14_x86_64.whl sha256 = 8373652056284ad40ea5220b659b3489b0a91f25536322345a3e4b5d29069308 [build.not(os=windows)] builder = python-wheel [build.os=windows] builder = nop
hhvm/build/fbcode_builder/manifests/python-filelock
[manifest] name = python-filelock [download] url = https://files.pythonhosted.org/packages/31/24/ee722b92f23b9ebd87783e893a75352c048bbbc1f67dce0d63b58b46cb48/filelock-3.3.2-py3-none-any.whl sha256 = bb2a1c717df74c48a2d00ed625e5a66f8572a3a30baacb7657add1d7bac4097b [build] builder = python-wheel
hhvm/build/fbcode_builder/manifests/python-ptyprocess
[manifest] name = python-ptyprocess [download] url = https://files.pythonhosted.org/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl sha256 = d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f [build] builder = python-wheel
hhvm/build/fbcode_builder/manifests/python-six
[manifest] name = python-six [download] url = https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl sha256 = 3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c [build] builder = python-wheel
hhvm/build/fbcode_builder/manifests/python-toml
[manifest] name = python-toml [download] url = https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl sha256 = 235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e [build] builder = python-wheel
hhvm/build/fbcode_builder/manifests/range-v3
[manifest] name = range-v3 [download] url = https://github.com/ericniebler/range-v3/archive/refs/tags/0.11.0.tar.gz sha256 = 376376615dbba43d3bef75aa590931431ecb49eb36d07bb726a19f680c75e20c [build] builder = cmake subdir = range-v3-0.11.0
hhvm/build/fbcode_builder/manifests/re2
[manifest] name = re2 [homebrew] re2 [debs] libre2-dev [rpms] re2 re2-devel [download] url = https://github.com/google/re2/archive/2019-06-01.tar.gz sha256 = 02b7d73126bd18e9fbfe5d6375a8bb13fadaf8e99e48cbb062e4500fc18e8e2e [build] builder = cmake subdir = re2-2019-06-01
hhvm/build/fbcode_builder/manifests/rocksdb
[manifest] name = rocksdb [download] url = https://github.com/facebook/rocksdb/archive/refs/tags/v7.7.3.tar.gz sha256 = b8ac9784a342b2e314c821f6d701148912215666ac5e9bdbccd93cf3767cb611 [dependencies] lz4 snappy [build] builder = cmake subdir = rocksdb-7.7.3 [cmake.defines] WITH_SNAPPY=ON WITH_LZ4=ON WITH_TESTS=OFF WITH_BENCHMARK_TOOLS=OFF # We get relocation errors with the static gflags lib, # and there's no clear way to make it pick the shared gflags # so just turn it off. WITH_GFLAGS=OFF # mac pro machines don't have some of the newer features that # rocksdb enables by default; ask it to disable their use even # when building on new hardware PORTABLE = ON # Disable the use of -Werror FAIL_ON_WARNINGS = OFF [cmake.defines.os=windows] ROCKSDB_INSTALL_ON_WINDOWS=ON # RocksDB hard codes the paths to the snappy libs to something # that doesn't exist; ignoring the usual cmake rules. As a result, # we can't build it with snappy without either patching rocksdb or # without introducing more complex logic to the build system to # connect the snappy build outputs to rocksdb's custom logic here. # Let's just turn it off on windows. WITH_SNAPPY=OFF WITH_LZ4=ON ROCKSDB_SKIP_THIRDPARTY=ON
hhvm/build/fbcode_builder/manifests/rust-shed
[manifest] name = rust-shed fbsource_path = fbcode/common/rust/shed shipit_project = rust-shed shipit_fbcode_builder = true [git] repo_url = https://github.com/facebookexperimental/rust-shed.git [build] builder = cargo [cargo] build_doc = true workspace_dir = [shipit.pathmap] fbcode/common/rust/shed = shed fbcode/common/rust/shed/public_autocargo = shed fbcode/common/rust/shed/public_tld = . tools/rust/ossconfigs = . [shipit.strip] ^fbcode/common/rust/shed/(?!public_autocargo|public_tld).+/Cargo\.toml$ [dependencies] fbthrift fb303 # We use the system openssl on linux [dependencies.not(os=linux)] openssl [dependencies.fbsource=on] rust
hhvm/build/fbcode_builder/manifests/snappy
[manifest] name = snappy [debs] libsnappy-dev [rpms] snappy-devel [download] url = https://github.com/google/snappy/archive/1.1.7.tar.gz sha256 = 3dfa02e873ff51a11ee02b9ca391807f0c8ea0529a4924afa645fbf97163f9d4 [build] builder = cmake subdir = snappy-1.1.7 [cmake.defines] SNAPPY_BUILD_TESTS = OFF # Avoid problems like `relocation R_X86_64_PC32 against symbol` on ELF systems # when linking rocksdb, which builds PIC even when building a static lib [cmake.defines.os=linux] BUILD_SHARED_LIBS = ON
hhvm/build/fbcode_builder/manifests/sqlite3
[manifest] name = sqlite3 [debs] libsqlite3-dev [homebrew] sqlite [rpms] sqlite-devel sqlite-libs [download] url = https://sqlite.org/2019/sqlite-amalgamation-3280000.zip sha256 = d02fc4e95cfef672b45052e221617a050b7f2e20103661cda88387349a9b1327 [dependencies] cmake ninja [build] builder = sqlite subdir = sqlite-amalgamation-3280000
hhvm/build/fbcode_builder/manifests/sqlite3-bin
[manifest] name = sqlite3-bin [rpms] sqlite [debs] sqlite3 [download.os=linux] url = https://github.com/sqlite/sqlite/archive/version-3.33.0.tar.gz sha256 = 48e5f989eefe9af0ac758096f82ead0f3c7b58118ac17cc5810495bd5084a331 [build.os=linux] builder = autoconf subdir = sqlite-version-3.33.0 [build.not(os=linux)] # MacOS comes with sqlite3 preinstalled and don't need Windows here builder = nop [dependencies.os=linux] tcl [autoconf.args] # This flag disabled tcl as a runtime library used for some functionality, # but tcl is still a required dependency as it is used by the build files --disable-tcl
hhvm/build/fbcode_builder/manifests/tcl
[manifest] name = tcl [rpms] tcl [debs] tcl [download] url = https://github.com/tcltk/tcl/archive/core-8-7a3.tar.gz sha256 = 22d748f0c9652f3ecc195fed3f24a1b6eea8d449003085e6651197951528982e [build.os=linux] builder = autoconf subdir = tcl-core-8-7a3/unix [build.not(os=linux)] # This is for sqlite3 on Linux for now builder = nop
hhvm/build/fbcode_builder/manifests/tree
[manifest] name = tree [debs] tree [homebrew] tree [rpms] tree [download.os=linux] url = https://salsa.debian.org/debian/tree-packaging/-/archive/debian/1.8.0-1/tree-packaging-debian-1.8.0-1.tar.gz sha256 = a841eee1d52bfd64a48f54caab9937b9bd92935055c48885c4ab1ae4dab7fae5 [download.os=darwin] # The official package of tree source requires users of non-Linux platform to # comment/uncomment certain lines in the Makefile to build for their platform. # Besauce getdeps.py doesn't have that functionality we just use this custom # fork of tree which has proper lines uncommented for a OSX build url = https://github.com/lukaspiatkowski/tree-command/archive/debian/1.8.0-1-macos.tar.gz sha256 = 9cbe889553d95cf5a2791dd0743795d46a3c092c5bba691769c0e5c52e11229e [build.os=linux] builder = make subdir = tree-packaging-debian-1.8.0-1 [build.os=darwin] builder = make subdir = tree-command-debian-1.8.0-1-macos [build.os=windows] builder = nop [make.install_args] install
hhvm/build/fbcode_builder/manifests/wangle
[manifest] name = wangle fbsource_path = fbcode/wangle shipit_project = wangle shipit_fbcode_builder = true [git] repo_url = https://github.com/facebook/wangle.git [build] builder = cmake subdir = wangle [cmake.defines.test=on] BUILD_TESTS=ON [cmake.defines.test=off] BUILD_TESTS=OFF [dependencies] folly googletest fizz [shipit.pathmap] fbcode/wangle/public_tld = . fbcode/wangle = wangle
hhvm/build/fbcode_builder/manifests/watchman
[manifest] name = watchman fbsource_path = fbcode/watchman shipit_project = watchman shipit_fbcode_builder = true [git] repo_url = https://github.com/facebook/watchman.git [build] builder = cmake [dependencies] boost cpptoml edencommon fb303 fbthrift folly pcre2 googletest [dependencies.fbsource=on] rust [shipit.pathmap] fbcode/watchman = watchman fbcode/watchman/oss = . fbcode/eden/fs = eden/fs [shipit.strip] ^fbcode/eden/fs/(?!.*\.thrift|service/shipit_test_file\.txt) [cmake.defines.fb=on] ENABLE_EDEN_SUPPORT=ON IS_FB_BUILD=ON # FB macos specific settings [cmake.defines.all(fb=on,os=darwin)] # this path is coupled with the FB internal watchman-osx.spec WATCHMAN_STATE_DIR=/opt/facebook/watchman/var/run/watchman # tell cmake not to try to create /opt/facebook/... INSTALL_WATCHMAN_STATE_DIR=OFF USE_SYS_PYTHON=OFF [depends.environment] WATCHMAN_VERSION_OVERRIDE
hhvm/build/fbcode_builder/manifests/xz
[manifest] name = xz [debs] liblzma-dev [homebrew] xz [rpms] xz-devel [download] url = https://tukaani.org/xz/xz-5.2.5.tar.gz sha256 = f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10 [build] builder = autoconf subdir = xz-5.2.5 [autoconf.args] --disable-shared
hhvm/build/fbcode_builder/manifests/yaml-cpp
[manifest] name = yaml-cpp [download] url = https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.2.tar.gz sha256 = e4d8560e163c3d875fd5d9e5542b5fd5bec810febdcba61481fe5fc4e6b1fd05 [build.os=linux] builder = cmake subdir = yaml-cpp-yaml-cpp-0.6.2 [build.not(os=linux)] builder = nop [dependencies] boost googletest [cmake.defines] YAML_CPP_BUILD_TESTS=OFF
hhvm/build/fbcode_builder/manifests/zlib
[manifest] name = zlib [debs] zlib1g-dev [homebrew] zlib [rpms] zlib-devel zlib-static [download] url = https://zlib.net/zlib-1.3.tar.gz sha256 = ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e [build] builder = cmake subdir = zlib-1.3 patchfile = zlib_dont_build_more_than_needed.patch
hhvm/build/fbcode_builder/manifests/zstd
[manifest] name = zstd [homebrew] zstd # 18.04 zstd is too old [debs.not(all(distro=ubuntu,distro_vers="18.04"))] libzstd-dev [rpms] libzstd-devel libzstd [download] url = https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz sha256 = 9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4 [build] builder = cmake subdir = zstd-1.5.5/build/cmake # The zstd cmake build explicitly sets the install name # for the shared library in such a way that cmake discards # the path to the library from the install_name, rendering # the library non-resolvable during the build. The short # term solution for this is just to link static on macos. # # And while we're at it, let's just always link statically. [cmake.defines] ZSTD_BUILD_SHARED = OFF
hhvm/build/fbcode_builder/manifests/zstrong
[manifest] name = zstrong [git] repo_url = https://github.com/facebookincubator/zstrong.git [build] builder = cmake [dependencies] zstd [dependencies.test=on] benchmark fmt googletest [shipit.pathmap] fbcode/data_compression/experimental/zstrong = . [shipit.strip] ^fbcode/data_compression/experimental/zstrong/zstrong/zs2_config\.h$ [cmake.defines] BUILD_SHARED_LIBS=OFF [cmake.defines.test=on] BUILD_TESTS=ON BUILD_BENCHMARKS=ON [cmake.defines.test=off] BUILD_TESTS=OFF BUILD_BENCHMARKS=OFF
Patch
hhvm/build/fbcode_builder/patches/blake3_CMakeLists_txt.patch
diff --git a/BLAKE3Config.cmake.in b/BLAKE3Config.cmake.in new file mode 100644 index 0000000..5a8919d --- /dev/null +++ b/BLAKE3Config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +set_and_check(BLAKE3_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR@") +include("${CMAKE_CURRENT_LIST_DIR}/BLAKE3Targets.cmake") diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..171554b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,81 @@ +cmake_minimum_required(VERSION 3.12) +cmake_policy(VERSION ${CMAKE_VERSION}) + +project(BLAKE3 + VERSION 1.3.3 + DESCRIPTION "BLAKE3 C implementation" + HOMEPAGE_URL "https://github.com/BLAKE3-team/BLAKE3" + LANGUAGES C) + +include(GNUInstallDirs) + +add_library(blake3) + +set(INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH + "The subdirectory where header files should be installed") + +set_target_properties(blake3 PROPERTIES + PUBLIC_HEADER "blake3.h" + SOVERSION ${PROJECT_VERSION_MAJOR} + VERSION ${PROJECT_VERSION}) + +target_sources(blake3 PRIVATE + blake3.c + blake3_dispatch.c + blake3_portable.c) + +if((CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) OR (CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64)) + enable_language(ASM) + if(MSVC) + enable_language(ASM_MASM) + set(SUFFIX "windows_msvc.asm") + elseif(WIN32) + enable_language(ASM) + set(SUFFIX "windows_gnu.S") + else() + enable_language(ASM) + set(SUFFIX "unix.S") + endif() + target_sources(blake3 PRIVATE + blake3_avx2_x86-64_${SUFFIX} + blake3_avx512_x86-64_${SUFFIX} + blake3_sse2_x86-64_${SUFFIX} + blake3_sse41_x86-64_${SUFFIX}) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686) + target_compile_options(blake3 PRIVATE + -mavx2 + -mavx512f -mavx512vl + -msse2 + -msse4.1) + target_sources(blake3 PRIVATE + blake3_avx2.c + blake3_avx512.c + blake3_sse2.c + blake3_sse41.c) +elseif((CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) OR + (ANDROID_ABI STREQUAL armeabi-v7a)) + target_compile_definitions(blake3 PRIVATE BLAKE3_USE_NEON) + target_compile_options(blake3 PRIVATE -mfpu=neon) + target_sources(blake3 PRIVATE blake3_neon.c) +endif() + +install(TARGETS blake3 + EXPORT blake3_targets + PUBLIC_HEADER) +install(EXPORT blake3_targets + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" + FILE "${PROJECT_NAME}Targets.cmake" + NAMESPACE "${PROJECT_NAME}::") + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${PROJECT_NAME}ConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) +configure_package_config_file( + ${PROJECT_NAME}Config.cmake.in + ${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" + PATH_VARS INCLUDE_DIR) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
Patch
hhvm/build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch
diff -Naur ../zlib-1.2.13/CMakeLists.txt ./CMakeLists.txt --- ../zlib-1.2.13/CMakeLists.txt 2022-10-12 22:06:55.000000000 -0700 +++ ./CMakeLists.txt 2022-10-14 14:50:28.000000000 -0700 @@ -147,8 +147,7 @@ set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) endif(MINGW) -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +add_library(zlib ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) set_target_properties(zlib PROPERTIES SOVERSION 1) @@ -165,7 +164,7 @@ if(UNIX) # On unix-like platforms the library is almost always called libz - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) + set_target_properties(zlib PROPERTIES OUTPUT_NAME z) if(NOT APPLE) set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") endif() @@ -175,7 +174,7 @@ endif() if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) - install(TARGETS zlib zlibstatic + install(TARGETS zlib RUNTIME DESTINATION "${INSTALL_BIN_DIR}" ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
hhvm/ci/bin/make-debianish-package
#!/bin/bash # # Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. set -ex export DEBIAN_FRONTEND=noninteractive DEB_BUILD_OPTIONS="parallel=$(grep -E -c '^processor' /proc/cpuinfo)" export DEB_BUILD_OPTIONS DISTRO=${DISTRO:-"ubuntu-20.04-focal"} DISTRO_ROOT="ci/${DISTRO}" if [ ! -d "${DISTRO_ROOT}" ]; then echo "Unsupported distro: ${DISTRO}" exit 1 fi if [ ! "$IS_NIGHTLY" ]; then PKGBASE="hhvm" else PKGBASE="hhvm-nightly" fi VERSION=${VERSION:-"$(date +%Y.%m.%d)"} PKGVER="$(<"$DISTRO_ROOT/PKGVER")" DISTRIBUTION="$(<"$DISTRO_ROOT/DISTRIBUTION")" FULL_VERSION="${VERSION}-${PKGVER}" BUILD_DEPS="${PKGBASE}-build-deps_${FULL_VERSION}_all.deb" OUT=${OUT:-/var/out} mkdir -p "$OUT" # Environment set up apt-get -o Acquire::Retries=3 update -y apt-get clean apt-get -o Acquire::Retries=3 install -y devscripts equivs # Copy the debian directory to the root of the git repo # so that all the devscripts command work. cp -R "$DISTRO_ROOT/debian" . cp -R ci/skeleton/ debian/skeleton if [ ! "$IS_NIGHTLY" ]; then sed -i '/^Conflicts: hhvm$/d' debian/control sed -i 's/hhvm-nightly/hhvm/' debian/control sed -i 's/hhvm-nightly/hhvm/' debian/rules for file in debian/hhvm-nightly*; do mv "$file" "${file//hhvm-nightly/hhvm}" done fi # Add debian changelog entry dch --create -v "${FULL_VERSION}" --package "${PKGBASE}" --controlmaint --distribution "$DISTRIBUTION" --force-distribution --empty # Build debian package that depends on build-depends, and install it mk-build-deps dpkg -i --force-depends "$BUILD_DEPS" apt-get -o Acquire::Retries=3 install -y -f mv "$BUILD_DEPS" "$OUT" # Build the actual debian packages PREBUILD="$DISTRO_ROOT/make-package.prebuild" if [ -x "$PREBUILD" ]; then #shellcheck disable=SC1090 source $PREBUILD fi debuild -us -uc cd .. FILES=$(awk '/^Files:/ { files=1; next } /^[^ ]/ { files=0; next } files==1 { print $NF }' ./*.changes) if [ -z "$FILES" ]; then echo "Failed to identify neccessary files" exit 1 fi # FILES is one-per-line, but SC2086 wants to disable that expansion #shellcheck disable=SC2086 cp ./*.changes $FILES "$OUT" set +ex echo "Build tree: $OUT"
hhvm/ci/skeleton/etc/default/hhvm
## This is a configuration file for /etc/init.d/hhvm. ## Overwrite start up configuration of the hhvm service. ## ## This file is sourced by /bin/sh from /etc/init.d/hhvm. ## Configuration file location. ## Default: "/etc/hhvm/server.ini" ## Examples: ## "/etc/hhvm/conf.d/fastcgi.ini" Load configuration file from Debian/Ubuntu conf.d style location #CONFIG_FILE="/etc/hhvm/server.ini" ## User to run the service as. ## Default: "www-data" ## Examples: ## "hhvm" Custom 'hhvm' user ## "nobody" RHEL/CentOS 'www-data' equivalent #RUN_AS_USER="www-data" #RUN_AS_GROUP="www-data" ## Add additional arguments to the hhvm service start up that you can't put in CONFIG_FILE for some reason. ## Default: "" ## Examples: ## "-vLog.Level=Debug" Enable debug log level ## "-vServer.DefaultDocument=app.php" Change the default document #ADDITIONAL_ARGS="" ## PID file location. ## Default: "/var/run/hhvm/pid" #PIDFILE="/var/run/hhvm/pid"
INI Configuration
hhvm/ci/skeleton/etc/hhvm/php.ini
; php options session.save_handler = files session.save_path = /var/lib/hhvm/sessions session.gc_maxlifetime = 1440 ; hhvm specific hhvm.log.level = Warning hhvm.log.always_log_unhandled_exceptions = true hhvm.mysql.typed_results = false
INI Configuration
hhvm/ci/skeleton/etc/hhvm/server.ini
; php options pid = /var/run/hhvm/pid ; hhvm specific hhvm.server.port = 9000 hhvm.server.type = fastcgi hhvm.server.default_document = index.php hhvm.log.use_log_file = true hhvm.log.file = /var/log/hhvm/error.log hhvm.repo.central.path = /var/cache/hhvm/hhvm.hhbc
hhvm/ci/skeleton/etc/init.d/hhvm
#!/bin/sh # # /etc/init.d/hhvm -- startup script for HHVM FastCGI # ### BEGIN INIT INFO # Provides: hhvm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Description: Starts The HHVM FastCGI Daemon ### END INIT INFO # Author: Dominic Luechinger <[email protected]> # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="HHVM FastCGI Daemon" NAME=hhvm DAEMON=/usr/bin/hhvm PIDFILE=/var/run/hhvm/pid SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Default values. This values can be overwritten in '/etc/default/hhvm' CONFIG_FILE="/etc/hhvm/server.ini" SYSTEM_CONFIG_FILE="/etc/hhvm/php.ini" RUN_AS_USER="www-data" RUN_AS_GROUP="www-data" ADDITIONAL_ARGS="" # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME DAEMON_ARGS="--config ${SYSTEM_CONFIG_FILE} \ --config ${CONFIG_FILE} \ --user ${RUN_AS_USER} \ --mode daemon \ -vPidFile=${PIDFILE} \ ${ADDITIONAL_ARGS}" # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present # and status_of_proc is working. . /lib/lsb/init-functions # # Function that starts the daemon/service # check_run_dir() { # Only perform folder creation, if the PIDFILE location was not modified PIDFILE_BASEDIR=$(dirname ${PIDFILE}) # We might have a tmpfs /var/run. if [ "/var/run/hhvm" = "${PIDFILE_BASEDIR}" ] && [ ! -d /var/run/hhvm ]; then mkdir -p -m0755 /var/run/hhvm chown $RUN_AS_USER:$RUN_AS_GROUP /var/run/hhvm fi } do_start() { # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started touch $PIDFILE chown $RUN_AS_USER:$RUN_AS_GROUP $PIDFILE start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. } # # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=TERM/10/KILL/5 --pidfile $PIDFILE --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # Wait for children to finish too if this is a daemon that forks # and if the daemon is only ever run from this initscript. # If the above conditions are not satisfied then add some other code # that waits for the process to drop all resources that could be # needed by services started subsequently. A last resort is to # sleep for some time. start-stop-daemon --stop --quiet --oknodo --retry=0/10/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE return "$RETVAL" } # # Function that sends a SIGHUP to the daemon/service # do_reload() { # # If the daemon can reload its configuration without # restarting (for example, when it is sent a SIGHUP), # then implement that here. # start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME return 0 } case "$1" in start) check_run_dir [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; status) status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $? ;; #reload|force-reload) # # If do_reload() is not implemented then leave this commented out # and leave 'force-reload' as an alias for 'restart'. # #log_daemon_msg "Reloading $DESC" "$NAME" #do_reload #log_end_msg $? #;; restart|force-reload) # # If the "reload" option is implemented then remove the # 'force-reload' alias # check_run_dir log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 exit 3 ;; esac :
hhvm/ci/skeleton/etc/nginx/hhvm.conf
location ~ \.(hh|php|hack)$ { fastcgi_keep_conn on; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
Shell Script
hhvm/ci/skeleton/usr/share/hhvm/install_fastcgi.sh
#!/bin/bash if [ -f /etc/init.d/hhvm ] then /etc/init.d/hhvm start fi #!/bin/bash apache_check_installed() { echo "Checking if Apache is installed" if [ \( ! -d /etc/apache2/mods-enabled \) -o \( ! -d /etc/apache2/mods-available \) ] then echo "WARNING: Couldn't find Apache2 configuration paths, not configuring" return 1 fi echo "Detected Apache installation" return 0 } apache_check_custom() { echo "Looking for custom proxy configuration" if [ ! -z "$(grep 9000 -R /etc/apache2/mods-enabled | grep ProxyPass)" ] then echo "WARNING: Clashing existing configuration detected, not configuring" return 0 fi echo "No custom proxy configuration found" return 1 } apache_check_module() { echo "Checking for ${2} ${1}.${3}" if [ ! -f "/etc/apache2/mods-${2}/${1}.${3}" ] then echo "Not found" return 1 fi echo "Found, checking for loading directives" if [ "$3" == "load" ] then result=$(grep -E "^[^#]*LoadModule\\s*${1}_module" "/etc/apache2/mods-${2}/${1}.${3}") if [ -z "$result" ] then "Loading directive not found" return 1 fi fi echo "Detected ${2} ${1}.${3} configuration, setting up integration" return 0 } apache_force_enable_module() { echo "Force enabling module ${1}.${2}" if [ ! -f "/etc/apache2/mods-available/${1}.${2}" ] then echo "WARNING: Unsupported ${1}, not configuring" return 1 fi echo "Available module found" rm -f "/etc/apache2/mods-enabled/${1}.${2}" echo "Removed possible duplicates" apache_enable_module $1 $2 echo "Completed force enabling" return 0 } apache_enable_module() { echo "Enabling module ${1}.${2}" if [ ! -f "/etc/apache2/mods-available/${1}.${2}" ] then echo "WARNING: Could not enable ${1}, not configuring" return 1 fi echo "Found available module" if [ -f "/etc/apache2/mods-enabled/${1}.${2}" ] then echo "Module already enabled" return 0 fi echo "Creating a symlink" ln -s "../mods-available/${1}.${2}" "/etc/apache2/mods-enabled/${1}.${2}" echo "Finished creating a symlink" return 0 } apache_disable_module() { echo "Disabling a module ${1}.${2}" rm -f "/etc/apache2/mods-enabled/${1}.${2}" echo "Finished disabling a module" } apache_restart() { echo "Restarting apache" if [ ! -f "/etc/init.d/apache2" ] then echo "Apache init.d script not detected" return 0 fi result=$(/etc/init.d/apache2 status | grep 'is running') if [ ! -z "$result" ] then echo "Apache is running, restarting" /etc/init.d/apache2 restart echo "Finished restarting" fi echo "Finished restarting apache" return 0 } #!/bin/bash apache_postinst() { if ! apache_check_installed then return 0 fi if apache_check_custom then return 0 fi names="proxy_fcgi fastcgi fcgid" for name in $names do if ! apache_check_module "${name}" "enabled" "load"; then continue; fi if [ "$name" == "proxy_fcgi" ] then if ! apache_check_module "proxy" "enabled" "load"; then continue; fi if ! apache_check_module "proxy" "enabled" "conf"; then continue; fi fi apache_force_enable_module "hhvm_${name}" "conf" apache_restart return 0 done for name in $names do if ! apache_check_module "${name}" "available" "load"; then continue; fi if ! apache_check_module "hhvm_${name}" "available" "conf"; then continue; fi if [ "$name" == "proxy_fcgi" ] then if ! apache_check_module "proxy" "available" "load"; then continue; fi if ! apache_check_module "proxy" "available" "conf"; then continue; fi fi if [ "$name" == "proxy_fcgi" ] then apache_enable_module "proxy" "load" apache_enable_module "proxy" "conf" fi apache_enable_module "$name" "load" apache_force_enable_module "hhvm_${name}" "conf" apache_restart return 0 done echo "No matching Apache configuration found, not configuring" return 0 } apache_postinst #!/bin/bash insert_line() { file=`mktemp` sed -E "s/^(\\s*)${2}$/&\\n\\1${3}/" $1 > $file cat $file > $1 } remove_line() { file=`mktemp` sed -E "/^.*${2}.*$/d" $1 > $file cat $file > $1 } check_line() { if [ -z "$(grep $2 $1)" ] then return 0 fi return 1 } nginx_check_installed() { echo "Checking if Nginx is installed" if [ -d "/etc/nginx/conf.d/" ] then echo "Detected Nginx installation" return 0 fi echo "Nginx not found" return 1 } nginx_check_custom() { echo "Checking for custom Nginx configuration" if [ ! \( -z "$(grep -E "^[^#]*(fastcgi|hhvm.conf)" "/etc/nginx/nginx.conf")" \) \ -o ! \( -z "$(grep -ER "^[^#]*(fastcgi|hhvm.conf)" "/etc/nginx/conf.d/")" \) \ -o ! \( -z "$(grep -ER "^[^#]*(fastcgi|hhvm.conf)" "/etc/nginx/sites-enabled/")" \) ] then echo "WARNING: Detected clashing configuration. Look at /etc/nginx/hhvm.conf for information how to connect to the hhvm fastcgi instance." return 0 fi return 1 } nginx_enable_module() { echo "Enabling hhvm Nginx module" insert_line "/etc/nginx/sites-enabled/default" 'server_name.*$' 'include hhvm.conf;' echo "Finished enabling module" } nginx_disable_module() { echo "Disabling hhvm Nginx module" remove_line "/etc/nginx/sites-enabled/default" "hhvm.conf" echo "Finished disabling module" } nginx_restart() { echo "Restarting Nginx" if [ ! -f "/etc/init.d/nginx" ] then echo "Nginx init.d script not found" return 0 fi result=$(/etc/init.d/nginx status | grep 'is running') if [ ! -z "$result" ] then echo "Nginx is running, restarting" /etc/init.d/nginx stop /etc/init.d/nginx start echo "Restarted nginx" fi echo "Finished restarting Nginx" } #!/bin/bash nginx_postinst() { if ! nginx_check_installed then return 0 fi if nginx_check_custom then return 0 fi nginx_enable_module nginx_restart return 0 } nginx_postinst
Shell Script
hhvm/ci/skeleton/usr/share/hhvm/uninstall_fastcgi.sh
#!/bin/bash apache_check_installed() { echo "Checking if Apache is installed" if [ \( ! -d /etc/apache2/mods-enabled \) -o \( ! -d /etc/apache2/mods-available \) ] then echo "WARNING: Couldn't find Apache2 configuration paths, not configuring" return 1 fi echo "Detected Apache installation" return 0 } apache_check_custom() { echo "Looking for custom proxy configuration" if [ ! -z "$(grep 9000 -R /etc/apache2/mods-enabled | grep ProxyPass)" ] then echo "WARNING: Clashing existing configuration detected, not configuring" return 0 fi echo "No custom proxy configuration found" return 1 } apache_check_module() { echo "Checking for ${2} ${1}.${3}" if [ ! -f "/etc/apache2/mods-${2}/${1}.${3}" ] then echo "Not found" return 1 fi echo "Found, checking for loading directives" if [ "$3" == "load" ] then result=$(grep -E "^[^#]*LoadModule\\s*${1}_module" "/etc/apache2/mods-${2}/${1}.${3}") if [ -z "$result" ] then "Loading directive not found" return 1 fi fi echo "Detected ${2} ${1}.${3} configuration, setting up integration" return 0 } apache_force_enable_module() { echo "Force enabling module ${1}.${2}" if [ ! -f "/etc/apache2/mods-available/${1}.${2}" ] then echo "WARNING: Unsupported ${1}, not configuring" return 1 fi echo "Available module found" rm -f "/etc/apache2/mods-enabled/${1}.${2}" echo "Removed possible duplicates" apache_enable_module $1 $2 echo "Completed force enabling" return 0 } apache_enable_module() { echo "Enabling module ${1}.${2}" if [ ! -f "/etc/apache2/mods-available/${1}.${2}" ] then echo "WARNING: Could not enable ${1}, not configuring" return 1 fi echo "Found available module" if [ -f "/etc/apache2/mods-enabled/${1}.${2}" ] then echo "Module already enabled" return 0 fi echo "Creating a symlink" ln -s "../mods-available/${1}.${2}" "/etc/apache2/mods-enabled/${1}.${2}" echo "Finished creating a symlink" return 0 } apache_disable_module() { echo "Disabling a module ${1}.${2}" rm -f "/etc/apache2/mods-enabled/${1}.${2}" echo "Finished disabling a module" } apache_restart() { echo "Restarting apache" if [ ! -f "/etc/init.d/apache2" ] then echo "Apache init.d script not detected" return 0 fi result=$(/etc/init.d/apache2 status | grep 'is running') if [ ! -z "$result" ] then echo "Apache is running, restarting" /etc/init.d/apache2 restart echo "Finished restarting" fi echo "Finished restarting apache" return 0 } #!/bin/bash apache_prerm() { if ! apache_check_installed then return 0 fi names="proxy_fcgi fastcgi fcgid" for name in $names do apache_disable_module "hhvm_${name}" "conf" done apache_restart return 0 } apache_prerm #!/bin/bash insert_line() { file=`mktemp` sed -E "s/^(\\s*)${2}$/&\\n\\1${3}/" $1 > $file cat $file > $1 } remove_line() { file=`mktemp` sed -E "/^.*${2}.*$/d" $1 > $file cat $file > $1 } check_line() { if [ -z "$(grep $2 $1)" ] then return 0 fi return 1 } nginx_check_installed() { echo "Checking if Nginx is installed" if [ -d "/etc/nginx/conf.d/" ] then echo "Detected Nginx installation" return 0 fi echo "Nginx not found" return 1 } nginx_check_custom() { echo "Checking for custom Nginx configuration" if [ ! \( -z "$(grep -E "^[^#]*(fastcgi|hhvm.conf)" "/etc/nginx/nginx.conf")" \) \ -o ! \( -z "$(grep -ER "^[^#]*(fastcgi|hhvm.conf)" "/etc/nginx/conf.d/")" \) \ -o ! \( -z "$(grep -ER "^[^#]*(fastcgi|hhvm.conf)" "/etc/nginx/sites-enabled/")" \) ] then echo "WARNING: Detected clashing configuration, not configuring" return 0 fi return 1 } nginx_enable_module() { echo "Enabling hhvm Nginx module" insert_line "/etc/nginx/sites-enabled/default" 'server_name.*$' 'include hhvm.conf;' echo "Finished enabling module" } nginx_disable_module() { echo "Disabling hhvm Nginx module" remove_line "/etc/nginx/sites-enabled/default" "hhvm.conf" echo "Finished disabling module" } nginx_restart() { echo "Restarting Nginx" if [ ! -f "/etc/init.d/nginx" ] then echo "Nginx init.d script not found" return 0 fi result=$(/etc/init.d/nginx status | grep 'is running') if [ ! -z "$result" ] then echo "Nginx is running, restarting" /etc/init.d/nginx stop /etc/init.d/nginx start echo "Restarted nginx" fi echo "Finished restarting Nginx" } #!/bin/bash nginx_prerm() { if ! nginx_check_installed then return 0 fi nginx_disable_module } nginx_prerm #!/bin/bash set -e if [ -f /etc/init.d/hhvm ] then /etc/init.d/hhvm stop fi
hhvm/ci/ubuntu-20.04-focal/debian/conffiles
/etc/hhvm/server.ini /etc/hhvm/php.ini /etc/default/hhvm /etc/init.d/hhvm /etc/nginx/hhvm.conf /etc/apache2/mods-available/hhvm_proxy_fcgi.conf
hhvm/ci/ubuntu-20.04-focal/debian/control
Source: hhvm-nightly Maintainer: HHVM Open Source <[email protected]> Section: web Priority: optional Standards-Version: 3.9.2 Build-Depends: aspcud, autoconf, automake, binutils-dev, bison, build-essential, cmake, curl, debhelper (>= 9), flex, clang-12, gawk, git, gperf, libboost-all-dev, libbz2-dev, libc-client-dev, libc-client2007e-dev, libcap-dev, libcurl4-openssl-dev, libdwarf-dev, libedit-dev, libelf-dev, libevent-dev, libexpat-dev, libgd-dev, libgmp3-dev, libgoogle-glog-dev, libgoogle-perftools-dev, libiberty-dev, libiconv-hook-dev, libicu-dev, libinotifytools0-dev, libjemalloc-dev, libkrb5-dev, libldap2-dev, libmagickwand-dev, libmcrypt-dev, libmemcached-dev, libncurses-dev, libnotify-dev, libnuma-dev, libonig-dev, libpcre3-dev, libpq-dev, libre2-dev, libsodium-dev, libsqlite3-dev, libssl-dev, libtool, libxml2-dev, libxslt1-dev, libyaml-dev, python3, re2c, rsync, tzdata, unzip, wget, zlib1g-dev Package: hhvm-nightly Architecture: any Conflicts: hhvm Depends: tzdata, lsof, ${shlibs:Depends}, ${misc:Depends} Description: HHVM virtual machine, runtime, and JIT for the Hack language Package: hhvm-nightly-dbg Architecture: any Depends: hhvm-nightly (= ${binary:Version}), ${misc:Depends} Recommends: perf, gdb Section: debug Priority: extra Description: Debugging symbols for HHVM. Package: hhvm-nightly-dev Architecture: any Depends: hhvm-nightly (= ${binary:Version}), ${misc:Depends} Recommends: cmake Section: libdevel Priority: extra Description: Header and build system files for HHVM extension.
hhvm/ci/ubuntu-20.04-focal/debian/copying
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: hhvm Source: http://github.com/facebook/hhvm Comment: HHVM stands for "HipHop for PHP Virtual Machine". That name respects the PHP license. Files: * Copyright: 2010-2014 Facebook, Inc. (http://www.facebook.com) License: PHP-3.01 Files: CMake/FindBISON.cmake CMake/FindFLEX.cmake Copyright: 2006 Tristan Carel License: BSD-3-clause Files: CMake/FindLibElf.cmake Copyright: 2008 Bernhard Walle <[email protected]> License: BSD-3-clause Files: CMake/FindMySQL.cmake Copyright: 1995-2007 MySQL AB License: GPL-2 Comment: Although they talk in the header about exceptions, I checked them and they are only for MySQL drivers, not for the build system, so this is simply GPL-2. Files: CMake/HPHPFindLibs.cmake hphp/runtime/base/dummy-resource.* hphp/runtime/server/upload* hphp/zend/html-table* Copyright: 2010-2014 Facebook, Inc. (http://www.facebook.com) 1997-2010 The PHP Group License: PHP-3.01 Files: hphp/parser/hphp.5.tab.cpp hphp/parser/hphp.7.tab.cpp Copyright: 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. License: Bison-GPL-3+ Files: hphp/hack/* Copyright: 2013-2014 Facebook, Inc. (http://www.facebook.com) License: BSD-3-clause Files: hphp/hack/src/third-party/avl/* Copyright: 1996 Institut National de Recherche en Informatique et en Automatique (INRIA) License: LGPL-2-INRIA Files: hphp/hack/src/third-party/core/* Copyright: 2008 Jane Street Group, LLC License: Apache-2.0 Files: hphp/hack/src/third-party/inotify/* Copyright: 2006-2008 Vincent Hanquez <[email protected]> License: LGPL-2.1 Files: hphp/hack/src/third-party/libancillary/* Copyright: Nicolas George License: BSD-3-clause Files: hphp/neo/neo* hphp/neo/ulist* hphp/neo/ulocks.c Copyright: 2001-2004 Brandon Long License: Clearsilver Files: hphp/neo/ulocks.h Copyright: 1998-2000 Scott Shambarger <[email protected]> License: Free Files: hphp/runtime/* Copyright: 2010-2014 Facebook, Inc. (http://www.facebook.com) License: PHP-3.01 Files: hphp/runtime/base/ini-parser/* hphp/runtime/base/intl-convert.* hphp/runtime/base/utf8-decode.cpp hphp/runtime/base/zend-* Copyright: 2010-2014 Facebook, Inc. (http://www.facebook.com) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) License: PHP-3.01 Files: hphp/runtime/base/stat-cache.cpp Copyright: 2003 Constantin S. Svintsoff <[email protected]> 2010-2014 Facebook, Inc. (http://www.facebook.com) License: BSD-3-clause and PHP-3.01 Files: hphp/runtime/ext/* Copyright: 2010-2014 Facebook, Inc. (http://www.facebook.com) 1997-2010 The PHP Group License: PHP-3.01 Files: hphp/runtime/ext/bcmath/* Copyright: 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc. 2000 Philip A. Nelson License: LGPL-2.1 Files: hphp/runtime/ext/fileinfo/libmagic/* Copyright: 2010-2014 Facebook, Inc. (http://www.facebook.com) 1997-2010 The PHP Group 1986-1995 Ian F. Darwin and others 1995-2013 Christos Zoulas and others License: PHP-3.01 and BSD-2-clause Files: hphp/runtime/ext/gd/libgd/* Copyright: 2010-2014 Facebook, Inc. (http://www.facebook.com) 1997-2010 The PHP Group 1994-2002 Cold Spring Harbor Laboratory 1996-2002 Thomas Boutell (Boutell.Com, Inc.) 1999-2002 Philip Warner 1999-2002 Greg Roelofs 1999-2002 John Ellson <[email protected]> 2000-2002 Maurice Szmurlo <[email protected]> 2000-2002 Johan Van den Brande <[email protected]> 2000-2002 Doug Becker <[email protected]> 2000-2007 Pierre-Alain Joye <[email protected]> 2000-2002 Doug Becker 1991-2002 Thomas G. Lane License: GD Files: hphp/runtime/ext_zend_compat/ftp/* Copyright: 1997-2010 The PHP Group License: PHP-3.01 Files: hphp/runtime/ext_zend_compat/php-src/* Copyright: 1997-2013 The PHP Group License: Zend-2.00 Files: hphp/runtime/ext_zend_compat/calendar/dow.cpp hphp/runtime/ext_zend_compat/calendar/french.cpp hphp/runtime/ext_zend_compat/calendar/gregor.cpp hphp/runtime/ext_zend_compat/calendar/jewish.cpp hphp/runtime/ext_zend_compat/calendar/julian.cpp hphp/runtime/ext_zend_compat/calendar/sdncal.h Copyright: 1993-1995, Scott E. Lee License: Free Files: hphp/runtime/ext_zend_compat/mongo/* Copyright: 2009-2013 10gen, Inc. License: Apache-2.0 Files: hphp/runtime/ext_zend_compat/oauth/* Copyright: 2008, Yahoo! Inc. License: BSD-3-clause Files: hphp/runtime/ext_zend_compat/yaml/* Copyright: 2007 Ryusuke SEKIYAMA 2009 Keynetics Inc. 2012 Bryan Davis License: MIT Files: hphp/runtime/vm/jit/vtune/* Copyright: 2005-2013 Intel Corporation License: BSD-3-clause Files: hphp/test/frameworks/spyc/* Copyright: 2006-2011 Vladimir Andersen License: MIT Files: hphp/test/slow/ext_imagick/php_imagick_tests/* Copyright: 1999-2011 The PHP Group License: PHP-3.01 Files: hphp/test/server/fastcgi/Adoy/* Copyright: 2010-2013 Pierrick Charron <[email protected]> License: MIT Files: hphp/util/asm-x64.h Copyright: 2009 Andrew J. Paroski 2010-2014 Facebook, Inc. (http://www.facebook.com) License: PHP-3.01 and BSD-3-clause Files: hphp/util/compression.cpp Copyright: 1995-2005 Jean-loup Gailly and Mark Adler 1997-2010 The PHP Group 2010-2014 Facebook, Inc. (http://www.facebook.com) License: PHP-3.01 and zlib Files: hphp/util/cronoutils.* Copyright: 1996-1999 by Ford & Mason Ltd License: Apache-1.0 Files: hphp/util/safesort.h Copyright: 2009-2012 LLVM Team, University of Illinois at Urbana-Champaign. Additional contributors can be found at: http://llvm.org/svn/llvm-project/libcxx/trunk/CREDITS.TXT License: Illinois-NCSA or MIT Files: hphp/runtime/ext/password/ext_password.php Copyright: 2012 Anthony Ferrara <[email protected]> License: MIT Files: hphp/zend/crypt-blowfish.cpp hphp/zend/crypt-blowfish.h Copyright: 1998-2011 Solar Designer <solar at openwall.com> License: public-domain Files: hphp/zend/zend-html.* hphp/zend/zend-sha1.* hphp/zend/zend-string.* Copyright: 2010-2014 Facebook, Inc. (http://www.facebook.com) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) License: Zend-2.00 Files: hphp/vixl/* Copyright: 2013 ARM Limited License: BSD-3-clause Files: third-party/fastlz/* Copyright: 2005-2007 Ariya Hidayat <[email protected]> License: MIT Files: third-party/folly/* Copyright: 2015 Facebook, Inc. (http://www.facebook.com) License: Apache-2.0 Files: third-party/libafdt/* Copyright: David Reiss and Facebook, Inc. (http://www.facebook.com) License: MIT Files: third-party/libafdt/src/strlcpy.c Copyright: 1998 Todd C. Miller <[email protected]> License: MIT Files: third-party/libmbfl/* Copyright: 1998,1999,2000,2001 HappySize, Inc. License: LGPL-2.1 Files: third-party/mcrouter/* Copyright: 2015 Facebook, Inc. (http://www.facebook.com) License: BSD-3-clause Files: third-party/proxygen/* Copyright: 2015 Facebook, Inc. (http://www.facebook.com) License: BSD-3-clause Files: third-party/squangle/* Copyright: 2014-2013 Facebook, Inc. (http://www.facebook.com) License: BSD-3-clause Files: third-party/thrift/* Copyright: 2006-2014 Facebook, Inc. (http://www.facebook.com) License: Apache-2.0 Files: third-party/timelib/* Copyright: 1997-2014 The PHP Group License: PHP-3.01 Files: third-party/wangle/* Copyright: 2015 Facebook, Inc. (http://www.facebook.com) License: BSD-3-clause Files: debian/* Copyright: 2014-2015 David Martínez Moreno <[email protected]> 2014-2015 Faidon Liambotis <[email protected]> 2014-2015 Giuseppe Lavagetto <[email protected]> License: GPL-2+ License: PHP-3.01 Redistribution and use in source and binary forms, with or without modification, is permitted provided that the following conditions are met: . 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . 3. The name "PHP" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [email protected]. . 4. Products derived from this software may not be called "PHP", nor may "PHP" appear in their name, without prior written permission from [email protected]. You may indicate that your software works in conjunction with PHP by saying "Foo for PHP" instead of calling it "PHP Foo" or "phpfoo" . 5. The PHP Group may publish revised and/or new versions of the license from time to time. Each version will be given a distinguishing version number. Once covered code has been published under a particular version of the license, you may always continue to use it under the terms of that version. You may also choose to use such covered code under the terms of any subsequent version of the license published by the PHP Group. No one other than the PHP Group has the right to modify the terms applicable to covered code created under this License. . 6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes PHP software, freely available from <http://www.php.net/software/>". . THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: GPL-2 This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". License: GPL-2+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/> . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". License: LGPL-2-INRIA In the following, "the Library" refers to all files marked "Copyright INRIA" this directory. . The Library is distributed under the terms of the GNU Library General Public License version 2 (included below). . As a special exception to the GNU Library General Public License, you may link, statically or dynamically, a "work that uses the Library" with a publicly distributed version of the Library to produce an executable file containing portions of the Library, and distribute that executable file under terms of your choice, without any of the additional requirements listed in clause 6 of the GNU Library General Public License. By "a publicly distributed version of the Library", we mean either the unmodified Library as distributed by INRIA, or a modified version of the Library that is distributed under the conditions defined in clause 2 of the GNU Library General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU Library General Public License. . This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; version 2. . This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU Lbrary General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . On Debian systems, the complete text of the GNU Library General Public License can be found in `/usr/share/common-licenses/LGPL-2'. License: LGPL-2.1 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1. . This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . On Debian systems, the complete text of the GNU Lesser General Public License can be found in `/usr/share/common-licenses/LGPL-2.1'. License: Bison-GPL-3+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". . As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. . This special exception was added by the Free Software Foundation in version 2.2 of Bison. License: Clearsilver Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: Free This software is open source. Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies. No warranty of any kind is expressed or implied. Use at your own risk. License: Zend-2.00 Redistribution and use in source and binary forms, with or without modification, is permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names "Zend" and "Zend Engine" must not be used to endorse or promote products derived from this software without prior permission from Zend Technologies Ltd. For written permission, please contact [email protected]. 4. Zend Technologies Ltd. may publish revised and/or new versions of the license from time to time. Each version will be given a distinguishing version number. Once covered code has been published under a particular version of the license, you may always continue to use it under the terms of that version. You may also choose to use such covered code under the terms of any subsequent version of the license published by Zend Technologies Ltd. No one other than Zend Technologies Ltd. has the right to modify the terms applicable to covered code created under this License. 5. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes the Zend Engine, freely available at http://www.zend.com" 6. All advertising materials mentioning features or use of this software must display the following acknowledgment: "The Zend Engine is freely available at http://www.zend.com" THIS SOFTWARE IS PROVIDED BY ZEND TECHNOLOGIES LTD. ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ZEND TECHNOLOGIES LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: BSD-2-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: BSD-3-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . 3) Neither the name of the ORGANIZATION nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: zlib This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. . Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: . 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. License: Apache-1.0 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . 3. All advertising materials mentioning features or use of this software must display the following acknowledgment: "This product includes software developed by the Apache Group for use in the Apache HTTP server project (http://www.apache.org/)." . 4. The names "Apache Server" and "Apache Group" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [email protected]. . 5. Products derived from this software may not be called "Apache" nor may "Apache" appear in their names without prior written permission of the Apache Group. . 6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes software developed by the Apache Group for use in the Apache HTTP server project (http://www.apache.org/)." . THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. . This software consists of voluntary contributions made by many individuals on behalf of the Apache Group and was originally based on public domain software written at the National Center for Supercomputing Applications, University of Illinois, Urbana-Champaign. For more information on the Apache Group and the Apache HTTP server project, please see http://www.apache.org/. License: Apache-2.0 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at . http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. . On Debian systems, the complete text of the Apache 2.0 License can be found in "/usr/share/common-licenses/Apache-2.0". License: public-domain No copyright is claimed, and the software is hereby placed in the public domain. In case this attempt to disclaim copyright and place the software in the public domain is deemed null and void, then the software is Copyright (c) 1998-2011 Solar Designer and it is hereby released to the general public under the following terms: . Redistribution and use in source and binary forms, with or without modification, are permitted. . There's ABSOLUTELY NO WARRANTY, express or implied. . It is my intent that you should be able to use this on your system, as part of a software package, or anywhere else to improve security, ensure compatibility, or for any other purpose. I would appreciate it if you give credit where it is due and keep your modifications in the public domain as well, but I don't require that in order to let you place this code and any modifications you make under a license of your choice. License: Illinois-NCSA Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. . * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. . * Neither the names of the LLVM Team, University of Illinois at Urbana-Champaign, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. License: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License: GD Permission has been granted to copy, distribute and modify gd in any context without fee, including a commercial application, provided that this notice is present in user-accessible supporting documentation. . This does not affect your ownership of the derived work itself, and the intent is to assure proper credit for the authors of gd, not to interfere with your productive use of gd. If you have questions, ask. "Derived works" includes all programs that utilize the library. Credit must be given in user-accessible documentation. . This software is provided "AS IS." The copyright holders disclaim all warranties, either express or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose, with respect to this code and accompanying documentation.
Inno Setup Script
hhvm/ci/ubuntu-20.04-focal/debian/hhvm-nightly-dev.install.in
__PKGROOT__/bin/hhvm-gdb __PKGROOT__/bin __PKGROOT__/bin/hphpize __PKGROOT__/bin __PKGROOT__/include/hphp __PKGROOT__/include __PKGROOT__/lib __PKGROOT__/
Inno Setup Script
hhvm/ci/ubuntu-20.04-focal/debian/hhvm-nightly.install.in
__PKGROOT__/bin/hackfmt __PKGROOT__/bin __PKGROOT__/bin/hh_client __PKGROOT__/bin __PKGROOT__/bin/hh_parse __PKGROOT__/bin __PKGROOT__/bin/hh_server __PKGROOT__/bin __PKGROOT__/bin/hhvm __PKGROOT__/bin __PKGROOT__/bin/hhvm-repo-mode __PKGROOT__/bin third-party/third_party_notices.txt __PKGROOT__/share/doc/hhvm debian/skeleton/usr/share/hhvm/ __PKGROOT__/share debian/skeleton/etc /
Inno Setup Script
hhvm/ci/ubuntu-20.04-focal/debian/postinst.in
#!/bin/bash echo "********************************************************************" echo "* HHVM is installed." echo "*" echo "* The best way to get started is to use HHVM's built-in webserver: " echo "*" echo "* $ hhvm -m server -p 8080" echo "*" echo "* Running command-line scripts with HHVM requires no special setup:" echo "*" echo "* $ hhvm example.hack" echo "*" echo "* FastCGI is also supported; see https://docs.hhvm.com/hhvm/advanced-usage/fastCGI" echo "*" echo "********************************************************************" RUN_AS_USER="www-data" RUN_AS_GROUP="www-data" if [ -f /etc/default/hhvm ]; then . /etc/default/hhvm fi install -d -m 755 -o $RUN_AS_USER -g $RUN_AS_GROUP /var/run/hhvm install -d -m 01733 /var/lib/hhvm/sessions if [ -f /usr/sbin/update-alternatives ]; then UPDATE_ALTERNATIVES=/usr/sbin/update-alternatives fi if [ -f /usr/bin/update-alternatives ]; then UPDATE_ALTERNATIVES=/usr/bin/update-alternatives fi if [ -n "$UPDATE_ALTERNATIVES" ]; then "$UPDATE_ALTERNATIVES" \ --install /usr/bin/hhvm hhvm __PKGROOT__/bin/hhvm 10 \ --slave /usr/bin/hh_client hh_client __PKGROOT__/bin/hh_client \ --slave /usr/bin/hh_parse hh_parse __PKGROOT__/bin/hh_parse \ --slave /usr/bin/hh_server hh_server __PKGROOT__/bin/hh_server \ --slave /usr/bin/hackfmt hackfmt __PKGROOT__/bin/hackfmt fi if which invoke-rc.d >/dev/null 2>&1; then invoke-rc.d hhvm start fi
hhvm/ci/ubuntu-20.04-focal/debian/postrm
#!/bin/sh # hphp.postrm, runs ldconfig, removes alternative set -e if [ "$1" = "remove" ]; then ldconfig fi
hhvm/ci/ubuntu-20.04-focal/debian/preinst
#!/bin/sh set -e if which invoke-rc.d >/dev/null 2>&1 && [ -e "/etc/init.d/hhvm" ]; then invoke-rc.d hhvm stop fi
Inno Setup Script
hhvm/ci/ubuntu-20.04-focal/debian/prerm.in
#!/bin/bash set -e if [ -f /etc/init.d/hhvm ]; then /etc/init.d/hhvm stop fi if [ -f /usr/sbin/update-alternatives ]; then UPDATE_ALTERNATIVES=/usr/sbin/update-alternatives fi if [ -f /usr/bin/update-alternatives ]; then UPDATE_ALTERNATIVES=/usr/bin/update-alternatives fi if [ ! -z "$UPDATE_ALTERNATIVES" ]; then "$UPDATE_ALTERNATIVES" --remove hhvm __PKGROOT__/bin/hhvm fi
hhvm/ci/ubuntu-20.04-focal/debian/rules
#!/usr/bin/make -f include /usr/share/dpkg/pkg-info.mk %: dh $@ --buildsystem=cmake --parallel override_dh_auto_configure: dh_auto_configure -- \ -Wno-dev \ -DCMAKE_INSTALL_PREFIX=/opt/hhvm/$(DEB_VERSION_UPSTREAM) \ -DMYSQL_UNIX_SOCK_ADDR=/var/run/mysqld/mysqld.sock \ -DCMAKE_BUILD_TYPE=RelWithDebInfo override_dh_auto_build: dh_auto_build -- -j1 hack hack_rust_ffi_bridge_targets hhbc_ast_cbindgen hack_dune dh_auto_build -- -j8 override_dh_strip: dh_strip --dbg-package=hhvm-nightly-dbg generated=$(patsubst %.in,%,$(wildcard debian/*.in)) $(generated): %: %.in sed 's,__PKGROOT__,/opt/hhvm/$(DEB_VERSION_UPSTREAM),g' $< > $@ override_dh_auto_install: $(generated) dh_auto_install override_dh_fixperms: dh_fixperms chown www-data:www-data debian/hhvm-nightly/var/log/hhvm chown www-data:www-data debian/hhvm-nightly/var/cache/hhvm
CMake
hhvm/CMake/cotire.cmake
# - cotire (compile time reducer) # # See the cotire manual for usage hints. # #============================================================================= # Copyright 2012-2014 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without # restriction, including without limitation the rights to use, # copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following # conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. #============================================================================= if(__COTIRE_INCLUDED) return() endif() set(__COTIRE_INCLUDED TRUE) # call cmake_minimum_required, but prevent modification of the CMake policy stack in include mode # cmake_minimum_required also sets the policy version as a side effect, which we have to avoid if (NOT CMAKE_SCRIPT_MODE_FILE) cmake_policy(PUSH) endif() # we need the CMake variables CMAKE_SCRIPT_MODE_FILE and CMAKE_ARGV available since 2.8.5 # we need APPEND_STRING option for set_property available since 2.8.6 cmake_minimum_required(VERSION 2.8.6) if (NOT CMAKE_SCRIPT_MODE_FILE) cmake_policy(POP) endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") set (COTIRE_CMAKE_MODULE_VERSION "1.6.6") include(CMakeParseArguments) include(ProcessorCount) function (cotire_determine_compiler_version _language _versionPrefix) if (NOT ${_versionPrefix}_VERSION) # use CMake's predefined compiler version variable (available since CMake 2.8.8) if (DEFINED CMAKE_${_language}_COMPILER_VERSION) set (${_versionPrefix}_VERSION "${CMAKE_${_language}_COMPILER_VERSION}") elseif (WIN32) # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) execute_process ( COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} ERROR_VARIABLE _versionLine OUTPUT_QUIET TIMEOUT 10) string (REGEX REPLACE ".*Version *([0-9]+(\\.[0-9]+)*).*" "\\1" ${_versionPrefix}_VERSION "${_versionLine}") else() # assume GCC like command line interface string (STRIP "${CMAKE_${_language}_COMPILER_ARG1}" _compilerArg1) execute_process ( COMMAND ${CMAKE_${_language}_COMPILER} ${_compilerArg1} "-dumpversion" OUTPUT_VARIABLE ${_versionPrefix}_VERSION RESULT_VARIABLE _result OUTPUT_STRIP_TRAILING_WHITESPACE TIMEOUT 10) if (_result) set (${_versionPrefix}_VERSION "") endif() endif() if (${_versionPrefix}_VERSION) set (${_versionPrefix}_VERSION "${${_versionPrefix}_VERSION}" CACHE INTERNAL "${_language} compiler version") endif() set (${_versionPrefix}_VERSION "${${_versionPrefix}_VERSION}" PARENT_SCOPE) if (COTIRE_DEBUG) message (STATUS "${CMAKE_${_language}_COMPILER} version ${${_versionPrefix}_VERSION}") endif() endif() endfunction() function (cotire_get_source_file_extension _sourceFile _extVar) # get_filename_component returns extension from first occurrence of . in file name # this function computes the extension from last occurrence of . in file name string (FIND "${_sourceFile}" "." _index REVERSE) if (_index GREATER -1) math (EXPR _index "${_index} + 1") string (SUBSTRING "${_sourceFile}" ${_index} -1 _sourceExt) else() set (_sourceExt "") endif() set (${_extVar} "${_sourceExt}" PARENT_SCOPE) endfunction() macro (cotire_check_is_path_relative_to _path _isRelativeVar) set (${_isRelativeVar} FALSE) if (IS_ABSOLUTE "${_path}") foreach (_dir ${ARGN}) file (RELATIVE_PATH _relPath "${_dir}" "${_path}") if (NOT _relPath OR (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.")) set (${_isRelativeVar} TRUE) break() endif() endforeach() endif() endmacro() function (cotire_filter_language_source_files _language _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar) set (_sourceFiles "") set (_excludedSourceFiles "") set (_cotiredSourceFiles "") if (CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) set (_languageExtensions "${CMAKE_${_language}_SOURCE_FILE_EXTENSIONS}") else() set (_languageExtensions "") endif() if (CMAKE_${_language}_IGNORE_EXTENSIONS) set (_ignoreExtensions "${CMAKE_${_language}_IGNORE_EXTENSIONS}") else() set (_ignoreExtensions "") endif() if (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS) set (_excludeExtensions "${COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS}") else() set (_excludeExtensions "") endif() if (COTIRE_DEBUG) message (STATUS "${_language} source file extensions: ${_languageExtensions}") message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}") message (STATUS "${_language} exclude extensions: ${_excludeExtensions}") endif() foreach (_sourceFile ${ARGN}) get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT) get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC) get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE) set (_sourceIsFiltered FALSE) if (NOT _sourceIsHeaderOnly AND NOT _sourceIsExternal AND NOT _sourceIsSymbolic) cotire_get_source_file_extension("${_sourceFile}" _sourceExt) if (_sourceExt) list (FIND _ignoreExtensions "${_sourceExt}" _ignoreIndex) if (_ignoreIndex LESS 0) list (FIND _excludeExtensions "${_sourceExt}" _excludeIndex) if (_excludeIndex GREATER -1) list (APPEND _excludedSourceFiles "${_sourceFile}") else() list (FIND _languageExtensions "${_sourceExt}" _sourceIndex) if (_sourceIndex GREATER -1) set (_sourceIsFiltered TRUE) elseif ("${_sourceLanguage}" STREQUAL "${_language}") # add to excluded sources, if file is not ignored and has correct language without having the correct extension list (APPEND _excludedSourceFiles "${_sourceFile}") endif() endif() endif() endif() endif() if (COTIRE_DEBUG) message (STATUS "${_sourceFile} filtered=${_sourceIsFiltered} language=${_sourceLanguage} header=${_sourceIsHeaderOnly}") endif() if (_sourceIsFiltered) get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED) get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET) get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS) if (COTIRE_DEBUG) message (STATUS "${_sourceFile} excluded=${_sourceIsExcluded} cotired=${_sourceIsCotired} compileFlags=${_sourceCompileFlags}") endif() if (_sourceIsCotired) list (APPEND _cotiredSourceFiles "${_sourceFile}") elseif (_sourceIsExcluded OR _sourceCompileFlags) list (APPEND _excludedSourceFiles "${_sourceFile}") else() list (APPEND _sourceFiles "${_sourceFile}") endif() endif() endforeach() if (COTIRE_DEBUG) message (STATUS "All: ${ARGN}") message (STATUS "${_language}: ${_sourceFiles}") message (STATUS "Excluded: ${_excludedSourceFiles}") message (STATUS "Cotired: ${_cotiredSourceFiles}") endif() set (${_sourceFilesVar} ${_sourceFiles} PARENT_SCOPE) set (${_excludedSourceFilesVar} ${_excludedSourceFiles} PARENT_SCOPE) set (${_cotiredSourceFilesVar} ${_cotiredSourceFiles} PARENT_SCOPE) endfunction() function (cotire_get_objects_with_property_on _filteredObjectsVar _property _type) set (_filteredObjects "") foreach (_object ${ARGN}) get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET) if (_isSet) get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) if (_propertyValue) list (APPEND _filteredObjects "${_object}") endif() endif() endforeach() set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE) endfunction() function (cotire_get_objects_with_property_off _filteredObjectsVar _property _type) set (_filteredObjects "") foreach (_object ${ARGN}) get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET) if (_isSet) get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) if (NOT _propertyValue) list (APPEND _filteredObjects "${_object}") endif() endif() endforeach() set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE) endfunction() function (cotire_get_source_file_property_values _valuesVar _property) set (_values "") foreach (_sourceFile ${ARGN}) get_source_file_property(_propertyValue "${_sourceFile}" ${_property}) if (_propertyValue) list (APPEND _values "${_propertyValue}") endif() endforeach() set (${_valuesVar} ${_values} PARENT_SCOPE) endfunction() function (cotire_resolve_config_properties _configurations _propertiesVar) set (_properties "") foreach (_property ${ARGN}) if ("${_property}" MATCHES "<CONFIG>") foreach (_config ${_configurations}) string (TOUPPER "${_config}" _upperConfig) string (REPLACE "<CONFIG>" "${_upperConfig}" _configProperty "${_property}") list (APPEND _properties ${_configProperty}) endforeach() else() list (APPEND _properties ${_property}) endif() endforeach() set (${_propertiesVar} ${_properties} PARENT_SCOPE) endfunction() function (cotire_copy_set_properties _configurations _type _source _target) cotire_resolve_config_properties("${_configurations}" _properties ${ARGN}) foreach (_property ${_properties}) get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET) if (_isSet) get_property(_propertyValue ${_type} ${_source} PROPERTY ${_property}) set_property(${_type} ${_target} PROPERTY ${_property} "${_propertyValue}") endif() endforeach() endfunction() function (cotire_get_target_link_libraries_for_usage_requirements _target _targetLinkLibrariesVar) set (_targetLinkLibraries "") get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES) while (_librariesToProcess) # remove from head list (GET _librariesToProcess 0 _library) list (REMOVE_AT _librariesToProcess 0) list (FIND _targetLinkLibraries ${_library} _index) if (_index LESS 0) list (APPEND _targetLinkLibraries ${_library}) # process transitive libraries if (TARGET ${_library}) get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES) if (_libraries) list (APPEND _librariesToProcess ${_libraries}) endif() endif() endif() endwhile() set (${_targetLinkLibrariesVar} ${_targetLinkLibraries} PARENT_SCOPE) endfunction() function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _unmatchedOptionsVar) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") set (_flagPrefix "[/-]") else() set (_flagPrefix "--?") endif() set (_optionFlag "") set (_matchedOptions "") set (_unmatchedOptions "") foreach (_compileFlag ${ARGN}) if (_compileFlag) if (_optionFlag AND NOT "${_compileFlag}" MATCHES "^${_flagPrefix}") # option with separate argument list (APPEND _matchedOptions "${_compileFlag}") set (_optionFlag "") elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})$") # remember option set (_optionFlag "${CMAKE_MATCH_2}") elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})(.+)$") # option with joined argument list (APPEND _matchedOptions "${CMAKE_MATCH_3}") set (_optionFlag "") else() # flush remembered option if (_optionFlag) list (APPEND _matchedOptions "${_optionFlag}") set (_optionFlag "") endif() # add to unfiltered options list (APPEND _unmatchedOptions "${_compileFlag}") endif() endif() endforeach() if (_optionFlag) list (APPEND _matchedOptions "${_optionFlag}") endif() if (COTIRE_DEBUG) message (STATUS "Filter ${_flagFilter}") if (_matchedOptions) message (STATUS "Matched ${_matchedOptions}") endif() if (_unmatchedOptions) message (STATUS "Unmatched ${_unmatchedOptions}") endif() endif() set (${_matchedOptionsVar} ${_matchedOptions} PARENT_SCOPE) set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE) endfunction() function (cotire_get_target_compile_flags _config _language _directory _target _flagsVar) string (TOUPPER "${_config}" _upperConfig) # collect options from CMake language variables set (_compileFlags "") if (CMAKE_${_language}_FLAGS) set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS}") endif() if (CMAKE_${_language}_FLAGS_${_upperConfig}) set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_upperConfig}}") endif() if (_target) # add option from CMake target type variable get_target_property(_targetType ${_target} TYPE) if (POLICY CMP0018) # handle POSITION_INDEPENDENT_CODE property introduced with CMake 2.8.9 if policy CMP0018 is turned on cmake_policy(GET CMP0018 _PIC_Policy) else() # default to old behavior set (_PIC_Policy "OLD") endif() if (COTIRE_DEBUG) message(STATUS "CMP0018=${_PIC_Policy}") endif() if (_PIC_Policy STREQUAL "NEW") # NEW behavior: honor the POSITION_INDEPENDENT_CODE target property get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) if (_targetPIC) if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE) set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC) set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") endif() endif() else() # OLD behavior or policy not set: use the value of CMAKE_SHARED_LIBRARY_<Lang>_FLAGS if (_targetType STREQUAL "MODULE_LIBRARY") # flags variable for module library uses different name SHARED_MODULE # (e.g., CMAKE_SHARED_MODULE_C_FLAGS) set (_targetType SHARED_MODULE) endif() if (CMAKE_${_targetType}_${_language}_FLAGS) set (_compileFlags "${_compileFlags} ${CMAKE_${_targetType}_${_language}_FLAGS}") endif() endif() endif() if (_directory) # add_definitions may have been used to add flags to the compiler command get_directory_property(_dirDefinitions DIRECTORY "${_directory}" DEFINITIONS) if (_dirDefinitions) set (_compileFlags "${_compileFlags} ${_dirDefinitions}") endif() endif() if (_target) # add target compile options get_target_property(_targetflags ${_target} COMPILE_FLAGS) if (_targetflags) set (_compileFlags "${_compileFlags} ${_targetflags}") endif() get_target_property(_targetOptions ${_target} COMPILE_OPTIONS) if (_targetOptions) set (_compileFlags "${_compileFlags} ${_targetOptions}") endif() # interface compile options from linked library targets cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) if (TARGET ${_library}) get_target_property(_targetOptions ${_library} INTERFACE_COMPILE_OPTIONS) if (_targetOptions) set (_compileFlags "${_compileFlags} ${_targetOptions}") endif() endif() endforeach() endif() if (UNIX) separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}") elseif(WIN32) separate_arguments(_compileFlags WINDOWS_COMMAND "${_compileFlags}") else() separate_arguments(_compileFlags) endif() # platform specific flags if (APPLE) get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_upperConfig}) if (NOT _architectures) get_target_property(_architectures ${_target} OSX_ARCHITECTURES) endif() if (_architectures) foreach (_arch ${_architectures}) list (APPEND _compileFlags "-arch" "${_arch}") endforeach() endif() if (CMAKE_OSX_SYSROOT) if (CMAKE_${_language}_SYSROOT_FLAG) list (APPEND _compileFlags "${CMAKE_${_language}_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}") else() list (APPEND _compileFlags "-isysroot" "${CMAKE_OSX_SYSROOT}") endif() endif() if (CMAKE_OSX_DEPLOYMENT_TARGET) if (CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG) list (APPEND _compileFlags "${CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}") else() list (APPEND _compileFlags "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") endif() endif() endif() if (COTIRE_DEBUG AND _compileFlags) message (STATUS "Target ${_target} compile flags ${_compileFlags}") endif() set (${_flagsVar} ${_compileFlags} PARENT_SCOPE) endfunction() function (cotire_get_target_include_directories _config _language _targetSourceDir _targetBinaryDir _target _includeDirsVar _systemIncludeDirsVar) set (_includeDirs "") set (_systemIncludeDirs "") # default include dirs if (CMAKE_INCLUDE_CURRENT_DIR) list (APPEND _includeDirs "${_targetBinaryDir}") list (APPEND _includeDirs "${_targetSourceDir}") endif() # parse additional include directories from target compile flags set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "I" _dirs _ignore ${_targetFlags}) if (_dirs) list (APPEND _includeDirs ${_dirs}) endif() # target include directories get_directory_property(_dirs DIRECTORY "${_targetSourceDir}" INCLUDE_DIRECTORIES) if (_target) get_target_property(_targetDirs ${_target} INCLUDE_DIRECTORIES) if (_targetDirs) list (APPEND _dirs ${_targetDirs}) endif() get_target_property(_targetDirs ${_target} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) if (_targetDirs) list (APPEND _systemIncludeDirs ${_targetDirs}) endif() # interface include directories from linked library targets cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) if (TARGET ${_library}) get_target_property(_targetDirs ${_library} INTERFACE_INCLUDE_DIRECTORIES) if (_targetDirs) list (APPEND _dirs ${_targetDirs}) endif() get_target_property(_targetDirs ${_library} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) if (_targetDirs) list (APPEND _systemIncludeDirs ${_targetDirs}) endif() endif() endforeach() endif() if (dirs) list (REMOVE_DUPLICATES _dirs) endif() list (LENGTH _includeDirs _projectInsertIndex) foreach (_dir ${_dirs}) if (CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE) cotire_check_is_path_relative_to("${_dir}" _isRelative "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}") if (_isRelative) list (LENGTH _includeDirs _len) if (_len EQUAL _projectInsertIndex) list (APPEND _includeDirs "${_dir}") else() list (INSERT _includeDirs _projectInsertIndex "${_dir}") endif() math (EXPR _projectInsertIndex "${_projectInsertIndex} + 1") else() list (APPEND _includeDirs "${_dir}") endif() else() list (APPEND _includeDirs "${_dir}") endif() endforeach() list (REMOVE_DUPLICATES _includeDirs) list (REMOVE_DUPLICATES _systemIncludeDirs) if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES) list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) endif() if (COTIRE_DEBUG AND _includeDirs) message (STATUS "Target ${_target} include dirs ${_includeDirs}") endif() set (${_includeDirsVar} ${_includeDirs} PARENT_SCOPE) if (COTIRE_DEBUG AND _systemIncludeDirs) message (STATUS "Target ${_target} system include dirs ${_systemIncludeDirs}") endif() set (${_systemIncludeDirsVar} ${_systemIncludeDirs} PARENT_SCOPE) endfunction() macro (cotire_make_C_identifier _identifierVar _str) if (CMAKE_VERSION VERSION_LESS "2.8.12") # mimic CMake SystemTools::MakeCindentifier behavior if ("${_str}" MATCHES "^[0-9].+$") set (_str "_${str}") endif() string (REGEX REPLACE "[^a-zA-Z0-9]" "_" ${_identifierVar} "${_str}") else() string (MAKE_C_IDENTIFIER "${_str}" "${_identifierVar}") endif() endmacro() function (cotire_get_target_export_symbol _target _exportSymbolVar) set (_exportSymbol "") get_target_property(_targetType ${_target} TYPE) get_target_property(_enableExports ${_target} ENABLE_EXPORTS) if (_targetType MATCHES "(SHARED|MODULE)_LIBRARY" OR (_targetType STREQUAL "EXECUTABLE" AND _enableExports)) get_target_property(_exportSymbol ${_target} DEFINE_SYMBOL) if (NOT _exportSymbol) set (_exportSymbol "${_target}_EXPORTS") endif() cotire_make_C_identifier(_exportSymbol "${_exportSymbol}") endif() set (${_exportSymbolVar} ${_exportSymbol} PARENT_SCOPE) endfunction() function (cotire_get_target_compile_definitions _config _language _directory _target _definitionsVar) string (TOUPPER "${_config}" _upperConfig) set (_configDefinitions "") # CMAKE_INTDIR for multi-configuration build systems if (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") list (APPEND _configDefinitions "CMAKE_INTDIR=\"${_config}\"") endif() # target export define symbol cotire_get_target_export_symbol("${_target}" _defineSymbol) if (_defineSymbol) list (APPEND _configDefinitions "${_defineSymbol}") endif() # directory compile definitions get_directory_property(_definitions DIRECTORY "${_directory}" COMPILE_DEFINITIONS) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() get_directory_property(_definitions DIRECTORY "${_directory}" COMPILE_DEFINITIONS_${_upperConfig}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() # target compile definitions get_target_property(_definitions ${_target} COMPILE_DEFINITIONS) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() get_target_property(_definitions ${_target} COMPILE_DEFINITIONS_${_upperConfig}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() # interface compile definitions from linked library targets cotire_get_target_link_libraries_for_usage_requirements(${_target} _linkLibraries) foreach (_library ${_linkLibraries}) if (TARGET ${_library}) get_target_property(_definitions ${_library} INTERFACE_COMPILE_DEFINITIONS) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() endif() endforeach() # parse additional compile definitions from target compile flags # and don't look at directory compile definitions, which we already handled set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags}) if (_definitions) list (APPEND _configDefinitions ${_definitions}) endif() list (REMOVE_DUPLICATES _configDefinitions) if (COTIRE_DEBUG AND _configDefinitions) message (STATUS "Target ${_target} compile definitions ${_configDefinitions}") endif() set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE) endfunction() function (cotire_get_target_compiler_flags _config _language _directory _target _compilerFlagsVar) # parse target compile flags omitting compile definitions and include directives set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_directory}" "${_target}" _targetFlags) set (_compilerFlags "") cotire_filter_compile_flags("${_language}" "[ID]" _ignore _compilerFlags ${_targetFlags}) if (COTIRE_DEBUG AND _compilerFlags) message (STATUS "Target ${_target} compiler flags ${_compilerFlags}") endif() set (${_compilerFlagsVar} ${_compilerFlags} PARENT_SCOPE) endfunction() function (cotire_add_sys_root_paths _pathsVar) if (APPLE) if (CMAKE_OSX_SYSROOT AND CMAKE_${_language}_HAS_ISYSROOT) foreach (_path IN LISTS ${_pathsVar}) if (IS_ABSOLUTE "${_path}") get_filename_component(_path "${CMAKE_OSX_SYSROOT}/${_path}" ABSOLUTE) if (EXISTS "${_path}") list (APPEND ${_pathsVar} "${_path}") endif() endif() endforeach() endif() endif() set (${_pathsVar} ${${_pathsVar}} PARENT_SCOPE) if (COTIRE_DEBUG) message (STATUS "${_pathsVar}=${${_pathsVar}}") endif() endfunction() function (cotire_get_source_extra_properties _sourceFile _pattern _resultVar) set (_extraProperties ${ARGN}) set (_result "") if (_extraProperties) list (FIND _extraProperties "${_sourceFile}" _index) if (_index GREATER -1) math (EXPR _index "${_index} + 1") list (LENGTH _extraProperties _len) math (EXPR _len "${_len} - 1") foreach (_index RANGE ${_index} ${_len}) list (GET _extraProperties ${_index} _value) if (_value MATCHES "${_pattern}") list (APPEND _result "${_value}") else() break() endif() endforeach() endif() endif() set (${_resultVar} ${_result} PARENT_SCOPE) endfunction() function (cotire_get_source_compile_definitions _config _language _sourceFile _definitionsVar) set (_compileDefinitions "") if (NOT CMAKE_SCRIPT_MODE_FILE) string (TOUPPER "${_config}" _upperConfig) get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS) if (_definitions) list (APPEND _compileDefinitions ${_definitions}) endif() get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS_${_upperConfig}) if (_definitions) list (APPEND _compileDefinitions ${_definitions}) endif() endif() cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+(=.*)?$" _definitions ${ARGN}) if (_definitions) list (APPEND _compileDefinitions ${_definitions}) endif() if (COTIRE_DEBUG AND _compileDefinitions) message (STATUS "Source ${_sourceFile} compile definitions ${_compileDefinitions}") endif() set (${_definitionsVar} ${_compileDefinitions} PARENT_SCOPE) endfunction() function (cotire_get_source_files_compile_definitions _config _language _definitionsVar) set (_configDefinitions "") foreach (_sourceFile ${ARGN}) cotire_get_source_compile_definitions("${_config}" "${_language}" "${_sourceFile}" _sourceDefinitions) if (_sourceDefinitions) list (APPEND _configDefinitions "${_sourceFile}" ${_sourceDefinitions} "-") endif() endforeach() set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE) endfunction() function (cotire_get_source_undefs _sourceFile _property _sourceUndefsVar) set (_sourceUndefs "") if (NOT CMAKE_SCRIPT_MODE_FILE) get_source_file_property(_undefs "${_sourceFile}" ${_property}) if (_undefs) list (APPEND _sourceUndefs ${_undefs}) endif() endif() cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+$" _undefs ${ARGN}) if (_undefs) list (APPEND _sourceUndefs ${_undefs}) endif() if (COTIRE_DEBUG AND _sourceUndefs) message (STATUS "Source ${_sourceFile} ${_property} undefs ${_sourceUndefs}") endif() set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE) endfunction() function (cotire_get_source_files_undefs _property _sourceUndefsVar) set (_sourceUndefs "") foreach (_sourceFile ${ARGN}) cotire_get_source_undefs("${_sourceFile}" ${_property} _undefs) if (_undefs) list (APPEND _sourceUndefs "${_sourceFile}" ${_undefs} "-") endif() endforeach() set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE) endfunction() macro (cotire_set_cmd_to_prologue _cmdVar) set (${_cmdVar} "${CMAKE_COMMAND}") if (COTIRE_DEBUG) list (APPEND ${_cmdVar} "--warn-uninitialized") endif() list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$<CONFIGURATION>") if (COTIRE_VERBOSE) list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON") elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles") list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=$(VERBOSE)") endif() endmacro() function (cotire_init_compile_cmd _cmdVar _language _compilerExe _compilerArg1) if (NOT _compilerExe) set (_compilerExe "${CMAKE_${_language}_COMPILER}") endif() if (NOT _compilerArg1) set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) endif() string (STRIP "${_compilerArg1}" _compilerArg1) set (${_cmdVar} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) endfunction() macro (cotire_add_definitions_to_cmd _cmdVar _language) foreach (_definition ${ARGN}) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") list (APPEND ${_cmdVar} "/D${_definition}") else() list (APPEND ${_cmdVar} "-D${_definition}") endif() endforeach() endmacro() macro (cotire_add_includes_to_cmd _cmdVar _language _includeSystemFlag _includesVar _systemIncludesVar) foreach (_include ${${_includesVar}}) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") file (TO_NATIVE_PATH "${_include}" _include) list (APPEND ${_cmdVar} "/I${_include}") else() list (FIND ${_systemIncludesVar} ${_include} _index) if(_index GREATER -1 AND NOT "${_includeSystemFlag}" STREQUAL "") list (APPEND ${_cmdVar} "${_includeSystemFlag}${_include}") else() list (APPEND ${_cmdVar} "-I${_include}") endif() endif() endforeach() endmacro() macro (cotire_add_frameworks_to_cmd _cmdVar _language) if (APPLE) set (_frameWorkDirs "") foreach (_include ${ARGN}) if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$") get_filename_component(_frameWorkDir "${_include}" PATH) list (APPEND _frameWorkDirs "${_frameWorkDir}") endif() endforeach() if (_frameWorkDirs) list (REMOVE_DUPLICATES _frameWorkDirs) foreach (_frameWorkDir ${_frameWorkDirs}) list (APPEND ${_cmdVar} "-F${_frameWorkDir}") endforeach() endif() endif() endmacro() macro (cotire_add_compile_flags_to_cmd _cmdVar) foreach (_flag ${ARGN}) list (APPEND ${_cmdVar} "${_flag}") endforeach() endmacro() function (cotire_check_file_up_to_date _fileIsUpToDateVar _file) set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE) set (_triggerFile "") foreach (_dependencyFile ${ARGN}) if (EXISTS "${_dependencyFile}" AND "${_dependencyFile}" IS_NEWER_THAN "${_file}") set (_triggerFile "${_dependencyFile}") break() endif() endforeach() get_filename_component(_fileName "${_file}" NAME) if (EXISTS "${_file}") if (_triggerFile) if (COTIRE_VERBOSE) message (STATUS "${_fileName} update triggered by ${_triggerFile} change.") endif() else() if (COTIRE_VERBOSE) message (STATUS "${_fileName} is up-to-date.") endif() set (${_fileIsUpToDateVar} TRUE PARENT_SCOPE) endif() else() if (COTIRE_VERBOSE) message (STATUS "${_fileName} does not exist yet.") endif() endif() endfunction() macro (cotire_find_closest_relative_path _headerFile _includeDirs _relPathVar) set (${_relPathVar} "") foreach (_includeDir ${_includeDirs}) if (IS_DIRECTORY "${_includeDir}") file (RELATIVE_PATH _relPath "${_includeDir}" "${_headerFile}") if (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.") string (LENGTH "${${_relPathVar}}" _closestLen) string (LENGTH "${_relPath}" _relLen) if (_closestLen EQUAL 0 OR _relLen LESS _closestLen) set (${_relPathVar} "${_relPath}") endif() endif() elseif ("${_includeDir}" STREQUAL "${_headerFile}") # if path matches exactly, return short non-empty string set (${_relPathVar} "1") break() endif() endforeach() endmacro() macro (cotire_check_header_file_location _headerFile _insideIncludeDirs _outsideIncludeDirs _headerIsInside) # check header path against ignored and honored include directories cotire_find_closest_relative_path("${_headerFile}" "${_insideIncludeDirs}" _insideRelPath) if (_insideRelPath) # header is inside, but could be become outside if there is a shorter outside match cotire_find_closest_relative_path("${_headerFile}" "${_outsideIncludeDirs}" _outsideRelPath) if (_outsideRelPath) string (LENGTH "${_insideRelPath}" _insideRelPathLen) string (LENGTH "${_outsideRelPath}" _outsideRelPathLen) if (_outsideRelPathLen LESS _insideRelPathLen) set (${_headerIsInside} FALSE) else() set (${_headerIsInside} TRUE) endif() else() set (${_headerIsInside} TRUE) endif() else() # header is outside set (${_headerIsInside} FALSE) endif() endmacro() macro (cotire_check_ignore_header_file_path _headerFile _headerIsIgnoredVar) if (NOT EXISTS "${_headerFile}") set (${_headerIsIgnoredVar} TRUE) elseif (IS_DIRECTORY "${_headerFile}") set (${_headerIsIgnoredVar} TRUE) elseif ("${_headerFile}" MATCHES "\\.\\.|[_-]fixed" AND "${_headerFile}" MATCHES "\\.h$") # heuristic: ignore C headers with embedded parent directory references or "-fixed" or "_fixed" in path # these often stem from using GCC #include_next tricks, which may break the precompiled header compilation # with the error message "error: no include path in which to search for header.h" set (${_headerIsIgnoredVar} TRUE) else() set (${_headerIsIgnoredVar} FALSE) endif() endmacro() macro (cotire_check_ignore_header_file_ext _headerFile _ignoreExtensionsVar _headerIsIgnoredVar) # check header file extension cotire_get_source_file_extension("${_headerFile}" _headerFileExt) set (${_headerIsIgnoredVar} FALSE) if (_headerFileExt) list (FIND ${_ignoreExtensionsVar} "${_headerFileExt}" _index) if (_index GREATER -1) set (${_headerIsIgnoredVar} TRUE) endif() endif() endmacro() macro (cotire_parse_line _line _headerFileVar _headerDepthVar) if (MSVC) # cl.exe /showIncludes output looks different depending on the language pack used, e.g.: # English: "Note: including file: C:\directory\file" # German: "Hinweis: Einlesen der Datei: C:\directory\file" # We use a very general regular expression, relying on the presence of the : characters if (_line MATCHES ":( +)([^:]+:[^:]+)$") # Visual Studio compiler output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) else() set (${_headerFileVar} "") set (${_headerDepthVar} 0) endif() else() if (_line MATCHES "^(\\.+) (.*)$") # GCC like output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) if (IS_ABSOLUTE "${CMAKE_MATCH_2}") set (${_headerFileVar} "${CMAKE_MATCH_2}") else() get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" REALPATH) endif() else() set (${_headerFileVar} "") set (${_headerDepthVar} 0) endif() endif() endmacro() function (cotire_parse_includes _language _scanOutput _ignoredIncludeDirs _honoredIncludeDirs _ignoredExtensions _selectedIncludesVar _unparsedLinesVar) if (WIN32) # prevent CMake macro invocation errors due to backslash characters in Windows paths string (REPLACE "\\" "/" _scanOutput "${_scanOutput}") endif() # canonize slashes string (REPLACE "//" "/" _scanOutput "${_scanOutput}") # prevent semicolon from being interpreted as a line separator string (REPLACE ";" "\\;" _scanOutput "${_scanOutput}") # then separate lines string (REGEX REPLACE "\n" ";" _scanOutput "${_scanOutput}") list (LENGTH _scanOutput _len) # remove duplicate lines to speed up parsing list (REMOVE_DUPLICATES _scanOutput) list (LENGTH _scanOutput _uniqueLen) if (COTIRE_VERBOSE OR COTIRE_DEBUG) message (STATUS "Scanning ${_uniqueLen} unique lines of ${_len} for includes") if (_ignoredExtensions) message (STATUS "Ignored extensions: ${_ignoredExtensions}") endif() if (_ignoredIncludeDirs) message (STATUS "Ignored paths: ${_ignoredIncludeDirs}") endif() if (_honoredIncludeDirs) message (STATUS "Included paths: ${_honoredIncludeDirs}") endif() endif() set (_sourceFiles ${ARGN}) set (_selectedIncludes "") set (_unparsedLines "") # stack keeps track of inside/outside project status of processed header files set (_headerIsInsideStack "") foreach (_line IN LISTS _scanOutput) if (_line) cotire_parse_line("${_line}" _headerFile _headerDepth) if (_headerFile) cotire_check_header_file_location("${_headerFile}" "${_ignoredIncludeDirs}" "${_honoredIncludeDirs}" _headerIsInside) if (COTIRE_DEBUG) message (STATUS "${_headerDepth}: ${_headerFile} ${_headerIsInside}") endif() # update stack list (LENGTH _headerIsInsideStack _stackLen) if (_headerDepth GREATER _stackLen) math (EXPR _stackLen "${_stackLen} + 1") foreach (_index RANGE ${_stackLen} ${_headerDepth}) list (APPEND _headerIsInsideStack ${_headerIsInside}) endforeach() else() foreach (_index RANGE ${_headerDepth} ${_stackLen}) list (REMOVE_AT _headerIsInsideStack -1) endforeach() list (APPEND _headerIsInsideStack ${_headerIsInside}) endif() if (COTIRE_DEBUG) message (STATUS "${_headerIsInsideStack}") endif() # header is a candidate if it is outside project if (NOT _headerIsInside) # get parent header file's inside/outside status if (_headerDepth GREATER 1) math (EXPR _index "${_headerDepth} - 2") list (GET _headerIsInsideStack ${_index} _parentHeaderIsInside) else() set (_parentHeaderIsInside TRUE) endif() # select header file if parent header file is inside project # (e.g., a project header file that includes a standard header file) if (_parentHeaderIsInside) cotire_check_ignore_header_file_path("${_headerFile}" _headerIsIgnored) if (NOT _headerIsIgnored) cotire_check_ignore_header_file_ext("${_headerFile}" _ignoredExtensions _headerIsIgnored) if (NOT _headerIsIgnored) list (APPEND _selectedIncludes "${_headerFile}") else() # fix header's inside status on stack, it is ignored by extension now list (REMOVE_AT _headerIsInsideStack -1) list (APPEND _headerIsInsideStack TRUE) endif() endif() if (COTIRE_DEBUG) message (STATUS "${_headerFile} ${_ignoredExtensions} ${_headerIsIgnored}") endif() endif() endif() else() if (MSVC) # for cl.exe do not keep unparsed lines which solely consist of a source file name string (FIND "${_sourceFiles}" "${_line}" _index) if (_index LESS 0) list (APPEND _unparsedLines "${_line}") endif() else() list (APPEND _unparsedLines "${_line}") endif() endif() endif() endforeach() list (REMOVE_DUPLICATES _selectedIncludes) set (${_selectedIncludesVar} ${_selectedIncludes} PARENT_SCOPE) set (${_unparsedLinesVar} ${_unparsedLines} PARENT_SCOPE) endfunction() function (cotire_scan_includes _includesVar) set(_options "") set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_VERSION INCLUDE_SYSTEM_FLAG LANGUAGE UNPARSED_LINES) set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) if (NOT _option_LANGUAGE) set (_option_LANGUAGE "CXX") endif() if (NOT _option_COMPILER_ID) set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") endif() set (_cmd "${_option_COMPILER_EXECUTABLE}" ${_option_COMPILER_ARG1}) cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" "${_option_INCLUDE_SYSTEM_FLAG}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd) # only consider existing source files for scanning set (_existingSourceFiles "") foreach (_sourceFile ${_sourceFiles}) if (EXISTS "${_sourceFile}") list (APPEND _existingSourceFiles "${_sourceFile}") endif() endforeach() if (NOT _existingSourceFiles) set (${_includesVar} "" PARENT_SCOPE) return() endif() list (APPEND _cmd ${_existingSourceFiles}) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() if (_option_COMPILER_ID MATCHES "MSVC") if (COTIRE_DEBUG) message (STATUS "clearing VS_UNICODE_OUTPUT") endif() # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() execute_process( COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE _result OUTPUT_QUIET ERROR_VARIABLE _output) if (_result) message (STATUS "Result ${_result} scanning includes of ${_existingSourceFiles}.") endif() cotire_parse_includes( "${_option_LANGUAGE}" "${_output}" "${_option_IGNORE_PATH}" "${_option_INCLUDE_PATH}" "${_option_IGNORE_EXTENSIONS}" _includes _unparsedLines ${_sourceFiles}) set (${_includesVar} ${_includes} PARENT_SCOPE) if (_option_UNPARSED_LINES) set (${_option_UNPARSED_LINES} ${_unparsedLines} PARENT_SCOPE) endif() endfunction() macro (cotire_append_undefs _contentsVar) set (_undefs ${ARGN}) if (_undefs) list (REMOVE_DUPLICATES _undefs) foreach (_definition ${_undefs}) list (APPEND ${_contentsVar} "#undef ${_definition}") endforeach() endif() endmacro() macro (cotire_comment_str _language _commentText _commentVar) if ("${_language}" STREQUAL "CMAKE") set (${_commentVar} "# ${_commentText}") else() set (${_commentVar} "/* ${_commentText} */") endif() endmacro() function (cotire_write_file _language _file _contents _force) get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) cotire_comment_str("${_language}" "${_moduleName} ${COTIRE_CMAKE_MODULE_VERSION} generated file" _header1) cotire_comment_str("${_language}" "${_file}" _header2) set (_contents "${_header1}\n${_header2}\n${_contents}") if (COTIRE_DEBUG) message (STATUS "${_contents}") endif() if (_force OR NOT EXISTS "${_file}") file (WRITE "${_file}" "${_contents}") else() file (READ "${_file}" _oldContents) if (NOT "${_oldContents}" STREQUAL "${_contents}") file (WRITE "${_file}" "${_contents}") else() if (COTIRE_DEBUG) message (STATUS "${_file} unchanged") endif() endif() endif() endfunction() function (cotire_generate_unity_source _unityFile) set(_options "") set(_oneValueArgs LANGUAGE) set(_multiValueArgs DEPENDS SOURCES_COMPILE_DEFINITIONS PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS PROLOGUE EPILOGUE) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (_option_DEPENDS) cotire_check_file_up_to_date(_unityFileIsUpToDate "${_unityFile}" ${_option_DEPENDS}) if (_unityFileIsUpToDate) return() endif() endif() set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) if (NOT _option_PRE_UNDEFS) set (_option_PRE_UNDEFS "") endif() if (NOT _option_SOURCES_PRE_UNDEFS) set (_option_SOURCES_PRE_UNDEFS "") endif() if (NOT _option_POST_UNDEFS) set (_option_POST_UNDEFS "") endif() if (NOT _option_SOURCES_POST_UNDEFS) set (_option_SOURCES_POST_UNDEFS "") endif() set (_contents "") if (_option_PROLOGUE) list (APPEND _contents ${_option_PROLOGUE}) endif() if (_option_LANGUAGE AND _sourceFiles) if ("${_option_LANGUAGE}" STREQUAL "CXX") list (APPEND _contents "#ifdef __cplusplus") elseif ("${_option_LANGUAGE}" STREQUAL "C") list (APPEND _contents "#ifndef __cplusplus") endif() endif() set (_compileUndefinitions "") foreach (_sourceFile ${_sourceFiles}) cotire_get_source_compile_definitions( "${_option_CONFIGURATION}" "${_option_LANGUAGE}" "${_sourceFile}" _compileDefinitions ${_option_SOURCES_COMPILE_DEFINITIONS}) cotire_get_source_undefs("${_sourceFile}" COTIRE_UNITY_SOURCE_PRE_UNDEFS _sourcePreUndefs ${_option_SOURCES_PRE_UNDEFS}) cotire_get_source_undefs("${_sourceFile}" COTIRE_UNITY_SOURCE_POST_UNDEFS _sourcePostUndefs ${_option_SOURCES_POST_UNDEFS}) if (_option_PRE_UNDEFS) list (APPEND _compileUndefinitions ${_option_PRE_UNDEFS}) endif() if (_sourcePreUndefs) list (APPEND _compileUndefinitions ${_sourcePreUndefs}) endif() if (_compileUndefinitions) cotire_append_undefs(_contents ${_compileUndefinitions}) set (_compileUndefinitions "") endif() if (_sourcePostUndefs) list (APPEND _compileUndefinitions ${_sourcePostUndefs}) endif() if (_option_POST_UNDEFS) list (APPEND _compileUndefinitions ${_option_POST_UNDEFS}) endif() foreach (_definition ${_compileDefinitions}) if (_definition MATCHES "^([a-zA-Z0-9_]+)=(.+)$") list (APPEND _contents "#define ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}") list (INSERT _compileUndefinitions 0 "${CMAKE_MATCH_1}") else() list (APPEND _contents "#define ${_definition}") list (INSERT _compileUndefinitions 0 "${_definition}") endif() endforeach() get_filename_component(_sourceFile "${_sourceFile}" ABSOLUTE) if (WIN32) file (TO_NATIVE_PATH "${_sourceFile}" _sourceFile) endif() list (APPEND _contents "#include \"${_sourceFile}\"") endforeach() if (_compileUndefinitions) cotire_append_undefs(_contents ${_compileUndefinitions}) set (_compileUndefinitions "") endif() if (_option_LANGUAGE AND _sourceFiles) list (APPEND _contents "#endif") endif() if (_option_EPILOGUE) list (APPEND _contents ${_option_EPILOGUE}) endif() list (APPEND _contents "") string (REPLACE ";" "\n" _contents "${_contents}") if (COTIRE_VERBOSE) message ("${_contents}") endif() cotire_write_file("${_option_LANGUAGE}" "${_unityFile}" "${_contents}" TRUE) endfunction() function (cotire_generate_prefix_header _prefixFile) set(_options "") set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION INCLUDE_SYSTEM_FLAG) set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (_option_DEPENDS) cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS}) if (_prefixFileIsUpToDate) set (_unparsedLinesFile "${_prefixFile}.log") file (WRITE "${_unparsedLinesFile}" "") return() endif() endif() set (_prologue "") set (_epilogue "") if (_option_COMPILER_ID MATCHES "Clang") set (_prologue "#pragma clang system_header") elseif (_option_COMPILER_ID MATCHES "GNU") set (_prologue "#pragma GCC system_header") elseif (_option_COMPILER_ID MATCHES "MSVC") set (_prologue "#pragma warning(push, 0)") set (_epilogue "#pragma warning(pop)") elseif (_option_COMPILER_ID MATCHES "Intel") # Intel compiler requires hdrstop pragma to stop generating PCH file set (_epilogue "#pragma hdrstop") endif() set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) cotire_scan_includes(_selectedHeaders ${_sourceFiles} LANGUAGE "${_option_LANGUAGE}" COMPILER_EXECUTABLE "${_option_COMPILER_EXECUTABLE}" COMPILER_ID "${_option_COMPILER_ID}" COMPILER_VERSION "${_option_COMPILER_VERSION}" COMPILE_DEFINITIONS ${_option_COMPILE_DEFINITIONS} COMPILE_FLAGS ${_option_COMPILE_FLAGS} INCLUDE_DIRECTORIES ${_option_INCLUDE_DIRECTORIES} INCLUDE_SYSTEM_FLAG ${_option_INCLUDE_SYSTEM_FLAG} SYSTEM_INCLUDE_DIRECTORIES ${_option_SYSTEM_INCLUDE_DIRECTORIES} IGNORE_PATH ${_option_IGNORE_PATH} INCLUDE_PATH ${_option_INCLUDE_PATH} IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} UNPARSED_LINES _unparsedLines) cotire_generate_unity_source("${_prefixFile}" PROLOGUE ${_prologue} EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) set (_unparsedLinesFile "${_prefixFile}.log") if (_unparsedLines) if (COTIRE_VERBOSE OR NOT _selectedHeaders) list (LENGTH _unparsedLines _skippedLineCount) file (RELATIVE_PATH _unparsedLinesFileRelPath "${CMAKE_BINARY_DIR}" "${_unparsedLinesFile}") message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFileRelPath}") endif() string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") endif() file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}") endfunction() function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flagsVar) set (_flags ${${_flagsVar}}) if (_compilerID MATCHES "MSVC") # cl.exe options used # /nologo suppresses display of sign-on banner # /TC treat all files named on the command line as C source files # /TP treat all files named on the command line as C++ source files # /EP preprocess to stdout without #line directives # /showIncludes list include files set (_sourceFileTypeC "/TC") set (_sourceFileTypeCXX "/TP") if (_flags) # append to list list (APPEND _flags /nologo "${_sourceFileType${_language}}" /EP /showIncludes) else() # return as a flag string set (_flags "${_sourceFileType${_language}} /EP /showIncludes") endif() elseif (_compilerID MATCHES "GNU") # GCC options used # -H print the name of each header file used # -E invoke preprocessor # -fdirectives-only do not expand macros, requires GCC >= 4.3 if (_flags) # append to list list (APPEND _flags -H -E) if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") list (APPEND _flags "-fdirectives-only") endif() else() # return as a flag string set (_flags "-H -E") if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") set (_flags "${_flags} -fdirectives-only") endif() endif() elseif (_compilerID MATCHES "Clang") # Clang options used # -H print the name of each header file used # -E invoke preprocessor if (_flags) # append to list list (APPEND _flags -H -E) else() # return as a flag string set (_flags "-H -E") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) # Windows Intel options used # /nologo do not display compiler version information # /QH display the include file order # /EP preprocess to stdout, omitting #line directives # /TC process all source or unrecognized file types as C source files # /TP process all source or unrecognized file types as C++ source files set (_sourceFileTypeC "/TC") set (_sourceFileTypeCXX "/TP") if (_flags) # append to list list (APPEND _flags /nologo "${_sourceFileType${_language}}" /EP /QH) else() # return as a flag string set (_flags "${_sourceFileType${_language}} /EP /QH") endif() else() # Linux / Mac OS X Intel options used # -H print the name of each header file used # -EP preprocess to stdout, omitting #line directives # -Kc++ process all source or unrecognized file types as C++ source files if (_flags) # append to list if ("${_language}" STREQUAL "CXX") list (APPEND _flags -Kc++) endif() list (APPEND _flags -H -EP) else() # return as a flag string if ("${_language}" STREQUAL "CXX") set (_flags "-Kc++ ") endif() set (_flags "${_flags}-H -EP") endif() endif() else() message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() set (${_flagsVar} ${_flags} PARENT_SCOPE) endfunction() function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersion _prefixFile _pchFile _hostFile _flagsVar) set (_flags ${${_flagsVar}}) if (_compilerID MATCHES "MSVC") file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative) # cl.exe options used # /Yc creates a precompiled header file # /Fp specifies precompiled header binary file name # /FI forces inclusion of file # /TC treat all files named on the command line as C source files # /TP treat all files named on the command line as C++ source files # /Zs syntax check only set (_sourceFileTypeC "/TC") set (_sourceFileTypeCXX "/TP") if (_flags) # append to list list (APPEND _flags /nologo "${_sourceFileType${_language}}" "/Yc${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}") else() # return as a flag string set (_flags "/Yc\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") endif() elseif (_compilerID MATCHES "GNU|Clang") # GCC / Clang options used # -x specify the source language # -c compile but do not link # -o place output in file # note that we cannot use -w to suppress all warnings upon pre-compiling, because turning off a warning may # alter compile flags as a side effect (e.g., -Wwrite-string implies -fconst-strings) set (_xLanguage_C "c-header") set (_xLanguage_CXX "c++-header") if (_flags) # append to list list (APPEND _flags "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") else() # return as a flag string set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative) # Windows Intel options used # /nologo do not display compiler version information # /Yc create a precompiled header (PCH) file # /Fp specify a path or file name for precompiled header files # /FI tells the preprocessor to include a specified file name as the header file # /TC process all source or unrecognized file types as C source files # /TP process all source or unrecognized file types as C++ source files # /Zs syntax check only # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) set (_sourceFileTypeC "/TC") set (_sourceFileTypeCXX "/TP") if (_flags) # append to list list (APPEND _flags /nologo "${_sourceFileType${_language}}" "/Yc" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") list (APPEND _flags "/Wpch-messages") endif() else() # return as a flag string set (_flags "/Yc /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") set (_flags "${_flags} /Wpch-messages") endif() endif() else() # Linux / Mac OS X Intel options used # -pch-dir location for precompiled header files # -pch-create name of the precompiled header (PCH) to create # -Kc++ process all source or unrecognized file types as C++ source files # -fsyntax-only check only for correct syntax # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) get_filename_component(_pchDir "${_pchFile}" PATH) get_filename_component(_pchName "${_pchFile}" NAME) set (_xLanguage_C "c-header") set (_xLanguage_CXX "c++-header") if (_flags) # append to list if ("${_language}" STREQUAL "CXX") list (APPEND _flags -Kc++) endif() list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-fsyntax-only" "${_hostFile}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") list (APPEND _flags "-Wpch-messages") endif() else() # return as a flag string set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") set (_flags "${_flags} -Wpch-messages") endif() endif() endif() else() message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() set (${_flagsVar} ${_flags} PARENT_SCOPE) endfunction() function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerVersion _prefixFile _pchFile _flagsVar) set (_flags ${${_flagsVar}}) if (_compilerID MATCHES "MSVC") file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) # cl.exe options used # /Yu uses a precompiled header file during build # /Fp specifies precompiled header binary file name # /FI forces inclusion of file if (_pchFile) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) if (_flags) # append to list list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") else() # return as a flag string set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") endif() else() # no precompiled header, force inclusion of prefix header if (_flags) # append to list list (APPEND _flags "/FI${_prefixFileNative}") else() # return as a flag string set (_flags "/FI\"${_prefixFileNative}\"") endif() endif() elseif (_compilerID MATCHES "GNU") # GCC options used # -include process include file as the first line of the primary source file # -Winvalid-pch warns if precompiled header is found but cannot be used # note: ccache requires the -include flag to be used in order to process precompiled header correctly if (_flags) # append to list list (APPEND _flags "-Winvalid-pch" "-include" "${_prefixFile}") else() # return as a flag string set (_flags "-Winvalid-pch -include \"${_prefixFile}\"") endif() elseif (_compilerID MATCHES "Clang") # Clang options used # -include process include file as the first line of the primary source file # -include-pch include precompiled header file # -Qunused-arguments don't emit warning for unused driver arguments # note: ccache requires the -include flag to be used in order to process precompiled header correctly if (_flags) # append to list list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") else() # return as a flag string set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") endif() elseif (_compilerID MATCHES "Intel") if (WIN32) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) # Windows Intel options used # /Yu use a precompiled header (PCH) file # /Fp specify a path or file name for precompiled header files # /FI tells the preprocessor to include a specified file name as the header file # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) if (_pchFile) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) if (_flags) # append to list list (APPEND _flags "/Yu" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") list (APPEND _flags "/Wpch-messages") endif() else() # return as a flag string set (_flags "/Yu /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") set (_flags "${_flags} /Wpch-messages") endif() endif() else() # no precompiled header, force inclusion of prefix header if (_flags) # append to list list (APPEND _flags "/FI${_prefixFileNative}") else() # return as a flag string set (_flags "/FI\"${_prefixFileNative}\"") endif() endif() else() # Linux / Mac OS X Intel options used # -pch-dir location for precompiled header files # -pch-use name of the precompiled header (PCH) to use # -include process include file as the first line of the primary source file # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) if (_pchFile) get_filename_component(_pchDir "${_pchFile}" PATH) get_filename_component(_pchName "${_pchFile}" NAME) if (_flags) # append to list list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") list (APPEND _flags "-Wpch-messages") endif() else() # return as a flag string set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") set (_flags "${_flags} -Wpch-messages") endif() endif() else() # no precompiled header, force inclusion of prefix header if (_flags) # append to list list (APPEND _flags "-include" "${_prefixFile}") else() # return as a flag string set (_flags "-include \"${_prefixFile}\"") endif() endif() endif() else() message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") endif() set (${_flagsVar} ${_flags} PARENT_SCOPE) endfunction() function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) set(_options "") set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ID COMPILER_VERSION INCLUDE_SYSTEM_FLAG LANGUAGE) set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES SYS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (NOT _option_LANGUAGE) set (_option_LANGUAGE "CXX") endif() if (NOT _option_COMPILER_ID) set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") endif() cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" "${_option_INCLUDE_SYSTEM_FLAG}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_INCLUDE_DIRECTORIES}) cotire_add_pch_compilation_flags( "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _cmd) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() if (_option_COMPILER_ID MATCHES "MSVC") if (COTIRE_DEBUG) message (STATUS "clearing VS_UNICODE_OUTPUT") endif() # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() execute_process( COMMAND ${_cmd} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE _result) if (_result) message (FATAL_ERROR "cotire: error ${_result} precompiling ${_prefixFile}.") endif() endfunction() function (cotire_check_precompiled_header_support _language _targetSourceDir _target _msgVar) set (_unsupportedCompiler "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}") if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") # supported since Visual Studio C++ 6.0 # and CMake does not support an earlier version set (${_msgVar} "" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") # GCC PCH support requires version >= 3.4 cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "3.4.0") set (${_msgVar} "${_unsupportedCompiler} version ${COTIRE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) else() set (${_msgVar} "" PARENT_SCOPE) endif() elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") # all Clang versions have PCH support set (${_msgVar} "" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") # Intel PCH support requires version >= 8.0.0 cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) if ("${COTIRE_${_language}_COMPILER_VERSION}" MATCHES ".+" AND "${COTIRE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0") set (${_msgVar} "${_unsupportedCompiler} version ${COTIRE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) else() set (${_msgVar} "" PARENT_SCOPE) endif() else() set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() if (CMAKE_${_language}_COMPILER MATCHES "ccache") if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") set (${_msgVar} "ccache requires the environment variable CCACHE_SLOPPINESS to be set to time_macros." PARENT_SCOPE) endif() endif() if (APPLE) # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64) if (CMAKE_CONFIGURATION_TYPES) set (_configs ${CMAKE_CONFIGURATION_TYPES}) elseif (CMAKE_BUILD_TYPE) set (_configs ${CMAKE_BUILD_TYPE}) else() set (_configs "None") endif() foreach (_config ${_configs}) set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_targetSourceDir}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "arch" _architectures _ignore ${_targetFlags}) list (LENGTH _architectures _numberOfArchitectures) if (_numberOfArchitectures GREATER 1) string (REPLACE ";" ", " _architectureStr "${_architectures}") set (${_msgVar} "Precompiled headers not supported on Darwin for multi-architecture builds (${_architectureStr})." PARENT_SCOPE) break() endif() endforeach() endif() endfunction() macro (cotire_get_intermediate_dir _cotireDir) get_filename_component(${_cotireDir} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${COTIRE_INTDIR}" ABSOLUTE) endmacro() macro (cotire_setup_file_extension_variables) set (_unityFileExt_C ".c") set (_unityFileExt_CXX ".cxx") set (_prefixFileExt_C ".h") set (_prefixFileExt_CXX ".hxx") set (_prefixSourceFileExt_C ".c") set (_prefixSourceFileExt_CXX ".cxx") endmacro() function (cotire_make_single_unity_source_file_path _language _target _unityFileVar) cotire_setup_file_extension_variables() if (NOT DEFINED _unityFileExt_${_language}) set (${_unityFileVar} "" PARENT_SCOPE) return() endif() set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") set (_unityFileName "${_unityFileBaseName}${_unityFileExt_${_language}}") cotire_get_intermediate_dir(_baseDir) set (_unityFile "${_baseDir}/${_unityFileName}") set (${_unityFileVar} "${_unityFile}" PARENT_SCOPE) if (COTIRE_DEBUG) message(STATUS "${_unityFile}") endif() endfunction() function (cotire_make_unity_source_file_paths _language _target _maxIncludes _unityFilesVar) cotire_setup_file_extension_variables() if (NOT DEFINED _unityFileExt_${_language}) set (${_unityFileVar} "" PARENT_SCOPE) return() endif() set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") cotire_get_intermediate_dir(_baseDir) set (_startIndex 0) set (_index 0) set (_unityFiles "") set (_sourceFiles ${ARGN}) foreach (_sourceFile ${_sourceFiles}) get_source_file_property(_startNew "${_sourceFile}" COTIRE_START_NEW_UNITY_SOURCE) math (EXPR _unityFileCount "${_index} - ${_startIndex}") if (_startNew OR (_maxIncludes GREATER 0 AND NOT _unityFileCount LESS _maxIncludes)) if (_index GREATER 0) # start new unity file segment math (EXPR _endIndex "${_index} - 1") set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}") list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") endif() set (_startIndex ${_index}) endif() math (EXPR _index "${_index} + 1") endforeach() list (LENGTH _sourceFiles _numberOfSources) if (_startIndex EQUAL 0) # there is only a single unity file cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFiles) elseif (_startIndex LESS _numberOfSources) # end with final unity file segment math (EXPR _endIndex "${_index} - 1") set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}") list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") endif() set (${_unityFilesVar} ${_unityFiles} PARENT_SCOPE) if (COTIRE_DEBUG) message(STATUS "${_unityFiles}") endif() endfunction() function (cotire_unity_to_prefix_file_path _language _target _unityFile _prefixFileVar) cotire_setup_file_extension_variables() if (NOT DEFINED _unityFileExt_${_language}) set (${_prefixFileVar} "" PARENT_SCOPE) return() endif() set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") set (_prefixFileBaseName "${_target}_${_language}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") string (REPLACE "${_unityFileBaseName}" "${_prefixFileBaseName}" _prefixFile "${_unityFile}") string (REGEX REPLACE "${_unityFileExt_${_language}}$" "${_prefixFileExt_${_language}}" _prefixFile "${_prefixFile}") set (${_prefixFileVar} "${_prefixFile}" PARENT_SCOPE) endfunction() function (cotire_prefix_header_to_source_file_path _language _prefixHeaderFile _prefixSourceFileVar) cotire_setup_file_extension_variables() if (NOT DEFINED _prefixSourceFileExt_${_language}) set (${_prefixSourceFileVar} "" PARENT_SCOPE) return() endif() string (REGEX REPLACE "${_prefixFileExt_${_language}}$" "${_prefixSourceFileExt_${_language}}" _prefixSourceFile "${_prefixHeaderFile}") set (${_prefixSourceFileVar} "${_prefixSourceFile}" PARENT_SCOPE) endfunction() function (cotire_make_prefix_file_name _language _target _prefixFileBaseNameVar _prefixFileNameVar) cotire_setup_file_extension_variables() if (NOT _language) set (_prefixFileBaseName "${_target}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_C}") elseif (DEFINED _prefixFileExt_${_language}) set (_prefixFileBaseName "${_target}_${_language}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_${_language}}") else() set (_prefixFileBaseName "") set (_prefixFileName "") endif() set (${_prefixFileBaseNameVar} "${_prefixFileBaseName}" PARENT_SCOPE) set (${_prefixFileNameVar} "${_prefixFileName}" PARENT_SCOPE) endfunction() function (cotire_make_prefix_file_path _language _target _prefixFileVar) cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName) set (${_prefixFileVar} "" PARENT_SCOPE) if (_prefixFileName) if (NOT _language) set (_language "C") endif() if (MSVC OR CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang|Intel") cotire_get_intermediate_dir(_baseDir) set (${_prefixFileVar} "${_baseDir}/${_prefixFileName}" PARENT_SCOPE) endif() endif() endfunction() function (cotire_make_pch_file_path _language _targetSourceDir _target _pchFileVar) cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName) set (${_pchFileVar} "" PARENT_SCOPE) if (_prefixFileBaseName AND _prefixFileName) cotire_check_precompiled_header_support("${_language}" "${_targetSourceDir}" "${_target}" _msg) if (NOT _msg) if (XCODE) # For Xcode, we completely hand off the compilation of the prefix header to the IDE return() endif() cotire_get_intermediate_dir(_baseDir) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") # MSVC uses the extension .pch added to the prefix header base name set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pch" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") # Clang looks for a precompiled header corresponding to the prefix header with the extension .pch appended set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.pch" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") # GCC looks for a precompiled header corresponding to the prefix header with the extension .gch appended set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.gch" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") # Intel uses the extension .pchi added to the prefix header base name set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pchi" PARENT_SCOPE) endif() endif() endif() endfunction() function (cotire_select_unity_source_files _unityFile _sourcesVar) set (_sourceFiles ${ARGN}) if (_sourceFiles AND "${_unityFile}" MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}_([0-9]+)_([0-9]+)") set (_startIndex ${CMAKE_MATCH_1}) set (_endIndex ${CMAKE_MATCH_2}) list (LENGTH _sourceFiles _numberOfSources) if (NOT _startIndex LESS _numberOfSources) math (EXPR _startIndex "${_numberOfSources} - 1") endif() if (NOT _endIndex LESS _numberOfSources) math (EXPR _endIndex "${_numberOfSources} - 1") endif() set (_files "") foreach (_index RANGE ${_startIndex} ${_endIndex}) list (GET _sourceFiles ${_index} _file) list (APPEND _files "${_file}") endforeach() else() set (_files ${_sourceFiles}) endif() set (${_sourcesVar} ${_files} PARENT_SCOPE) endfunction() function (cotire_get_unity_source_dependencies _language _target _dependencySourcesVar) set (_dependencySources "") # depend on target's generated source files cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${ARGN}) if (_generatedSources) # but omit all generated source files that have the COTIRE_EXCLUDED property set to true cotire_get_objects_with_property_on(_excludedGeneratedSources COTIRE_EXCLUDED SOURCE ${_generatedSources}) if (_excludedGeneratedSources) list (REMOVE_ITEM _generatedSources ${_excludedGeneratedSources}) endif() # and omit all generated source files that have the COTIRE_DEPENDENCY property set to false explicitly cotire_get_objects_with_property_off(_excludedNonDependencySources COTIRE_DEPENDENCY SOURCE ${_generatedSources}) if (_excludedNonDependencySources) list (REMOVE_ITEM _generatedSources ${_excludedNonDependencySources}) endif() if (_generatedSources) list (APPEND _dependencySources ${_generatedSources}) endif() endif() if (COTIRE_DEBUG AND _dependencySources) message (STATUS "${_language} ${_target} unity source depends on ${_dependencySources}") endif() set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) endfunction() function (cotire_get_prefix_header_dependencies _language _target _dependencySourcesVar) # depend on target source files marked with custom COTIRE_DEPENDENCY property set (_dependencySources "") cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # GCC and clang raise a fatal error if a file is not found during preprocessing # thus we depend on target's generated source files for prefix header generation cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${ARGN}) if (_generatedSources) list (APPEND _dependencySources ${_generatedSources}) endif() endif() if (COTIRE_DEBUG AND _dependencySources) message (STATUS "${_language} ${_target} prefix header DEPENDS ${_dependencySources}") endif() set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) endfunction() function (cotire_generate_target_script _language _configurations _targetSourceDir _targetBinaryDir _target _targetScriptVar _targetConfigScriptVar) set (COTIRE_TARGET_SOURCES ${ARGN}) cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${COTIRE_TARGET_SOURCES}) cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${COTIRE_TARGET_SOURCES}) # set up variables to be configured set (COTIRE_TARGET_LANGUAGE "${_language}") cotire_determine_compiler_version("${COTIRE_TARGET_LANGUAGE}" COTIRE_${_language}_COMPILER) get_target_property(COTIRE_TARGET_IGNORE_PATH ${_target} COTIRE_PREFIX_HEADER_IGNORE_PATH) cotire_add_sys_root_paths(COTIRE_TARGET_IGNORE_PATH) get_target_property(COTIRE_TARGET_INCLUDE_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PATH) cotire_add_sys_root_paths(COTIRE_TARGET_INCLUDE_PATH) get_target_property(COTIRE_TARGET_PRE_UNDEFS ${_target} COTIRE_UNITY_SOURCE_PRE_UNDEFS) get_target_property(COTIRE_TARGET_POST_UNDEFS ${_target} COTIRE_UNITY_SOURCE_POST_UNDEFS) get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${COTIRE_TARGET_SOURCES}) cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${COTIRE_TARGET_SOURCES}) string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" COTIRE_INCLUDE_SYSTEM_FLAG) set (COTIRE_TARGET_CONFIGURATION_TYPES "${_configurations}") foreach (_config ${_configurations}) string (TOUPPER "${_config}" _upperConfig) cotire_get_target_include_directories( "${_config}" "${_language}" "${_targetSourceDir}" "${_targetBinaryDir}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig} COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}) cotire_get_target_compile_definitions( "${_config}" "${_language}" "${_targetSourceDir}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}) cotire_get_target_compiler_flags( "${_config}" "${_language}" "${_targetSourceDir}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}) cotire_get_source_files_compile_definitions( "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig} ${COTIRE_TARGET_SOURCES}) endforeach() get_cmake_property(_vars VARIABLES) string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+" _matchVars "${_vars}") # remove COTIRE_VERBOSE which is passed as a CMake define on command line list (REMOVE_ITEM _matchVars COTIRE_VERBOSE) set (_contents "") set (_contentsHasGeneratorExpressions FALSE) foreach (_var IN LISTS _matchVars ITEMS MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) if (DEFINED ${_var}) string (REPLACE "\"" "\\\"" _value "${${_var}}") set (_contents "${_contents}set (${_var} \"${_value}\")\n") if (NOT _contentsHasGeneratorExpressions) if ("${_value}" MATCHES "\\$<.*>") set (_contentsHasGeneratorExpressions TRUE) endif() endif() endif() endforeach() get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_moduleName}") cotire_write_file("CMAKE" "${_targetCotireScript}" "${_contents}" FALSE) if (_contentsHasGeneratorExpressions) # use file(GENERATE ...) to expand generator expressions in the target script at CMake generate-time if (NOT CMAKE_VERSION VERSION_LESS "2.8.12") # the file(GENERATE ...) command requires cmake 2.8.12 or later set (_configNameOrNoneGeneratorExpression "$<$<CONFIG:>:None>$<$<NOT:$<CONFIG:>>:$<CONFIGURATION>>") set (_targetCotireConfigScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_configNameOrNoneGeneratorExpression}_${_moduleName}") file (GENERATE OUTPUT "${_targetCotireConfigScript}" INPUT "${_targetCotireScript}") else() message (WARNING "cotire: generator expression used in target ${_target}. This requires CMake 2.8.12 or later.") set (_targetCotireConfigScript "${_targetCotireScript}") endif() else() set (_targetCotireConfigScript "${_targetCotireScript}") endif() set (${_targetScriptVar} "${_targetCotireScript}" PARENT_SCOPE) set (${_targetConfigScriptVar} "${_targetCotireConfigScript}" PARENT_SCOPE) endfunction() function (cotire_setup_pch_file_compilation _language _target _targetSourceDir _targetScript _prefixFile _pchFile) set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # for Visual Studio and Intel, we attach the precompiled header compilation to the first source file # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion if (_sourceFiles) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) list (GET _sourceFiles 0 _hostFile) set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) cotire_add_pch_compilation_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags) set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") # make first source file depend on prefix header set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") # mark first source file as cotired to prevent it from being used in another cotired target set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}") endif() elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") # for makefile based generator, we add a custom command to precompile the prefix header if (_targetScript) cotire_set_cmd_to_prologue(_cmds) list (GET _sourceFiles 0 _hostFile) list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixFile}" "${_pchFile}" "${_hostFile}") file (RELATIVE_PATH _pchFileRelPath "${CMAKE_BINARY_DIR}" "${_pchFile}") if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") endif() set_property (SOURCE "${_pchFile}" PROPERTY GENERATED TRUE) add_custom_command( OUTPUT "${_pchFile}" COMMAND ${_cmds} DEPENDS "${_prefixFile}" IMPLICIT_DEPENDS ${_language} "${_prefixFile}" WORKING_DIRECTORY "${_targetSourceDir}" COMMENT "Building ${_language} precompiled header ${_pchFileRelPath}" VERBATIM) endif() endif() endfunction() function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefixFile _pchFile) set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # for Visual Studio and Intel, we include the precompiled header in all but the first source file # the first source file does the precompiled header compilation, see cotire_setup_pch_file_compilation list (LENGTH _sourceFiles _numberOfSourceFiles) if (_numberOfSourceFiles GREATER 1) # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") list (REMOVE_AT _sourceFiles 0) set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # make source files depend on precompiled header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") endif() elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") if (NOT _wholeTarget) # for makefile based generator, we force the inclusion of the prefix header for a subset # of the source files, if this is a multi-language target or has excluded files set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") endif() # make source files depend on precompiled header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") endif() endfunction() function (cotire_setup_prefix_file_inclusion _language _target _prefixFile) set (_sourceFiles ${ARGN}) # force the inclusion of the prefix header for the given source files set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") # make source files depend on prefix header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") endfunction() function (cotire_get_first_set_property_value _propertyValueVar _type _object) set (_properties ${ARGN}) foreach (_property ${_properties}) get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) if (_propertyValue) set (${_propertyValueVar} ${_propertyValue} PARENT_SCOPE) return() endif() endforeach() set (${_propertyValueVar} "" PARENT_SCOPE) endfunction() function (cotire_setup_combine_command _language _sourceDir _targetScript _joinedFile _cmdsVar) set (_files ${ARGN}) set (_filesPaths "") foreach (_file ${_files}) if (IS_ABSOLUTE "${_file}") set (_filePath "${_file}") else() get_filename_component(_filePath "${_sourceDir}/${_file}" ABSOLUTE) endif() file (RELATIVE_PATH _fileRelPath "${_sourceDir}" "${_filePath}") if (NOT IS_ABSOLUTE "${_fileRelPath}" AND NOT "${_fileRelPath}" MATCHES "^\\.\\.") list (APPEND _filesPaths "${_fileRelPath}") else() list (APPEND _filesPaths "${_filePath}") endif() endforeach() cotire_set_cmd_to_prologue(_prefixCmd) list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine") if (_targetScript) list (APPEND _prefixCmd "${_targetScript}") endif() list (APPEND _prefixCmd "${_joinedFile}" ${_filesPaths}) if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_joinedFile} COMMAND ${_prefixCmd} DEPENDS ${_files}") endif() set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) file (RELATIVE_PATH _joinedFileRelPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") get_filename_component(_joinedFileBaseName "${_joinedFile}" NAME_WE) get_filename_component(_joinedFileExt "${_joinedFile}" EXT) if (_language AND _joinedFileBaseName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") set (_comment "Generating ${_language} unity source ${_joinedFileRelPath}") elseif (_language AND _joinedFileBaseName MATCHES "${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}$") if (_joinedFileExt MATCHES "^\\.c") set (_comment "Generating ${_language} prefix source ${_joinedFileRelPath}") else() set (_comment "Generating ${_language} prefix header ${_joinedFileRelPath}") endif() else() set (_comment "Generating ${_joinedFileRelPath}") endif() add_custom_command( OUTPUT "${_joinedFile}" COMMAND ${_prefixCmd} DEPENDS ${_files} COMMENT "${_comment}" WORKING_DIRECTORY "${_sourceDir}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() function (cotire_setup_target_pch_usage _languages _targetSourceDir _target _wholeTarget) if (XCODE) # for Xcode, we attach a pre-build action to generate the unity sources and prefix headers # if necessary, we also generate a single prefix header which includes all language specific prefix headers set (_prefixFiles "") foreach (_language ${_languages}) get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) if (_prefixFile) list (APPEND _prefixFiles "${_prefixFile}") endif() endforeach() set (_cmds ${ARGN}) list (LENGTH _prefixFiles _numberOfPrefixFiles) if (_numberOfPrefixFiles GREATER 1) cotire_make_prefix_file_path("" ${_target} _prefixHeader) cotire_setup_combine_command("" "${_targetSourceDir}" "" "${_prefixHeader}" _cmds ${_prefixFiles}) else() set (_prefixHeader "${_prefixFiles}") endif() if (COTIRE_DEBUG) message (STATUS "add_custom_command: TARGET ${_target} PRE_BUILD ${_cmds}") endif() add_custom_command(TARGET "${_target}" PRE_BUILD ${_cmds} WORKING_DIRECTORY "${_targetSourceDir}" COMMENT "Updating target ${_target} prefix headers" VERBATIM) # make Xcode precompile the generated prefix header with ProcessPCH and ProcessPCH++ set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${_prefixHeader}") elseif ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") # for makefile based generator, we force inclusion of the prefix header for all target source files # if this is a single-language target without any excluded files if (_wholeTarget) set (_language "${_languages}") # for Visual Studio and Intel, precompiled header inclusion is always done on the source file level # see cotire_setup_pch_file_inclusion if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) set (_flags "") cotire_determine_compiler_version("${_language}" COTIRE_${_language}_COMPILER) cotire_add_prefix_pch_inclusion_flags( "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${COTIRE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property(TARGET ${_target} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") endif() endif() endif() endfunction() function (cotire_setup_unity_generation_commands _language _targetSourceDir _target _targetScript _targetConfigScript _unityFiles _cmdsVar) set (_dependencySources "") cotire_get_unity_source_dependencies(${_language} ${_target} _dependencySources ${ARGN}) foreach (_unityFile ${_unityFiles}) file (RELATIVE_PATH _unityFileRelPath "${CMAKE_BINARY_DIR}" "${_unityFile}") set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE) # set up compiled unity source dependencies # this ensures that missing source files are generated before the unity file is compiled if (COTIRE_DEBUG AND _dependencySources) message (STATUS "${_unityFile} OBJECT_DEPENDS ${_dependencySources}") endif() if (_dependencySources) set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_dependencySources}) endif() if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # unity file compilation results in potentially huge object file, thus use /bigobj by default under MSVC and Windows Intel set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS "/bigobj") endif() cotire_set_cmd_to_prologue(_unityCmd) list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetConfigScript}" "${_unityFile}") if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_targetScript}") endif() add_custom_command( OUTPUT "${_unityFile}" COMMAND ${_unityCmd} DEPENDS "${_targetScript}" COMMENT "Generating ${_language} unity source ${_unityFileRelPath}" WORKING_DIRECTORY "${_targetSourceDir}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) endforeach() list (LENGTH _unityFiles _numberOfUnityFiles) if (_numberOfUnityFiles GREATER 1) # create a joint unity file from all unity file segments cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetConfigScript}" "${_unityFile}" ${_cmdsVar} ${_unityFiles}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() function (cotire_setup_prefix_generation_command _language _target _targetSourceDir _targetScript _prefixFile _unityFile _cmdsVar) set (_sourceFiles ${ARGN}) set (_dependencySources "") cotire_get_prefix_header_dependencies(${_language} ${_target} _dependencySources ${_sourceFiles}) cotire_set_cmd_to_prologue(_prefixCmd) list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" "${_unityFile}") set_property (SOURCE "${_prefixFile}" PROPERTY GENERATED TRUE) if (COTIRE_DEBUG) message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources}") endif() file (RELATIVE_PATH _prefixFileRelPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") get_filename_component(_prefixFileExt "${_prefixFile}" EXT) if (_prefixFileExt MATCHES "^\\.c") set (_comment "Generating ${_language} prefix source ${_prefixFileRelPath}") else() set (_comment "Generating ${_language} prefix header ${_prefixFileRelPath}") endif() add_custom_command( OUTPUT "${_prefixFile}" "${_prefixFile}.log" COMMAND ${_prefixCmd} DEPENDS "${_unityFile}" ${_dependencySources} COMMENT "${_comment}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() function (cotire_setup_prefix_generation_from_unity_command _language _target _targetSourceDir _targetScript _prefixFile _unityFiles _cmdsVar) set (_sourceFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) else() set (_prefixSourceFile "${_prefixFile}") endif() list (LENGTH _unityFiles _numberOfUnityFiles) if (_numberOfUnityFiles GREATER 1) cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) cotire_setup_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" "${_unityFile}" ${_cmdsVar} ${_sourceFiles}) else() cotire_setup_prefix_generation_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) endif() if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" ${_cmdsVar} ${_prefixSourceFile}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() function (cotire_setup_prefix_generation_from_provided_command _language _target _targetSourceDir _targetScript _prefixFile _cmdsVar) set (_prefixHeaderFiles ${ARGN}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) else() set (_prefixSourceFile "${_prefixFile}") endif() cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixHeaderFiles}) if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") cotire_setup_combine_command(${_language} "${_targetSourceDir}" "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) endif() set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) endfunction() function (cotire_init_cotire_target_properties _target) get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER TRUE) endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD TRUE) endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ADD_CLEAN SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_ADD_CLEAN FALSE) endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_SOURCE_DIR}") cotire_check_is_path_relative_to("${CMAKE_BINARY_DIR}" _isRelative "${CMAKE_SOURCE_DIR}") if (NOT _isRelative) set_property(TARGET ${_target} APPEND PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_BINARY_DIR}") endif() endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH "") endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS "") endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS "") endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT SET) if (NOT _isSet) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "") endif() get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES SET) if (NOT _isSet) if (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES}") else() set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "") endif() endif() endfunction() function (cotire_make_target_message _target _languages _disableMsg _targetMsgVar) get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) string (REPLACE ";" " " _languagesStr "${_languages}") math (EXPR _numberOfExcludedFiles "${ARGC} - 4") if (_numberOfExcludedFiles EQUAL 0) set (_excludedStr "") elseif (COTIRE_VERBOSE OR _numberOfExcludedFiles LESS 4) string (REPLACE ";" ", " _excludedStr "excluding ${ARGN}") else() set (_excludedStr "excluding ${_numberOfExcludedFiles} files") endif() set (_targetMsg "") if (NOT _languages) set (_targetMsg "Target ${_target} cannot be cotired.") if (_disableMsg) set (_targetMsg "${_targetMsg} ${_disableMsg}") endif() elseif (NOT _targetUsePCH AND NOT _targetAddSCU) set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build and precompiled header.") if (_disableMsg) set (_targetMsg "${_targetMsg} ${_disableMsg}") endif() elseif (NOT _targetUsePCH) if (_excludedStr) set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header ${_excludedStr}.") else() set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header.") endif() if (_disableMsg) set (_targetMsg "${_targetMsg} ${_disableMsg}") endif() elseif (NOT _targetAddSCU) if (_excludedStr) set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build ${_excludedStr}.") else() set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build.") endif() else() if (_excludedStr) set (_targetMsg "${_languagesStr} target ${_target} cotired ${_excludedStr}.") else() set (_targetMsg "${_languagesStr} target ${_target} cotired.") endif() endif() set (${_targetMsgVar} "${_targetMsg}" PARENT_SCOPE) endfunction() function (cotire_choose_target_languages _targetSourceDir _target _targetLanguagesVar) set (_languages ${ARGN}) set (_allSourceFiles "") set (_allExcludedSourceFiles "") set (_allCotiredSourceFiles "") set (_targetLanguages "") get_target_property(_targetType ${_target} TYPE) get_target_property(_targetSourceFiles ${_target} SOURCES) get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) set (_disableMsg "") foreach (_language ${_languages}) get_target_property(_prefixHeader ${_target} COTIRE_${_language}_PREFIX_HEADER) get_target_property(_unityBuildFile ${_target} COTIRE_${_language}_UNITY_SOURCE) if (_prefixHeader OR _unityBuildFile) message (STATUS "cotire: target ${_target} has already been cotired.") set (${_targetLanguagesVar} "" PARENT_SCOPE) return() endif() if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$") cotire_check_precompiled_header_support("${_language}" "${_targetSourceDir}" "${_target}" _disableMsg) if (_disableMsg) set (_targetUsePCH FALSE) endif() endif() set (_sourceFiles "") set (_excludedSources "") set (_cotiredSources "") cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) if (_sourceFiles OR _excludedSources OR _cotiredSources) list (APPEND _targetLanguages ${_language}) endif() if (_sourceFiles) list (APPEND _allSourceFiles ${_sourceFiles}) endif() if (_excludedSources) list (APPEND _allExcludedSourceFiles ${_excludedSources}) endif() if (_cotiredSources) list (APPEND _allCotiredSourceFiles ${_cotiredSources}) endif() endforeach() set (_targetMsgLevel STATUS) if (NOT _targetLanguages) string (REPLACE ";" " or " _languagesStr "${_languages}") set (_disableMsg "No ${_languagesStr} source files.") set (_targetUsePCH FALSE) set (_targetAddSCU FALSE) endif() if (_targetUsePCH) list (LENGTH _allSourceFiles _numberOfSources) if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) set (_disableMsg "Too few applicable sources.") set (_targetUsePCH FALSE) elseif (_allCotiredSourceFiles) cotire_get_source_file_property_values(_cotireTargets COTIRE_TARGET ${_allCotiredSourceFiles}) list (REMOVE_DUPLICATES _cotireTargets) string (REPLACE ";" ", " _cotireTargetsStr "${_cotireTargets}") set (_disableMsg "Target sources already include a precompiled header for target(s) ${_cotireTargets}.") set (_disableMsg "${_disableMsg} Set target property COTIRE_ENABLE_PRECOMPILED_HEADER to FALSE for targets ${_target},") set (_disableMsg "${_disableMsg} ${_cotireTargetsStr} to get a workable build system.") set (_targetMsgLevel SEND_ERROR) set (_targetUsePCH FALSE) elseif (XCODE AND _allExcludedSourceFiles) # for Xcode, we cannot apply the precompiled header to individual sources, only to the whole target set (_disableMsg "Exclusion of source files not supported for generator Xcode.") set (_targetUsePCH FALSE) elseif (XCODE AND "${_targetType}" STREQUAL "OBJECT_LIBRARY") # for Xcode, we cannot apply the required PRE_BUILD action to generate the prefix header to an OBJECT_LIBRARY target set (_disableMsg "Required PRE_BUILD action not supported for OBJECT_LIBRARY targets for generator Xcode.") set (_targetUsePCH FALSE) endif() endif() set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${_targetUsePCH}) set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD ${_targetAddSCU}) cotire_make_target_message(${_target} "${_targetLanguages}" "${_disableMsg}" _targetMsg ${_allExcludedSourceFiles}) if (_targetMsg) if (NOT DEFINED COTIREMSG_${_target}) set (COTIREMSG_${_target} "") endif() if (COTIRE_VERBOSE OR NOT "${_targetMsgLevel}" STREQUAL "STATUS" OR NOT "${COTIREMSG_${_target}}" STREQUAL "${_targetMsg}") # cache message to avoid redundant messages on re-configure set (COTIREMSG_${_target} "${_targetMsg}" CACHE INTERNAL "${_target} cotire message.") message (${_targetMsgLevel} "${_targetMsg}") endif() endif() set (${_targetLanguagesVar} ${_targetLanguages} PARENT_SCOPE) endfunction() function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) set (_sourceFiles ${ARGN}) get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) if (_maxIncludes MATCHES "(-j|--parallel|--jobs) ?([0-9]*)") set (_numberOfThreads "${CMAKE_MATCH_2}") if (NOT _numberOfThreads) # use all available cores ProcessorCount(_numberOfThreads) endif() list (LENGTH _sourceFiles _numberOfSources) math (EXPR _maxIncludes "(${_numberOfSources} + ${_numberOfThreads} - 1) / ${_numberOfThreads}") # a unity source segment must not contain less than COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES files if (_maxIncludes LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) set (_maxIncludes ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) endif() elseif (NOT _maxIncludes MATCHES "[0-9]+") set (_maxIncludes 0) endif() if (COTIRE_DEBUG) message (STATUS "${_target} unity source max includes = ${_maxIncludes}") endif() set (${_maxIncludesVar} ${_maxIncludes} PARENT_SCOPE) endfunction() function (cotire_process_target_language _language _configurations _targetSourceDir _targetBinaryDir _target _wholeTargetVar _cmdsVar) set (${_cmdsVar} "" PARENT_SCOPE) get_target_property(_targetSourceFiles ${_target} SOURCES) set (_sourceFiles "") set (_excludedSources "") set (_cotiredSources "") cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) if (NOT _sourceFiles AND NOT _cotiredSources) return() endif() set (_wholeTarget ${${_wholeTargetVar}}) set (_cmds "") # check for user provided unity source file list get_property(_unitySourceFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE_INIT) if (NOT _unitySourceFiles) set (_unitySourceFiles ${_sourceFiles} ${_cotiredSources}) endif() cotire_generate_target_script( ${_language} "${_configurations}" "${_targetSourceDir}" "${_targetBinaryDir}" ${_target} _targetScript _targetConfigScript ${_unitySourceFiles}) cotire_compute_unity_max_number_of_includes(${_target} _maxIncludes ${_unitySourceFiles}) cotire_make_unity_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) if (NOT _unityFiles) return() endif() cotire_setup_unity_generation_commands( ${_language} "${_targetSourceDir}" ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) cotire_make_prefix_file_path(${_language} ${_target} _prefixFile) if (_prefixFile) # check for user provided prefix header files get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) if (_prefixHeaderFiles) cotire_setup_prefix_generation_from_provided_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) else() cotire_setup_prefix_generation_from_unity_command( ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_unityFiles}" _cmds ${_unitySourceFiles}) endif() get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) if (_targetUsePCH) cotire_make_pch_file_path(${_language} "${_targetSourceDir}" ${_target} _pchFile) if (_pchFile) cotire_setup_pch_file_compilation( ${_language} ${_target} "${_targetSourceDir}" "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) if (_excludedSources) set (_wholeTarget FALSE) endif() cotire_setup_pch_file_inclusion( ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) endif() elseif (_prefixHeaderFiles) # user provided prefix header must be included cotire_setup_prefix_file_inclusion( ${_language} ${_target} "${_prefixFile}" ${_sourceFiles}) endif() endif() # mark target as cotired for language set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE "${_unityFiles}") if (_prefixFile) set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER "${_prefixFile}") if (_targetUsePCH AND _pchFile) set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER "${_pchFile}") endif() endif() set (${_wholeTargetVar} ${_wholeTarget} PARENT_SCOPE) set (${_cmdsVar} ${_cmds} PARENT_SCOPE) endfunction() function (cotire_setup_clean_target _target) set (_cleanTargetName "${_target}${COTIRE_CLEAN_TARGET_SUFFIX}") if (NOT TARGET "${_cleanTargetName}") cotire_set_cmd_to_prologue(_cmds) get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" ABSOLUTE) list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${_outputDir}" "${COTIRE_INTDIR}" "${_target}") add_custom_target(${_cleanTargetName} COMMAND ${_cmds} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" COMMENT "Cleaning up target ${_target} cotire generated files" VERBATIM) cotire_init_target("${_cleanTargetName}") endif() endfunction() function (cotire_setup_pch_target _languages _configurations _target) if ("${CMAKE_GENERATOR}" MATCHES "Makefiles|Ninja") # for makefile based generators, we add a custom target to trigger the generation of the cotire related files set (_dependsFiles "") foreach (_language ${_languages}) set (_props COTIRE_${_language}_PREFIX_HEADER COTIRE_${_language}_UNITY_SOURCE) if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") # Visual Studio and Intel only create precompiled header as a side effect list (INSERT _props 0 COTIRE_${_language}_PRECOMPILED_HEADER) endif() cotire_get_first_set_property_value(_dependsFile TARGET ${_target} ${_props}) if (_dependsFile) list (APPEND _dependsFiles "${_dependsFile}") endif() endforeach() if (_dependsFiles) set (_pchTargetName "${_target}${COTIRE_PCH_TARGET_SUFFIX}") add_custom_target("${_pchTargetName}" DEPENDS ${_dependsFiles}) cotire_init_target("${_pchTargetName}") cotire_add_to_pch_all_target(${_pchTargetName}) endif() else() # for other generators, we add the "clean all" target to clean up the precompiled header cotire_setup_clean_all_target() endif() endfunction() function (cotire_setup_unity_build_target _languages _configurations _targetSourceDir _target) get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) if (NOT _unityTargetName) set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}") endif() # determine unity target sub type get_target_property(_targetType ${_target} TYPE) if ("${_targetType}" STREQUAL "EXECUTABLE") set (_unityTargetSubType "") elseif (_targetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") set (_unityTargetSubType "${CMAKE_MATCH_1}") else() message (WARNING "cotire: target ${_target} has unknown target type ${_targetType}.") return() endif() # determine unity target sources get_target_property(_targetSourceFiles ${_target} SOURCES) set (_unityTargetSources ${_targetSourceFiles}) foreach (_language ${_languages}) get_property(_unityFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE) if (_unityFiles) # remove source files that are included in the unity source set (_sourceFiles "") set (_excludedSources "") set (_cotiredSources "") cotire_filter_language_source_files(${_language} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) if (_sourceFiles OR _cotiredSources) list (REMOVE_ITEM _unityTargetSources ${_sourceFiles} ${_cotiredSources}) endif() # if cotire is applied to a target which has not been added in the current source dir, # non-existing files cannot be referenced from the unity build target (this is a CMake restriction) if (NOT "${_targetSourceDir}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") set (_nonExistingFiles "") foreach (_file ${_unityTargetSources}) if (NOT EXISTS "${_file}") list (APPEND _nonExistingFiles "${_file}") endif() endforeach() if (_nonExistingFiles) if (COTIRE_VERBOSE) message (STATUS "removing non-existing ${_nonExistingFiles} from ${_unityTargetName}") endif() list (REMOVE_ITEM _unityTargetSources ${_nonExistingFiles}) endif() endif() # add unity source files instead list (APPEND _unityTargetSources ${_unityFiles}) endif() endforeach() if (COTIRE_DEBUG) message (STATUS "add ${_targetType} ${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}") endif() # generate unity target if ("${_targetType}" STREQUAL "EXECUTABLE") add_executable(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) else() add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) endif() set (_outputDirProperties ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_<CONFIG> LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_<CONFIG> RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_<CONFIG>) # copy output location properties if (COTIRE_UNITY_OUTPUT_DIRECTORY) set (_setDefaultOutputDir TRUE) if (IS_ABSOLUTE "${COTIRE_UNITY_OUTPUT_DIRECTORY}") set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}") else() cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) cotire_resolve_config_properties("${_configurations}" _properties ${_outputDirProperties}) foreach (_property ${_properties}) get_property(_outputDir TARGET ${_target} PROPERTY ${_property}) if (_outputDir) get_filename_component(_outputDir "${_outputDir}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE) set_property(TARGET ${_unityTargetName} PROPERTY ${_property} "${_outputDir}") set (_setDefaultOutputDir FALSE) endif() endforeach() if (_setDefaultOutputDir) get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE) endif() endif() if (_setDefaultOutputDir) set_target_properties(${_unityTargetName} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${_outputDir}" LIBRARY_OUTPUT_DIRECTORY "${_outputDir}" RUNTIME_OUTPUT_DIRECTORY "${_outputDir}") endif() else() cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) endif() # copy output name cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_<CONFIG> LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_<CONFIG> OUTPUT_NAME OUTPUT_NAME_<CONFIG> RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_<CONFIG> PREFIX <CONFIG>_POSTFIX SUFFIX) # copy compile stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPILE_DEFINITIONS COMPILE_DEFINITIONS_<CONFIG> COMPILE_FLAGS COMPILE_OPTIONS Fortran_FORMAT Fortran_MODULE_DIRECTORY INCLUDE_DIRECTORIES INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_<CONFIG> POSITION_INDEPENDENT_CODE C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN) # copy interface stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_OPTIONS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES INTERFACE_AUTOUIC_OPTIONS) # copy link stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_FLAGS LINK_FLAGS_<CONFIG> LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_<CONFIG> LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_<CONFIG> LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_<CONFIG> NO_SONAME SOVERSION VERSION) # copy Qt stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} AUTOMOC AUTOMOC_MOC_OPTIONS AUTOUIC AUTOUIC_OPTIONS AUTORCC AUTORCC_OPTIONS AUTOGEN_TARGET_DEPENDS) # copy cmake stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) # copy Apple platform specific stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} BUNDLE BUNDLE_EXTENSION FRAMEWORK INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH OSX_ARCHITECTURES OSX_ARCHITECTURES_<CONFIG> PRIVATE_HEADER PUBLIC_HEADER RESOURCE) # copy Windows platform specific stuff cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS PDB_NAME PDB_NAME_<CONFIG> PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_<CONFIG> VS_DOTNET_REFERENCES VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE VS_KEYWORD VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES WIN32_EXECUTABLE) # use output name from original target get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) if (NOT _targetOutputName) set_property(TARGET ${_unityTargetName} PROPERTY OUTPUT_NAME "${_target}") endif() # use export symbol from original target cotire_get_target_export_symbol("${_target}" _defineSymbol) if (_defineSymbol) set_property(TARGET ${_unityTargetName} PROPERTY DEFINE_SYMBOL "${_defineSymbol}") if ("${_targetType}" STREQUAL "EXECUTABLE") set_property(TARGET ${_unityTargetName} PROPERTY ENABLE_EXPORTS TRUE) endif() endif() cotire_init_target(${_unityTargetName}) cotire_add_to_unity_all_target(${_unityTargetName}) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_TARGET_NAME "${_unityTargetName}") endfunction(cotire_setup_unity_build_target) function (cotire_target _target) set(_options "") set(_oneValueArgs SOURCE_DIR BINARY_DIR) set(_multiValueArgs LANGUAGES CONFIGURATIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) if (NOT _option_SOURCE_DIR) set (_option_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") endif() if (NOT _option_BINARY_DIR) set (_option_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") endif() if (NOT _option_LANGUAGES) get_property (_option_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) endif() if (NOT _option_CONFIGURATIONS) if (CMAKE_CONFIGURATION_TYPES) set (_option_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) elseif (CMAKE_BUILD_TYPE) set (_option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}") else() set (_option_CONFIGURATIONS "None") endif() endif() # trivial checks get_target_property(_imported ${_target} IMPORTED) if (_imported) message (WARNING "cotire: imported target ${_target} cannot be cotired.") return() endif() # resolve alias get_target_property(_aliasName ${_target} ALIASED_TARGET) if (_aliasName) if (COTIRE_DEBUG) message (STATUS "${_target} is an alias. Applying cotire to aliased target ${_aliasName} instead.") endif() set (_target ${_aliasName}) endif() # check if target needs to be cotired for build type # when using configuration types, the test is performed at build time cotire_init_cotire_target_properties(${_target}) if (NOT CMAKE_CONFIGURATION_TYPES) if (CMAKE_BUILD_TYPE) list (FIND _option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}" _index) else() list (FIND _option_CONFIGURATIONS "None" _index) endif() if (_index EQUAL -1) if (COTIRE_DEBUG) message (STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} not cotired (${_option_CONFIGURATIONS})") endif() return() endif() endif() # choose languages that apply to the target cotire_choose_target_languages("${_option_SOURCE_DIR}" "${_target}" _targetLanguages ${_option_LANGUAGES}) if (NOT _targetLanguages) return() endif() list (LENGTH _targetLanguages _numberOfLanguages) if (_numberOfLanguages GREATER 1) set (_wholeTarget FALSE) else() set (_wholeTarget TRUE) endif() set (_cmds "") foreach (_language ${_targetLanguages}) cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" "${_option_SOURCE_DIR}" "${_option_BINARY_DIR}" ${_target} _wholeTarget _cmd) if (_cmd) list (APPEND _cmds ${_cmd}) endif() endforeach() get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) if (_targetAddSCU) cotire_setup_unity_build_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" "${_option_SOURCE_DIR}" ${_target}) endif() get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) if (_targetUsePCH) cotire_setup_target_pch_usage("${_targetLanguages}" "${_option_SOURCE_DIR}" ${_target} ${_wholeTarget} ${_cmds}) cotire_setup_pch_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) endif() get_target_property(_targetAddCleanTarget ${_target} COTIRE_ADD_CLEAN) if (_targetAddCleanTarget) cotire_setup_clean_target(${_target}) endif() endfunction(cotire_target) function (cotire_map_libraries _strategy _mappedLibrariesVar) set (_mappedLibraries "") foreach (_library ${ARGN}) if (TARGET "${_library}" AND "${_strategy}" MATCHES "COPY_UNITY") get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME) if (TARGET "${_libraryUnityTargetName}") list (APPEND _mappedLibraries "${_libraryUnityTargetName}") else() list (APPEND _mappedLibraries "${_library}") endif() else() list (APPEND _mappedLibraries "${_library}") endif() endforeach() list (REMOVE_DUPLICATES _mappedLibraries) set (${_mappedLibrariesVar} ${_mappedLibraries} PARENT_SCOPE) endfunction() function (cotire_target_link_libraries _target) get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) if (TARGET "${_unityTargetName}") get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) if (COTIRE_DEBUG) message (STATUS "unity target ${_unityTargetName} link strategy: ${_linkLibrariesStrategy}") endif() if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$") if (CMAKE_VERSION VERSION_LESS "2.8.11") message (WARNING "cotire: unity target link strategy ${_linkLibrariesStrategy} requires CMake 2.8.11 or later. Defaulting to NONE for ${_target}.") else() get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_linkLibraries} ${_interfaceLinkLibraries}) if (COTIRE_DEBUG) message (STATUS "unity target ${_unityTargetName} libraries: ${_unityLinkLibraries}") endif() if (_unityLinkLibraries) target_link_libraries(${_unityTargetName} ${_unityLinkLibraries}) endif() endif() endif() endif() endfunction(cotire_target_link_libraries) function (cotire_cleanup _binaryDir _cotireIntermediateDirName _targetName) if (_targetName) file (GLOB_RECURSE _cotireFiles "${_binaryDir}/${_targetName}*.*") else() file (GLOB_RECURSE _cotireFiles "${_binaryDir}/*.*") endif() # filter files in intermediate directory set (_filesToRemove "") foreach (_file ${_cotireFiles}) get_filename_component(_dir "${_file}" PATH) get_filename_component(_dirName "${_dir}" NAME) if ("${_dirName}" STREQUAL "${_cotireIntermediateDirName}") list (APPEND _filesToRemove "${_file}") endif() endforeach() if (_filesToRemove) if (COTIRE_VERBOSE) message (STATUS "removing ${_filesToRemove}") endif() file (REMOVE ${_filesToRemove}) endif() endfunction() function (cotire_init_target _targetName) if (COTIRE_TARGETS_FOLDER) set_target_properties(${_targetName} PROPERTIES FOLDER "${COTIRE_TARGETS_FOLDER}") endif() if (MSVC_IDE) set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) endif() endfunction() function (cotire_add_to_pch_all_target _pchTargetName) set (_targetName "${COTIRE_PCH_ALL_TARGET_NAME}") if (NOT TARGET "${_targetName}") add_custom_target("${_targetName}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) cotire_init_target("${_targetName}") endif() cotire_setup_clean_all_target() add_dependencies(${_targetName} ${_pchTargetName}) endfunction() function (cotire_add_to_unity_all_target _unityTargetName) set (_targetName "${COTIRE_UNITY_BUILD_ALL_TARGET_NAME}") if (NOT TARGET "${_targetName}") add_custom_target("${_targetName}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" VERBATIM) cotire_init_target("${_targetName}") endif() cotire_setup_clean_all_target() add_dependencies(${_targetName} ${_unityTargetName}) endfunction() function (cotire_setup_clean_all_target) set (_targetName "${COTIRE_CLEAN_ALL_TARGET_NAME}") if (NOT TARGET "${_targetName}") cotire_set_cmd_to_prologue(_cmds) list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${CMAKE_BINARY_DIR}" "${COTIRE_INTDIR}") add_custom_target(${_targetName} COMMAND ${_cmds} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" COMMENT "Cleaning up all cotire generated files" VERBATIM) cotire_init_target("${_targetName}") endif() endfunction() function (cotire) set(_options "") set(_oneValueArgs SOURCE_DIR BINARY_DIR) set(_multiValueArgs LANGUAGES CONFIGURATIONS) cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) set (_targets ${_option_UNPARSED_ARGUMENTS}) if (NOT _option_SOURCE_DIR) set (_option_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") endif() if (NOT _option_BINARY_DIR) set (_option_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") endif() foreach (_target ${_targets}) if (TARGET ${_target}) cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS} SOURCE_DIR "${_option_SOURCE_DIR}" BINARY_DIR "${_option_BINARY_DIR}") else() message (WARNING "cotire: ${_target} is not a target.") endif() endforeach() foreach (_target ${_targets}) if (TARGET ${_target}) cotire_target_link_libraries(${_target}) endif() endforeach() endfunction() if (CMAKE_SCRIPT_MODE_FILE) # cotire is being run in script mode # locate -P on command args set (COTIRE_ARGC -1) foreach (_index RANGE ${CMAKE_ARGC}) if (COTIRE_ARGC GREATER -1) set (COTIRE_ARGV${COTIRE_ARGC} "${CMAKE_ARGV${_index}}") math (EXPR COTIRE_ARGC "${COTIRE_ARGC} + 1") elseif ("${CMAKE_ARGV${_index}}" STREQUAL "-P") set (COTIRE_ARGC 0) endif() endforeach() # include target script if available if ("${COTIRE_ARGV2}" MATCHES "\\.cmake$") # the included target scripts sets up additional variables relating to the target (e.g., COTIRE_TARGET_SOURCES) include("${COTIRE_ARGV2}") endif() if (COTIRE_DEBUG) message (STATUS "${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}") endif() if (WIN32) # for MSVC, compiler IDs may not always be set correctly if (MSVC) set (CMAKE_C_COMPILER_ID "MSVC") set (CMAKE_CXX_COMPILER_ID "MSVC") endif() endif() if (NOT COTIRE_BUILD_TYPE) set (COTIRE_BUILD_TYPE "None") endif() string (TOUPPER "${COTIRE_BUILD_TYPE}" _upperConfig) set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}}) set (_systemIncludeDirs ${COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}}) set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}}) set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}}) # check if target has been cotired for actual build type COTIRE_BUILD_TYPE list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index) if (_index GREATER -1) set (_sources ${COTIRE_TARGET_SOURCES}) set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig}}) else() if (COTIRE_DEBUG) message (STATUS "COTIRE_BUILD_TYPE=${COTIRE_BUILD_TYPE} not cotired (${COTIRE_TARGET_CONFIGURATION_TYPES})") endif() set (_sources "") set (_sourcesDefinitions "") endif() set (_targetPreUndefs ${COTIRE_TARGET_PRE_UNDEFS}) set (_targetPostUndefs ${COTIRE_TARGET_POST_UNDEFS}) set (_sourcesPreUndefs ${COTIRE_TARGET_SOURCES_PRE_UNDEFS}) set (_sourcesPostUndefs ${COTIRE_TARGET_SOURCES_POST_UNDEFS}) if ("${COTIRE_ARGV1}" STREQUAL "unity") cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources}) cotire_generate_unity_source( "${COTIRE_ARGV3}" ${_sources} LANGUAGE "${COTIRE_TARGET_LANGUAGE}" DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV2}" SOURCES_COMPILE_DEFINITIONS ${_sourcesDefinitions} PRE_UNDEFS ${_targetPreUndefs} POST_UNDEFS ${_targetPostUndefs} SOURCES_PRE_UNDEFS ${_sourcesPreUndefs} SOURCES_POST_UNDEFS ${_sourcesPostUndefs}) elseif ("${COTIRE_ARGV1}" STREQUAL "prefix") set (_files "") foreach (_index RANGE 4 ${COTIRE_ARGC}) if (COTIRE_ARGV${_index}) list (APPEND _files "${COTIRE_ARGV${_index}}") endif() endforeach() cotire_generate_prefix_header( "${COTIRE_ARGV3}" ${_files} COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" DEPENDS "${COTIRE_ARGV0}" "${COTIRE_ARGV4}" ${COTIRE_TARGET_PREFIX_DEPENDS} IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} COMPILE_DEFINITIONS ${_compileDefinitions} COMPILE_FLAGS ${_compileFlags}) elseif ("${COTIRE_ARGV1}" STREQUAL "precompile") set (_files "") foreach (_index RANGE 5 ${COTIRE_ARGC}) if (COTIRE_ARGV${_index}) list (APPEND _files "${COTIRE_ARGV${_index}}") endif() endforeach() cotire_precompile_prefix_header( "${COTIRE_ARGV3}" "${COTIRE_ARGV4}" "${COTIRE_ARGV5}" COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" COMPILER_VERSION "${COTIRE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" LANGUAGE "${COTIRE_TARGET_LANGUAGE}" INCLUDE_SYSTEM_FLAG "${COTIRE_INCLUDE_SYSTEM_FLAG}" INCLUDE_DIRECTORIES ${_includeDirs} SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} COMPILE_DEFINITIONS ${_compileDefinitions} COMPILE_FLAGS ${_compileFlags}) elseif ("${COTIRE_ARGV1}" STREQUAL "combine") if (COTIRE_TARGET_LANGUAGE) set (_startIndex 3) else() set (_startIndex 2) endif() set (_files "") foreach (_index RANGE ${_startIndex} ${COTIRE_ARGC}) if (COTIRE_ARGV${_index}) list (APPEND _files "${COTIRE_ARGV${_index}}") endif() endforeach() if (COTIRE_TARGET_LANGUAGE) cotire_generate_unity_source(${_files} LANGUAGE "${COTIRE_TARGET_LANGUAGE}") else() cotire_generate_unity_source(${_files}) endif() elseif ("${COTIRE_ARGV1}" STREQUAL "cleanup") cotire_cleanup("${COTIRE_ARGV2}" "${COTIRE_ARGV3}" "${COTIRE_ARGV4}") else() message (FATAL_ERROR "cotire: unknown command \"${COTIRE_ARGV1}\".") endif() else() # cotire is being run in include mode # set up all variable and property definitions unset (COTIRE_C_COMPILER_VERSION CACHE) unset (COTIRE_CXX_COMPILER_VERSION CACHE) if (NOT DEFINED COTIRE_DEBUG_INIT) if (DEFINED COTIRE_DEBUG) set (COTIRE_DEBUG_INIT ${COTIRE_DEBUG}) else() set (COTIRE_DEBUG_INIT FALSE) endif() endif() option (COTIRE_DEBUG "Enable cotire debugging output?" ${COTIRE_DEBUG_INIT}) if (NOT DEFINED COTIRE_VERBOSE_INIT) if (DEFINED COTIRE_VERBOSE) set (COTIRE_VERBOSE_INIT ${COTIRE_VERBOSE}) else() set (COTIRE_VERBOSE_INIT FALSE) endif() endif() option (COTIRE_VERBOSE "Enable cotire verbose output?" ${COTIRE_VERBOSE_INIT}) set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "inc;inl;ipp" CACHE STRING "Ignore headers with the listed file extensions from the generated prefix header.") set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH "" CACHE STRING "Ignore headers from these directories when generating the prefix header.") set (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS "m;mm" CACHE STRING "Ignore sources with the listed file extensions from the generated unity source.") set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "3" CACHE STRING "Minimum number of sources in target required to enable use of precompiled header.") if (NOT DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT) if (DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES) set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT ${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES}) elseif ("${CMAKE_GENERATOR}" MATCHES "JOM|Ninja|Visual Studio") # enable parallelization for generators that run multiple jobs by default set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT "-j") else() set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT "0") endif() endif() set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES "${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT}" CACHE STRING "Maximum number of source files to include in a single unity source file.") if (NOT COTIRE_PREFIX_HEADER_FILENAME_SUFFIX) set (COTIRE_PREFIX_HEADER_FILENAME_SUFFIX "_prefix") endif() if (NOT COTIRE_UNITY_SOURCE_FILENAME_SUFFIX) set (COTIRE_UNITY_SOURCE_FILENAME_SUFFIX "_unity") endif() if (NOT COTIRE_INTDIR) set (COTIRE_INTDIR "cotire") endif() if (NOT COTIRE_PCH_ALL_TARGET_NAME) set (COTIRE_PCH_ALL_TARGET_NAME "all_pch") endif() if (NOT COTIRE_UNITY_BUILD_ALL_TARGET_NAME) set (COTIRE_UNITY_BUILD_ALL_TARGET_NAME "all_unity") endif() if (NOT COTIRE_CLEAN_ALL_TARGET_NAME) set (COTIRE_CLEAN_ALL_TARGET_NAME "clean_cotire") endif() if (NOT COTIRE_CLEAN_TARGET_SUFFIX) set (COTIRE_CLEAN_TARGET_SUFFIX "_clean_cotire") endif() if (NOT COTIRE_PCH_TARGET_SUFFIX) set (COTIRE_PCH_TARGET_SUFFIX "_pch") endif() if (NOT COTIRE_UNITY_BUILD_TARGET_SUFFIX) set (COTIRE_UNITY_BUILD_TARGET_SUFFIX "_unity") endif() if (NOT DEFINED COTIRE_TARGETS_FOLDER) set (COTIRE_TARGETS_FOLDER "cotire") endif() if (NOT DEFINED COTIRE_UNITY_OUTPUT_DIRECTORY) if ("${CMAKE_GENERATOR}" MATCHES "Ninja") # generated Ninja build files do not work if the unity target produces the same output file as the cotired target set (COTIRE_UNITY_OUTPUT_DIRECTORY "unity") else() set (COTIRE_UNITY_OUTPUT_DIRECTORY "") endif() endif() # define cotire cache variables define_property( CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH" BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." FULL_DOCS "The variable can be set to a semicolon separated list of include directories." "If a header file is found in one of these directories or sub-directories, it will be excluded from the generated prefix header." "If not defined, defaults to empty list." ) define_property( CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS" BRIEF_DOCS "Ignore includes with the listed file extensions from the generated prefix header." FULL_DOCS "The variable can be set to a semicolon separated list of file extensions." "If a header file extension matches one in the list, it will be excluded from the generated prefix header." "Includes with an extension in CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS are always ignored." "If not defined, defaults to inc;inl;ipp." ) define_property( CACHED_VARIABLE PROPERTY "COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS" BRIEF_DOCS "Exclude sources with the listed file extensions from the generated unity source." FULL_DOCS "The variable can be set to a semicolon separated list of file extensions." "If a source file extension matches one in the list, it will be excluded from the generated unity source file." "Source files with an extension in CMAKE_<LANG>_IGNORE_EXTENSIONS are always excluded." "If not defined, defaults to m;mm." ) define_property( CACHED_VARIABLE PROPERTY "COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES" BRIEF_DOCS "Minimum number of sources in target required to enable use of precompiled header." FULL_DOCS "The variable can be set to an integer > 0." "If a target contains less than that number of source files, cotire will not enable the use of the precompiled header for the target." "If not defined, defaults to 3." ) define_property( CACHED_VARIABLE PROPERTY "COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES" BRIEF_DOCS "Maximum number of source files to include in a single unity source file." FULL_DOCS "This may be set to an integer >= 0." "If 0, cotire will only create a single unity source file." "If a target contains more than that number of source files, cotire will create multiple unity source files for it." "Can be set to \"-j\" to optimize the count of unity source files for the number of available processor cores." "Can be set to \"-j jobs\" to optimize the number of unity source files for the given number of simultaneous jobs." "Is used to initialize the target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." "Defaults to \"-j\" for the generators Visual Studio, JOM or Ninja. Defaults to 0 otherwise." ) # define cotire directory properties define_property( DIRECTORY PROPERTY "COTIRE_ENABLE_PRECOMPILED_HEADER" BRIEF_DOCS "Modify build command of cotired targets added in this directory to make use of the generated precompiled header." FULL_DOCS "See target property COTIRE_ENABLE_PRECOMPILED_HEADER." ) define_property( DIRECTORY PROPERTY "COTIRE_ADD_UNITY_BUILD" BRIEF_DOCS "Add a new target that performs a unity build for cotired targets added in this directory." FULL_DOCS "See target property COTIRE_ADD_UNITY_BUILD." ) define_property( DIRECTORY PROPERTY "COTIRE_ADD_CLEAN" BRIEF_DOCS "Add a new target that cleans all cotire generated files for cotired targets added in this directory." FULL_DOCS "See target property COTIRE_ADD_CLEAN." ) define_property( DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_IGNORE_PATH" BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." FULL_DOCS "See target property COTIRE_PREFIX_HEADER_IGNORE_PATH." ) define_property( DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PATH" BRIEF_DOCS "Honor headers from these directories when generating the prefix header." FULL_DOCS "See target property COTIRE_PREFIX_HEADER_INCLUDE_PATH." ) define_property( DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each source file." FULL_DOCS "See target property COTIRE_UNITY_SOURCE_PRE_UNDEFS." ) define_property( DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of each source file." FULL_DOCS "See target property COTIRE_UNITY_SOURCE_POST_UNDEFS." ) define_property( DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES" BRIEF_DOCS "Maximum number of source files to include in a single unity source file." FULL_DOCS "See target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." ) define_property( DIRECTORY PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT" BRIEF_DOCS "Define strategy for setting up the unity target's link libraries." FULL_DOCS "See target property COTIRE_UNITY_LINK_LIBRARIES_INIT." ) # define cotire target properties define_property( TARGET PROPERTY "COTIRE_ENABLE_PRECOMPILED_HEADER" INHERITED BRIEF_DOCS "Modify this target's build command to make use of the generated precompiled header." FULL_DOCS "If this property is set to TRUE, cotire will modify the build command to make use of the generated precompiled header." "Irrespective of the value of this property, cotire will setup custom commands to generate the unity source and prefix header for the target." "For makefile based generators cotire will also set up a custom target to manually invoke the generation of the precompiled header." "The target name will be set to this target's name with the suffix _pch appended." "Inherited from directory." "Defaults to TRUE." ) define_property( TARGET PROPERTY "COTIRE_ADD_UNITY_BUILD" INHERITED BRIEF_DOCS "Add a new target that performs a unity build for this target." FULL_DOCS "If this property is set to TRUE, cotire creates a new target of the same type that uses the generated unity source file instead of the target sources." "Most of the relevant target properties will be copied from this target to the new unity build target." "Target dependencies and linked libraries have to be manually set up for the new unity build target." "The unity target name will be set to this target's name with the suffix _unity appended." "Inherited from directory." "Defaults to TRUE." ) define_property( TARGET PROPERTY "COTIRE_ADD_CLEAN" INHERITED BRIEF_DOCS "Add a new target that cleans all cotire generated files for this target." FULL_DOCS "If this property is set to TRUE, cotire creates a new target that clean all files (unity source, prefix header, precompiled header)." "The clean target name will be set to this target's name with the suffix _clean_cotire appended." "Inherited from directory." "Defaults to FALSE." ) define_property( TARGET PROPERTY "COTIRE_PREFIX_HEADER_IGNORE_PATH" INHERITED BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." FULL_DOCS "The property can be set to a list of directories." "If a header file is found in one of these directories or sub-directories, it will be excluded from the generated prefix header." "Inherited from directory." "If not set, this property is initialized to \${CMAKE_SOURCE_DIR};\${CMAKE_BINARY_DIR}." ) define_property( TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PATH" INHERITED BRIEF_DOCS "Honor headers from these directories when generating the prefix header." FULL_DOCS "The property can be set to a list of directories." "If a header file is found in one of these directories or sub-directories, it will be included in the generated prefix header." "If a header file is both selected by COTIRE_PREFIX_HEADER_IGNORE_PATH and COTIRE_PREFIX_HEADER_INCLUDE_PATH," "the option which yields the closer relative path match wins." "Inherited from directory." "If not set, this property is initialized to the empty list." ) define_property( TARGET PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" INHERITED BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each target source file." FULL_DOCS "This may be set to a semicolon-separated list of preprocessor symbols." "cotire will add corresponding #undef directives to the generated unit source file before each target source file." "Inherited from directory." "Defaults to empty string." ) define_property( TARGET PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" INHERITED BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of each target source file." FULL_DOCS "This may be set to a semicolon-separated list of preprocessor symbols." "cotire will add corresponding #undef directives to the generated unit source file after each target source file." "Inherited from directory." "Defaults to empty string." ) define_property( TARGET PROPERTY "COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES" INHERITED BRIEF_DOCS "Maximum number of source files to include in a single unity source file." FULL_DOCS "This may be set to an integer > 0." "If a target contains more than that number of source files, cotire will create multiple unity build files for it." "If not set, cotire will only create a single unity source file." "Inherited from directory." "Defaults to empty." ) define_property( TARGET PROPERTY "COTIRE_<LANG>_UNITY_SOURCE_INIT" BRIEF_DOCS "User provided unity source file to be used instead of the automatically generated one." FULL_DOCS "If set, cotire will only add the given file(s) to the generated unity source file." "If not set, cotire will add all the target source files to the generated unity source file." "The property can be set to a user provided unity source file." "Defaults to empty." ) define_property( TARGET PROPERTY "COTIRE_<LANG>_PREFIX_HEADER_INIT" BRIEF_DOCS "User provided prefix header file to be used instead of the automatically generated one." FULL_DOCS "If set, cotire will add the given header file(s) to the generated prefix header file." "If not set, cotire will generate a prefix header by tracking the header files included by the unity source file." "The property can be set to a user provided prefix header file (e.g., stdafx.h)." "Defaults to empty." ) define_property( TARGET PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT" INHERITED BRIEF_DOCS "Define strategy for setting up unity target's link libraries." FULL_DOCS "If this property is empty, the generated unity target's link libraries have to be set up manually." "If this property is set to COPY, the unity target's link libraries will be copied from this target." "If this property is set to COPY_UNITY, the unity target's link libraries will be copied from this target with considering existing unity targets." "Inherited from directory." "Defaults to empty." ) define_property( TARGET PROPERTY "COTIRE_<LANG>_UNITY_SOURCE" BRIEF_DOCS "Read-only property. The generated <LANG> unity source file(s)." FULL_DOCS "cotire sets this property to the path of the generated <LANG> single computation unit source file for the target." "Defaults to empty string." ) define_property( TARGET PROPERTY "COTIRE_<LANG>_PREFIX_HEADER" BRIEF_DOCS "Read-only property. The generated <LANG> prefix header file." FULL_DOCS "cotire sets this property to the full path of the generated <LANG> language prefix header for the target." "Defaults to empty string." ) define_property( TARGET PROPERTY "COTIRE_<LANG>_PRECOMPILED_HEADER" BRIEF_DOCS "Read-only property. The generated <LANG> precompiled header file." FULL_DOCS "cotire sets this property to the full path of the generated <LANG> language precompiled header binary for the target." "Defaults to empty string." ) define_property( TARGET PROPERTY "COTIRE_UNITY_TARGET_NAME" BRIEF_DOCS "The name of the generated unity build target corresponding to this target." FULL_DOCS "This property can be set to the desired name of the unity target that will be created by cotire." "If not set, the unity target name will be set to this target's name with the suffix _unity appended." "After this target has been processed by cotire, the property is set to the actual name of the generated unity target." "Defaults to empty string." ) # define cotire source properties define_property( SOURCE PROPERTY "COTIRE_EXCLUDED" BRIEF_DOCS "Do not modify source file's build command." FULL_DOCS "If this property is set to TRUE, the source file's build command will not be modified to make use of the precompiled header." "The source file will also be excluded from the generated unity source file." "Source files that have their COMPILE_FLAGS property set will be excluded by default." "Defaults to FALSE." ) define_property( SOURCE PROPERTY "COTIRE_DEPENDENCY" BRIEF_DOCS "Add this source file to dependencies of the automatically generated prefix header file." FULL_DOCS "If this property is set to TRUE, the source file is added to dependencies of the generated prefix header file." "If the file is modified, cotire will re-generate the prefix header source upon build." "Defaults to FALSE." ) define_property( SOURCE PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of this source file." FULL_DOCS "This may be set to a semicolon-separated list of preprocessor symbols." "cotire will add corresponding #undef directives to the generated unit source file before this file is included." "Defaults to empty string." ) define_property( SOURCE PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of this source file." FULL_DOCS "This may be set to a semicolon-separated list of preprocessor symbols." "cotire will add corresponding #undef directives to the generated unit source file after this file is included." "Defaults to empty string." ) define_property( SOURCE PROPERTY "COTIRE_START_NEW_UNITY_SOURCE" BRIEF_DOCS "Start a new unity source file which includes this source file as the first one." FULL_DOCS "If this property is set to TRUE, cotire will complete the current unity file and start a new one." "The new unity source file will include this source file as the first one." "This property essentially works as a separator for unity source files." "Defaults to FALSE." ) define_property( SOURCE PROPERTY "COTIRE_TARGET" BRIEF_DOCS "Read-only property. Mark this source file as cotired for the given target." FULL_DOCS "cotire sets this property to the name of target, that the source file's build command has been altered for." "Defaults to empty string." ) message (STATUS "cotire ${COTIRE_CMAKE_MODULE_VERSION} loaded.") endif()
CMake
hhvm/CMake/EXTFunctions.cmake
# Functions/Macros for use when building extensions statically # These functions also exist in CMake/HPHPIZEFunctions.cmake # Their signatures should be kept consistent, though their behavior # will differ slightly. macro(HHVM_LINK_LIBRARIES EXTNAME) foreach (lib ${ARGN}) list(APPEND HRE_LIBRARIES ${lib}) endforeach() endmacro() function(HHVM_ADD_INCLUDES EXTNAME) include_directories(${ARGN}) endfunction() macro(HHVM_EXTENSION EXTNAME) foreach (src ${ARGN}) list(APPEND CXX_SOURCES "${HRE_CURRENT_EXT_PATH}/${src}") endforeach() endmacro() macro(HHVM_SYSTEMLIB EXTNAME) foreach (slib ${ARGN}) list(APPEND PHP_SOURCES "${HRE_CURRENT_EXT_PATH}/${slib}") endforeach() endmacro() function(HHVM_DEFINE EXTNAME) add_definitions(${ARGN}) endfunction()
CMake
hhvm/CMake/FindBoost.cmake
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. #[=======================================================================[.rst: FindBoost --------- Find Boost include dirs and libraries Use this module by invoking :command:`find_package` with the form: .. code-block:: cmake find_package(Boost [version] [EXACT] # Minimum or EXACT version e.g. 1.67.0 [REQUIRED] # Fail with error if Boost is not found [COMPONENTS <libs>...] # Boost libraries by their canonical name # e.g. "date_time" for "libboost_date_time" [OPTIONAL_COMPONENTS <libs>...] # Optional Boost libraries by their canonical name) ) # e.g. "date_time" for "libboost_date_time" This module finds headers and requested component libraries OR a CMake package configuration file provided by a "Boost CMake" build. For the latter case skip to the :ref:`Boost CMake` section below. .. versionadded:: 3.7 ``bzip2`` and ``zlib`` components (Windows only). .. versionadded:: 3.11 The ``OPTIONAL_COMPONENTS`` option. .. versionadded:: 3.13 ``stacktrace_*`` components. .. versionadded:: 3.19 ``bzip2`` and ``zlib`` components on all platforms. Result Variables ^^^^^^^^^^^^^^^^ This module defines the following variables: ``Boost_FOUND`` True if headers and requested libraries were found. ``Boost_INCLUDE_DIRS`` Boost include directories. ``Boost_LIBRARY_DIRS`` Link directories for Boost libraries. ``Boost_LIBRARIES`` Boost component libraries to be linked. ``Boost_<COMPONENT>_FOUND`` True if component ``<COMPONENT>`` was found (``<COMPONENT>`` name is upper-case). ``Boost_<COMPONENT>_LIBRARY`` Libraries to link for component ``<COMPONENT>`` (may include :command:`target_link_libraries` debug/optimized keywords). ``Boost_VERSION_MACRO`` ``BOOST_VERSION`` value from ``boost/version.hpp``. ``Boost_VERSION_STRING`` Boost version number in ``X.Y.Z`` format. ``Boost_VERSION`` Boost version number in ``X.Y.Z`` format (same as ``Boost_VERSION_STRING``). .. versionchanged:: 3.15 In previous CMake versions, this variable used the raw version string from the Boost header (same as ``Boost_VERSION_MACRO``). See policy :policy:`CMP0093`. ``Boost_LIB_VERSION`` Version string appended to library filenames. ``Boost_VERSION_MAJOR``, ``Boost_MAJOR_VERSION`` Boost major version number (``X`` in ``X.Y.Z``). ``Boost_VERSION_MINOR``, ``Boost_MINOR_VERSION`` Boost minor version number (``Y`` in ``X.Y.Z``). ``Boost_VERSION_PATCH``, ``Boost_SUBMINOR_VERSION`` Boost subminor version number (``Z`` in ``X.Y.Z``). ``Boost_VERSION_COUNT`` Amount of version components (3). ``Boost_LIB_DIAGNOSTIC_DEFINITIONS`` (Windows-specific) Pass to :command:`add_definitions` to have diagnostic information about Boost's automatic linking displayed during compilation .. versionadded:: 3.15 The ``Boost_VERSION_<PART>`` variables. Cache variables ^^^^^^^^^^^^^^^ Search results are saved persistently in CMake cache entries: ``Boost_INCLUDE_DIR`` Directory containing Boost headers. ``Boost_LIBRARY_DIR_RELEASE`` Directory containing release Boost libraries. ``Boost_LIBRARY_DIR_DEBUG`` Directory containing debug Boost libraries. ``Boost_<COMPONENT>_LIBRARY_DEBUG`` Component ``<COMPONENT>`` library debug variant. ``Boost_<COMPONENT>_LIBRARY_RELEASE`` Component ``<COMPONENT>`` library release variant. .. versionadded:: 3.3 Per-configuration variables ``Boost_LIBRARY_DIR_RELEASE`` and ``Boost_LIBRARY_DIR_DEBUG``. Hints ^^^^^ This module reads hints about search locations from variables: ``BOOST_ROOT``, ``BOOSTROOT`` Preferred installation prefix. ``BOOST_INCLUDEDIR`` Preferred include directory e.g. ``<prefix>/include``. ``BOOST_LIBRARYDIR`` Preferred library directory e.g. ``<prefix>/lib``. ``Boost_NO_SYSTEM_PATHS`` Set to ``ON`` to disable searching in locations not specified by these hint variables. Default is ``OFF``. ``Boost_ADDITIONAL_VERSIONS`` List of Boost versions not known to this module. (Boost install locations may contain the version). Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but instead use the above result variables. Note that some hint names start in upper-case ``BOOST``. One may specify these as environment variables if they are not specified as CMake variables or cache entries. This module first searches for the Boost header files using the above hint variables (excluding ``BOOST_LIBRARYDIR``) and saves the result in ``Boost_INCLUDE_DIR``. Then it searches for requested component libraries using the above hints (excluding ``BOOST_INCLUDEDIR`` and ``Boost_ADDITIONAL_VERSIONS``), "lib" directories near ``Boost_INCLUDE_DIR``, and the library name configuration settings below. It saves the library directories in ``Boost_LIBRARY_DIR_DEBUG`` and ``Boost_LIBRARY_DIR_RELEASE`` and individual library locations in ``Boost_<COMPONENT>_LIBRARY_DEBUG`` and ``Boost_<COMPONENT>_LIBRARY_RELEASE``. When one changes settings used by previous searches in the same build tree (excluding environment variables) this module discards previous search results affected by the changes and searches again. Imported Targets ^^^^^^^^^^^^^^^^ .. versionadded:: 3.5 This module defines the following :prop_tgt:`IMPORTED` targets: ``Boost::boost`` Target for header-only dependencies. (Boost include directory). ``Boost::headers`` .. versionadded:: 3.15 Alias for ``Boost::boost``. ``Boost::<component>`` Target for specific component dependency (shared or static library); ``<component>`` name is lower-case. ``Boost::diagnostic_definitions`` Interface target to enable diagnostic information about Boost's automatic linking during compilation (adds ``-DBOOST_LIB_DIAGNOSTIC``). ``Boost::disable_autolinking`` Interface target to disable automatic linking with MSVC (adds ``-DBOOST_ALL_NO_LIB``). ``Boost::dynamic_linking`` Interface target to enable dynamic linking with MSVC (adds ``-DBOOST_ALL_DYN_LINK``). Implicit dependencies such as ``Boost::filesystem`` requiring ``Boost::system`` will be automatically detected and satisfied, even if system is not specified when using :command:`find_package` and if ``Boost::system`` is not added to :command:`target_link_libraries`. If using ``Boost::thread``, then ``Threads::Threads`` will also be added automatically. It is important to note that the imported targets behave differently than variables created by this module: multiple calls to :command:`find_package(Boost)` in the same directory or sub-directories with different options (e.g. static or shared) will not override the values of the targets created by the first call. Other Variables ^^^^^^^^^^^^^^^ Boost libraries come in many variants encoded in their file name. Users or projects may tell this module which variant to find by setting variables: ``Boost_USE_DEBUG_LIBS`` .. versionadded:: 3.10 Set to ``ON`` or ``OFF`` to specify whether to search and use the debug libraries. Default is ``ON``. ``Boost_USE_RELEASE_LIBS`` .. versionadded:: 3.10 Set to ``ON`` or ``OFF`` to specify whether to search and use the release libraries. Default is ``ON``. ``Boost_USE_MULTITHREADED`` Set to OFF to use the non-multithreaded libraries ("mt" tag). Default is ``ON``. ``Boost_USE_STATIC_LIBS`` Set to ON to force the use of the static libraries. Default is ``OFF``. ``Boost_USE_STATIC_RUNTIME`` Set to ``ON`` or ``OFF`` to specify whether to use libraries linked statically to the C++ runtime ("s" tag). Default is platform dependent. ``Boost_USE_DEBUG_RUNTIME`` Set to ``ON`` or ``OFF`` to specify whether to use libraries linked to the MS debug C++ runtime ("g" tag). Default is ``ON``. ``Boost_USE_DEBUG_PYTHON`` Set to ``ON`` to use libraries compiled with a debug Python build ("y" tag). Default is ``OFF``. ``Boost_USE_STLPORT`` Set to ``ON`` to use libraries compiled with STLPort ("p" tag). Default is ``OFF``. ``Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS`` Set to ON to use libraries compiled with STLPort deprecated "native iostreams" ("n" tag). Default is ``OFF``. ``Boost_COMPILER`` Set to the compiler-specific library suffix (e.g. ``-gcc43``). Default is auto-computed for the C++ compiler in use. .. versionchanged:: 3.9 A list may be used if multiple compatible suffixes should be tested for, in decreasing order of preference. ``Boost_LIB_PREFIX`` .. versionadded:: 3.18 Set to the platform-specific library name prefix (e.g. ``lib``) used by Boost static libs. This is needed only on platforms where CMake does not know the prefix by default. ``Boost_ARCHITECTURE`` .. versionadded:: 3.13 Set to the architecture-specific library suffix (e.g. ``-x64``). Default is auto-computed for the C++ compiler in use. ``Boost_THREADAPI`` Suffix for ``thread`` component library name, such as ``pthread`` or ``win32``. Names with and without this suffix will both be tried. ``Boost_NAMESPACE`` Alternate namespace used to build boost with e.g. if set to ``myboost``, will search for ``myboost_thread`` instead of ``boost_thread``. Other variables one may set to control this module are: ``Boost_DEBUG`` Set to ``ON`` to enable debug output from ``FindBoost``. Please enable this before filing any bug report. ``Boost_REALPATH`` Set to ``ON`` to resolve symlinks for discovered libraries to assist with packaging. For example, the "system" component library may be resolved to ``/usr/lib/libboost_system.so.1.67.0`` instead of ``/usr/lib/libboost_system.so``. This does not affect linking and should not be enabled unless the user needs this information. ``Boost_LIBRARY_DIR`` Default value for ``Boost_LIBRARY_DIR_RELEASE`` and ``Boost_LIBRARY_DIR_DEBUG``. ``Boost_NO_WARN_NEW_VERSIONS`` .. versionadded:: 3.20 Set to ``ON`` to suppress the warning about unknown dependencies for new Boost versions. On Visual Studio and Borland compilers Boost headers request automatic linking to corresponding libraries. This requires matching libraries to be linked explicitly or available in the link library search path. In this case setting ``Boost_USE_STATIC_LIBS`` to ``OFF`` may not achieve dynamic linking. Boost automatic linking typically requests static libraries with a few exceptions (such as ``Boost.Python``). Use: .. code-block:: cmake add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) to ask Boost to report information about automatic linking requests. Examples ^^^^^^^^ Find Boost headers only: .. code-block:: cmake find_package(Boost 1.36.0) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) add_executable(foo foo.cc) endif() Find Boost libraries and use imported targets: .. code-block:: cmake find_package(Boost 1.56 REQUIRED COMPONENTS date_time filesystem iostreams) add_executable(foo foo.cc) target_link_libraries(foo Boost::date_time Boost::filesystem Boost::iostreams) Find Boost Python 3.6 libraries and use imported targets: .. code-block:: cmake find_package(Boost 1.67 REQUIRED COMPONENTS python36 numpy36) add_executable(foo foo.cc) target_link_libraries(foo Boost::python36 Boost::numpy36) Find Boost headers and some *static* (release only) libraries: .. code-block:: cmake set(Boost_USE_STATIC_LIBS ON) # only find static libs set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and set(Boost_USE_RELEASE_LIBS ON) # only find release libs set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.66.0 COMPONENTS date_time filesystem system ...) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) add_executable(foo foo.cc) target_link_libraries(foo ${Boost_LIBRARIES}) endif() .. _`Boost CMake`: Boost CMake ^^^^^^^^^^^ If Boost was built using the boost-cmake project or from Boost 1.70.0 on it provides a package configuration file for use with find_package's config mode. This module looks for the package configuration file called ``BoostConfig.cmake`` or ``boost-config.cmake`` and stores the result in ``CACHE`` entry ``Boost_DIR``. If found, the package configuration file is loaded and this module returns with no further action. See documentation of the Boost CMake package configuration for details on what it provides. Set ``Boost_NO_BOOST_CMAKE`` to ``ON``, to disable the search for boost-cmake. #]=======================================================================] # The FPHSA helper provides standard way of reporting final search results to # the user including the version and component checks. include(FindPackageHandleStandardArgs) # Save project's policies cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST #cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var) function(_boost_get_existing_target component target_var) set(names "${component}") if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$") # handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc. list(APPEND names "${CMAKE_MATCH_1}${CMAKE_MATCH_2}" # python "${CMAKE_MATCH_1}${CMAKE_MATCH_2}${CMAKE_MATCH_3}" # pythonX "${CMAKE_MATCH_1}${CMAKE_MATCH_2}${CMAKE_MATCH_3}${CMAKE_MATCH_4}" #pythonXY ) endif() # https://github.com/boost-cmake/boost-cmake uses boost::file_system etc. # So handle similar constructions of target names string(TOLOWER "${component}" lower_component) list(APPEND names "${lower_component}") foreach(prefix Boost boost) foreach(name IN LISTS names) if(TARGET "${prefix}::${name}") # The target may be an INTERFACE library that wraps around a single other # target for compatibility. Unwrap this layer so we can extract real info. if("${name}" MATCHES "^(python|numpy|mpi_python)([1-9])([0-9])$") set(name_nv "${CMAKE_MATCH_1}") if(TARGET "${prefix}::${name_nv}") get_property(type TARGET "${prefix}::${name}" PROPERTY TYPE) if(type STREQUAL "INTERFACE_LIBRARY") get_property(lib TARGET "${prefix}::${name}" PROPERTY INTERFACE_LINK_LIBRARIES) if("${lib}" STREQUAL "${prefix}::${name_nv}") set(${target_var} "${prefix}::${name_nv}" PARENT_SCOPE) return() endif() endif() endif() endif() set(${target_var} "${prefix}::${name}" PARENT_SCOPE) return() endif() endforeach() endforeach() set(${target_var} "" PARENT_SCOPE) endfunction() function(_boost_get_canonical_target_name component target_var) string(TOLOWER "${component}" component) if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$") # handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc. set(${target_var} "Boost::${CMAKE_MATCH_1}${CMAKE_MATCH_2}" PARENT_SCOPE) else() set(${target_var} "Boost::${component}" PARENT_SCOPE) endif() endfunction() macro(_boost_set_in_parent_scope name value) # Set a variable in parent scope and make it visible in current scope set(${name} "${value}" PARENT_SCOPE) set(${name} "${value}") endmacro() macro(_boost_set_if_unset name value) if(NOT ${name}) _boost_set_in_parent_scope(${name} "${value}") endif() endmacro() macro(_boost_set_cache_if_unset name value) if(NOT ${name}) set(${name} "${value}" CACHE STRING "" FORCE) endif() endmacro() macro(_boost_append_include_dir target) get_target_property(inc "${target}" INTERFACE_INCLUDE_DIRECTORIES) if(inc) list(APPEND include_dirs "${inc}") endif() endmacro() function(_boost_set_legacy_variables_from_config) # Set legacy variables for compatibility if not set set(include_dirs "") set(library_dirs "") set(libraries "") # Header targets Boost::headers or Boost::boost foreach(comp headers boost) _boost_get_existing_target(${comp} target) if(target) _boost_append_include_dir("${target}") endif() endforeach() # Library targets foreach(comp IN LISTS Boost_FIND_COMPONENTS) string(TOUPPER ${comp} uppercomp) # Overwrite if set _boost_set_in_parent_scope(Boost_${uppercomp}_FOUND "${Boost_${comp}_FOUND}") if(Boost_${comp}_FOUND) _boost_get_existing_target(${comp} target) if(NOT target) if(Boost_DEBUG OR Boost_VERBOSE) message(WARNING "Could not find imported target for required component '${comp}'. Legacy variables for this component might be missing. Refer to the documentation of your Boost installation for help on variables to use.") endif() continue() endif() _boost_append_include_dir("${target}") _boost_set_if_unset(Boost_${uppercomp}_LIBRARY "${target}") _boost_set_if_unset(Boost_${uppercomp}_LIBRARIES "${target}") # Very old legacy variable list(APPEND libraries "${target}") get_property(type TARGET "${target}" PROPERTY TYPE) if(NOT type STREQUAL "INTERFACE_LIBRARY") foreach(cfg RELEASE DEBUG) get_target_property(lib ${target} IMPORTED_LOCATION_${cfg}) if(lib) get_filename_component(lib_dir "${lib}" DIRECTORY) list(APPEND library_dirs ${lib_dir}) _boost_set_cache_if_unset(Boost_${uppercomp}_LIBRARY_${cfg} "${lib}") endif() endforeach() elseif(Boost_DEBUG OR Boost_VERBOSE) # For projects using only the Boost::* targets this warning can be safely ignored. message(WARNING "Imported target '${target}' for required component '${comp}' has no artifact. Legacy variables for this component might be missing. Refer to the documentation of your Boost installation for help on variables to use.") endif() _boost_get_canonical_target_name("${comp}" canonical_target) if(NOT TARGET "${canonical_target}") add_library("${canonical_target}" INTERFACE IMPORTED) target_link_libraries("${canonical_target}" INTERFACE "${target}") endif() endif() endforeach() list(REMOVE_DUPLICATES include_dirs) list(REMOVE_DUPLICATES library_dirs) _boost_set_if_unset(Boost_INCLUDE_DIRS "${include_dirs}") _boost_set_if_unset(Boost_LIBRARY_DIRS "${library_dirs}") _boost_set_if_unset(Boost_LIBRARIES "${libraries}") _boost_set_if_unset(Boost_VERSION_STRING "${Boost_VERSION_MAJOR}.${Boost_VERSION_MINOR}.${Boost_VERSION_PATCH}") find_path(Boost_INCLUDE_DIR NAMES boost/version.hpp boost/config.hpp HINTS ${Boost_INCLUDE_DIRS} NO_DEFAULT_PATH ) if(NOT Boost_VERSION_MACRO OR NOT Boost_LIB_VERSION) set(version_file ${Boost_INCLUDE_DIR}/boost/version.hpp) if(EXISTS "${version_file}") file(STRINGS "${version_file}" contents REGEX "#define BOOST_(LIB_)?VERSION ") if(contents MATCHES "#define BOOST_VERSION ([0-9]+)") _boost_set_if_unset(Boost_VERSION_MACRO "${CMAKE_MATCH_1}") endif() if(contents MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"") _boost_set_if_unset(Boost_LIB_VERSION "${CMAKE_MATCH_1}") endif() endif() endif() _boost_set_if_unset(Boost_MAJOR_VERSION ${Boost_VERSION_MAJOR}) _boost_set_if_unset(Boost_MINOR_VERSION ${Boost_VERSION_MINOR}) _boost_set_if_unset(Boost_SUBMINOR_VERSION ${Boost_VERSION_PATCH}) if(WIN32) _boost_set_if_unset(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC") endif() if(NOT TARGET Boost::headers) add_library(Boost::headers INTERFACE IMPORTED) target_include_directories(Boost::headers INTERFACE ${Boost_INCLUDE_DIRS}) endif() # Legacy targets w/o functionality as all handled by defined targets foreach(lib diagnostic_definitions disable_autolinking dynamic_linking) if(NOT TARGET Boost::${lib}) add_library(Boost::${lib} INTERFACE IMPORTED) endif() endforeach() if(NOT TARGET Boost::boost) add_library(Boost::boost INTERFACE IMPORTED) target_link_libraries(Boost::boost INTERFACE Boost::headers) endif() endfunction() #------------------------------------------------------------------------------- # Before we go searching, check whether a boost cmake package is available, unless # the user specifically asked NOT to search for one. # # If Boost_DIR is set, this behaves as any find_package call would. If not, # it looks at BOOST_ROOT and BOOSTROOT to find Boost. # if (NOT Boost_NO_BOOST_CMAKE) # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives, # since these are more conventional for Boost. if ("$ENV{Boost_DIR}" STREQUAL "") if (NOT "$ENV{BOOST_ROOT}" STREQUAL "") set(ENV{Boost_DIR} $ENV{BOOST_ROOT}) elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "") set(ENV{Boost_DIR} $ENV{BOOSTROOT}) endif() endif() set(_boost_FIND_PACKAGE_ARGS "") if(Boost_NO_SYSTEM_PATHS) list(APPEND _boost_FIND_PACKAGE_ARGS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) endif() # Do the same find_package call but look specifically for the CMake version. # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no # need to delegate them to this find_package call. if(BOOST_ROOT AND NOT Boost_ROOT) # Honor BOOST_ROOT by setting Boost_ROOT with CMP0074 NEW behavior. cmake_policy(PUSH) #cmake_policy(SET CMP0074 NEW) set(Boost_ROOT "${BOOST_ROOT}") set(_Boost_ROOT_FOR_CONFIG 1) endif() find_package(Boost QUIET NO_MODULE ${_boost_FIND_PACKAGE_ARGS}) if(_Boost_ROOT_FOR_CONFIG) unset(_Boost_ROOT_FOR_CONFIG) unset(Boost_ROOT) cmake_policy(POP) endif() if (DEFINED Boost_DIR) mark_as_advanced(Boost_DIR) endif () # If we found a boost cmake package, then we're done. Print out what we found. # Otherwise let the rest of the module try to find it. if(Boost_FOUND) # Convert component found variables to standard variables if required # Necessary for legacy boost-cmake and 1.70 builtin BoostConfig if(Boost_FIND_COMPONENTS) # Ignore the meta-component "ALL", introduced by Boost 1.73 list(REMOVE_ITEM Boost_FIND_COMPONENTS "ALL") foreach(_comp IN LISTS Boost_FIND_COMPONENTS) if(DEFINED Boost_${_comp}_FOUND) continue() endif() string(TOUPPER ${_comp} _uppercomp) if(DEFINED Boost${_comp}_FOUND) # legacy boost-cmake project set(Boost_${_comp}_FOUND ${Boost${_comp}_FOUND}) elseif(DEFINED Boost_${_uppercomp}_FOUND) # Boost 1.70 set(Boost_${_comp}_FOUND ${Boost_${_uppercomp}_FOUND}) endif() endforeach() endif() find_package_handle_standard_args(Boost HANDLE_COMPONENTS CONFIG_MODE) _boost_set_legacy_variables_from_config() # Restore project's policies cmake_policy(POP) return() endif() endif() #------------------------------------------------------------------------------- # FindBoost functions & macros # # # Print debug text if Boost_DEBUG is set. # Call example: # _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "debug message") # function(_Boost_DEBUG_PRINT file line text) if(Boost_DEBUG) message(STATUS "[ ${file}:${line} ] ${text}") endif() endfunction() # # _Boost_DEBUG_PRINT_VAR(file line variable_name [ENVIRONMENT] # [SOURCE "short explanation of origin of var value"]) # # ENVIRONMENT - look up environment variable instead of CMake variable # # Print variable name and its value if Boost_DEBUG is set. # Call example: # _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" BOOST_ROOT) # function(_Boost_DEBUG_PRINT_VAR file line name) if(Boost_DEBUG) cmake_parse_arguments(_args "ENVIRONMENT" "SOURCE" "" ${ARGN}) unset(source) if(_args_SOURCE) set(source " (${_args_SOURCE})") endif() if(_args_ENVIRONMENT) if(DEFINED ENV{${name}}) set(value "\"$ENV{${name}}\"") else() set(value "<unset>") endif() set(_name "ENV{${name}}") else() if(DEFINED "${name}") set(value "\"${${name}}\"") else() set(value "<unset>") endif() set(_name "${name}") endif() _Boost_DEBUG_PRINT("${file}" "${line}" "${_name} = ${value}${source}") endif() endfunction() ############################################ # # Check the existence of the libraries. # ############################################ # This macro was taken directly from the FindQt4.cmake file that is included # with the CMake distribution. This is NOT my work. All work was done by the # original authors of the FindQt4.cmake file. Only minor modifications were # made to remove references to Qt and make this file more generally applicable # And ELSE/ENDIF pairs were removed for readability. ######################################################################### macro(_Boost_ADJUST_LIB_VARS basename) if(Boost_INCLUDE_DIR ) if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE) # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for # single-config generators, set optimized and debug libraries get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig OR CMAKE_BUILD_TYPE) set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) else() # For single-config generators where CMAKE_BUILD_TYPE has no value, # just use the release libraries set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) endif() # FIXME: This probably should be set for both cases set(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) endif() # if only the release version was found, set the debug variable also to the release version if(Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG) set(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE}) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE}) set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE}) endif() # if only the debug version was found, set the release variable also to the debug version if(Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE) set(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG}) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG}) set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG}) endif() # If the debug & release library ends up being the same, omit the keywords if("${Boost_${basename}_LIBRARY_RELEASE}" STREQUAL "${Boost_${basename}_LIBRARY_DEBUG}") set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} ) endif() if(Boost_${basename}_LIBRARY AND Boost_${basename}_HEADER) set(Boost_${basename}_FOUND ON) if("x${basename}" STREQUAL "xTHREAD" AND NOT TARGET Threads::Threads) string(APPEND Boost_ERROR_REASON_THREAD " (missing dependency: Threads)") set(Boost_THREAD_FOUND OFF) endif() endif() endif() # Make variables changeable to the advanced user mark_as_advanced( Boost_${basename}_LIBRARY_RELEASE Boost_${basename}_LIBRARY_DEBUG ) endmacro() # Detect changes in used variables. # Compares the current variable value with the last one. # In short form: # v != v_LAST -> CHANGED = 1 # v is defined, v_LAST not -> CHANGED = 1 # v is not defined, but v_LAST is -> CHANGED = 1 # otherwise -> CHANGED = 0 # CHANGED is returned in variable named ${changed_var} macro(_Boost_CHANGE_DETECT changed_var) set(${changed_var} 0) foreach(v ${ARGN}) if(DEFINED _Boost_COMPONENTS_SEARCHED) if(${v}) if(_${v}_LAST) string(COMPARE NOTEQUAL "${${v}}" "${_${v}_LAST}" _${v}_CHANGED) else() set(_${v}_CHANGED 1) endif() elseif(_${v}_LAST) set(_${v}_CHANGED 1) endif() if(_${v}_CHANGED) set(${changed_var} 1) endif() else() set(_${v}_CHANGED 0) endif() endforeach() endmacro() # # Find the given library (var). # Use 'build_type' to support different lib paths for RELEASE or DEBUG builds # macro(_Boost_FIND_LIBRARY var build_type) find_library(${var} ${ARGN}) if(${var}) # If this is the first library found then save Boost_LIBRARY_DIR_[RELEASE,DEBUG]. if(NOT Boost_LIBRARY_DIR_${build_type}) get_filename_component(_dir "${${var}}" PATH) set(Boost_LIBRARY_DIR_${build_type} "${_dir}" CACHE PATH "Boost library directory ${build_type}" FORCE) endif() elseif(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT) # Try component-specific hints but do not save Boost_LIBRARY_DIR_[RELEASE,DEBUG]. find_library(${var} HINTS ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT} ${ARGN}) endif() # If Boost_LIBRARY_DIR_[RELEASE,DEBUG] is known then search only there. if(Boost_LIBRARY_DIR_${build_type}) set(_boost_LIBRARY_SEARCH_DIRS_${build_type} ${Boost_LIBRARY_DIR_${build_type}} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_LIBRARY_DIR_${build_type}") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_LIBRARY_SEARCH_DIRS_${build_type}") endif() endmacro() #------------------------------------------------------------------------------- # Convert CMAKE_CXX_COMPILER_VERSION to boost compiler suffix version. function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION _OUTPUT_VERSION_MAJOR _OUTPUT_VERSION_MINOR) string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\1" _boost_COMPILER_VERSION_MAJOR "${CMAKE_CXX_COMPILER_VERSION}") string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\2" _boost_COMPILER_VERSION_MINOR "${CMAKE_CXX_COMPILER_VERSION}") set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}${_boost_COMPILER_VERSION_MINOR}") set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE) set(${_OUTPUT_VERSION_MAJOR} ${_boost_COMPILER_VERSION_MAJOR} PARENT_SCOPE) set(${_OUTPUT_VERSION_MINOR} ${_boost_COMPILER_VERSION_MINOR} PARENT_SCOPE) endfunction() # # Take a list of libraries with "thread" in it # and prepend duplicates with "thread_${Boost_THREADAPI}" # at the front of the list # function(_Boost_PREPEND_LIST_WITH_THREADAPI _output) set(_orig_libnames ${ARGN}) string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames "${_orig_libnames}") set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE) endfunction() # # If a library is found, replace its cache entry with its REALPATH # function(_Boost_SWAP_WITH_REALPATH _library _docstring) if(${_library}) get_filename_component(_boost_filepathreal ${${_library}} REALPATH) unset(${_library} CACHE) set(${_library} ${_boost_filepathreal} CACHE FILEPATH "${_docstring}") endif() endfunction() function(_Boost_CHECK_SPELLING _var) if(${_var}) string(TOUPPER ${_var} _var_UC) message(FATAL_ERROR "ERROR: ${_var} is not the correct spelling. The proper spelling is ${_var_UC}.") endif() endfunction() # Guesses Boost's compiler prefix used in built library names # Returns the guess by setting the variable pointed to by _ret function(_Boost_GUESS_COMPILER_PREFIX _ret) if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel" OR "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "xIntelLLVM") if(WIN32) set (_boost_COMPILER "-iw") else() set (_boost_COMPILER "-il") endif() elseif (GHSMULTI) set(_boost_COMPILER "-ghs") elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") if(MSVC_TOOLSET_VERSION GREATER_EQUAL 150) # Not yet known. set(_boost_COMPILER "") elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 140) # MSVC toolset 14.x versions are forward compatible. set(_boost_COMPILER "") foreach(v 9 8 7 6 5 4 3 2 1 0) if(MSVC_TOOLSET_VERSION GREATER_EQUAL 14${v}) list(APPEND _boost_COMPILER "-vc14${v}") endif() endforeach() elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 80) set(_boost_COMPILER "-vc${MSVC_TOOLSET_VERSION}") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.10) set(_boost_COMPILER "-vc71") elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) # Good luck! set(_boost_COMPILER "-vc7") # yes, this is correct else() # VS 6.0 Good luck! set(_boost_COMPILER "-vc6") # yes, this is correct endif() if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang") string(REPLACE "." ";" VERSION_LIST "${CMAKE_CXX_COMPILER_VERSION}") list(GET VERSION_LIST 0 CLANG_VERSION_MAJOR) set(_boost_COMPILER "-clangw${CLANG_VERSION_MAJOR};${_boost_COMPILER}") endif() elseif (BORLAND) set(_boost_COMPILER "-bcb") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") set(_boost_COMPILER "-sw") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "XL") set(_boost_COMPILER "-xlc") elseif (MINGW) if(Boost_VERSION_STRING VERSION_LESS 1.34) set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 else() _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR) if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.73 AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER_EQUAL 5) set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION_MAJOR}") else() set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}") endif() endif() elseif (UNIX) _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR) if(NOT Boost_VERSION_STRING VERSION_LESS 1.69.0) # From GCC 5 and clang 4, versioning changes and minor becomes patch. # For those compilers, patch is exclude from compiler tag in Boost 1.69+ library naming. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 4) set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 3) set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}") endif() endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(Boost_VERSION_STRING VERSION_LESS 1.34) set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 else() # Determine which version of GCC we have. if(APPLE) if(Boost_VERSION_STRING VERSION_LESS 1.36.0) # In Boost <= 1.35.0, there is no mangled compiler name for # the macOS/Darwin version of GCC. set(_boost_COMPILER "") else() # In Boost 1.36.0 and newer, the mangled compiler name used # on macOS/Darwin is "xgcc". set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") endif() else() set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") endif() endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # TODO: Find out any Boost version constraints vs clang support. set(_boost_COMPILER "-clang${_boost_COMPILER_VERSION}") endif() else() set(_boost_COMPILER "") endif() _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_COMPILER" SOURCE "guessed") set(${_ret} ${_boost_COMPILER} PARENT_SCOPE) endfunction() # # Get component dependencies. Requires the dependencies to have been # defined for the Boost release version. # # component - the component to check # _ret - list of library dependencies # function(_Boost_COMPONENT_DEPENDENCIES component _ret) # Note: to add a new Boost release, run # # % cmake -DBOOST_DIR=/path/to/boost/source -P Utilities/Scripts/BoostScanDeps.cmake # # The output may be added in a new block below. If it's the same as # the previous release, simply update the version range of the block # for the previous release. Also check if any new components have # been added, and add any new components to # _Boost_COMPONENT_HEADERS. # # This information was originally generated by running # BoostScanDeps.cmake against every boost release to date supported # by FindBoost: # # % for version in /path/to/boost/sources/* # do # cmake -DBOOST_DIR=$version -P Utilities/Scripts/BoostScanDeps.cmake # done # # The output was then updated by search and replace with these regexes: # # - Strip message(STATUS) prefix dashes # s;^-- ;; # - Indent # s;^set(; set(;; # - Add conditionals # s;Scanning /path/to/boost/sources/boost_\(.*\)_\(.*\)_\(.*); elseif(NOT Boost_VERSION_STRING VERSION_LESS \1\.\2\.\3 AND Boost_VERSION_STRING VERSION_LESS xxxx); # # This results in the logic seen below, but will require the xxxx # replacing with the following Boost release version (or the next # minor version to be released, e.g. 1.59 was the latest at the time # of writing, making 1.60 the next. Identical consecutive releases # were then merged together by updating the end range of the first # block and removing the following redundant blocks. # # Running the script against all historical releases should be # required only if the BoostScanDeps.cmake script logic is changed. # The addition of a new release should only require it to be run # against the new release. # Handle Python version suffixes if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9])\$") set(component "${CMAKE_MATCH_1}") set(component_python_version "${CMAKE_MATCH_2}") endif() set(_Boost_IMPORTED_TARGETS TRUE) if(Boost_VERSION_STRING) if(Boost_VERSION_STRING VERSION_LESS 1.33.0) message(WARNING "Imported targets and dependency information not available for Boost version ${Boost_VERSION_STRING} (all versions older than 1.33)") set(_Boost_IMPORTED_TARGETS FALSE) elseif(Boost_VERSION_STRING VERSION_LESS 1.35.0) set(_Boost_IOSTREAMS_DEPENDENCIES regex thread) set(_Boost_REGEX_DEPENDENCIES thread) set(_Boost_WAVE_DEPENDENCIES filesystem thread) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.36.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_WAVE_DEPENDENCIES filesystem system thread) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.38.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_WAVE_DEPENDENCIES filesystem system thread) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.43.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.44.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.45.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random serialization) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES serialization filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.47.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.48.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.50.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.53.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES chrono system date_time) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.54.0) set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.55.0) set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.56.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.59.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.60.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.61.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.62.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.63.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.65.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_COROUTINE2_DEPENDENCIES context fiber thread chrono system date_time) set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.67.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.68.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.69.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) set(_Boost_RANDOM_DEPENDENCIES system) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.70.0) set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.72.0) set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.73.0) set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l chrono atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) elseif(Boost_VERSION_STRING VERSION_LESS 1.75.0) set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_JSON_DEPENDENCIES container) set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.76.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() endif() string(TOUPPER ${component} uppercomponent) set(${_ret} ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE) set(_Boost_IMPORTED_TARGETS ${_Boost_IMPORTED_TARGETS} PARENT_SCOPE) string(REGEX REPLACE ";" " " _boost_DEPS_STRING "${_Boost_${uppercomponent}_DEPENDENCIES}") if (NOT _boost_DEPS_STRING) set(_boost_DEPS_STRING "(none)") endif() # message(STATUS "Dependencies for Boost::${component}: ${_boost_DEPS_STRING}") endfunction() # # Get component headers. This is the primary header (or headers) for # a given component, and is used to check that the headers are present # as well as the library itself as an extra sanity check of the build # environment. # # component - the component to check # _hdrs # function(_Boost_COMPONENT_HEADERS component _hdrs) # Handle Python version suffixes if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9])\$") set(component "${CMAKE_MATCH_1}") set(component_python_version "${CMAKE_MATCH_2}") endif() # Note: new boost components will require adding here. The header # must be present in all versions of Boost providing a library. set(_Boost_ATOMIC_HEADERS "boost/atomic.hpp") set(_Boost_CHRONO_HEADERS "boost/chrono.hpp") set(_Boost_CONTAINER_HEADERS "boost/container/container_fwd.hpp") set(_Boost_CONTRACT_HEADERS "boost/contract.hpp") if(Boost_VERSION_STRING VERSION_LESS 1.61.0) set(_Boost_CONTEXT_HEADERS "boost/context/all.hpp") else() set(_Boost_CONTEXT_HEADERS "boost/context/detail/fcontext.hpp") endif() set(_Boost_COROUTINE_HEADERS "boost/coroutine/all.hpp") set(_Boost_DATE_TIME_HEADERS "boost/date_time/date.hpp") set(_Boost_EXCEPTION_HEADERS "boost/exception/exception.hpp") set(_Boost_FIBER_HEADERS "boost/fiber/all.hpp") set(_Boost_FILESYSTEM_HEADERS "boost/filesystem/path.hpp") set(_Boost_GRAPH_HEADERS "boost/graph/adjacency_list.hpp") set(_Boost_GRAPH_PARALLEL_HEADERS "boost/graph/adjacency_list.hpp") set(_Boost_IOSTREAMS_HEADERS "boost/iostreams/stream.hpp") set(_Boost_LOCALE_HEADERS "boost/locale.hpp") set(_Boost_LOG_HEADERS "boost/log/core.hpp") set(_Boost_LOG_SETUP_HEADERS "boost/log/detail/setup_config.hpp") set(_Boost_MATH_HEADERS "boost/math_fwd.hpp") set(_Boost_MATH_C99_HEADERS "boost/math/tr1.hpp") set(_Boost_MATH_C99F_HEADERS "boost/math/tr1.hpp") set(_Boost_MATH_C99L_HEADERS "boost/math/tr1.hpp") set(_Boost_MATH_TR1_HEADERS "boost/math/tr1.hpp") set(_Boost_MATH_TR1F_HEADERS "boost/math/tr1.hpp") set(_Boost_MATH_TR1L_HEADERS "boost/math/tr1.hpp") set(_Boost_MPI_HEADERS "boost/mpi.hpp") set(_Boost_MPI_PYTHON_HEADERS "boost/mpi/python/config.hpp") set(_Boost_NUMPY_HEADERS "boost/python/numpy.hpp") set(_Boost_NOWIDE_HEADERS "boost/nowide/cstdlib.hpp") set(_Boost_PRG_EXEC_MONITOR_HEADERS "boost/test/prg_exec_monitor.hpp") set(_Boost_PROGRAM_OPTIONS_HEADERS "boost/program_options.hpp") set(_Boost_PYTHON_HEADERS "boost/python.hpp") set(_Boost_RANDOM_HEADERS "boost/random.hpp") set(_Boost_REGEX_HEADERS "boost/regex.hpp") set(_Boost_SERIALIZATION_HEADERS "boost/serialization/serialization.hpp") set(_Boost_SIGNALS_HEADERS "boost/signals.hpp") set(_Boost_STACKTRACE_ADDR2LINE_HEADERS "boost/stacktrace.hpp") set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp") set(_Boost_STACKTRACE_BASIC_HEADERS "boost/stacktrace.hpp") set(_Boost_STACKTRACE_NOOP_HEADERS "boost/stacktrace.hpp") set(_Boost_STACKTRACE_WINDBG_CACHED_HEADERS "boost/stacktrace.hpp") set(_Boost_STACKTRACE_WINDBG_HEADERS "boost/stacktrace.hpp") set(_Boost_SYSTEM_HEADERS "boost/system/config.hpp") set(_Boost_TEST_EXEC_MONITOR_HEADERS "boost/test/test_exec_monitor.hpp") set(_Boost_THREAD_HEADERS "boost/thread.hpp") set(_Boost_TIMER_HEADERS "boost/timer.hpp") set(_Boost_TYPE_ERASURE_HEADERS "boost/type_erasure/config.hpp") set(_Boost_UNIT_TEST_FRAMEWORK_HEADERS "boost/test/framework.hpp") set(_Boost_WAVE_HEADERS "boost/wave.hpp") set(_Boost_WSERIALIZATION_HEADERS "boost/archive/text_wiarchive.hpp") set(_Boost_BZIP2_HEADERS "boost/iostreams/filter/bzip2.hpp") set(_Boost_ZLIB_HEADERS "boost/iostreams/filter/zlib.hpp") string(TOUPPER ${component} uppercomponent) set(${_hdrs} ${_Boost_${uppercomponent}_HEADERS} PARENT_SCOPE) string(REGEX REPLACE ";" " " _boost_HDRS_STRING "${_Boost_${uppercomponent}_HEADERS}") if (NOT _boost_HDRS_STRING) set(_boost_HDRS_STRING "(none)") endif() # message(STATUS "Headers for Boost::${component}: ${_boost_HDRS_STRING}") endfunction() # # Determine if any missing dependencies require adding to the component list. # # Sets _Boost_${COMPONENT}_DEPENDENCIES for each required component, # plus _Boost_IMPORTED_TARGETS (TRUE if imported targets should be # defined; FALSE if dependency information is unavailable). # # componentvar - the component list variable name # extravar - the indirect dependency list variable name # # function(_Boost_MISSING_DEPENDENCIES componentvar extravar) # _boost_unprocessed_components - list of components requiring processing # _boost_processed_components - components already processed (or currently being processed) # _boost_new_components - new components discovered for future processing # list(APPEND _boost_unprocessed_components ${${componentvar}}) while(_boost_unprocessed_components) list(APPEND _boost_processed_components ${_boost_unprocessed_components}) foreach(component ${_boost_unprocessed_components}) string(TOUPPER ${component} uppercomponent) set(${_ret} ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE) _Boost_COMPONENT_DEPENDENCIES("${component}" _Boost_${uppercomponent}_DEPENDENCIES) set(_Boost_${uppercomponent}_DEPENDENCIES ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE) set(_Boost_IMPORTED_TARGETS ${_Boost_IMPORTED_TARGETS} PARENT_SCOPE) foreach(componentdep ${_Boost_${uppercomponent}_DEPENDENCIES}) if (NOT ("${componentdep}" IN_LIST _boost_processed_components OR "${componentdep}" IN_LIST _boost_new_components)) list(APPEND _boost_new_components ${componentdep}) endif() endforeach() endforeach() set(_boost_unprocessed_components ${_boost_new_components}) unset(_boost_new_components) endwhile() set(_boost_extra_components ${_boost_processed_components}) if(_boost_extra_components AND ${componentvar}) list(REMOVE_ITEM _boost_extra_components ${${componentvar}}) endif() set(${componentvar} ${_boost_processed_components} PARENT_SCOPE) set(${extravar} ${_boost_extra_components} PARENT_SCOPE) endfunction() # # Some boost libraries may require particular set of compiler features. # The very first one was `boost::fiber` introduced in Boost 1.62. # One can check required compiler features of it in # - `${Boost_ROOT}/libs/fiber/build/Jamfile.v2`; # - `${Boost_ROOT}/libs/context/build/Jamfile.v2`. # # TODO (Re)Check compiler features on (every?) release ??? # One may use the following command to get the files to check: # # $ find . -name Jamfile.v2 | grep build | xargs grep -l cxx1 # function(_Boost_COMPILER_FEATURES component _ret) # Boost >= 1.62 if(NOT Boost_VERSION_STRING VERSION_LESS 1.62.0) set(_Boost_FIBER_COMPILER_FEATURES cxx_alias_templates cxx_auto_type cxx_constexpr cxx_defaulted_functions cxx_final cxx_lambdas cxx_noexcept cxx_nullptr cxx_rvalue_references cxx_thread_local cxx_variadic_templates ) # Compiler feature for `context` same as for `fiber`. set(_Boost_CONTEXT_COMPILER_FEATURES ${_Boost_FIBER_COMPILER_FEATURES}) endif() # Boost Contract library available in >= 1.67 if(NOT Boost_VERSION_STRING VERSION_LESS 1.67.0) # From `libs/contract/build/boost_contract_build.jam` set(_Boost_CONTRACT_COMPILER_FEATURES cxx_lambdas cxx_variadic_templates ) endif() string(TOUPPER ${component} uppercomponent) set(${_ret} ${_Boost_${uppercomponent}_COMPILER_FEATURES} PARENT_SCOPE) endfunction() # # Update library search directory hint variable with paths used by prebuilt boost binaries. # # Prebuilt windows binaries (https://sourceforge.net/projects/boost/files/boost-binaries/) # have library directories named using MSVC compiler version and architecture. # This function would append corresponding directories if MSVC is a current compiler, # so having `BOOST_ROOT` would be enough to specify to find everything. # function(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS componentlibvar basedir) if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_arch_suffix 64) else() set(_arch_suffix 32) endif() if(MSVC_TOOLSET_VERSION GREATER_EQUAL 150) # Not yet known. elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 140) # MSVC toolset 14.x versions are forward compatible. foreach(v 9 8 7 6 5 4 3 2 1 0) if(MSVC_TOOLSET_VERSION GREATER_EQUAL 14${v}) list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.${v}) endif() endforeach() elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 80) math(EXPR _toolset_major_version "${MSVC_TOOLSET_VERSION} / 10") list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-${_toolset_major_version}.0) endif() set(${componentlibvar} ${${componentlibvar}} PARENT_SCOPE) endif() endfunction() # # End functions/macros # #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # main. #------------------------------------------------------------------------------- # If the user sets Boost_LIBRARY_DIR, use it as the default for both # configurations. if(NOT Boost_LIBRARY_DIR_RELEASE AND Boost_LIBRARY_DIR) set(Boost_LIBRARY_DIR_RELEASE "${Boost_LIBRARY_DIR}") endif() if(NOT Boost_LIBRARY_DIR_DEBUG AND Boost_LIBRARY_DIR) set(Boost_LIBRARY_DIR_DEBUG "${Boost_LIBRARY_DIR}") endif() if(NOT DEFINED Boost_USE_DEBUG_LIBS) set(Boost_USE_DEBUG_LIBS TRUE) endif() if(NOT DEFINED Boost_USE_RELEASE_LIBS) set(Boost_USE_RELEASE_LIBS TRUE) endif() if(NOT DEFINED Boost_USE_MULTITHREADED) set(Boost_USE_MULTITHREADED TRUE) endif() if(NOT DEFINED Boost_USE_DEBUG_RUNTIME) set(Boost_USE_DEBUG_RUNTIME TRUE) endif() # Check the version of Boost against the requested version. if(Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR) message(SEND_ERROR "When requesting a specific version of Boost, you must provide at least the major and minor version numbers, e.g., 1.34") endif() if(Boost_FIND_VERSION_EXACT) # The version may appear in a directory with or without the patch # level, even when the patch level is non-zero. set(_boost_TEST_VERSIONS "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}" "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") else() # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. # # Note: When adding a new Boost release, also update the dependency # information in _Boost_COMPONENT_DEPENDENCIES and # _Boost_COMPONENT_HEADERS. See the instructions at the top of # _Boost_COMPONENT_DEPENDENCIES. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.75.0" "1.75" "1.74.0" "1.74" "1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70" "1.69.0" "1.69" "1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65" "1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60" "1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55" "1.54.0" "1.54" "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51" "1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") set(_boost_TEST_VERSIONS) if(Boost_FIND_VERSION) set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") # Select acceptable versions. foreach(version ${_Boost_KNOWN_VERSIONS}) if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}") # This version is high enough. list(APPEND _boost_TEST_VERSIONS "${version}") elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99") # This version is a short-form for the requested version with # the patch level dropped. list(APPEND _boost_TEST_VERSIONS "${version}") endif() endforeach() else() # Any version is acceptable. set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}") endif() endif() _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_TEST_VERSIONS") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_MULTITHREADED") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_STATIC_LIBS") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_STATIC_RUNTIME") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_ADDITIONAL_VERSIONS") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_NO_SYSTEM_PATHS") #cmake_policy(GET CMP0074 _Boost_CMP0074) if(NOT "x${_Boost_CMP0074}x" STREQUAL "xNEWx") _Boost_CHECK_SPELLING(Boost_ROOT) endif() unset(_Boost_CMP0074) _Boost_CHECK_SPELLING(Boost_LIBRARYDIR) _Boost_CHECK_SPELLING(Boost_INCLUDEDIR) # Collect environment variable inputs as hints. Do not consider changes. foreach(v BOOSTROOT BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR) set(_env $ENV{${v}}) if(_env) file(TO_CMAKE_PATH "${_env}" _ENV_${v}) else() set(_ENV_${v} "") endif() endforeach() if(NOT _ENV_BOOST_ROOT AND _ENV_BOOSTROOT) set(_ENV_BOOST_ROOT "${_ENV_BOOSTROOT}") endif() # Collect inputs and cached results. Detect changes since the last run. if(NOT BOOST_ROOT AND BOOSTROOT) set(BOOST_ROOT "${BOOSTROOT}") endif() set(_Boost_VARS_DIR BOOST_ROOT Boost_NO_SYSTEM_PATHS ) _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_ROOT") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_ROOT" ENVIRONMENT) _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_INCLUDEDIR") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_INCLUDEDIR" ENVIRONMENT) _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_LIBRARYDIR") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_LIBRARYDIR" ENVIRONMENT) # ------------------------------------------------------------------------ # Search for Boost include DIR # ------------------------------------------------------------------------ set(_Boost_VARS_INC BOOST_INCLUDEDIR Boost_INCLUDE_DIR Boost_ADDITIONAL_VERSIONS) _Boost_CHANGE_DETECT(_Boost_CHANGE_INCDIR ${_Boost_VARS_DIR} ${_Boost_VARS_INC}) # Clear Boost_INCLUDE_DIR if it did not change but other input affecting the # location did. We will find a new one based on the new inputs. if(_Boost_CHANGE_INCDIR AND NOT _Boost_INCLUDE_DIR_CHANGED) unset(Boost_INCLUDE_DIR CACHE) endif() if(NOT Boost_INCLUDE_DIR) set(_boost_INCLUDE_SEARCH_DIRS "") if(BOOST_INCLUDEDIR) list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR}) elseif(_ENV_BOOST_INCLUDEDIR) list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_INCLUDEDIR}) endif() if( BOOST_ROOT ) list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${BOOST_ROOT}) elseif( _ENV_BOOST_ROOT ) list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_ROOT}/include ${_ENV_BOOST_ROOT}) endif() if( Boost_NO_SYSTEM_PATHS) list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) else() if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") foreach(ver ${_boost_TEST_VERSIONS}) string(REPLACE "." "_" ver "${ver}") list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS "C:/local/boost_${ver}") endforeach() endif() list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS C:/boost/include C:/boost /sw/local/include ) endif() # Try to find Boost by stepping backwards through the Boost versions # we know about. # Build a list of path suffixes for each version. set(_boost_PATH_SUFFIXES) foreach(_boost_VER ${_boost_TEST_VERSIONS}) # Add in a path suffix, based on the required version, ideally # we could read this from version.hpp, but for that to work we'd # need to know the include dir already set(_boost_BOOSTIFIED_VERSION) # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0 if(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)") set(_boost_BOOSTIFIED_VERSION "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}_${CMAKE_MATCH_3}") elseif(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)") set(_boost_BOOSTIFIED_VERSION "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}") endif() list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}" "boost_${_boost_BOOSTIFIED_VERSION}" "boost/boost-${_boost_BOOSTIFIED_VERSION}" "boost/boost_${_boost_BOOSTIFIED_VERSION}" ) endforeach() _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_INCLUDE_SEARCH_DIRS") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_PATH_SUFFIXES") # Look for a standard boost header file. find_path(Boost_INCLUDE_DIR NAMES boost/config.hpp HINTS ${_boost_INCLUDE_SEARCH_DIRS} PATH_SUFFIXES ${_boost_PATH_SUFFIXES} ) endif() # ------------------------------------------------------------------------ # Extract version information from version.hpp # ------------------------------------------------------------------------ if(Boost_INCLUDE_DIR) _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp") # Extract Boost_VERSION_MACRO and Boost_LIB_VERSION from version.hpp set(Boost_VERSION_MACRO 0) set(Boost_LIB_VERSION "") file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ") if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_VERSION ([0-9]+)") set(Boost_VERSION_MACRO "${CMAKE_MATCH_1}") endif() if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"") set(Boost_LIB_VERSION "${CMAKE_MATCH_1}") endif() unset(_boost_VERSION_HPP_CONTENTS) # Calculate version components math(EXPR Boost_VERSION_MAJOR "${Boost_VERSION_MACRO} / 100000") math(EXPR Boost_VERSION_MINOR "${Boost_VERSION_MACRO} / 100 % 1000") math(EXPR Boost_VERSION_PATCH "${Boost_VERSION_MACRO} % 100") set(Boost_VERSION_COUNT 3) # Define alias variables for backwards compat. set(Boost_MAJOR_VERSION ${Boost_VERSION_MAJOR}) set(Boost_MINOR_VERSION ${Boost_VERSION_MINOR}) set(Boost_SUBMINOR_VERSION ${Boost_VERSION_PATCH}) # Define Boost version in x.y.z format set(Boost_VERSION_STRING "${Boost_VERSION_MAJOR}.${Boost_VERSION_MINOR}.${Boost_VERSION_PATCH}") # Define final Boost_VERSION #cmake_policy(GET CMP0093 _Boost_CMP0093 # PARENT_SCOPE # undocumented, do not use outside of CMake #) if("x${_Boost_CMP0093}x" STREQUAL "xNEWx") set(Boost_VERSION ${Boost_VERSION_STRING}) else() set(Boost_VERSION ${Boost_VERSION_MACRO}) endif() unset(_Boost_CMP0093) _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_STRING") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MACRO") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MAJOR") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MINOR") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_PATCH") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_COUNT") endif() # ------------------------------------------------------------------------ # Prefix initialization # ------------------------------------------------------------------------ if ( NOT DEFINED Boost_LIB_PREFIX ) # Boost's static libraries use a "lib" prefix on DLL platforms # to distinguish them from the DLL import libraries. if (Boost_USE_STATIC_LIBS AND ( (WIN32 AND NOT CYGWIN) OR GHSMULTI )) set(Boost_LIB_PREFIX "lib") else() set(Boost_LIB_PREFIX "") endif() endif() if ( NOT Boost_NAMESPACE ) set(Boost_NAMESPACE "boost") endif() _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_LIB_PREFIX") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_NAMESPACE") # ------------------------------------------------------------------------ # Suffix initialization and compiler suffix detection. # ------------------------------------------------------------------------ set(_Boost_VARS_NAME Boost_NAMESPACE Boost_COMPILER Boost_THREADAPI Boost_USE_DEBUG_PYTHON Boost_USE_MULTITHREADED Boost_USE_STATIC_LIBS Boost_USE_STATIC_RUNTIME Boost_USE_STLPORT Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS ) _Boost_CHANGE_DETECT(_Boost_CHANGE_LIBNAME ${_Boost_VARS_NAME}) # Setting some more suffixes for the library if (Boost_COMPILER) set(_boost_COMPILER ${Boost_COMPILER}) _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_COMPILER" SOURCE "user-specified via Boost_COMPILER") else() # Attempt to guess the compiler suffix # NOTE: this is not perfect yet, if you experience any issues # please report them and use the Boost_COMPILER variable # to work around the problems. _Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER) endif() set (_boost_MULTITHREADED "-mt") if( NOT Boost_USE_MULTITHREADED ) set (_boost_MULTITHREADED "") endif() _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_MULTITHREADED") #====================== # Systematically build up the Boost ABI tag for the 'tagged' and 'versioned' layouts # http://boost.org/doc/libs/1_66_0/more/getting_started/windows.html#library-naming # http://boost.org/doc/libs/1_66_0/boost/config/auto_link.hpp # http://boost.org/doc/libs/1_66_0/tools/build/src/tools/common.jam # http://boost.org/doc/libs/1_66_0/boostcpp.jam set( _boost_RELEASE_ABI_TAG "-") set( _boost_DEBUG_ABI_TAG "-") # Key Use this library when: # s linking statically to the C++ standard library and # compiler runtime support libraries. if(Boost_USE_STATIC_RUNTIME) set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s") set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s") endif() # g using debug versions of the standard and runtime # support libraries if(WIN32 AND Boost_USE_DEBUG_RUNTIME) if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang" OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel" OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntelLLVM") string(APPEND _boost_DEBUG_ABI_TAG "g") endif() endif() # y using special debug build of python if(Boost_USE_DEBUG_PYTHON) string(APPEND _boost_DEBUG_ABI_TAG "y") endif() # d using a debug version of your code string(APPEND _boost_DEBUG_ABI_TAG "d") # p using the STLport standard library rather than the # default one supplied with your compiler if(Boost_USE_STLPORT) string(APPEND _boost_RELEASE_ABI_TAG "p") string(APPEND _boost_DEBUG_ABI_TAG "p") endif() # n using the STLport deprecated "native iostreams" feature # removed from the documentation in 1.43.0 but still present in # boost/config/auto_link.hpp if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS) string(APPEND _boost_RELEASE_ABI_TAG "n") string(APPEND _boost_DEBUG_ABI_TAG "n") endif() # -x86 Architecture and address model tag # First character is the architecture, then word-size, either 32 or 64 # Only used in 'versioned' layout, added in Boost 1.66.0 if(DEFINED Boost_ARCHITECTURE) set(_boost_ARCHITECTURE_TAG "${Boost_ARCHITECTURE}") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_ARCHITECTURE_TAG" SOURCE "user-specified via Boost_ARCHITECTURE") else() set(_boost_ARCHITECTURE_TAG "") # {CMAKE_CXX_COMPILER_ARCHITECTURE_ID} is not currently set for all compilers if(NOT "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x" AND NOT Boost_VERSION_STRING VERSION_LESS 1.66.0) string(APPEND _boost_ARCHITECTURE_TAG "-") # This needs to be kept in-sync with the section of CMakePlatformId.h.in # inside 'defined(_WIN32) && defined(_MSC_VER)' if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "IA64") string(APPEND _boost_ARCHITECTURE_TAG "i") elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "X86" OR CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "x64") string(APPEND _boost_ARCHITECTURE_TAG "x") elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "^ARM") string(APPEND _boost_ARCHITECTURE_TAG "a") elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "MIPS") string(APPEND _boost_ARCHITECTURE_TAG "m") endif() if(CMAKE_SIZEOF_VOID_P EQUAL 8) string(APPEND _boost_ARCHITECTURE_TAG "64") else() string(APPEND _boost_ARCHITECTURE_TAG "32") endif() endif() _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_ARCHITECTURE_TAG" SOURCE "detected") endif() _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_RELEASE_ABI_TAG") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_DEBUG_ABI_TAG") # ------------------------------------------------------------------------ # Begin finding boost libraries # ------------------------------------------------------------------------ set(_Boost_VARS_LIB "") foreach(c DEBUG RELEASE) set(_Boost_VARS_LIB_${c} BOOST_LIBRARYDIR Boost_LIBRARY_DIR_${c}) list(APPEND _Boost_VARS_LIB ${_Boost_VARS_LIB_${c}}) _Boost_CHANGE_DETECT(_Boost_CHANGE_LIBDIR_${c} ${_Boost_VARS_DIR} ${_Boost_VARS_LIB_${c}} Boost_INCLUDE_DIR) # Clear Boost_LIBRARY_DIR_${c} if it did not change but other input affecting the # location did. We will find a new one based on the new inputs. if(_Boost_CHANGE_LIBDIR_${c} AND NOT _Boost_LIBRARY_DIR_${c}_CHANGED) unset(Boost_LIBRARY_DIR_${c} CACHE) endif() # If Boost_LIBRARY_DIR_[RELEASE,DEBUG] is set, prefer its value. if(Boost_LIBRARY_DIR_${c}) set(_boost_LIBRARY_SEARCH_DIRS_${c} ${Boost_LIBRARY_DIR_${c}} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) else() set(_boost_LIBRARY_SEARCH_DIRS_${c} "") if(BOOST_LIBRARYDIR) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_LIBRARYDIR}) elseif(_ENV_BOOST_LIBRARYDIR) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_LIBRARYDIR}) endif() if(BOOST_ROOT) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib) _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${BOOST_ROOT}") elseif(_ENV_BOOST_ROOT) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib) _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${_ENV_BOOST_ROOT}") endif() list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${Boost_INCLUDE_DIR}/lib ${Boost_INCLUDE_DIR}/../lib ${Boost_INCLUDE_DIR}/stage/lib ) _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${Boost_INCLUDE_DIR}/..") _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${Boost_INCLUDE_DIR}") if( Boost_NO_SYSTEM_PATHS ) list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) else() foreach(ver ${_boost_TEST_VERSIONS}) string(REPLACE "." "_" ver "${ver}") _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/local/boost_${ver}") endforeach() _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/boost") list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} PATHS C:/boost/lib C:/boost /sw/local/lib ) endif() endif() endforeach() _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_LIBRARY_SEARCH_DIRS_RELEASE") _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_LIBRARY_SEARCH_DIRS_DEBUG") # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES if( Boost_USE_STATIC_LIBS ) set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) if(WIN32) list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a) else() set(CMAKE_FIND_LIBRARY_SUFFIXES .a) endif() endif() # We want to use the tag inline below without risking double dashes if(_boost_RELEASE_ABI_TAG) if(${_boost_RELEASE_ABI_TAG} STREQUAL "-") set(_boost_RELEASE_ABI_TAG "") endif() endif() if(_boost_DEBUG_ABI_TAG) if(${_boost_DEBUG_ABI_TAG} STREQUAL "-") set(_boost_DEBUG_ABI_TAG "") endif() endif() # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled # on WIN32 was to: # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found) # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found) # We maintain this behavior since changing it could break people's builds. # To disable the ambiguous behavior, the user need only # set Boost_USE_STATIC_RUNTIME either ON or OFF. set(_boost_STATIC_RUNTIME_WORKAROUND false) if(WIN32 AND Boost_USE_STATIC_LIBS) if(NOT DEFINED Boost_USE_STATIC_RUNTIME) set(_boost_STATIC_RUNTIME_WORKAROUND TRUE) endif() endif() # On versions < 1.35, remove the System library from the considered list # since it wasn't added until 1.35. if(Boost_VERSION_STRING AND Boost_FIND_COMPONENTS) if(Boost_VERSION_STRING VERSION_LESS 1.35.0) list(REMOVE_ITEM Boost_FIND_COMPONENTS system) endif() endif() # Additional components may be required via component dependencies. # Add any missing components to the list. _Boost_MISSING_DEPENDENCIES(Boost_FIND_COMPONENTS _Boost_EXTRA_FIND_COMPONENTS) # If thread is required, get the thread libs as a dependency if("thread" IN_LIST Boost_FIND_COMPONENTS) if(Boost_FIND_QUIETLY) set(_Boost_find_quiet QUIET) else() set(_Boost_find_quiet "") endif() find_package(Threads ${_Boost_find_quiet}) unset(_Boost_find_quiet) endif() # If the user changed any of our control inputs flush previous results. if(_Boost_CHANGE_LIBDIR_DEBUG OR _Boost_CHANGE_LIBDIR_RELEASE OR _Boost_CHANGE_LIBNAME) foreach(COMPONENT ${_Boost_COMPONENTS_SEARCHED}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) foreach(c DEBUG RELEASE) set(_var Boost_${UPPERCOMPONENT}_LIBRARY_${c}) unset(${_var} CACHE) set(${_var} "${_var}-NOTFOUND") endforeach() endforeach() set(_Boost_COMPONENTS_SEARCHED "") endif() foreach(COMPONENT ${Boost_FIND_COMPONENTS}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) set( _boost_docstring_release "Boost ${COMPONENT} library (release)") set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)") # Compute component-specific hints. set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "") if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR ${COMPONENT} STREQUAL "graph_parallel") foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES}) if(IS_ABSOLUTE "${lib}") get_filename_component(libdir "${lib}" PATH) string(REPLACE "\\" "/" libdir "${libdir}") list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT ${libdir}) endif() endforeach() endif() # Handle Python version suffixes unset(COMPONENT_PYTHON_VERSION_MAJOR) unset(COMPONENT_PYTHON_VERSION_MINOR) if(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\$") set(COMPONENT_UNVERSIONED "${CMAKE_MATCH_1}") set(COMPONENT_PYTHON_VERSION_MAJOR "${CMAKE_MATCH_2}") elseif(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\\.?([0-9])\$") set(COMPONENT_UNVERSIONED "${CMAKE_MATCH_1}") set(COMPONENT_PYTHON_VERSION_MAJOR "${CMAKE_MATCH_2}") set(COMPONENT_PYTHON_VERSION_MINOR "${CMAKE_MATCH_3}") endif() unset(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME) if (COMPONENT_PYTHON_VERSION_MINOR) # Boost >= 1.67 list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}${COMPONENT_PYTHON_VERSION_MAJOR}${COMPONENT_PYTHON_VERSION_MINOR}") # Debian/Ubuntu (Some versions omit the 2 and/or 3 from the suffix) list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}${COMPONENT_PYTHON_VERSION_MAJOR}-py${COMPONENT_PYTHON_VERSION_MAJOR}${COMPONENT_PYTHON_VERSION_MINOR}") list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}-py${COMPONENT_PYTHON_VERSION_MAJOR}${COMPONENT_PYTHON_VERSION_MINOR}") # Gentoo list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}-${COMPONENT_PYTHON_VERSION_MAJOR}.${COMPONENT_PYTHON_VERSION_MINOR}") # RPMs list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}-${COMPONENT_PYTHON_VERSION_MAJOR}${COMPONENT_PYTHON_VERSION_MINOR}") endif() if (COMPONENT_PYTHON_VERSION_MAJOR AND NOT COMPONENT_PYTHON_VERSION_MINOR) # Boost < 1.67 list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}${COMPONENT_PYTHON_VERSION_MAJOR}") endif() # Consolidate and report component-specific hints. if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME) list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME) _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Component-specific library search names for ${COMPONENT_NAME}: ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME}") endif() if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT) list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT) _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Component-specific library search paths for ${COMPONENT}: ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}") endif() # # Find headers # _Boost_COMPONENT_HEADERS("${COMPONENT}" Boost_${UPPERCOMPONENT}_HEADER_NAME) # Look for a standard boost header file. if(Boost_${UPPERCOMPONENT}_HEADER_NAME) if(EXISTS "${Boost_INCLUDE_DIR}/${Boost_${UPPERCOMPONENT}_HEADER_NAME}") set(Boost_${UPPERCOMPONENT}_HEADER ON) else() set(Boost_${UPPERCOMPONENT}_HEADER OFF) endif() else() set(Boost_${UPPERCOMPONENT}_HEADER ON) message(WARNING "No header defined for ${COMPONENT}; skipping header check " "(note: header-only libraries have no designated component)") endif() # # Find RELEASE libraries # unset(_boost_RELEASE_NAMES) foreach(component IN LISTS _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME COMPONENT) foreach(compiler IN LISTS _boost_COMPILER) list(APPEND _boost_RELEASE_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} ) endforeach() list(APPEND _boost_RELEASE_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component} ) if(_boost_STATIC_RUNTIME_WORKAROUND) set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") foreach(compiler IN LISTS _boost_COMPILER) list(APPEND _boost_RELEASE_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) endforeach() list(APPEND _boost_RELEASE_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) endif() endforeach() if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES}) endif() _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}") # if Boost_LIBRARY_DIR_RELEASE is not defined, # but Boost_LIBRARY_DIR_DEBUG is, look there first for RELEASE libs if(NOT Boost_LIBRARY_DIR_RELEASE AND Boost_LIBRARY_DIR_DEBUG) list(INSERT _boost_LIBRARY_SEARCH_DIRS_RELEASE 0 ${Boost_LIBRARY_DIR_DEBUG}) endif() # Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing. string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_RELEASE}") if(Boost_USE_RELEASE_LIBS) _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE RELEASE NAMES ${_boost_RELEASE_NAMES} HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp} NAMES_PER_DIR DOC "${_boost_docstring_release}" ) endif() # # Find DEBUG libraries # unset(_boost_DEBUG_NAMES) foreach(component IN LISTS _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME COMPONENT) foreach(compiler IN LISTS _boost_COMPILER) list(APPEND _boost_DEBUG_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} ) endforeach() list(APPEND _boost_DEBUG_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component} ) if(_boost_STATIC_RUNTIME_WORKAROUND) set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}") foreach(compiler IN LISTS _boost_COMPILER) list(APPEND _boost_DEBUG_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) endforeach() list(APPEND _boost_DEBUG_NAMES ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG} ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) endif() endforeach() if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES}) endif() _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}") # if Boost_LIBRARY_DIR_DEBUG is not defined, # but Boost_LIBRARY_DIR_RELEASE is, look there first for DEBUG libs if(NOT Boost_LIBRARY_DIR_DEBUG AND Boost_LIBRARY_DIR_RELEASE) list(INSERT _boost_LIBRARY_SEARCH_DIRS_DEBUG 0 ${Boost_LIBRARY_DIR_RELEASE}) endif() # Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing. string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_DEBUG}") if(Boost_USE_DEBUG_LIBS) _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG DEBUG NAMES ${_boost_DEBUG_NAMES} HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp} NAMES_PER_DIR DOC "${_boost_docstring_debug}" ) endif () if(Boost_REALPATH) _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}") _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" ) endif() _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT}) # Check if component requires some compiler features _Boost_COMPILER_FEATURES(${COMPONENT} _Boost_${UPPERCOMPONENT}_COMPILER_FEATURES) endforeach() # Restore the original find library ordering if( Boost_USE_STATIC_LIBS ) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) endif() # ------------------------------------------------------------------------ # End finding boost libraries # ------------------------------------------------------------------------ set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) set(Boost_LIBRARY_DIRS) if(Boost_LIBRARY_DIR_RELEASE) list(APPEND Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR_RELEASE}) endif() if(Boost_LIBRARY_DIR_DEBUG) list(APPEND Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR_DEBUG}) endif() if(Boost_LIBRARY_DIRS) list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS) endif() # ------------------------------------------------------------------------ # Call FPHSA helper, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html # ------------------------------------------------------------------------ # Define aliases as needed by the component handler in the FPHSA helper below foreach(_comp IN LISTS Boost_FIND_COMPONENTS) string(TOUPPER ${_comp} _uppercomp) if(DEFINED Boost_${_uppercomp}_FOUND) set(Boost_${_comp}_FOUND ${Boost_${_uppercomp}_FOUND}) endif() endforeach() find_package_handle_standard_args(Boost REQUIRED_VARS Boost_INCLUDE_DIR VERSION_VAR Boost_VERSION_STRING HANDLE_COMPONENTS) if(Boost_FOUND) if( NOT Boost_LIBRARY_DIRS ) # Compatibility Code for backwards compatibility with CMake # 2.4's FindBoost module. # Look for the boost library path. # Note that the user may not have installed any libraries # so it is quite possible the Boost_LIBRARY_DIRS may not exist. set(_boost_LIB_DIR ${Boost_INCLUDE_DIR}) if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) endif() if("${_boost_LIB_DIR}" MATCHES "/include$") # Strip off the trailing "/include" in the path. get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) endif() if(EXISTS "${_boost_LIB_DIR}/lib") string(APPEND _boost_LIB_DIR /lib) elseif(EXISTS "${_boost_LIB_DIR}/stage/lib") string(APPEND _boost_LIB_DIR "/stage/lib") else() set(_boost_LIB_DIR "") endif() if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR}) endif() endif() else() # Boost headers were not found so no components were found. foreach(COMPONENT ${Boost_FIND_COMPONENTS}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) set(Boost_${UPPERCOMPONENT}_FOUND 0) endforeach() endif() # ------------------------------------------------------------------------ # Add imported targets # ------------------------------------------------------------------------ if(Boost_FOUND) # The builtin CMake package in Boost 1.70+ introduces a new name # for the header-only lib, let's provide the same UI in module mode if(NOT TARGET Boost::headers) add_library(Boost::headers INTERFACE IMPORTED) if(Boost_INCLUDE_DIRS) set_target_properties(Boost::headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}") endif() endif() # Define the old target name for header-only libraries for backwards # compat. if(NOT TARGET Boost::boost) add_library(Boost::boost INTERFACE IMPORTED) set_target_properties(Boost::boost PROPERTIES INTERFACE_LINK_LIBRARIES Boost::headers) endif() foreach(COMPONENT ${Boost_FIND_COMPONENTS}) if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) if(Boost_${UPPERCOMPONENT}_FOUND) if(Boost_USE_STATIC_LIBS) add_library(Boost::${COMPONENT} STATIC IMPORTED) else() # Even if Boost_USE_STATIC_LIBS is OFF, we might have static # libraries as a result. add_library(Boost::${COMPONENT} UNKNOWN IMPORTED) endif() if(Boost_INCLUDE_DIRS) set_target_properties(Boost::${COMPONENT} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}") endif() if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY}") set_target_properties(Boost::${COMPONENT} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LOCATION "${Boost_${UPPERCOMPONENT}_LIBRARY}") endif() if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE}") set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(Boost::${COMPONENT} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" IMPORTED_LOCATION_RELEASE "${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE}") endif() if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}") set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_target_properties(Boost::${COMPONENT} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX" IMPORTED_LOCATION_DEBUG "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}") endif() if(_Boost_${UPPERCOMPONENT}_DEPENDENCIES) unset(_Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES) foreach(dep ${_Boost_${UPPERCOMPONENT}_DEPENDENCIES}) list(APPEND _Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES Boost::${dep}) endforeach() if(COMPONENT STREQUAL "thread") list(APPEND _Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES Threads::Threads) endif() set_target_properties(Boost::${COMPONENT} PROPERTIES INTERFACE_LINK_LIBRARIES "${_Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES}") endif() if(_Boost_${UPPERCOMPONENT}_COMPILER_FEATURES) set_target_properties(Boost::${COMPONENT} PROPERTIES INTERFACE_COMPILE_FEATURES "${_Boost_${UPPERCOMPONENT}_COMPILER_FEATURES}") endif() endif() endif() endforeach() # Supply Boost_LIB_DIAGNOSTIC_DEFINITIONS as a convenience target. It # will only contain any interface definitions on WIN32, but is created # on all platforms to keep end user code free from platform dependent # code. Also provide convenience targets to disable autolinking and # enable dynamic linking. if(NOT TARGET Boost::diagnostic_definitions) add_library(Boost::diagnostic_definitions INTERFACE IMPORTED) add_library(Boost::disable_autolinking INTERFACE IMPORTED) add_library(Boost::dynamic_linking INTERFACE IMPORTED) set_target_properties(Boost::dynamic_linking PROPERTIES INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK") endif() if(WIN32) # In windows, automatic linking is performed, so you do not have # to specify the libraries. If you are linking to a dynamic # runtime, then you can choose to link to either a static or a # dynamic Boost library, the default is to do a static link. You # can alter this for a specific library "whatever" by defining # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be # linked dynamically. Alternatively you can force all Boost # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. # This feature can be disabled for Boost library "whatever" by # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining # BOOST_ALL_NO_LIB. # If you want to observe which libraries are being linked against # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking # code to emit a #pragma message each time a library is selected # for linking. set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC") set_target_properties(Boost::diagnostic_definitions PROPERTIES INTERFACE_COMPILE_DEFINITIONS "BOOST_LIB_DIAGNOSTIC") set_target_properties(Boost::disable_autolinking PROPERTIES INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB") endif() endif() # ------------------------------------------------------------------------ # Finalize # ------------------------------------------------------------------------ # Report Boost_LIBRARIES set(Boost_LIBRARIES "") foreach(_comp IN LISTS Boost_FIND_COMPONENTS) string(TOUPPER ${_comp} _uppercomp) if(Boost_${_uppercomp}_FOUND) list(APPEND Boost_LIBRARIES ${Boost_${_uppercomp}_LIBRARY}) if(_comp STREQUAL "thread") list(APPEND Boost_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) endif() endif() endforeach() # Configure display of cache entries in GUI. foreach(v BOOSTROOT BOOST_ROOT ${_Boost_VARS_INC} ${_Boost_VARS_LIB}) get_property(_type CACHE ${v} PROPERTY TYPE) if(_type) set_property(CACHE ${v} PROPERTY ADVANCED 1) if("x${_type}" STREQUAL "xUNINITIALIZED") if("x${v}" STREQUAL "xBoost_ADDITIONAL_VERSIONS") set_property(CACHE ${v} PROPERTY TYPE STRING) else() set_property(CACHE ${v} PROPERTY TYPE PATH) endif() endif() endif() endforeach() # Record last used values of input variables so we can # detect on the next run if the user changed them. foreach(v ${_Boost_VARS_INC} ${_Boost_VARS_LIB} ${_Boost_VARS_DIR} ${_Boost_VARS_NAME} ) if(DEFINED ${v}) set(_${v}_LAST "${${v}}" CACHE INTERNAL "Last used ${v} value.") else() unset(_${v}_LAST CACHE) endif() endforeach() # Maintain a persistent list of components requested anywhere since # the last flush. set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}") list(APPEND _Boost_COMPONENTS_SEARCHED ${Boost_FIND_COMPONENTS}) list(REMOVE_DUPLICATES _Boost_COMPONENTS_SEARCHED) list(SORT _Boost_COMPONENTS_SEARCHED) set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}" CACHE INTERNAL "Components requested for this build tree.") # Restore project's policies cmake_policy(POP)
CMake
hhvm/CMake/FindCClient.cmake
IF(CCLIENT_FOUND) SET(CCLIENT_FIND_QUIETLY TRUE) ENDIF(CCLIENT_FOUND) FIND_PATH(CCLIENT_INCLUDE_PATH NAMES c-client.h PATH_SUFFIXES c-client imap PATHS /usr/include /usr/local/include /usr/pkg/include ) FIND_LIBRARY(CCLIENT_LIBRARY NAMES c-client c-client4 PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib ) IF (CCLIENT_INCLUDE_PATH AND CCLIENT_LIBRARY) SET(CCLIENT_FOUND TRUE) ENDIF() MARK_AS_ADVANCED( CCLIENT_INCLUDE_PATH CCLIENT_LIBRARY )
CMake
hhvm/CMake/FindDoubleConversion.cmake
# Finds libdouble-conversion. # # This module defines: # DOUBLE_CONVERSION_INCLUDE_DIR # DOUBLE_CONVERSION_LIBRARY # find_path(DOUBLE_CONVERSION_INCLUDE_DIR NAMES double-conversion.h PATHS /usr/include/double-conversion /usr/local/include/double-conversion) find_library(DOUBLE_CONVERSION_LIBRARY NAMES double-conversion) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( DOUBLE_CONVERSION DEFAULT_MSG DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR) if (NOT DOUBLE_CONVERSION_FOUND) message(STATUS "Using third-party bundled double-conversion") else() message(STATUS "Found double-conversion: ${DOUBLE_CONVERSION_LIBRARY}") endif (NOT DOUBLE_CONVERSION_FOUND) mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY)
CMake
hhvm/CMake/FindEditline.cmake
if (EDITLINE_LIBRARIES AND EDITLINE_INCLUDE_DIRS) set (Editline_FIND_QUIETLY TRUE) endif (EDITLINE_LIBRARIES AND EDITLINE_INCLUDE_DIRS) find_path(EDITLINE_INCLUDE_DIRS NAMES editline/readline.h) find_library(EDITLINE_LIBRARIES NAMES edit) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Editline DEFAULT_MSG EDITLINE_LIBRARIES EDITLINE_INCLUDE_DIRS) mark_as_advanced(EDITLINE_INCLUDE_DIRS EDITLINE_LIBRARIES)
CMake
hhvm/CMake/FindFastLZ.cmake
if (FASTLZ_LIBRARY AND FASTLZ_INCLUDE_DIR) set (FASTLZ_FIND_QUIETLY TRUE) endif (FASTLZ_LIBRARY AND FASTLZ_INCLUDE_DIR) find_path(FASTLZ_INCLUDE_DIR NAMES fastlz.h) find_library(FASTLZ_LIBRARY NAMES fastlz) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(FastLZ DEFAULT_MSG FASTLZ_LIBRARY FASTLZ_INCLUDE_DIR) if (NOT FASTLZ_FOUND) message(STATUS "Using third-party bundled fastlz") else() message(STATUS "Found fastlz: ${FASTLZ_LIBRARY}") endif (NOT FASTLZ_FOUND) mark_as_advanced(FASTLZ_INCLUDE_DIR FASTLZ_LIBRARY)
CMake
hhvm/CMake/FindFreetype.cmake
find_package(PkgConfig) pkg_check_modules(PC_FREETYPE QUIET freetype2) find_path(FREETYPE_INCLUDE_DIR_FT2BUILD NAMES ft2build.h HINTS ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS} PATH_SUFFIXES freetype2) if(FREETYPE_INCLUDE_DIR_FT2BUILD AND NOT EXISTS "${FREETYPE_INCLUDE_DIR_FT2BUILD}/freetype2/freetype/config/ftheader.h") add_definitions(-DHAVE_FT2BUILD) set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR_FT2BUILD}) else() find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/config/ftheader.h freetype2/config/ftheader.h HINTS ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS} PATH_SUFFIXES freetype2) if(FREETYPE_INCLUDE_DIRS AND NOT EXISTS "${FREETYPE_INCLUDE_DIRS}/freetype/config/ftheader.h") add_definitions(-DFREETYPE_PATH_FREETYPE2) endif() endif() find_library(FREETYPE_LIBRARIES NAMES freetype) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype DEFAULT_MSG FREETYPE_LIBRARIES FREETYPE_INCLUDE_DIRS) mark_as_advanced(FREETYPE_INCLUDE_DIRS FREETYPE_LIBRARIES)
CMake
hhvm/CMake/Findfribidi.cmake
find_package(PkgConfig) pkg_check_modules(FRIBIDI QUIET fribidi) find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi/fribidi.h) find_library(FRIBIDI_LIBRARY NAMES fribidi) if (NOT FRIBIDI_FOUND) message(STATUS "GNU FriBidi not found") else() message(STATUS "Found GNU FriBidi: ${FRIBIDI_LIBRARY}") endif (NOT FRIBIDI_FOUND)
CMake
hhvm/CMake/FindGLIB.cmake
find_path(GLIB_INCLUDE_DIR NAMES "glib.h" PATHS "/usr/include" "/usr/local/include" PATH_SUFFIXES "glib-2.0") find_path(GLIB_CONFIG_INCLUDE_DIR NAMES "glibconfig.h" PATHS "/usr/lib64" "/usr/lib" "/usr/local/lib64" "/usr/local/lib" "/usr/lib/x86_64-linux-gnu" "/usr/lib/aarch64-linux-gnu" PATH_SUFFIXES "glib-2.0/include") include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB DEFAULT_MSG GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR) mark_as_advanced(GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR)
CMake
hhvm/CMake/FindGold.cmake
set(GOLD_FOUND FALSE) mark_as_advanced(GOLD_FOUND) if(LINUX) find_program(GOLD_EXECUTABLE NAMES gold ld.gold DOC "path to gold") mark_as_advanced(GOLD_EXECUTABLE) if(GOLD_EXECUTABLE) set(GOLD_FOUND TRUE) execute_process(COMMAND ${GOLD_EXECUTABLE} --version OUTPUT_VARIABLE GOLD_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS "Found gold: ${GOLD_EXECUTABLE}") else() message(STATUS "Could not find gold linker. Using the default") endif() endif()
CMake
hhvm/CMake/FindICU.cmake
# Finds the International Components for Unicode (ICU) Library # # ICU_FOUND - True if ICU found. # ICU_I18N_FOUND - True if ICU's internationalization library found. # ICU_INCLUDE_DIRS - Directory to include to get ICU headers # Note: always include ICU headers as, e.g., # unicode/utypes.h # ICU_LIBRARIES - Libraries to link against for the common ICU # ICU_I18N_LIBRARIES - Libraries to link against for ICU internationalization # (note: in addition to ICU_LIBRARIES) # Look for the header file. find_path( ICU_INCLUDE_DIR NAMES unicode/utypes.h DOC "Include directory for the ICU library") mark_as_advanced(ICU_INCLUDE_DIR) # Look for the library. find_library( ICU_LIBRARY NAMES icuuc cygicuuc cygicuuc32 DOC "Libraries to link against for the common parts of ICU") mark_as_advanced(ICU_LIBRARY) # Copy the results to the output variables. if(ICU_INCLUDE_DIR AND ICU_LIBRARY) set(ICU_FOUND 1) set(ICU_LIBRARIES ${ICU_LIBRARY}) set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR}) set(ICU_VERSION 0) set(ICU_MAJOR_VERSION 0) set(ICU_MINOR_VERSION 0) if (EXISTS "${ICU_INCLUDE_DIR}/unicode/uvernum.h") FILE(READ "${ICU_INCLUDE_DIR}/unicode/uvernum.h" _ICU_VERSION_CONTENTS) else() FILE(READ "${ICU_INCLUDE_DIR}/unicode/uversion.h" _ICU_VERSION_CONTENTS) endif() STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MAJOR_NUM ([0-9]+).*" "\\1" ICU_MAJOR_VERSION "${_ICU_VERSION_CONTENTS}") STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MINOR_NUM ([0-9]+).*" "\\1" ICU_MINOR_VERSION "${_ICU_VERSION_CONTENTS}") set(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}") # Look for the ICU internationalization libraries find_library( ICU_I18N_LIBRARY NAMES icuin icui18n cygicuin cygicuin32 DOC "Libraries to link against for ICU internationalization") mark_as_advanced(ICU_I18N_LIBRARY) if (ICU_I18N_LIBRARY) set(ICU_I18N_FOUND 1) set(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY}) else (ICU_I18N_LIBRARY) set(ICU_I18N_FOUND 0) set(ICU_I18N_LIBRARIES) endif (ICU_I18N_LIBRARY) # Look for the ICU data libraries find_library( ICU_DATA_LIBRARY NAMES icudt icudata cygicudata cygicudata32 DOC "Libraries to link against for ICU data") mark_as_advanced(ICU_DATA_LIBRARY) if (ICU_DATA_LIBRARY) set(ICU_DATA_FOUND 1) set(ICU_DATA_LIBRARIES ${ICU_DATA_LIBRARY}) else (ICU_DATA_LIBRARY) set(ICU_DATA_FOUND 0) set(ICU_DATA_LIBRARIES) endif (ICU_DATA_LIBRARY) else(ICU_INCLUDE_DIR AND ICU_LIBRARY) set(ICU_FOUND 0) set(ICU_I18N_FOUND 0) set(ICU_LIBRARIES) set(ICU_I18N_LIBRARIES) set(ICU_INCLUDE_DIRS) set(ICU_VERSION) set(ICU_MAJOR_VERSION) set(ICU_MINOR_VERSION) endif(ICU_INCLUDE_DIR AND ICU_LIBRARY) IF(ICU_FOUND) IF( NOT ICU_FIND_QUIETLY ) MESSAGE( STATUS "Found ICU header files in ${ICU_INCLUDE_DIRS}") MESSAGE( STATUS "Found ICU libraries: ${ICU_LIBRARIES}") ENDIF( NOT ICU_FIND_QUIETLY ) ELSE(ICU_FOUND) IF(ICU_FIND_REQUIRED) MESSAGE( FATAL_ERROR "Could not find ICU" ) ELSE(ICU_FIND_REQUIRED) MESSAGE( STATUS "Optional package ICU was not found" ) ENDIF(ICU_FIND_REQUIRED) ENDIF(ICU_FOUND)
CMake
hhvm/CMake/FindLdap.cmake
# - Try to find the LDAP client libraries # Once done this will define # # LDAP_FOUND - system has libldap # LDAP_INCLUDE_DIR - the ldap include directory # LDAP_LIBRARIES - libldap + liblber (if found) library # LBER_LIBRARIES - liblber library if(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES) # Already in cache, be silent set(Ldap_FIND_QUIETLY TRUE) endif(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES) if(UNIX) FIND_PATH(LDAP_INCLUDE_DIR ldap.h) FIND_LIBRARY(LDAP_LIBRARIES NAMES ldap) FIND_LIBRARY(LBER_LIBRARIES NAMES lber) else(UNIX) FIND_PATH(LDAP_INCLUDE_DIR winldap.h) FIND_LIBRARY(LDAP_LIBRARIES NAMES wldap32) endif(UNIX) if(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES) set(LDAP_FOUND TRUE) if(LBER_LIBRARIES) set(LDAP_LIBRARIES ${LDAP_LIBRARIES} ${LBER_LIBRARIES}) endif(LBER_LIBRARIES) endif(LDAP_INCLUDE_DIR AND LDAP_LIBRARIES) if(LDAP_FOUND) if(NOT Ldap_FIND_QUIETLY) message(STATUS "Found ldap: ${LDAP_LIBRARIES}") endif(NOT Ldap_FIND_QUIETLY) else(LDAP_FOUND) if (Ldap_FIND_REQUIRED) message(FATAL_ERROR "Could NOT find ldap") endif (Ldap_FIND_REQUIRED) endif(LDAP_FOUND) MARK_AS_ADVANCED(LDAP_INCLUDE_DIR LDAP_LIBRARIES LBER_LIBRARIES)
CMake
hhvm/CMake/FindLibAfdt.cmake
# - Find LibAfdt (a cross platform RPC lib/tool) # This module defines # LibAfdt_INCLUDE_DIR, where to find LibAfdt headers # LibAfdt_LIBS, LibAfdt libraries # LibAfdt_FOUND, If false, do not try to use LibAfdt find_path(LibAfdt_INCLUDE_DIR afdt.h PATHS /usr/local/include /opt/local/include ) set(LibAfdt_LIB_PATHS /usr/local/lib /opt/local/lib) find_library(LibAfdt_LIB NAMES afdt PATHS ${LibAfdt_LIB_PATHS}) if (LibAfdt_LIB AND LibAfdt_INCLUDE_DIR) set(LibAfdt_FOUND TRUE) set(LibAfdt_LIBS ${LibAfdt_LIB}) else () set(LibAfdt_FOUND FALSE) endif () if (LibAfdt_FOUND) if (NOT LibAfdt_FIND_QUIETLY) message(STATUS "Found libafdt: ${LibAfdt_LIBS}") endif () else () if (LibAfdt_FIND_REQUIRED) message(FATAL_ERROR "Could NOT find libafdt.") endif () message(STATUS "libafdt NOT found.") endif () mark_as_advanced( LibAfdt_LIB LibAfdt_INCLUDE_DIR )
CMake
hhvm/CMake/FindLibCh.cmake
# - Find LibCh (a cross platform RPC lib/tool) # This module defines # LibCh_INCLUDE_DIR, where to find LibCh headers # LibCh_LIBS, LibCh libraries # LibCh_FOUND, If false, do not try to use LibCh find_path(LibCh_INCLUDE_DIR ch/continuum.h PATHS /usr/local/include /opt/local/include ) set(LibCh_LIB_PATHS /usr/local/lib /opt/local/lib) find_library(LibCh_LIB NAMES ch PATHS ${LibCh_LIB_PATHS}) if (LibCh_LIB AND LibCh_INCLUDE_DIR) set(LibCh_FOUND TRUE) set(LibCh_LIBS ${LibCh_LIB}) else () set(LibCh_FOUND FALSE) endif () if (LibCh_FOUND) if (NOT LibCh_FIND_QUIETLY) message(STATUS "Found libCh: ${LibCh_LIBS}") endif () else () if (LibCh_FIND_REQUIRED) message(FATAL_ERROR "Could NOT find libch library.") endif () message(STATUS "libCh NOT found.") endif () mark_as_advanced( LibCh_LIB LibCh_INCLUDE_DIR )
CMake
hhvm/CMake/FindLibDL.cmake
# - Try to find libdl # Once done this will define # # LIBDL_FOUND - system has libdl # LIBDL_INCLUDE_DIRS - the libdl include directory # LIBDL_LIBRARIES - Link these to use libdl # LIBDL_NEEDS_UNDERSCORE - If extern "C" symbols are prefixed (BSD/Apple) # find_path (LIBDL_INCLUDE_DIRS NAMES dlfcn.h) find_library (LIBDL_LIBRARIES NAMES dl) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDL DEFAULT_MSG LIBDL_LIBRARIES LIBDL_INCLUDE_DIRS) SET(CMAKE_REQUIRED_LIBRARIES dl) INCLUDE(CheckCSourceRuns) CHECK_C_SOURCE_RUNS("#include <dlfcn.h> #include <stdlib.h> void testfunc() {} int main() { testfunc(); if (dlsym(0, \"_testfunc\") != (void*)0) { return EXIT_SUCCESS; } else { return EXIT_FAILURE; } }" LIBDL_NEEDS_UNDERSCORE) mark_as_advanced(LIBDL_INCLUDE_DIRS LIBDL_LIBRARIES LIBDL_NEEDS_UNDERSCORE)
CMake
hhvm/CMake/FindLibDwarf.cmake
# Copyright (c) 2004-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the MIT license found in the # LICENSE file in the hphp/hsl/ subdirectory of this source tree. # - Try to find libdwarf # Once done this will define # # LIBDWARF_FOUND - system has libdwarf # LIBDWARF_INCLUDE_DIRS - the libdwarf include directory # LIBDWARF_LIBRARIES - Link these to use libdwarf # LIBDWARF_DEFINITIONS - Compiler switches required for using libdwarf # # Locate libelf library at first if (NOT LIBELF_FOUND) find_package (LibElf) endif (NOT LIBELF_FOUND) if (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS) set (LibDwarf_FIND_QUIETLY TRUE) endif (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS) find_package(PkgConfig) pkg_check_modules(PkgConfig_LibDwarf QUIET libdwarf) find_path (DWARF_INCLUDE_DIR NAMES libdwarf.h dwarf.h PATHS ${PkgConfig_LibDwarf_INCLUDE_DIRS} /usr/include /usr/include/libdwarf /usr/local/include /usr/local/include/libdwarf /opt/local/include /sw/include ENV CPATH) # PATH and INCLUDE will also work if (DWARF_INCLUDE_DIR) set (LIBDWARF_INCLUDE_DIRS ${DWARF_INCLUDE_DIR}) endif () find_library (LIBDWARF_LIBRARIES NAMES dwarf libdwarf PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib ${PkgConfig_LibDwarf_LIBRARY_DIRS} ENV LIBRARY_PATH # PATH and LIB will also work ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBDWARF_FOUND to TRUE # if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDwarf DEFAULT_MSG LIBELF_FOUND LIBDWARF_LIBRARIES LIBDWARF_INCLUDE_DIRS) if (LIBDWARF_LIBRARIES AND LIBDWARF_INCLUDE_DIRS) set(CMAKE_REQUIRED_INCLUDES ${LIBDWARF_INCLUDE_DIRS}) set(CMAKE_REQUIRED_LIBRARIES ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES}) # libdwarf makes breaking changes occasionally and doesn't provide an easy # way to test for them. The following checks should detect the changes and # pass that information on accordingly. INCLUDE(CheckCXXSourceCompiles) INCLUDE(CheckFunctionExists) MACRO(CHECK_LIBDWARF_INIT init params var) # Check for the existence of this particular init function. unset(INIT_EXISTS CACHE) CHECK_FUNCTION_EXISTS(${init} INIT_EXISTS) if (INIT_EXISTS) set(LIBDWARF_USE_INIT_C ${var}) # Check to see if we can use a const name. unset(DW_CONST CACHE) if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # -std=c++11 is already set in HPHPCompiler.cmake, don't # add -std=c++0x on top of that or clang will give errors set(CMAKE_REQUIRED_FLAGS "-std=c++0x") endif() CHECK_CXX_SOURCE_COMPILES(" #include <libdwarf.h> #include <cstddef> int dwarfCallback(const char * a, int b, Dwarf_Unsigned c, Dwarf_Unsigned d, Dwarf_Unsigned e, Dwarf_Unsigned f, Dwarf_Unsigned * g, Dwarf_Ptr h, int * i) {} int main() { ${init}(${params}); return 0; }" DW_CONST) if (DW_CONST) set(LIBDWARF_CONST_NAME 1) else() set(LIBDWARF_CONST_NAME 0) endif() endif() ENDMACRO(CHECK_LIBDWARF_INIT) # Order is important, last one is used. CHECK_LIBDWARF_INIT("dwarf_producer_init" "0, dwarfCallback, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr" 0) CHECK_LIBDWARF_INIT("dwarf_producer_init_c" "0, dwarfCallback, nullptr, nullptr, nullptr, nullptr" 1) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_LIBRARIES) endif() if(LIBDWARF_CONST_NAME) message(STATUS "libdwarf uses const char* type") else() message(STATUS "libdwarf uses char* type") endif() if(LIBDWARF_USE_INIT_C) message(STATUS "libdwarf has dwarf_producer_init_c") else() message(STATUS "libdwarf does not have dwarf_producer_init_c, using dwarf_producer_init") endif() mark_as_advanced(LIBDW_INCLUDE_DIR DWARF_INCLUDE_DIR) mark_as_advanced(LIBDWARF_INCLUDE_DIRS LIBDWARF_LIBRARIES) mark_as_advanced(LIBDWARF_CONST_NAME LIBDWARF_USE_INIT_C)
CMake
hhvm/CMake/FindLibElf.cmake
# - Try to find libelf # Once done this will define # # LIBELF_FOUND - system has libelf # LIBELF_INCLUDE_DIRS - the libelf include directory # LIBELF_LIBRARIES - Link these to use libelf # LIBELF_DEFINITIONS - Compiler switches required for using libelf # # Copyright (c) 2008 Bernhard Walle <[email protected]> # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # if (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS) set (LibElf_FIND_QUIETLY TRUE) endif (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS) find_package(PkgConfig) pkg_check_modules(PkgConfig_LibElf QUIET libelf) find_path (LIBELF_INCLUDE_DIRS NAMES libelf.h PATHS ${PkgConfig_LibElf_INCLUDE_DIRS} /usr/include /usr/include/libelf /usr/local/include /usr/local/include/libelf /opt/local/include /opt/local/include/libelf /sw/include /sw/include/libelf ENV CPATH) find_library (LIBELF_LIBRARIES NAMES elf PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib ${PkgConfig_LibElf_LIBRARY_DIRS} ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBELF_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibElf DEFAULT_MSG LIBELF_LIBRARIES LIBELF_INCLUDE_DIRS) SET(CMAKE_REQUIRED_LIBRARIES elf) INCLUDE(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES("#include <libelf.h> int main() { Elf *e = (Elf*)0; size_t sz; elf_getshdrstrndx(e, &sz); return 0; }" ELF_GETSHDRSTRNDX) SET(CMAKE_REQUIRED_LIBRARIES) mark_as_advanced(LIBELF_INCLUDE_DIRS LIBELF_LIBRARIES ELF_GETSHDRSTRNDX)
CMake
hhvm/CMake/FindLibEvent.cmake
# - Find LibEvent (a cross event library) # This module defines # LIBEVENT_INCLUDE_DIR, where to find LibEvent headers # LIBEVENT_LIB, LibEvent libraries # LibEvent_FOUND, If false, do not try to use libevent set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}") foreach(prefix ${LibEvent_EXTRA_PREFIXES}) list(APPEND LibEvent_INCLUDE_PATHS "${prefix}/include") list(APPEND LibEvent_LIB_PATHS "${prefix}/lib") endforeach() find_path(LIBEVENT_INCLUDE_DIR event.h PATHS ${LibEvent_INCLUDE_PATHS}) find_library(LIBEVENT_LIB NAMES event PATHS ${LibEvent_LIB_PATHS}) find_library(LIBEVENT_PTHREAD_LIB NAMES event_pthreads PATHS ${LibEvent_LIB_PATHS}) if (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR AND LIBEVENT_PTHREAD_LIB) set(LibEvent_FOUND TRUE) set(LIBEVENT_LIB ${LIBEVENT_LIB} ${LIBEVENT_PTHREAD_LIB}) else () set(LibEvent_FOUND FALSE) endif () if (LibEvent_FOUND) if (NOT LibEvent_FIND_QUIETLY) message(STATUS "Found libevent: ${LIBEVENT_LIB}") endif () else () if (LibEvent_FIND_REQUIRED) message(FATAL_ERROR "Could NOT find libevent and libevent_pthread.") endif () message(STATUS "libevent and libevent_pthread NOT found.") endif () mark_as_advanced( LIBEVENT_LIB LIBEVENT_INCLUDE_DIR )
CMake
hhvm/CMake/FindLibGmp.cmake
find_path(GMP_INCLUDE_DIR NAMES gmp.h) find_library(GMP_LIBRARY NAMES gmp) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( GMP DEFAULT_MSG GMP_LIBRARY GMP_INCLUDE_DIR) mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARY)
CMake
hhvm/CMake/FindLibiberty.cmake
# Copyright (c) Facebook, Inc. and its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. find_path(LIBIBERTY_INCLUDE_DIR NAMES libiberty.h PATH_SUFFIXES libiberty) mark_as_advanced(LIBIBERTY_INCLUDE_DIR) find_library(LIBIBERTY_LIBRARY NAMES iberty) mark_as_advanced(LIBIBERTY_LIBRARY) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( LIBIBERTY REQUIRED_VARS LIBIBERTY_LIBRARY LIBIBERTY_INCLUDE_DIR) if(LIBIBERTY_FOUND) set(LIBIBERTY_LIBRARIES ${LIBIBERTY_LIBRARY}) set(LIBIBERTY_INCLUDE_DIRS ${LIBIBERTY_INCLUDE_DIR}) endif()
CMake
hhvm/CMake/FindLibiconv.cmake
# # $Id$ # # - Find libiconv # Find libiconv # # LIBICONV_INCLUDE_DIR - where to find iconv.h, etc. # LIBICONV_LIBRARY - List of libraries when using libiconv. # LIBICONV_FOUND - True if libiconv found. IF (LIBICONV_INCLUDE_DIR) # Already in cache, be silent SET(LIBICONV_FIND_QUIETLY TRUE) ENDIF () FIND_PATH(LIBICONV_INCLUDE_DIR iconv.h) FIND_LIBRARY(LIBICONV_LIBRARY iconv) # handle the QUIETLY and REQUIRED arguments and set Libmemcached_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBICONV DEFAULT_MSG LIBICONV_LIBRARY LIBICONV_INCLUDE_DIR) SET(LIBICONV_OLD_CMAKE_REQUIRED_LIBRARIES) SET(CMAKE_REQUIRED_LIBRARIES iconv) INCLUDE(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES("#include <string.h> #include <iconv.h> int main() { iconv_t cd = 0; const char *in_p = \"testing\"; size_t in_left = strlen(in_p); char out_p[20]; size_t out_left = sizeof(out_p); iconv(cd, (const char **)&in_p, &in_left, (char **)&out_p, &out_left); return 0; }" LIBICONV_CONST) SET(CMAKE_REQUIRED_LIBRARIES LIBICONV_OLD_CMAKE_REQUIRED_LIBRARIES) MARK_AS_ADVANCED(LIBICONV_LIBRARY LIBICONV_INCLUDE_DIR LIBICONV_CONST)
CMake
hhvm/CMake/FindLibinotify.cmake
# # $Id$ # # - Find libinotify # Find libinotify # # LIBINOTIFY_INCLUDE_DIR - where to find sys/inotify.h # LIBINOTIFY_LIBRARY - List of libraries when using libinotify # LIBINOTIFY_FOUND - True if libinotify found. if(LIBINOTIFY_INCLUDE_DIR) # Already in cache, be silent SET(LIBINOTIFY_FIND_QUIETLY TRUE) endif() FIND_PATH(LIBINOTIFY_INCLUDE_DIR sys/inotify.h) FIND_LIBRARY(LIBINOTIFY_LIBRARY inotify) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBINOTIFY DEFAULT_MSG LIBINOTIFY_LIBRARY LIBINOTIFY_INCLUDE_DIR) MARK_AS_ADVANCED(LIBINOTIFY_LIBRARY LIBINOTIFY_INCLUDE_DIR)
CMake
hhvm/CMake/FindLibIntl.cmake
#.rst: # FindIntl # -------- # # Find the Gettext libintl headers and libraries. # # This module reports information about the Gettext libintl # installation in several variables. General variables:: # # Intl_FOUND - true if the libintl headers and libraries were found # Intl_INCLUDE_DIRS - the directory containing the libintl headers # Intl_LIBRARIES - libintl libraries to be linked # # The following cache variables may also be set:: # # Intl_INCLUDE_DIR - the directory containing the libintl headers # Intl_LIBRARY - the libintl library (if any) # # .. note:: # On some platforms, such as Linux with GNU libc, the gettext # functions are present in the C standard library and libintl # is not required. ``Intl_LIBRARIES`` will be empty in this # case. # # .. note:: # If you wish to use the Gettext tools (``msgmerge``, # ``msgfmt``, etc.), use :module:`FindGettext`. # Written by Roger Leigh <[email protected]> #============================================================================= # CMake - Cross Platform Makefile Generator # Copyright 2000-2015 Kitware, Inc. # Copyright 2000-2011 Insight Software Consortium # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # * Neither the names of Kitware, Inc., the Insight Software Consortium, # nor the names of their contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # ------------------------------------------------------------------------------ # # The above copyright and license notice applies to distributions of # CMake in source and binary form. Some source files contain additional # notices of original copyright by their contributors; see each source # for details. Third-party software packages supplied with CMake under # compatible licenses provide their own copyright notices documented in # corresponding subdirectories. # # ------------------------------------------------------------------------------ # # CMake was initially developed by Kitware with the following sponsorship: # # * National Library of Medicine at the National Institutes of Health # as part of the Insight Segmentation and Registration Toolkit (ITK). # # * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel # Visualization Initiative. # # * National Alliance for Medical Image Computing (NAMIC) is funded by the # National Institutes of Health through the NIH Roadmap for Medical Research, # Grant U54 EB005149. # # * Kitware, Inc. # #============================================================================= # Find include directory find_path(LIBINTL_INCLUDE_DIR NAMES "libintl.h" DOC "libintl include directory") mark_as_advanced(LIBINTL_INCLUDE_DIR) # Find all Intl libraries find_library(LIBINTL_LIBRARY "intl" DOC "libintl libraries (if not in the C library)") mark_as_advanced(LIBINTL_LIBRARY) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBINTL REQUIRED_VARS LIBINTL_INCLUDE_DIR FAIL_MESSAGE "Failed to find Gettext libintl") if(LIBINTL_FOUND) set(LIBINTL_INCLUDE_DIRS "${LIBINTL_INCLUDE_DIR}") if(LIBINTL_LIBRARY) set(LIBINTL_LIBRARIES "${LIBINTL_LIBRARY}") else() unset(LIBINTL_LIBRARIES) endif() endif()
CMake
hhvm/CMake/FindLibJpeg.cmake
if (LIBJPEG_LIBRARIES AND LIBJPEG_INCLUDE_DIRS) set (LibJpeg_FIND_QUIETLY TRUE) endif (LIBJPEG_LIBRARIES AND LIBJPEG_INCLUDE_DIRS) find_path(LIBJPEG_INCLUDE_DIRS NAMES jpeglib.h) find_library(LIBJPEG_LIBRARIES NAMES jpeg) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibJpeg DEFAULT_MSG LIBJPEG_LIBRARIES LIBJPEG_INCLUDE_DIRS) mark_as_advanced(LIBJPEG_INCLUDE_DIRS LIBJPEG_LIBRARIES)
CMake
hhvm/CMake/FindLibMagickWand.cmake
# - Try to find libmagickwand # Once done this will define # # LIBMAGICKWAND_FOUND - system has libmagickwand # LIBMAGICKWAND_INCLUDE_DIRS - the libmagickwand include directory # LIBMAGICKWAND_LIBRARIES - Link these to use libmagickwand # LIBMAGICKWAND_DEFINITIONS - Compiler switches required for using libmagickwand # # Copyright (c) 2008 Bernhard Walle <[email protected]> # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # if (LIBMAGICKWAND_LIBRARIES AND LIBMAGICKWAND_INCLUDE_DIRS) set (LibMagicWand_FIND_QUIETLY TRUE) endif (LIBMAGICKWAND_LIBRARIES AND LIBMAGICKWAND_INCLUDE_DIRS) set (ImageMagick_FIND_QUIETLY TRUE) find_package(ImageMagick COMPONENTS MagickWand MagickCore) if (ImageMagick_MagickWand_FOUND) set (LIBMAGICKWAND_INCLUDE_DIRS ${ImageMagick_MagickWand_INCLUDE_DIR} ${ImageMagick_MagickWand_ARCH_INCLUDE_DIR} CACHE STRING "") set (LIBMAGICKWAND_LIBRARIES ${ImageMagick_MagickWand_LIBRARY} CACHE STRING "") endif () if (ImageMagick_MagickCore_FOUND) set (LIBMAGICKCORE_INCLUDE_DIRS ${ImageMagick_MagickCore_INCLUDE_DIR} ${ImageMagick_MagickCore_ARCH_INCLUDE_DIR} CACHE STRING "") set (LIBMAGICKCORE_LIBRARIES ${ImageMagick_MagickCore_LIBRARY} CACHE STRING "") endif () find_path (LIBMAGICKWAND_INCLUDE_DIRS NAMES wand/MagickWand.h PATH_SUFFIXES ImageMagick-6 PATHS /usr/include/ImageMagick /usr/local/include/ImageMagick ENV CPATH) find_library (LIBMAGICKWAND_LIBRARIES NAMES MagickWand MagickWand-6.Q16 PATHS /usr/lib /usr/local/lib ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) find_library (LIBMAGICKCORE_LIBRARIES NAMES MagickCore MagickCore-6.Q16 PATHS /usr/lib /usr/local/lib ENV LIBRARY_PATH ENV LD_LIBRARY_PATH) include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBMAGICKWAND_FOUND to TRUE if all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibMagicWand DEFAULT_MSG LIBMAGICKWAND_LIBRARIES LIBMAGICKCORE_LIBRARIES LIBMAGICKWAND_INCLUDE_DIRS) mark_as_advanced(LIBMAGICKWAND_INCLUDE_DIRS LIBMAGICKWAND_LIBRARIES LIBMAGICKCORE_LIBRARIES)
CMake
hhvm/CMake/FindLibmemcached.cmake
# Find libmemcached # # LIBMEMCACHED_INCLUDE_DIR - where to find libmemcached/memcached.h, etc. # LIBMEMCACHED_LIBRARY - List of libraries when using libmemcached. # LIBMEMCACHED_FOUND - True if libmemcached found. find_package(PkgConfig) pkg_check_modules(LIBMEMCACHED QUIET libmemcached) IF (LIBMEMCACHED_INCLUDE_DIR) # Already in cache, be silent SET(LIBMEMCACHED_FIND_QUIETLY TRUE) ENDIF () FIND_PATH(LIBMEMCACHED_INCLUDE_DIR libmemcached/memcached.h) FIND_LIBRARY(LIBMEMCACHED_LIBRARY memcached) # handle the QUIETLY and REQUIRED arguments and set Libmemcached_FOUND to TRUE # if all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBMEMCACHED DEFAULT_MSG LIBMEMCACHED_LIBRARY LIBMEMCACHED_INCLUDE_DIR) SET(LIBMEMCACHED_VERSION 0) IF(LIBMEMCACHED_FOUND) if (EXISTS "${LIBMEMCACHED_INCLUDE_DIR}/libmemcached/configure.h") FILE(READ "${LIBMEMCACHED_INCLUDE_DIR}/libmemcached/configure.h" _MEMCACHE_VERSION_CONTENTS) endif() if (EXISTS "${LIBMEMCACHED_INCLUDE_DIR}/libmemcached-1.0/configure.h") FILE(READ "${LIBMEMCACHED_INCLUDE_DIR}/libmemcached-1.0/configure.h" _MEMCACHE_VERSION_CONTENTS) endif() if (_MEMCACHE_VERSION_CONTENTS) STRING(REGEX REPLACE ".*#define LIBMEMCACHED_VERSION_STRING \"([0-9.]+)\".*" "\\1" LIBMEMCACHED_VERSION "${_MEMCACHE_VERSION_CONTENTS}") endif() ENDIF() SET(LIBMEMCACHED_VERSION ${LIBMEMCACHED_VERSION} CACHE STRING "Version number of libmemcached") MARK_AS_ADVANCED(LIBMEMCACHED_LIBRARY LIBMEMCACHED_INCLUDE_DIR LIBMEMCACHED_VERSION)
CMake
hhvm/CMake/FindLibNuma.cmake
if (LIBNUMA_LIBRARIES AND LIBNUMA_INCLUDE_DIRS) set (LibNuma_FIND_QUIETLY TRUE) endif (LIBNUMA_LIBRARIES AND LIBNUMA_INCLUDE_DIRS) find_path(LIBNUMA_INCLUDE_DIRS NAMES numa.h) find_library(LIBNUMA_LIBRARIES NAMES numa) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibNuma DEFAULT_MSG LIBNUMA_LIBRARIES LIBNUMA_INCLUDE_DIRS) mark_as_advanced(LIBNUMA_INCLUDE_DIRS LIBNUMA_LIBRARIES)
CMake
hhvm/CMake/FindLibpam.cmake
IF(PAM_FOUND) SET(PAM_FIND_QUIETLY TRUE) ENDIF(PAM_FOUND) FIND_PATH(PAM_INCLUDE_PATH NAMES pam_modules.h PATH_SUFFIXES security PATHS /usr/include /usr/local/include /usr/pkg/include ) FIND_LIBRARY(PAM_LIBRARY NAMES pam PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib ) IF (PAM_INCLUDE_PATH AND PAM_LIBRARY) SET(PAM_FOUND TRUE) ENDIF() MARK_AS_ADVANCED( PAM_INCLUDE_PATH PAM_LIBRARY )
CMake
hhvm/CMake/FindLibPng.cmake
if (LIBPNG_LIBRARIES AND LIBPNG_INCLUDE_DIRS) set (LibPng_FIND_QUIETLY TRUE) endif (LIBPNG_LIBRARIES AND LIBPNG_INCLUDE_DIRS) find_path(LIBPNG_INCLUDE_DIRS NAMES png.h) find_library(LIBPNG_LIBRARIES NAMES png) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibPng DEFAULT_MSG LIBPNG_LIBRARIES LIBPNG_INCLUDE_DIRS) mark_as_advanced(LIBPNG_INCLUDE_DIRS LIBPNG_LIBRARIES)
CMake
hhvm/CMake/FindLibSodium.cmake
# Finds sodium C client library # # This module defines: # LIBSODIUM_INCLUDE_DIRS # LIBSODIUM_LIBRARIES # find_package(PkgConfig) if (LibSodium_FIND_VERSION) pkg_check_modules(LIBSODIUM libsodium>=${LibSodium_FIND_VERSION}) else() pkg_check_modules(LIBSODIUM libsodium) endif() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( libsodium DEFAULT_MSG LIBSODIUM_LIBRARIES LIBSODIUM_INCLUDEDIR) set(LIBSODIUM_INCLUDE_DIRS "${LIBSODIUM_INCLUDEDIR}") if (LIBSODIUM_INCLUDEDIR) add_definitions(-DHAVE_LIBSODIUM) endif()
CMake
hhvm/CMake/FindLibSQLite.cmake
# Finds libsqlite3. # # This module defines: # LIBSQLITE3_INCLUDE_DIR # LIBSQLITE3_LIBRARY # find_package(PkgConfig) pkg_check_modules(PC_SQLITE3 QUIET sqlite3) if (PC_SQLITE3_FOUND) find_path(LIBSQLITE3_INCLUDE_DIR NAMES sqlite3.h HINTS ${PC_SQLITE3_INCLUDE_DIRS}) find_library(LIBSQLITE3_LIBRARY NAMES sqlite3) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSQLITE3 DEFAULT_MSG LIBSQLITE3_LIBRARY LIBSQLITE3_INCLUDE_DIR) message(STATUS "Found libsqlite3: ${LIBSQLITE3_LIBRARY}") else() message(STATUS "Using third-party bundled libsqlite3") endif (PC_SQLITE3_FOUND)
CMake
hhvm/CMake/FindLibVpx.cmake
if (LIBVPX_LIBRARIES AND LIBVPX_INCLUDE_DIRS) set (LibVpx_FIND_QUIETLY TRUE) endif (LIBVPX_LIBRARIES AND LIBVPX_INCLUDE_DIRS) find_path(LIBVPX_INCLUDE_DIRS vp8cx.h /usr/local/include/vpx /usr/include/vpx) find_library(LIBVPX_LIBRARIES NAMES vpx) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibVPX DEFAULT_MSG LIBVPX_LIBRARIES LIBVPX_INCLUDE_DIRS) mark_as_advanced(LIBVPX_INCLUDE_DIRS LIBVPX_LIBRARIES)
CMake
hhvm/CMake/FindlibWatchmanClient.cmake
# Finds Watchman C++ client library # # This module defines: # WATCHMANCLIENT_INCLUDE_DIRS # WATCHMANCLIENT_LIBRARIES # find_package(PkgConfig) pkg_check_modules(WATCHMANCLIENT watchmanclient) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( libWatchmanClient DEFAULT_MSG WATCHMANCLIENT_LIBRARIES WATCHMANCLIENT_INCLUDE_DIRS)
CMake
hhvm/CMake/FindLibXed.cmake
find_path(LibXed_INCLUDE_DIR xed-interface.h) find_library(LibXed_LIBRARY NAMES xed) if (LibXed_INCLUDE_DIR AND LibXed_LIBRARY) include(CheckCSourceRuns) set(CMAKE_REQUIRED_INCLUDES ${LibXed_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${LibXed_LIBRARY}) check_c_source_runs(" #include <xed-interface.h> #include <stdlib.h> #include <string.h> int main() { const char* version = xed_get_version(); if(strlen(version) < 2) { return -1; } // Format is Vxx.yy* // we're only interested in the major version number return !(atoi(version + 1) >= 10); }" LibXed_GOOD_VERSION) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_LIBRARIES) if (NOT LibXed_GOOD_VERSION) message(STATUS "LibXed version check failed") endif() endif() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXed DEFAULT_MSG LibXed_LIBRARY LibXed_INCLUDE_DIR LibXed_GOOD_VERSION) if (NOT LibXed_FOUND) message(STATUS "Using third-party bundled LibXed") else() message(STATUS "Using LibXed from: ${LibXed_LIBRARY}") endif() mark_as_advanced(LibXed_INCLUDE_DIR LibXed_LIBRARY)
CMake
hhvm/CMake/FindLibZip.cmake
# Finds libzip. # # This module defines: # LIBZIP_INCLUDE_DIR_ZIP # LIBZIP_INCLUDE_DIR_ZIPCONF # LIBZIP_LIBRARY # find_package(PkgConfig) pkg_check_modules(PC_LIBZIP QUIET libzip) find_path(LIBZIP_INCLUDE_DIR_ZIP NAMES zip.h HINTS ${PC_LIBZIP_INCLUDE_DIRS}) find_path(LIBZIP_INCLUDE_DIR_ZIPCONF NAMES zipconf.h HINTS ${PC_LIBZIP_INCLUDE_DIRS}) find_library(LIBZIP_LIBRARY NAMES zip) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( LIBZIP DEFAULT_MSG LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR_ZIP LIBZIP_INCLUDE_DIR_ZIPCONF) set(LIBZIP_VERSION 0) if (LIBZIP_INCLUDE_DIR_ZIPCONF) FILE(READ "${LIBZIP_INCLUDE_DIR_ZIPCONF}/zipconf.h" _LIBZIP_VERSION_CONTENTS) if (_LIBZIP_VERSION_CONTENTS) STRING(REGEX REPLACE ".*#define LIBZIP_VERSION \"([0-9.]+)\".*" "\\1" LIBZIP_VERSION "${_LIBZIP_VERSION_CONTENTS}") endif () endif () set(LIBZIP_VERSION ${LIBZIP_VERSION} CACHE STRING "Version number of libzip")
CMake
hhvm/CMake/FindLZ4.cmake
# Finds liblz4. # # This module defines: # LZ4_FOUND # LZ4_INCLUDE_DIR # LZ4_LIBRARY # find_path(LZ4_INCLUDE_DIR NAMES lz4.h) find_library(LZ4_LIBRARY NAMES lz4) # fb-mysql requires LZ4F_resetDecompressionContext() which was added in v1.8.0 if (LZ4_LIBRARY) include(CheckCSourceRuns) set(CMAKE_REQUIRED_INCLUDES ${LZ4_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${LZ4_LIBRARY}) check_c_source_runs(" #include <lz4.h> int main() { int good = (LZ4_VERSION_MAJOR > 1) || ((LZ4_VERSION_MAJOR == 1) && (LZ4_VERSION_MINOR >= 8)); return !good; }" LZ4_GOOD_VERSION) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_LIBRARIES) endif() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR LZ4_GOOD_VERSION) if (NOT LZ4_FOUND) message(STATUS "Using third-party bundled LZ4") else() message(STATUS "Found LZ4: ${LZ4_LIBRARY}") endif (NOT LZ4_FOUND) mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY)
CMake
hhvm/CMake/FindMcrypt.cmake
# - Find Mcrypt (a cross platform RPC lib/tool) # This module defines # Mcrypt_INCLUDE_DIR, where to find Mcrypt headers # Mcrypt_LIBS, Mcrypt libraries # Mcrypt_FOUND, If false, do not try to use Mcrypt find_path(Mcrypt_INCLUDE_DIR mcrypt.h PATHS /usr/local/include /opt/local/include ) #find_library can't seem to find a 64-bit binary if the 32-bit isn't there set(Mcrypt_LIB_PATHS /usr/local/lib /opt/local/lib /usr/lib64) find_library(Mcrypt_LIB NAMES mcrypt PATHS ${Mcrypt_LIB_PATHS}) if (Mcrypt_LIB AND Mcrypt_INCLUDE_DIR) set(Mcrypt_FOUND TRUE) set(Mcrypt_LIBS ${Mcrypt_LIB}) else () set(Mcrypt_FOUND FALSE) endif () if (Mcrypt_FOUND) if (NOT Mcrypt_FIND_QUIETLY) message(STATUS "Found mcrypt: ${Mcrypt_LIBS}") endif () else () if (Mcrypt_FIND_REQUIRED) message(FATAL_ERROR "Could NOT find mcrypt library.") endif () message(STATUS "mcrypt NOT found.") endif () mark_as_advanced( Mcrypt_LIB Mcrypt_INCLUDE_DIR )
CMake
hhvm/CMake/FindONIGURUMA.cmake
# - Find oniguruma # Find the native Oniguruma includes and library # # ONIGURUMA_INCLUDE_DIRS - where to find oniguruma.h, etc. # ONIGURUMA_LIBRARIES - List of libraries when using oniguruma. # ONIGURUMA_FOUND - True if oniguruma found. IF (ONIGURUMA_INCLUDE_DIRS) # Already in cache, be silent SET(ONIGURUMA_FIND_QUIETLY TRUE) ENDIF () FIND_PATH(ONIGURUMA_INCLUDE_DIR oniguruma.h) SET(ONIGURUMA_NAMES onig) FIND_LIBRARY(ONIGURUMA_LIBRARY NAMES ${ONIGURUMA_NAMES} ) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ONIGURUMA DEFAULT_MSG ONIGURUMA_LIBRARY ONIGURUMA_INCLUDE_DIR) IF(ONIGURUMA_FOUND) SET( ONIGURUMA_LIBRARIES ${ONIGURUMA_LIBRARY} ) SET( ONIGURUMA_INCLUDE_DIRS ${ONIGURUMA_INCLUDE_DIR} ) ELSE() SET( ONIGURUMA_LIBRARIES ) SET( PONIGURUMA_INCLUDE_DIRS ) ENDIF() MARK_AS_ADVANCED( ONIGURUMA_LIBRARIES ONIGURUMA_INCLUDE_DIRS )
CMake
hhvm/CMake/FindPCRE.cmake
# # $Id$ # # - Find pcre # Find the native PCRE includes and library # # PCRE_INCLUDE_DIR - where to find pcre.h, etc. # PCRE_LIBRARY - Path to the pcre library. # PCRE_FOUND - True if pcre found. IF (PCRE_INCLUDE_DIR) # Already in cache, be silent SET(PCRE_FIND_QUIETLY TRUE) ENDIF (PCRE_INCLUDE_DIR) FIND_PATH(SYSTEM_PCRE_INCLUDE_DIR pcre.h) SET(PCRE_NAMES pcre) FIND_LIBRARY(SYSTEM_PCRE_LIBRARY NAMES ${PCRE_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE DEFAULT_MSG SYSTEM_PCRE_LIBRARY SYSTEM_PCRE_INCLUDE_DIR ) # Make sure it's got the jit enabled. If not, don't use it. IF (PCRE_FOUND) INCLUDE(CheckCSourceRuns) SET(CMAKE_REQUIRED_LIBRARIES pcre) CHECK_C_SOURCE_RUNS("#include <pcre.h> int main() { int has_jit = 0; pcre_config(PCRE_CONFIG_JIT, &has_jit); return has_jit ? 0 : 1; } " SYSTEM_PCRE_HAS_JIT) ENDIF (PCRE_FOUND) IF(NOT SYSTEM_PCRE_HAS_JIT) MESSAGE(STATUS "System PCRE does not have JIT enabled - will use hhvm-third-party/pcre") UNSET(PCRE_INCLUDE_DIR CACHE) UNSET(PCRE_LIBRARY CACHE) # This is used to configure bundled pcre SET(PCRE_SUPPORT_JIT ON CACHE BOOL "") SET(PCRE_SUPPORT_UTF ON CACHE BOOL "") SET(PCRE_SUPPORT_UNICODE_PROPERTIES ON CACHE BOOL "") ELSE() SET(PCRE_INCLUDE_DIR ${SYSTEM_PCRE_INCLUDE_DIR} CACHE PATH "PCRE include directory") SET(PCRE_LIBRARY ${SYSTEM_PCRE_LIBRARY} CACHE FILEPATH "PCRE library") ENDIF() MARK_AS_ADVANCED( PCRE_LIBRARY PCRE_INCLUDE_DIR )
CMake
hhvm/CMake/FindPThread.cmake
# - Try to find libpthread # # Once done this will define # # LIBPTHREAD_FOUND - system has libpthread # LIBPTHREAD_INCLUDE_DIRS - the libpthread include directory # LIBPTHREAD_LIBRARIES - Link these to use libpthread # LIBPTHREAD_DEFINITIONS - Compiler switches required for using libpthread # # Redistribution and use is allowed according to the terms of the New # BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # if (LIBPTHREAD_LIBRARIES AND LIBPTHREAD_INCLUDE_DIRS) set (LIBPTHREAD_FIND_QUIETLY TRUE) endif (LIBPTHREAD_LIBRARIES AND LIBPTHREAD_INCLUDE_DIRS) find_path (LIBPTHREAD_INCLUDE_DIRS NAMES pthread.h) find_library (LIBPTHREAD_LIBRARIES NAMES pthread) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPTHREAD DEFAULT_MSG LIBPTHREAD_LIBRARIES LIBPTHREAD_INCLUDE_DIRS) mark_as_advanced(LIBPTHREAD_INCLUDE_DIRS LIBPTHREAD_LIBRARIES LIBPTHREAD_FOUND)
CMake
hhvm/CMake/FindRE2.cmake
FIND_PATH(SYSTEM_RE2_INCLUDE_DIR re2/re2.h) IF (SYSTEM_RE2_INCLUDE_DIR) MESSAGE(STATUS "Found RE2 include dir") FIND_LIBRARY(SYSTEM_RE2_LIBRARY re2) IF (SYSTEM_RE2_LIBRARY) MESSAGE(STATUS "Found RE2 library") SET(RE2_INCLUDE_DIR ${SYSTEM_RE2_INCLUDE_DIR}) SET(RE2_LIBRARY ${SYSTEM_RE2_LIBRARY}) ELSE () MESSAGE(FATAL_ERROR "Found RE2 headers, but not the library") ENDIF () ELSE () MESSAGE(STATUS "Did not find system RE2") ENDIF ()
CMake
hhvm/CMake/FindReadline.cmake
# from http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/FindReadline.cmake # http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/COPYING-CMAKE-SCRIPTS # --> BSD licensed # # GNU Readline library finder if(READLINE_INCLUDE_DIR AND READLINE_LIBRARY) set(READLINE_FOUND TRUE) else(READLINE_INCLUDE_DIR AND READLINE_LIBRARY) FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h /usr/include/readline ) # 2008-04-22 The next clause used to read like this: # # FIND_LIBRARY(READLINE_LIBRARY NAMES readline) # FIND_LIBRARY(NCURSES_LIBRARY NAMES ncurses ) # include(FindPackageHandleStandardArgs) # FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG NCURSES_LIBRARY READLINE_INCLUDE_DIR READLINE_LIBRARY ) # # I was advised to modify it such that it will find an ncurses library if # required, but not if one was explicitly given, that is, it allows the # default to be overridden. PH FIND_LIBRARY(READLINE_LIBRARY NAMES readline) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY ) MARK_AS_ADVANCED(READLINE_INCLUDE_DIR READLINE_LIBRARY) endif(READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
CMake
hhvm/CMake/FindSnappy.cmake
# - Find Snappy # This module defines # SNAPPY_INCLUDE_DIR, where to find Snappy headers # SNAPPY_LIBS, Snappy libraries # SNAPPY_FOUND, If false, do not try to use Snappy find_path(SNAPPY_INCLUDE_DIR snappy.h PATHS /usr/local/include /opt/local/include ) #find_library can't seem to find a 64-bit binary if the 32-bit isn't there set(SNAPPY_LIB_NAMES libsnappy snappy) set(SNAPPY_LIB_PATHS /usr/local/lib /opt/local/lib /usr/lib64) find_library(SNAPPY_LIB NAMES ${SNAPPY_LIB_NAMES} PATHS ${SNAPPY_LIB_PATHS}) if (SNAPPY_LIB AND SNAPPY_INCLUDE_DIR) set(SNAPPY_FOUND TRUE) set(SNAPPY_LIBS ${SNAPPY_LIB}) else () set(SNAPPY_FOUND FALSE) endif () if (SNAPPY_FOUND) if (NOT SNAPPY_FIND_QUIETLY) message(STATUS "Found Snappy: ${SNAPPY_LIBS}") endif () else () if (SNAPPY_FIND_REQUIRED) message(FATAL_ERROR "Could NOT find the Snappy library.") endif () message(STATUS "Snappy NOT found.") endif () mark_as_advanced( SNAPPY_LIB SNAPPY_INCLUDE_DIR )
CMake
hhvm/CMake/HHVMExtensionConfig.cmake
# This file holds the configuration mechanism for extensions. # # Now, the structure of the globals this uses. # # HHVM_EXTENSION_COUNT: <int> # An integer representing the number of extensions that have # been defined. # # HHVM_EXTENSIONS_REQUIRED_LIBRARIES: <list of paths> # A list of the additional libraries that need to be linked # against for the enabled extensions. # # HHVM_EXTENSIONS_REQUIRED_INCLUDE_DIRS: <list of paths> # A list of the additional include paths that need to be used # in order to compile the enabled extensions. # # HHVM_EXTENSIONS_REQUIRED_DEFINES: <list of strings> # A list of the additional defines that need to be used in order # to compile the enabled extensions. # # # The extensions' internal info is stored in globals, prefixed by # HHVM_EXTENSION_#_ where # represents a number between 0 and # HHVM_EXTENSION_COUNT. # # HHVM_EXTENSION_#_NAME: <string> # The name of extension. # # HHVM_EXTENSION_#_PRETTY_NAME: <string> # The name of the extension to use in messages. # # HHVM_EXTENSION_#_REQUIRED: <ON/OFF> # If ON, then the extension is integral to the function # of HHVM itself, so failing to build it is not an option, # and a FATAL_ERROR should be triggered if dependencies # fail. # # HHVM_EXTENSION_#_ROOT_DIR: <string> # The root directory to which all file paths # referenced by the extension are relative to. # # HHVM_EXTENSION_#_ENABLED_STATE: <int {0, 1, 2, 3, 4}> # The state of an extension's enabling. If this is 0, then the extension # may be enabled once dependency calculation is performed. If this is 1, # then the extension is enabled, and if it is 2, then it is disabled. # If this is 3, then the extension has been forcefully enabled, and its # dependencies should be checked. If this is 4, then the extension is a # 'wanted' extension, and we should error if dependencies for it can't # be resolved, unless the dependency that fails is an os* or var* dependency, # in which case, we don't error, but just disable the extension. # # HHVM_EXTENSION_#_SOURCE_FILES: <list> # The list of files to compile for the extension. # # HHVM_EXTENSION_#_HEADER_FILES: <list> # The list of header files that make up this extension. # # HHVM_EXTENSION_#_SYSTEMLIB: <list> # The list of php files that make up this extension's own systemlib. # # HHVM_EXTENSION_#_DEPENDENCIES: <list> # The list of dependencies of this extension. For details on the specifics # of values in this list, see the documentation of the DEPENDS parameter # of HHVM_DEFINE_EXTENSION. # # HHVM_EXTENSION_#_DEPENDENCIES_OPTIONAL: <list> # A list of ON/OFF values mapping to the values in HHVM_EXTENSION_#_DEPENDENCIES. # If the value is ON, then the dependency is optional, and the build should # not fail if the dependency can't be resolved. include(CheckFunctionExists) include(HPHPFunctions) include(Options) # function HHVM_DEFINE_EXTENSION: # This is the function that each individual extension will call. It # defines everything about the extension. # # Note that HRE_CURRENT_EXT_PATH should have been defined before calling this, # and it should be set to the root directory to which all paths passed to this # function are relative to. # # Parameters: # # NAME # The name of the extension. This name will be used in the variable names, # so spaces are not allowed. # # [REQUIRED] # This extension is integral to the functioning of HHVM, and # can not be disabled via `-DENABLE_EXTENSION_FOO=Off`. # A FATAL_ERROR will be triggered if dependencies fail to resolve. # # [IMPLICIT] # If the library dependencies for this extension fail to resolve, # and it has not be explicitly enabled via `-DENABLE_EXTENSION_FOO=On`, # then it will be implicitly disabled by the build system. # # [WANTED] (default) # If the library dependencies for this extension fail to resolve, # and it has not been explicitly disabled with `-DENABLE_EXTENSION_FOO=Off` # a FATAL_ERROR will be triggered, unless the dependency that fails is # an os* or var* dependency, in which case the extension will be implicitly # disabled by the build system. # # Note that it does not make sense to specify more than one of the above # three settings as the behavior they imply is mutually exclusive. # Using more than one will result in undefined behavior. # # [PRETTY_NAME string] # If passed, use this name when naming the extension in messages. If this is # not passed, default to NAME. # # [IS_ENABLED VARNAME] # If the parameter passed is defined, and has a trueish value, # then the extension will be enabled. This is only used to maintain # backwards compatibility with existing options. All other # extensions can be enabled or disabled with ENABLE_EXTENSION_*. # The ENABLE_EXTENSION_* variables will also be defined for the source # code so that fallbacks may be used where needed. # # [SOURCES ...] # The source files of the extension # # [HEADERS ...] # The header files of the extension # # [SYSTEMLIB ...] # The PHP API of the extension. # # [HACK_SYSTEMLIB_DIR ...] # A directory containing a Hack library that should be part of the # extension. # # [DEPENDS ...] # The dependencies of the extension. Extensions are prefixed # with "ext_", and external libraries with "lib". # "systemlib" is a special dependency that represents the # systemlib header. # # A dependency may optionally be followed by "OPTIONAL", which # means that the build won't fail if the dependency is not found. # # Dependencies prefixed with "os" represent the OS required to # build the extension. The only valid value for this currently # is osPosix, which represents everything with a valid posix # API, which is most everything except for Windows. # # Dependencies prefixed with "var" represent a CMake variable # which must evaluate to a trueish value for the extension to # be enabled. If the value isn't defined, it is assumed to be # false. # # If there is a space in an argument with a string in it, and # the argument is a library, the exact version of the library # required is expected to be the second part of the string. # For example, "libFribidi 0.19.6" would require the Fribidi # package to be exactly version 0.19.6. # # For libBoost, a single component is expected to be specified # by appending a -componentName to the value, for example # libBoost-variant would require the variant component of libBoost. # This is only required if a library needs to be linked against. # If a boost component is a headers-only library, libBoost is # enough of a dependency. # # Note that libFolly is currently a dependency of everything # for the sanity of the Windows port. function(HHVM_DEFINE_EXTENSION extNameIn) if (NOT DEFINED HHVM_EXTENSION_COUNT) set(HHVM_EXTENSION_COUNT 0) endif() set(extensionName "") set(extensionPrettyName "") set(extensionRequired OFF) # If WANTED is specified, then the extension must be explicitly disabled # If IMPLICIT is specified, then the extension will be implicitly disabled # when the dependencies are not found # If neither is specified, we default to WANTED anyway set(extensionEnabledState 4) set(extensionSources) set(extensionHeaders) set(extensionLibrary) set(extensionDependencies) set(extensionDependenciesOptional) # Make sure there are no spaces. string(FIND ${extNameIn} " " extNameSpace) if (NOT ${extNameSpace} EQUAL -1) message(FATAL_ERROR "An extension name cannot have a space in it! Got name '${extNameIn}'.") endif() # Make sure another extension with the same hasn't already # been defined. set(i 0) while (i LESS HHVM_EXTENSION_COUNT) if (${HHVM_EXTENSION_${i}_NAME} STREQUAL ${extNameIn}) message(FATAL_ERROR "An extension with the name '${extNameIn}' has already been defined!") endif() math(EXPR i "${i} + 1") endwhile() set(extensionName ${extNameIn}) set(extensionPrettyName ${extensionName}) set(argumentState 0) foreach (arg ${ARGN}) if ("x${arg}" STREQUAL "xPRETTY_NAME") set(argumentState 1) elseif ("x${arg}" STREQUAL "xIS_ENABLED") set(argumentState 2) elseif ("x${arg}" STREQUAL "xSOURCES") set(argumentState 3) elseif ("x${arg}" STREQUAL "xHEADERS") set(argumentState 4) elseif ("x${arg}" STREQUAL "xSYSTEMLIB") set(argumentState 5) elseif ("x${arg}" STREQUAL "xDEPENDS") set(argumentState 7) elseif ("x${arg}" STREQUAL "xHACK_SYSTEMLIB_DIR") set(argumentState 8) elseif ("x${arg}" STREQUAL "xREQUIRED") if (NOT ${argumentState} EQUAL 0) message(FATAL_ERROR "The REQUIRED modifier should only be placed immediately after the extension's name! (while processing the '${extensionPrettyName}' extension)") endif() set(extensionRequired ON) elseif ("x${arg}" STREQUAL "xIMPLICIT") if (NOT ${argumentState} EQUAL 0) message(FATAL_ERROR "The IMPLICIT modifier should only be placed immediately after the extension's name! (while processing the '${extensionPrettyName}' extension)") endif() set(extensionEnabledState 0) elseif ("x${arg}" STREQUAL "xWANTED") if (NOT ${argumentState} EQUAL 0) message(FATAL_ERROR "The WANTED modifier should only be placed immediately after the extension's name! (while processing the '${extensionPrettyName}' extension)") endif() set(extensionEnabledState 4) elseif ("x${arg}" STREQUAL "xOPTIONAL") if (${argumentState} EQUAL 7) list(LENGTH extensionDependenciesOptional optDepLen) math(EXPR optDepLen "${optDepLen} - 1") list(REMOVE_AT extensionDependenciesOptional ${optDepLen}) list(APPEND extensionDependenciesOptional ON) else() message(FATAL_ERROR "The OPTIONAL modifier is only currently valid in the DEPENDS section of extension '${extensionPrettyName}'!") endif() elseif (${argumentState} EQUAL 0) message(FATAL_ERROR "Unknown argument '${arg}' while processing extension '${extensionPrettyName}'!") elseif (${argumentState} EQUAL 1) # PRETTY_NAME set(extensionPrettyName ${arg}) set(argumentState 0) elseif (${argumentState} EQUAL 2) # IS_ENABLED if (DEFINED ${arg}) if (${${arg}}) set(extensionEnabledState 3) else() set(extensionEnabledState 2) endif() endif() set(argumentState 0) elseif (${argumentState} EQUAL 3) # SOURCES list(FIND extensionSources ${arg} listIDX) if (NOT ${listIDX} EQUAL -1) message(FATAL_ERROR "The file '${arg}' was already specified as a source of '${extensionPrettyName}'!") endif() list(APPEND extensionSources ${arg}) elseif (${argumentState} EQUAL 4) # HEADERS list(FIND extensionHeaders ${arg} listIDX) if (NOT ${listIDX} EQUAL -1) message(FATAL_ERROR "The file '${arg}' was already specified as a header of '${extensionPrettyName}'!") endif() list(APPEND extensionHeaders ${arg}) elseif (${argumentState} EQUAL 5) # SYSTEMLIB list(FIND extensionLibrary ${arg} listIDX) if (NOT ${listIDX} EQUAL -1) message(FATAL_ERROR "The file '${arg}' was already specified as part of the library of '${extensionPrettyName}'!") endif() list(APPEND extensionLibrary ${arg}) elseif (${argumentState} EQUAL 7) # DEPENDS list(FIND extensionDependencies ${arg} listIDX) if (NOT ${listIDX} EQUAL -1) message(FATAL_ERROR "'${arg}' was already specified as a dependency of '${extensionPrettyName}'!") endif() list(APPEND extensionDependencies ${arg}) list(APPEND extensionDependenciesOptional OFF) elseif (${argumentState} EQUAL 8) # HACK_SYSTEMLIB_DIR set(singleFilePath "${CMAKE_CURRENT_BINARY_DIR}/ext_${extensionName}.hack") if(IS_ABSOLUTE ${arg}) set(sourceDir ${arg}) else() set(sourceDir "${HRE_CURRENT_EXT_PATH}/${arg}") endif() add_custom_command( OUTPUT "${singleFilePath}" COMMAND "${CMAKE_SOURCE_DIR}/hphp/hack/scripts/concatenate_all.sh" "--install_dir=${CMAKE_CURRENT_BINARY_DIR}" "--root=${sourceDir}" "--output_file=${singleFilePath}" VERBATIM ) add_custom_target( "ext_${extensionName}_generated_systemlib" DEPENDS "${singleFilePath}" ) add_dependencies(generated_systemlib "ext_${extensionName}_generated_systemlib") list(APPEND extensionLibrary "${singleFilePath}") else() message(FATAL_ERROR "An error occurred while processing the arguments of the '${extensionPrettyName}' extension!") endif() endforeach() # Check if the extension has been explicitly enabled or disabled. string(TOUPPER ${extensionName} upperExtName) if (DEFINED ENABLE_EXTENSION_${upperExtName}) if (${ENABLE_EXTENSION_${upperExtName}}) set(extensionEnabledState 3) elseif (${extensionRequired}) message(WARNING "Attempt to explicitly disable the required extension '${extensionPrettyName}' by setting 'ENABLE_EXTENSION_${upperExtName}' was ignored.") else() set(extensionEnabledState 2) endif() endif() # Increment the extension count. set(extensionID ${HHVM_EXTENSION_COUNT}) math(EXPR newCount "${HHVM_EXTENSION_COUNT} + 1") set(HHVM_EXTENSION_COUNT ${newCount} PARENT_SCOPE) # And lastly, export the globals. # We put these in the cache to make debugging easier. # The only one that absolutely has to be in the cache is # the ENABLED_STATE, due to it's modification from fairly # arbitrary scope depths. HHVM_EXTENSION_COUNT must NEVER # be in the cache, otherwise this will break. set(HHVM_EXTENSION_${extensionID}_NAME ${extensionName} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_PRETTY_NAME ${extensionPrettyName} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_REQUIRED ${extensionRequired} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_ROOT_DIR ${HRE_CURRENT_EXT_PATH} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_ENABLED_STATE ${extensionEnabledState} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_SOURCE_FILES ${extensionSources} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_HEADER_FILES ${extensionHeaders} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_SYSTEMLIB ${extensionLibrary} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_DEPENDENCIES ${extensionDependencies} CACHE INTERNAL "" FORCE) set(HHVM_EXTENSION_${extensionID}_DEPENDENCIES_OPTIONAL ${extensionDependenciesOptional} CACHE INTERNAL "" FORCE) endfunction() # Call after all of the calls to HHVM_DEFINE_EXTENSION are complete. # # This will also add the appropriate libraries, include directories, and # defines for the enabled extensions' dependencies. function(HHVM_EXTENSION_RESOLVE_DEPENDENCIES) set(HHVM_EXTENSIONS_REQUIRED_LIBRARIES "" CACHE INTERNAL "" FORCE) set(HHVM_EXTENSIONS_REQUIRED_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) set(HHVM_EXTENSIONS_REQUIRED_DEFINES "" CACHE INTERNAL "" FORCE) set(i 0) while (i LESS HHVM_EXTENSION_COUNT) HHVM_EXTENSION_INTERNAL_RESOLVE_DEPENDENCIES_OF_EXTENSION(wasResolved ${i} " ") string(TOUPPER ${HHVM_EXTENSION_${i}_NAME} upperExtName) if (${wasResolved} EQUAL 1) message(STATUS "Building the ${HHVM_EXTENSION_${i}_PRETTY_NAME} extension.") # Now we need to make sure the dependencies are included and linked in # correctly. set(i2 0) list(LENGTH HHVM_EXTENSION_${i}_DEPENDENCIES depCount) while (i2 LESS depCount) list(GET HHVM_EXTENSION_${i}_DEPENDENCIES ${i2} currentDependency) string(FIND ${currentDependency} "lib" libIdx) if (${libIdx} EQUAL 0) HHVM_EXTENSION_INTERNAL_HANDLE_LIBRARY_DEPENDENCY(${i} ${currentDependency} ON) endif() math(EXPR i2 "${i2} + 1") endwhile() if (HHVM_EXTENSION_${i}_REQUIRED) set(ENABLE_EXTENSION_${upperExtName} ON CACHE INTERNAL "Enable the ${HHVM_EXTENSION_${i}_PRETTY_NAME} extension.") else() set(ENABLE_EXTENSION_${upperExtName} ON CACHE BOOL "Enable the ${HHVM_EXTENSION_${i}_PRETTY_NAME} extension.") endif() else() if (HHVM_EXTENSION_${i}_REQUIRED) message(FATAL_ERROR "Failed to resolve a dependency of the ${HHVM_EXTENSION_${i}_PRETTY_NAME} extension, which is a required extension!") endif() message("Not building the ${HHVM_EXTENSION_${i}_PRETTY_NAME} extension.") set(ENABLE_EXTENSION_${upperExtName} OFF CACHE BOOL "Enable the ${HHVM_EXTENSION_${i}_PRETTY_NAME} extension.") endif() math(EXPR i "${i} + 1") endwhile() endfunction() # This will append the files of the enabled extensions to the following variables: # C_SOURCES: C Source Files # CXX_SOURCES: C++ Source Files # HEADER_SOURCES: C/C++ Header Files # ASM_SOURCES: asm source files appropriate for the current compiler. # PHP_SOURCES: PHP files representing the various extensions' systemlib. function (HHVM_EXTENSION_BUILD_SOURCE_LISTS) set(i 0) while (i LESS HHVM_EXTENSION_COUNT) if (${HHVM_EXTENSION_${i}_ENABLED_STATE} EQUAL 1) HHVM_EXTENSION_INTERNAL_SORT_OUT_SOURCES(${HHVM_EXTENSION_${i}_ROOT_DIR} ${HHVM_EXTENSION_${i}_SOURCE_FILES} ${HHVM_EXTENSION_${i}_HEADER_FILES} ${HHVM_EXTENSION_${i}_SYSTEMLIB} ) endif() math(EXPR i "${i} + 1") endwhile() # Propagate the extra files to the parent scope. set(C_SOURCES ${C_SOURCES} PARENT_SCOPE) set(CXX_SOURCES ${CXX_SOURCES} PARENT_SCOPE) set(HEADER_SOURCES ${HEADER_SOURCES} PARENT_SCOPE) set(ASM_SOURCES ${ASM_SOURCES} PARENT_SCOPE) set(PHP_SOURCES ${PHP_SOURCES} PARENT_SCOPE) endfunction() # Sort out all the files into their appropriate variable, as well as transform the paths # to their fully-resolved forms. function (HHVM_EXTENSION_INTERNAL_SORT_OUT_SOURCES rootDir) foreach (fileName ${ARGN}) string(LENGTH ${fileName} fileNameLength) string(FIND ${fileName} "." dotPos REVERSE) if (${dotPos} EQUAL -1) message(FATAL_ERROR "No extension on file '${fileName}'!") endif() math(EXPR endPos "${fileNameLength} - ${dotPos}") string(SUBSTRING ${fileName} ${dotPos} ${endPos} fileExtension) string(TOLOWER ${fileExtension} fileExtension) if (${fileExtension} STREQUAL ".c") list(APPEND C_SOURCES "${rootDir}/${fileName}") elseif (${fileExtension} STREQUAL ".cpp" OR ${fileExtension} STREQUAL ".cxx" OR ${fileExtension} STREQUAL ".cc") list(APPEND CXX_SOURCES "${rootDir}/${fileName}") elseif (${fileExtension} STREQUAL ".h" OR ${fileExtension} STREQUAL ".hpp") list(APPEND HEADER_SOURCES "${rootDir}/${fileName}") elseif (${fileExtension} STREQUAL ".s") # AT&T syntax, MSVC doesn't like. if (NOT MSVC) list(APPEND ASM_SOURCES "${rootDir}/${fileName}") endif() elseif (${fileExtension} STREQUAL ".asm") # MASM syntax. MSVC only. if (MSVC) list(APPEND ASM_SOURCES "${rootDir}/${fileName}") endif() elseif (${fileExtension} STREQUAL ".php") list(APPEND PHP_SOURCES "${rootDir}/${fileName}") elseif (${fileExtension} STREQUAL ".hack") # .hack files are used by typechecked systemlib; there's a directory, # and the actual .hack file is generated. As such, it's in the build # directory instead, so we have an absolute path list(APPEND PHP_SOURCES "${fileName}") else() message(FATAL_ERROR "Unknown file extension '${fileExtension}'!") endif() endforeach() set(C_SOURCES ${C_SOURCES} PARENT_SCOPE) set(CXX_SOURCES ${CXX_SOURCES} PARENT_SCOPE) set(HEADER_SOURCES ${HEADER_SOURCES} PARENT_SCOPE) set(ASM_SOURCES ${ASM_SOURCES} PARENT_SCOPE) set(PHP_SOURCES ${PHP_SOURCES} PARENT_SCOPE) endfunction() # Configure the specified target so that it can compile when # linked against the enabled extensions. function(HHVM_CONFIGURE_TARGET_FOR_EXTENSION_DEPENDENCIES targetName) target_link_libraries(${targetName} ${HHVM_EXTENSIONS_REQUIRED_LIBRARIES}) target_include_directories(${targetName} PUBLIC ${HHVM_EXTENSIONS_REQUIRED_INCLUDE_DIRS}) target_compile_definitions(${targetName} PUBLIC ${HHVM_EXTENSIONS_REQUIRED_DEFINES}) endfunction() # Resolve the dependencies of the specified extension, and update it's enabled state. function(HHVM_EXTENSION_INTERNAL_RESOLVE_DEPENDENCIES_OF_EXTENSION resolvedDestVar extensionID) # If already resolved, return that state. if (NOT HHVM_EXTENSION_${extensionID}_ENABLED_STATE EQUAL 0 AND NOT HHVM_EXTENSION_${extensionID}_ENABLED_STATE EQUAL 3 AND NOT HHVM_EXTENSION_${extensionID}_ENABLED_STATE EQUAL 4) set(${resolvedDestVar} ${HHVM_EXTENSION_${extensionID}_ENABLED_STATE} PARENT_SCOPE) return() endif() # If already in resolution stack, it's a circular dependency, # assume for now that it's enabled. list(FIND HHVM_EXTENSION_RESOLUTION_STACK ${HHVM_EXTENSION_${extensionID}_NAME} resIDX) if (NOT ${resIDX} EQUAL -1) set(${resolvedDestVar} 1 PARENT_SCOPE) return() endif() # Go through the dependencies, checking each one recursively in turn. list(LENGTH HHVM_EXTENSION_${extensionID}_DEPENDENCIES depCount) set(i 0) while (i LESS depCount) list(GET HHVM_EXTENSION_${extensionID}_DEPENDENCIES ${i} currentDependency) string(FIND ${currentDependency} "lib" listIDX) if (${listIDX} EQUAL 0) # Library Dependency HHVM_EXTENSION_INTERNAL_HANDLE_LIBRARY_DEPENDENCY(${extensionID} ${currentDependency} OFF) if (HHVM_EXTENSION_${extensionID}_ENABLED_STATE EQUAL 2) break() endif() else() string(FIND ${currentDependency} "var" listIDX) if (${listIDX} EQUAL 0) # CMake Variable Dependency string(LENGTH ${currentDependency} depLength) math(EXPR depLength "${depLength} - 3") string(SUBSTRING ${currentDependency} 3 ${depLength} varName) if (DEFINED ${varName}) if (NOT ${${varName}}) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${currentDependency} ON) break() endif() else() HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${currentDependency} ON) break() endif() else() string(FIND ${currentDependency} "os" listIDX) if (${listIDX} EQUAL 0) # OS Dependency if (${currentDependency} STREQUAL "osPosix") if (MSVC) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${currentDependency} ON) break() endif() else() message(FATAL_ERROR "The only OS restriction that is currently valid is 'osPosix', got '${currentDependency}'!") endif() elseif (${currentDependency} STREQUAL "systemlib") # TODO: Mark this somehow? else() message(FATAL_ERROR "Unknown dependency '${currentDependency}' for extension '${HHVM_EXTENSION_${extensionID}_PRETTY_NAME}'!") endif() endif() endif() math(EXPR i "${i} + 1") endwhile() if (HHVM_EXTENSION_${extensionID}_ENABLED_STATE EQUAL 0 OR HHVM_EXTENSION_${extensionID}_ENABLED_STATE EQUAL 3 OR HHVM_EXTENSION_${extensionID}_ENABLED_STATE EQUAL 4) set(HHVM_EXTENSION_${extensionID}_ENABLED_STATE 1 CACHE INTERNAL "" FORCE) endif() set(${resolvedDestVar} ${HHVM_EXTENSION_${extensionID}_ENABLED_STATE} PARENT_SCOPE) endfunction() # Set that an extension was disabled because of the specified dependency not being # possible to resolve. # This optionally takes a third BOOL parameter that should be set to ON only if the # dependency that failed to resolve is an os* or var* dependency. function(HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY extensionID failedDependency) list(FIND HHVM_EXTENSION_${extensionID}_DEPENDENCIES ${failedDependency} depIdx) if (depIdx EQUAL -1) message(FATAL_ERROR "An issue occurred while processing the '${failedDependency}' dependency of the ${HHVM_EXTENSION_${extensionID}_PRETTY_NAME} extension!") endif() list(GET HHVM_EXTENSION_${extensionID}_DEPENDENCIES_OPTIONAL ${depIdx} isOptional) if (NOT ${isOptional}) if (${HHVM_EXTENSION_${extensionID}_ENABLED_STATE} EQUAL 4 AND (NOT ${ARGC} EQUAL 3 OR NOT "${ARGV2}" STREQUAL "ON")) message(FATAL_ERROR "The ${HHVM_EXTENSION_${extensionID}_PRETTY_NAME} extension is an extension you probably want, but resolving the dependency '${failedDependency}' failed!") elseif (${HHVM_EXTENSION_${extensionID}_ENABLED_STATE} EQUAL 3) message(FATAL_ERROR "The ${HHVM_EXTENSION_${extensionID}_PRETTY_NAME} extension was forcefully enabled, but resolving the dependency '${failedDependency}' failed!") elseif (${HHVM_EXTENSION_${extensionID}_ENABLED_STATE} EQUAL 1) # Currently only triggers for issues with find_package when applying the library dependencies. message(FATAL_ERROR "An error occurred while applying the '${failedDependency}' dependency of the ${HHVM_EXTENSION_${extensionID}_PRETTY_NAME} extension!") endif() message(STATUS "The ${HHVM_EXTENSION_${extensionID}_PRETTY_NAME} extension was disabled because resolving the dependency '${failedDependency}' failed.") set(HHVM_EXTENSION_${extensionID}_ENABLED_STATE 2 CACHE INTERNAL "" FORCE) endif() endfunction() # Add a set of libraries to link against. function(HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES) set(reqLibs ${HHVM_EXTENSIONS_REQUIRED_LIBRARIES}) foreach (lib ${ARGN}) list(APPEND reqLibs ${lib}) endforeach() set(HHVM_EXTENSIONS_REQUIRED_LIBRARIES ${reqLibs} CACHE INTERNAL "" FORCE) endfunction() # Add a set of include directories to use. function(HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS) set(incDirs ${HHVM_EXTENSIONS_REQUIRED_INCLUDE_DIRS}) foreach (inc ${ARGN}) list(APPEND incDirs ${inc}) endforeach() set(HHVM_EXTENSIONS_REQUIRED_INCLUDE_DIRS ${incDirs} CACHE INTERNAL "" FORCE) endfunction() # Add a set of defines to use when compiling. function(HHVM_EXTENSION_INTERNAL_ADD_DEFINES) set(defs ${HHVM_EXTENSIONS_REQUIRED_DEFINES}) foreach (def ${ARGN}) list(APPEND defs ${def}) endforeach() set(HHVM_EXTENSIONS_REQUIRED_DEFINES ${defs} CACHE INTERNAL "" FORCE) endfunction() # This handles all the library dependencies, and determines if the libraries are present. function (HHVM_EXTENSION_INTERNAL_HANDLE_LIBRARY_DEPENDENCY extensionID dependencyName addPaths) string(FIND ${dependencyName} "lib" libIdx) if (NOT libIdx EQUAL 0) message(FATAL_ERROR "Non-library dependency '${dependencyName}' passed to HHVM_EXTENSION_INTERNAL_HANDLE_LIBRARY_DEPENDENCY!") endif() set(requiredVersion) string(LENGTH ${dependencyName} depLength) math(EXPR depLength "${depLength} - 3") string(SUBSTRING ${dependencyName} 3 ${depLength} originalLibraryName) string(FIND ${originalLibraryName} " " spaceIDX) if (NOT ${spaceIDX} EQUAL -1) math(EXPR spaceIDX "${spaceIDX} + 1") string(LENGTH ${originalLibraryName} libNameLength) math(EXPR libNameLength "${libNameLength} - ${spaceIDX}") string(SUBSTRING ${originalLibraryName} ${spaceIDX} ${libNameLength} requiredVersion) math(EXPR spaceIDX "${spaceIDX} - 1") string(SUBSTRING ${originalLibraryName} 0 ${spaceIDX} originalLibraryName) endif() string(TOLOWER ${originalLibraryName} libraryName) # This first check is for libraries that are used by default # Keep these in alphabetical order. if ( ${libraryName} STREQUAL "boost" OR ${libraryName} STREQUAL "editline" OR ${libraryName} STREQUAL "fastlz" OR ${libraryName} STREQUAL "folly" OR ${libraryName} STREQUAL "lz4" OR ${libraryName} STREQUAL "mbfl" OR ${libraryName} STREQUAL "oniguruma" OR ${libraryName} STREQUAL "openssl" OR ${libraryName} STREQUAL "pcre" OR ${libraryName} STREQUAL "readline" OR ${libraryName} STREQUAL "sqlite" OR ${libraryName} STREQUAL "zip" OR ${libraryName} STREQUAL "zlib" ) # Nothing to do, they are included by default. elseif (${libraryName} STREQUAL "bzip2") find_package(BZip2 ${requiredVersion}) find_package(EXPAT ${requiredVersion}) if (NOT BZIP2_INCLUDE_DIR OR NOT BZIP2_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${BZIP2_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES(${BZIP2_DEFINITIONS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${BZIP2_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBBZIP2") endif() elseif (${libraryName} STREQUAL "cclient") find_package(CClient ${requiredVersion}) if (NOT CCLIENT_INCLUDE_PATH OR NOT CCLIENT_LIBRARY) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() CONTAINS_STRING("${CCLIENT_INCLUDE_PATH}/utf8.h" U8T_DECOMPOSE RECENT_CCLIENT) if (NOT RECENT_CCLIENT) unset(RECENT_CCLIENT CACHE) if (${addPaths}) message(FATAL_ERROR "Your version of c-client is too old, you need 2007") else() message(STATUS "Your version of c-client is too old, you need 2007") HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${CCLIENT_INCLUDE_PATH}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${CCLIENT_LIBRARY}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBCCLIENT") if (EXISTS "${CCLIENT_INCLUDE_PATH}/linkage.c") CONTAINS_STRING("${CCLIENT_INCLUDE_PATH}/linkage.c" auth_gss CCLIENT_HAS_GSS) elseif (EXISTS "${CCLIENT_INCLUDE_PATH}/linkage.h") CONTAINS_STRING("${CCLIENT_INCLUDE_PATH}/linkage.h" auth_gss CCLIENT_HAS_GSS) endif() if (NOT CCLIENT_HAS_GSS) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DSKIP_IMAP_GSS=1") endif() if (EXISTS "${CCLIENT_INCLUDE_PATH}/linkage.c") CONTAINS_STRING("${CCLIENT_INCLUDE_PATH}/linkage.c" ssl_onceonlyinit CCLIENT_HAS_SSL) elseif (EXISTS "${CCLIENT_INCLUDE_PATH}/linkage.h") CONTAINS_STRING("${CCLIENT_INCLUDE_PATH}/linkage.h" ssl_onceonlyinit CCLIENT_HAS_SSL) endif() if (NOT CCLIENT_HAS_SSL) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DSKIP_IMAP_SSL=1") endif() endif() elseif (${libraryName} STREQUAL "curl") find_package(CURL ${requiredVersion}) if (NOT CURL_INCLUDE_DIR OR NOT CURL_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${CURL_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${CURL_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBCURL") endif() elseif (${libraryName} STREQUAL "expat") find_package(EXPAT ${requiredVersion}) if (NOT EXPAT_INCLUDE_DIRS OR NOT EXPAT_LIBRARY) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${EXPAT_INCLUDE_DIRS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${EXPAT_LIBRARY}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBEXPAT") if (EXPAT_STATIC) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DXML_STATIC") endif() endif() elseif (${libraryName} STREQUAL "freetype") find_package(Freetype ${requiredVersion}) if (NOT FREETYPE_INCLUDE_DIRS OR NOT FREETYPE_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${FREETYPE_INCLUDE_DIRS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${FREETYPE_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBFREETYPE") HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_GD_FREETYPE") HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DENABLE_GD_TTF") endif() elseif (${libraryName} STREQUAL "fribidi") find_package(fribidi ${requiredVersion}) if (NOT FRIBIDI_INCLUDE_DIR OR NOT FRIBIDI_LIBRARY) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${FRIBIDI_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${FRIBIDI_LIBRARY}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBFRIBIDI") endif() elseif (${libraryName} STREQUAL "glib") find_package(GLIB ${requiredVersion}) if (NOT GLIB_INCLUDE_DIR OR NOT GLIB_CONFIG_INCLUDE_DIR) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBGLIB") endif() elseif (${libraryName} STREQUAL "gmp") find_package(LibGmp ${requiredVersion}) if (NOT GMP_INCLUDE_DIR OR NOT GMP_LIBRARY) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${GMP_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${GMP_LIBRARY}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBGMP") endif() elseif (${libraryName} STREQUAL "iconv") find_package(Libiconv ${requiredVersion}) if (NOT LIBICONV_INCLUDE_DIR) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBICONV_INCLUDE_DIR}) if (LIBICONV_LIBRARY) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBICONV_LIBRARY}) endif() HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_ICONV") HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBICONV") if (LIBICONV_CONST) message(STATUS "Using const for input to iconv() call") HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DICONV_CONST=const") endif() endif() elseif (${libraryName} STREQUAL "icu") find_package(ICU ${requiredVersion}) if (NOT ICU_FOUND OR NOT ICU_DATA_LIBRARIES OR NOT ICU_I18N_LIBRARIES OR NOT ICU_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (ICU_VERSION VERSION_LESS "4.2") unset(ICU_FOUND CACHE) unset(ICU_INCLUDE_DIRS CACHE) unset(ICU_LIBRARIES CACHE) if (${addPaths}) message(FATAL_ERROR "ICU is too old, found ${ICU_VERSION} and we need 4.2") else() message(STATUS "ICU is too old, found ${ICU_VERSION} and we need 4.2") HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() endif () if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${ICU_INCLUDE_DIRS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${ICU_DATA_LIBRARIES} ${ICU_I18N_LIBRARIES} ${ICU_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBICU") endif() elseif (${libraryName} STREQUAL "intl") find_package(LibIntl ${requiredVersion}) if (NOT LIBINTL_INCLUDE_DIRS) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBINTL_INCLUDE_DIRS}) if (LIBINTL_LIBRARIES) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBINTL_LIBRARIES}) endif() HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBINTL") endif() elseif (${libraryName} STREQUAL "jpeg") find_package(LibJpeg ${requiredVersion}) if (NOT LIBJPEG_INCLUDE_DIRS OR NOT LIBJPEG_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBJPEG_INCLUDE_DIRS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBJPEG_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBJPEG") HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_GD_JPG") endif() elseif (${libraryName} STREQUAL "ldap") find_package(Ldap ${requiredVersion}) if (NOT LDAP_INCLUDE_DIR OR NOT LDAP_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LDAP_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LDAP_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBLDAP") endif() elseif (${libraryName} STREQUAL "magickwand") find_package(LibMagickWand ${requiredVersion}) if (NOT LIBMAGICKWAND_INCLUDE_DIRS OR NOT LIBMAGICKWAND_LIBRARIES OR NOT LIBMAGICKCORE_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBMAGICKWAND_INCLUDE_DIRS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBMAGICKWAND_LIBRARIES} ${LIBMAGICKCORE_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBMAGICKWAND") endif() elseif (${libraryName} STREQUAL "mcrypt") find_package(Mcrypt ${requiredVersion}) if (NOT Mcrypt_INCLUDE_DIR OR NOT Mcrypt_LIB) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${Mcrypt_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${Mcrypt_LIB}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBMCRYPT") endif() elseif (${libraryName} STREQUAL "memcached") find_package(Libmemcached ${requiredVersion}) if (NOT LIBMEMCACHED_INCLUDE_DIR OR NOT LIBMEMCACHED_LIBRARY) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (LIBMEMCACHED_VERSION VERSION_LESS "0.39") unset(LIBMEMCACHED_INCLUDE_DIR CACHE) unset(LIBMEMCACHED_LIBRARY CACHE) unset(LIBMEMCACHED_VERSION CACHE) if (${addPaths}) message(FATAL_ERROR "libmemcached is too old, found ${LIBMEMCACHED_VERSION} and we need 0.39") else() message(STATUS "libmemcached is too old, found ${LIBMEMCACHED_VERSION} and we need 0.39") HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBMEMCACHED_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBMEMCACHED_LIBRARY}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBMEMCACHED") endif() elseif (${libraryName} STREQUAL "mysql") HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(fbmysqlclient) MYSQL_SOCKET_SEARCH() HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DPHP_MYSQL_UNIX_SOCK_ADDR=\"${MYSQL_UNIX_SOCK_ADDR}\"") elseif (${libraryName} STREQUAL "pgsql") FIND_PATH(PGSQL_INCLUDE_DIR NAMES libpq-fe.h PATHS /usr/include /usr/include/postgresql /usr/include/pgsql /usr/local/include /usr/local/include/postgresql /usr/local/include/pgsql ) FIND_LIBRARY(PGSQL_LIBRARY NAMES pq PATHS /lib /usr/lib /usr/local/lib ) IF (NOT PGSQL_INCLUDE_DIR OR NOT PGSQL_LIBRARY) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if(${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${PGSQL_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${PGSQL_LIBRARY}) endif() elseif (${libraryName} STREQUAL "png") find_package(LibPng ${requiredVersion}) if (NOT LIBPNG_INCLUDE_DIRS OR NOT LIBPNG_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBPNG_INCLUDE_DIRS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBPNG_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBPNG") HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_GD_PNG") HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DPNG_SKIP_SETJMP_CHECK") endif() elseif (${libraryName} STREQUAL "snappy") find_package(Snappy ${requiredVersion}) if (NOT SNAPPY_INCLUDE_DIRS OR NOT SNAPPY_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${SNAPPY_INCLUDE_DIRS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${SNAPPY_LIBRARIES}) endif() elseif (${libraryName} STREQUAL "squangle") HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(squangle) elseif (${libraryName} STREQUAL "thrift") HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(thrift) elseif (${libraryName} STREQUAL "vpx") find_package(LibVpx ${requiredVersion}) if (NOT LIBVPX_INCLUDE_DIRS OR NOT LIBVPX_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBVPX_INCLUDE_DIRS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBVPX_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBVPX") endif() elseif (${libraryName} STREQUAL "xml2") find_package(LibXml2 ${requiredVersion}) if (NOT LIBXML2_INCLUDE_DIR OR NOT LIBXML2_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBXML2_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES(${LIBXML2_DEFINITIONS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBXML2_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBXML2") endif() elseif (${libraryName} STREQUAL "xslt") find_package(LibXslt ${requiredVersion}) if (NOT LIBXSLT_INCLUDE_DIR OR NOT LIBXSLT_LIBRARIES) HHVM_EXTENSION_INTERNAL_SET_FAILED_DEPENDENCY(${extensionID} ${dependencyName}) return() endif() if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS(${LIBXSLT_INCLUDE_DIR}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES(${LIBXSLT_DEFINITIONS}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${LIBXSLT_LIBRARIES} ${LIBXSLT_EXSLT_LIBRARIES}) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DHAVE_LIBXSLT") if (LIBXSLT_STATIC) HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DLIBXSLT_STATIC=1") HHVM_EXTENSION_INTERNAL_ADD_DEFINES("-DLIBEXSLT_STATIC=1") endif() endif() elseif (TARGET "${dependencyName}") # If we have libfoo, resolve as libfoo message(STATUS "Resolving extension '${HHVM_EXTENSION_${extensionID}_NAME}' dependency '${dependencyName}' as CMake target") if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${dependencyName}) get_target_property(DEPENDENCY_TARGET_INCLUDE_DIR ${dependencyName} INTERFACE_INCLUDE_DIRECTORIES) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS("${DEPENDENCY_TARGET_INCLUDE_DIR}") endif () elseif (TARGET "${originalLibraryName}") # If we have libfoo, resolve as 'foo'; the `lib` prefix is needed for our cmake to consider it to be a # library dependency, so either case is valid :( message(STATUS "Resolving extension '${HHVM_EXTENSION_${extensionID}_NAME}' dependency '${dependencyName}' as CMake target '${originalLibraryName}'") if (${addPaths}) HHVM_EXTENSION_INTERNAL_ADD_LINK_LIBRARIES(${originalLibraryName}) get_target_property(DEPENDENCY_TARGET_INCLUDE_DIR ${originalLibraryName} INTERFACE_INCLUDE_DIRECTORIES) HHVM_EXTENSION_INTERNAL_ADD_INCLUDE_DIRS("${DEPENDENCY_TARGET_INCLUDE_DIR}") endif () else() message(FATAL_ERROR "Unknown library '${originalLibraryName}' as a dependency of the '${HHVM_EXTENSION_${extensionID}_PRETTY_NAME}' extension!") endif() endfunction()
CMake
hhvm/CMake/HHVMGenerateConfig.cmake
# The core function for generating `hphp-config.h`. This is done here to keep # the main CMake tree clean. # # If you add any defines here or in hphp-config.h.in, you must make sure # to update the non-CMake side. If you are not sure if a particular define # should be present, ask your FB reviewer. include(CheckCXXSourceCompiles) include(CheckFunctionExists) include(CheckIncludeFile) # Build a string to define the appropriate macros for the headers that # we are able to find. function(HHVM_GENERATE_CONFIG_HEADERS_FOUND_DEFINE_STRING destVarName) # This is a list of headers to check for and add defines in the form of # HAVE_*_H if they are present. Note that all slashes will be replaced # with a single underscore. Please keep ordered such that all headers # in a root directory are first, followed by headers in a subdirectory. # Note that .h will automatically be appended to the names of these before # searching for them. set(HHVM_HEADERS_TO_CHECK) list(APPEND HHVM_HEADERS_TO_CHECK "inttypes" "limits" "utime" "wchar" "wctype" "sys/mman" "sys/utime" ) set(builtString "") list(LENGTH HHVM_HEADERS_TO_CHECK headersCount) set(i 0) while (i LESS ${headersCount}) list(GET HHVM_HEADERS_TO_CHECK ${i} curHeader) string(REPLACE "/" "_" curHeaderClean "${curHeader}") string(TOUPPER "${curHeaderClean}" curHeaderUpper) CHECK_INCLUDE_FILE("${curHeader}.h" HAVE_${curHeaderUpper}_H) if (${HAVE_${curHeaderUpper}_H}) set(builtString "${builtString}\n#define HAVE_${curHeaderUpper}_H 1") else() set(builtString "${builtString}\n/* #undef HAVE_${curHeaderUpper}_H */") endif() math(EXPR i "${i} + 1") endwhile() set(${destVarName} "${builtString}" PARENT_SCOPE) endfunction() # Build a string to define the appropriate macros for the functions that # we are able to find. function(HHVM_GENERATE_CONFIG_FUNCTIONS_FOUND_DEFINE_STRING destVarName) # This is a list of functions that need to be checked for. set(HHVM_FUNCTIONS_TO_CHECK) list(APPEND HHVM_FUNCTIONS_TO_CHECK "getline" "mbrtowc" "mkstemp" "mmap" "strerror" "strlcpy" "strtof" "strtoul" "utime" "utimes" ) # This is a list of functions that are known to be present under MSVC # because they are implemented via Folly's portability headers. For an # item in this list to have any effect, it must first fail to be found # when checking the item in the main list. set(HHVM_FUNCTIONS_KNOWN_TO_BE_PRESENT_MSVC) list(APPEND HHVM_FUNCTIONS_KNOWN_TO_BE_PRESENT_MSVC "mkstemp" "mmap" ) set(builtString "") list(LENGTH HHVM_FUNCTIONS_TO_CHECK functionCount) set(i 0) while (i LESS ${functionCount}) list(GET HHVM_FUNCTIONS_TO_CHECK ${i} curFunc) string(TOUPPER "${curFunc}" curFuncUpper) CHECK_FUNCTION_EXISTS("${curFunc}" HAVE_${curFuncUpper}) if (${HAVE_${curFuncUpper}}) set(builtString "${builtString}\n#define HAVE_${curFuncUpper} 1") else() list(FIND HHVM_FUNCTIONS_KNOWN_TO_BE_PRESENT_MSVC "${curFunc}" curFuncIdx) if (curFuncIdx EQUAL -1 OR NOT MSVC) set(builtString "${builtString}\n/* #undef HAVE_${curFuncUpper} */") else() set(builtString "${builtString}\n#define HAVE_${curFuncUpper} 1 /* Implemented via Folly Portability header */") endif() endif() math(EXPR i "${i} + 1") endwhile() set(${destVarName} "${builtString}" PARENT_SCOPE) endfunction() # Check if the source passed in compiles and add the appropriate define. function(HHVM_GENERATE_CONFIG_CHECK_COMPILES destVarName defineName sourceToCheck) CHECK_CXX_SOURCE_COMPILES("${sourceToCheck}" ${defineName}) if (${defineName}) set(${destVarName} "${${destVarName}}\n#define ${defineName} 1" PARENT_SCOPE) else() set(${destVarName} "${${destVarName}}\n/* #undef ${defineName} */" PARENT_SCOPE) endif() endfunction() # A quick check for use by HHVM_GENERATE_CONFIG_COMPILES_DEFINE_STRING to # check if a struct defined in a particular header has a member with # the specified name. function(HHVM_GENERATE_CONFIG_STRUCT_HAS_MEMBER destVarName defineName headers structName memberName) HHVM_GENERATE_CONFIG_CHECK_COMPILES(${destVarName} ${defineName} " ${headers} int main(void) { (void)((${structName}*)0)->${memberName}; return 0; }") set(${destVarName} ${${destVarName}} PARENT_SCOPE) endfunction() # A quick check for use by HHVM_GENERATE_CONFIG_COMPILES_DEFINE_STRING to # check if a symbol is defined in a particular header. function(HHVM_GENERATE_CONFIG_SYMBOL_EXISTS destVarName defineName headers symbolName) HHVM_GENERATE_CONFIG_CHECK_COMPILES(${destVarName} ${defineName} " ${headers} int main(void) { #ifdef ${symbolName} return 0; #else return ((int*)(&${symbolName}))[0]; #endif }") set(${destVarName} ${${destVarName}} PARENT_SCOPE) endfunction() # Build a define string for checks that require checking if some source code # compiles. function(HHVM_GENERATE_CONFIG_COMPILES_DEFINE_STRING destVarName) set(builtString "") HHVM_GENERATE_CONFIG_STRUCT_HAS_MEMBER(builtString HAVE_TM_ISDST "#include <time.h>" "tm" "tm_isdst") HHVM_GENERATE_CONFIG_STRUCT_HAS_MEMBER(builtString HAVE_STRUCT_TM_TM_GMTOFF "#include <time.h>" "tm" "tm_gmtoff") HHVM_GENERATE_CONFIG_STRUCT_HAS_MEMBER(builtString HAVE_STRUCT_TM_TM_ZONE "#include <time.h>" "tm" "tm_zone") HHVM_GENERATE_CONFIG_SYMBOL_EXISTS(builtString HAVE_DAYLIGHT "#include <time.h>" "daylight") HHVM_GENERATE_CONFIG_SYMBOL_EXISTS(builtString MAJOR_IN_MKDEV "#include <mkdev.h>" "major") HHVM_GENERATE_CONFIG_SYMBOL_EXISTS(builtString MAJOR_IN_SYSMACROS "#include <sysmacros.h>" "major") HHVM_GENERATE_CONFIG_CHECK_COMPILES(builtString HAVE_VISIBILITY " __attribute__ ((__visibility__(\"hidden\"))) void someMethod(void); int main(void) { return 0; }") set(${destVarName} "${builtString}" PARENT_SCOPE) endfunction() # Builds a string to define the macros for all enabled extensions. function(HHVM_GENERATE_CONFIG_EXTENSIONS_ENABLED_DEFINE_STRING destVarName) set(builtString "/* Extensions */") set(i 0) while (i LESS HHVM_EXTENSION_COUNT) string(TOUPPER ${HHVM_EXTENSION_${i}_NAME} upperExtName) if (${HHVM_EXTENSION_${i}_ENABLED_STATE} EQUAL 1) set(builtString "${builtString}\n#define ENABLE_EXTENSION_${upperExtName} 1") else() set(builtString "${builtString}\n/* #undef ENABLE_EXTENSION_${upperExtName} */") endif() math(EXPR i "${i} + 1") endwhile() set(${destVarName} "${builtString}" PARENT_SCOPE) endfunction() # Generate the config file for HHVM. function(HHVM_GENERATE_CONFIG dest) HHVM_GENERATE_CONFIG_HEADERS_FOUND_DEFINE_STRING(HHVM_HEADERS_FOUND_DEFINE_STRING) HHVM_GENERATE_CONFIG_FUNCTIONS_FOUND_DEFINE_STRING(HHVM_FUNCTIONS_FOUND_DEFINE_STRING) HHVM_GENERATE_CONFIG_COMPILES_DEFINE_STRING(HHVM_COMPILES_DEFINE_STRING) HHVM_GENERATE_CONFIG_EXTENSIONS_ENABLED_DEFINE_STRING(HHVM_EXTENSIONS_ENABLED_DEFINE_STRING) configure_file("${HPHP_HOME}/hphp/util/hphp-config.h.in" "${dest}") endfunction()
CMake
hhvm/CMake/HHVMProject.cmake
# This must be done after the 'project' command if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Release") message(STATUS "Build type not specified: cmake build type Release.") endif()
CMake
hhvm/CMake/HPHPCompiler.cmake
set(FREEBSD FALSE) if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") set(FREEBSD TRUE) endif() set(LINUX FALSE) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") set(LINUX TRUE) endif() set(DARWIN FALSE) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") set(DARWIN TRUE) endif() set(WINDOWS FALSE) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") set(WINDOWS TRUE) endif() # Do this until cmake has a define for ARMv8 INCLUDE(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES(" #ifndef __x86_64__ #error Not x64 #endif int main() { return 0; }" IS_X64) CHECK_CXX_SOURCE_COMPILES(" #ifndef __AARCH64EL__ #error Not ARMv8 #endif int main() { return 0; }" IS_AARCH64) # using Clang or GCC if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") # Warnings to disable by name, -Wno-${name} set(DISABLED_NAMED_WARNINGS) list(APPEND DISABLED_NAMED_WARNINGS "error=array-bounds" "error=switch" "attributes" "deprecated" "invalid-offsetof" "register" "sign-compare" "strict-aliasing" "unused-function" "unused-local-typedefs" "unused-result" "write-strings" ) # Warnings to disable by name when building C code. set(DISABLED_C_NAMED_WARNINGS) list(APPEND DISABLED_C_NAMED_WARNINGS "missing-field-initializers" "sign-compare" ) # General options to pass to both C & C++ compilers set(GENERAL_OPTIONS) # General options to pass to the C++ compiler set(GENERAL_CXX_OPTIONS) list(APPEND GENERAL_CXX_OPTIONS "std=gnu++1z" "fno-omit-frame-pointer" "fno-operator-names" "Wall" "Werror=format-security" "Wno-unused-variable" "Wno-unused-value" "Wno-comment" "Wno-class-memaccess" "Wno-adress" "Wno-error=stringop-overflow" ) # Options to pass for debug mode to the C++ compiler set(DEBUG_CXX_OPTIONS) # Options to pass for release mode to the C++ compiler set(RELEASE_CXX_OPTIONS) # Suboption of -g in debug mode set(GDB_SUBOPTION) # Enable GCC/LLVM stack-smashing protection if(ENABLE_SSP) list(APPEND GENERAL_OPTIONS # This needs two dashes in the name, so put one here. "-param=ssp-buffer-size=4" "pie" "fPIC" ) endif() if (IS_X64) # For unclear reasons, our detection for what crc32 intrinsics you have # will cause Apple clang to ICE. Specifying a baseline here works around # the issue. (SSE4.2 has been available on processors for quite some time now.) if(ENABLE_SSE4_2 OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang") list(APPEND GENERAL_CXX_OPTIONS # SSE4.2 has been available on processors for quite some time now. This # allows enabling CRC hash function code "msse4.2" ) # Also pass the right option to ASM files to avoid inconsistencies # in CRC hash function handling set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -msse4.2") endif() endif() if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang") # using Clang list(APPEND GENERAL_CXX_OPTIONS "Qunused-arguments" ) list(APPEND DISABLED_C_NAMED_WARNINGS "unused-command-line-argument" ) list(APPEND DISABLED_NAMED_WARNINGS "return-type-c-linkage" "unknown-warning-option" "unused-command-line-argument" ) # Enabled GCC/LLVM stack-smashing protection if(ENABLE_SSP) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.6 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 3.6) list(APPEND GENERAL_OPTIONS "fstack-protector-strong") else() list(APPEND GENERAL_OPTIONS "fstack-protector") endif() endif() if(CLANG_FORCE_LIBSTDCXX) list(APPEND GENERAL_CXX_OPTIONS "stdlib=libstdc++") endif() else() # using GCC list(APPEND DISABLED_NAMED_WARNINGS "deprecated-declarations" "maybe-uninitialized" ) list(APPEND DISABLED_C_NAMED_WARNINGS "maybe-uninitialized" "old-style-declaration" ) list(APPEND GENERAL_OPTIONS "ffunction-sections" ) list(APPEND GENERAL_CXX_OPTIONS "fdata-sections" "fno-gcse" "fno-canonical-system-headers" "Wvla" ) list(APPEND RELEASE_CXX_OPTIONS "-param max-inline-insns-auto=100" "-param early-inlining-insns=200" "-param max-early-inliner-iterations=50" "-param=inline-unit-growth=200" "-param=large-unit-insns=10000" ) # Fix problem with GCC 4.9, https://kb.isc.org/article/AA-01167 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9) list(APPEND GENERAL_OPTIONS "fno-delete-null-pointer-checks") else() message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.9 or greater.") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.4) message(WARNING "HHVM is primarily tested on GCC 7.4-11.3. Using other versions may produce unexpected results, or may not even build at all.") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 11.3) message(WARNING "HHVM is primarily tested on GCC 7.4-11.3. Using other versions may produce unexpected results, or may not even build at all.") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.1 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 5.1) list(APPEND DISABLED_NAMED_WARNINGS "bool-compare") list(APPEND GENERAL_OPTIONS "DFOLLY_HAVE_MALLOC_H") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 6.0) list(APPEND GENERAL_CXX_OPTIONS "Wno-misleading-indentation") endif() # Enabled GCC/LLVM stack-smashing protection if(ENABLE_SSP) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.8) if(LINUX) # https://isisblogs.poly.edu/2011/06/01/relro-relocation-read-only/ list(APPEND GENERAL_OPTIONS "Wl,-z,relro,-z,now") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9) list(APPEND GENERAL_OPTIONS "fstack-protector-strong") endif() else() list(APPEND GENERAL_OPTIONS "fstack-protector") endif() endif() # X64 if(IS_X64) list(APPEND GENERAL_CXX_OPTIONS "mcrc32") endif() # ARM64 if(IS_AARCH64) # Force char type to be signed, which is not the case on aarch64. list(APPEND GENERAL_OPTIONS "fsigned-char") # If a CPU was specified, build a -mcpu option for the compiler. set(AARCH64_TARGET_CPU "" CACHE STRING "CPU to tell gcc to optimize for (-mcpu)") if(AARCH64_TARGET_CPU) list(APPEND GENERAL_OPTIONS "mcpu=${AARCH64_TARGET_CPU}") set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -mcpu=${AARCH64_TARGET_CPU}") # Make sure GCC is not using the fix for errata 843419. This change # interferes with the gold linker. Note that GCC applies this fix # even if you specify an mcpu other than cortex-a53, which is why # it's explicitly being disabled here for any cpu other than # cortex-a53. If you're running a newer pass of the cortex-a53, then # you can likely disable this fix with the following flag too. YMMV if(NOT ${AARCH64_TARGET_CPU} STREQUAL "cortex-a53") list(APPEND GENERAL_OPTIONS "mno-fix-cortex-a53-843419") endif() endif() endif() if(STATIC_CXX_LIB) set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") endif() if (ENABLE_SPLIT_DWARF) set(GDB_SUBOPTION "split-dwarf") endif() endif() # No optimizations for debug builds. # -Og enables some optimizations, but makes debugging harder by optimizing # away some functions and locals. -O0 is more debuggable. # -O0-ggdb was reputed to cause gdb to crash (github #4450) set(CMAKE_C_FLAGS_DEBUG "-O0 -g${GDB_SUBOPTION}") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g${GDB_SUBOPTION}") set(CMAKE_C_FLAGS_DEBUGOPT "-O2 -g${GDB_SUBOPTION}") set(CMAKE_CXX_FLAGS_DEBUGOPT "-O2 -g${GDB_SUBOPTION}") set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g${GDB_SUBOPTION} -DNDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g${GDB_SUBOPTION} -DNDEBUG") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Werror=implicit-function-declaration") mark_as_advanced(CMAKE_C_FLAGS_DEBUGOPT CMAKE_CXX_FLAGS_DEBUGOPT) foreach(opt ${DISABLED_NAMED_WARNINGS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-${opt}") endforeach() foreach(opt ${DISABLED_C_NAMED_WARNINGS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-${opt}") endforeach() foreach(opt ${GENERAL_OPTIONS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -${opt}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -${opt}") endforeach() foreach(opt ${GENERAL_CXX_OPTIONS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -${opt}") endforeach() foreach(opt ${DEBUG_CXX_OPTIONS}) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -${opt}") endforeach() foreach(opt ${RELEASE_CXX_OPTIONS}) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -${opt}") endforeach() # The ASM part of this makes it more effort than it's worth # to add these to the general flags system. if(ENABLE_AVX2) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2 -march=core-avx2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2 -march=core-avx2") set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -mavx2 -march=core-avx2") endif() # using Intel C++ elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -no-ipo -fp-model precise -wd584 -wd1418 -wd1918 -wd383 -wd869 -wd981 -wd424 -wd1419 -wd444 -wd271 -wd2259 -wd1572 -wd1599 -wd82 -wd177 -wd593 -w") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -no-ipo -fp-model precise -wd584 -wd1418 -wd1918 -wd383 -wd869 -wd981 -wd424 -wd1419 -wd444 -wd271 -wd2259 -wd1572 -wd1599 -wd82 -wd177 -wd593 -fno-omit-frame-pointer -Wall -Woverloaded-virtual -Wno-deprecated -w1 -Wno-strict-aliasing -Wno-write-strings -Wno-invalid-offsetof -fno-operator-names") # using Visual Studio C++ elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") message(WARNING "MSVC support is VERY experimental. It will likely not compile, and is intended for the utterly insane.") ############################################################ # First we setup and account for the option sets. ############################################################ set(MSVC_GENERAL_OPTIONS) set(MSVC_DISABLED_WARNINGS) set(MSVC_WARNINGS_AS_ERRORS) set(MSVC_ADDITIONAL_DEFINES) set(MSVC_EXE_LINKER_OPTIONS) set(MSVC_DEBUG_OPTIONS) set(MSVC_RELEASE_OPTIONS) set(MSVC_RELEASE_LINKER_OPTIONS) set(MSVC_DEBUG_EXE_LINKER_OPTIONS) set(MSVC_RELEASE_EXE_LINKER_OPTIONS) # Some additional configuration options. set(MSVC_ENABLE_ALL_WARNINGS ON CACHE BOOL "If enabled, pass /Wall to the compiler.") set(MSVC_ENABLE_DEBUG_INLINING ON CACHE BOOL "If enabled, enable inlining in the debug configuration. This allows /Zc:inline to be far more effective, resulting in hphp_runtime_static being ~450mb smaller.") set(MSVC_ENABLE_LTCG OFF CACHE BOOL "If enabled, use Link Time Code Generation for Release builds.") set(MSVC_ENABLE_PARALLEL_BUILD ON CACHE BOOL "If enabled, build multiple source files in parallel.") set(MSVC_ENABLE_PCH ON CACHE BOOL "If enabled, use precompiled headers to speed up the build.") set(MSVC_ENABLE_STATIC_ANALYSIS OFF CACHE BOOL "If enabled, do more complex static analysis and generate warnings appropriately.") set(MSVC_FAVORED_ARCHITECTURE "blend" CACHE STRING "One of 'blend', 'AMD64', 'INTEL64', or 'ATOM'. This tells the compiler to generate code optimized to run best on the specified architecture.") # The general options passed: list(APPEND MSVC_GENERAL_OPTIONS "bigobj" # Support objects with > 65k sections. Needed for folly due to templates. "fp:precise" # Precise floating point model used in every other build, use it here as well. "EHa" # Enable both SEH and C++ Exceptions. "Oy-" # Disable elimination of stack frames. "Zc:inline" # Have the compiler eliminate unreferenced COMDAT functions and data before emitting the object file. This produces significantly less input to the linker, resulting in MUCH faster linking. "Zo" # Enable enhanced optimized debugging. Produces slightly larger pdb files, but the resulting optimized code is much much easier to debug. ) # Enable all warnings if requested. if (MSVC_ENABLE_ALL_WARNINGS) list(APPEND MSVC_GENERAL_OPTIONS "Wall") endif() # Enable static analysis if requested. if (MSVC_ENABLE_STATIC_ANALYSIS) list(APPEND MSVC_GENERAL_OPTIONS "analyze") endif() # Enable multi-processor compilation if requested. if (MSVC_ENABLE_PARALLEL_BUILD) list(APPEND MSVC_GENERAL_OPTIONS "MP") endif() # Enable AVX2 codegen if available and requested. if (ENABLE_AVX2) list(APPEND MSVC_GENERAL_OPTIONS "arch:AVX2") endif() # Validate, and then add the favored architecture. if (NOT MSVC_FAVORED_ARCHITECTURE STREQUAL "blend" AND NOT MSVC_FAVORED_ARCHITECTURE STREQUAL "AMD64" AND NOT MSVC_FAVORED_ARCHITECTURE STREQUAL "INTEL64" AND NOT MSVC_FAVORED_ARCHITECTURE STREQUAL "ATOM") message(FATAL_ERROR "MSVC_FAVORED_ARCHITECTURE must be set to one of exactly, 'blend', 'AMD64', 'INTEL64', or 'ATOM'! Got '${MSVC_FAVORED_ARCHITECTURE}' instead!") endif() list(APPEND MSVC_GENERAL_OPTIONS "favor:${MSVC_FAVORED_ARCHITECTURE}") # The warnings that are disabled: list(APPEND MSVC_DISABLED_WARNINGS "4068" # Unknown pragma. "4091" # 'typedef' ignored on left of '' when no variable is declared. "4101" # Unused variables "4103" # Alignment changed after including header. This is needed because boost includes an ABI header that does some #pragma pack push/pop stuff, and we've passed our own packing "4146" # Unary minus applied to unsigned type, result still unsigned. "4250" # Function was inherited via dominance. "4800" # Values being forced to bool, this happens many places, and is a "performance warning". ) if (MSVC_ENABLE_ALL_WARNINGS) # These warnings are disabled because we've # enabled all warnings. If all warnings are # not enabled, then these don't need to be # disabled. list(APPEND MSVC_DISABLED_WARNINGS "4061" # Enum value not handled by a case in a switch on an enum. This isn't very helpful because it is produced even if a default statement is present. "4100" # Unreferenced formal parameter. "4127" # Conditional expression is constant. "4131" # Old style declarator used. This is triggered by ext_bc's backend code. "4189" # Local variable is initialized but not referenced. "4191" # Unsafe type cast. "4200" # Non-standard extension, zero sized array. "4201" # Non-standard extension used: nameless struct/union. "4232" # Non-standard extension used: 'pCurrent': address of dllimport. "4245" # Implicit change from signed/unsigned when initializing. "4255" # Implicitly converting function prototype from `()` to `(void)`. "4265" # Class has virtual functions, but destructor is not virtual. "4287" # Unsigned/negative constant mismatch. "4296" # '<' Expression is always false. "4315" # 'this' pointer for member may not be aligned to 8 bytes as expected by the constructor. "4324" # Structure was padded due to alignment specifier. "4355" # 'this' used in base member initializer list. "4365" # Signed/unsigned mismatch. "4371" # Layout of class may have changed due to fixes in packing. "4388" # Signed/unsigned mismatch on relative comparison operator. "4389" # Signed/unsigned mismatch on equality comparison operator. "4435" # Object layout under /vd2 will change due to virtual base. "4456" # Declaration of local hides previous definition of local by the same name. "4457" # Declaration of local hides function parameter. "4458" # Declaration of parameter hides class member. "4459" # Declaration of parameter hides global declaration. "4464" # Relative include path contains "..". This is triggered by the TBB headers. "4505" # Unreferenced local function has been removed. This is mostly the result of things not being needed under MSVC. "4514" # Unreferenced inline function has been removed. (caused by /Zc:inline) "4548" # Expression before comma has no effect. I wouldn't disable this normally, but malloc.h triggers this warning. "4555" # Expression has no effect; expected expression with side-effect. This is triggered by boost/variant.hpp. "4574" # ifdef'd macro was defined to 0. "4582" # Constructor is not implicitly called. "4583" # Destructor is not implicitly called. "4608" # Member has already been initialized by another union member initializer. "4619" # Invalid warning number used in #pragma warning. "4623" # Default constructor was implicitly defined as deleted. "4625" # Copy constructor was implicitly defined as deleted. "4626" # Assignment operator was implicitly defined as deleted. "4647" # __is_pod() has a different value in pervious versions of MSVC. "4668" # Macro was not defined, replacing with 0. "4701" # Potentially uninitialized local variable used. "4702" # Unreachable code. "4706" # Assignment within conditional expression. "4709" # Comma operator within array index expression. This currently just produces false-positives. "4710" # Function was not inlined. "4711" # Function was selected for automated inlining. This produces tens of thousands of warnings in release mode if you leave it enabled, which will completely break Visual Studio, so don't enable it. "4714" # Function marked as __forceinline not inlined. "4774" # Format string expected in argument is not a string literal. "4820" # Padding added after data member. "4917" # A GUID can only be associated with a class. This is triggered by some standard windows headers. "4946" # reinterpret_cast used between related types. "5026" # Move constructor was implicitly defined as deleted. "5027" # Move assignment operator was implicitly defined as deleted. "5031" # #pragma warning(pop): likely mismatch, popping warning state pushed in different file. This is needed because of how boost does things. ) endif() if (MSVC_ENABLE_STATIC_ANALYSIS) # Warnings disabled for /analyze list(APPEND MSVC_DISABLED_WARNINGS "6001" # Using uninitialized memory. This is disabled because it is wrong 99% of the time. "6011" # Dereferencing potentially NULL pointer. "6031" # Return value ignored. "6235" # (<non-zero constant> || <expression>) is always a non-zero constant. "6237" # (<zero> && <expression>) is always zero. <expression> is never evaluated and may have side effects. "6239" # (<non-zero constant> && <expression>) always evaluates to the result of <expression>. "6240" # (<expression> && <non-zero constant>) always evaluates to the result of <expression>. "6246" # Local declaration hides declaration of same name in outer scope. "6248" # Setting a SECURITY_DESCRIPTOR's DACL to NULL will result in an unprotected object. This is done by one of the boost headers. "6255" # _alloca indicates failure by raising a stack overflow exception. "6262" # Function uses more than x bytes of stack space. "6271" # Extra parameter passed to format function. The analysis pass doesn't recognize %j or %z, even though the runtime does. "6285" # (<non-zero constant> || <non-zero constant>) is always true. "6297" # 32-bit value is shifted then cast to 64-bits. The places this occurs never use more than 32 bits. "6308" # Realloc might return null pointer: assigning null pointer to '<name>', which is passed as an argument to 'realloc', will cause the original memory to leak. "6326" # Potential comparison of a constant with another constant. "6330" # Unsigned/signed mismatch when passed as a parameter. "6340" # Mismatch on sign when passed as format string value. "6387" # '<value>' could be '0': This does not adhere to the specification for a function. "28182" # Dereferencing NULL pointer. '<value>' contains the same NULL value as '<expression>'. "28251" # Inconsistent annotation for function. This is because we only annotate the declaration and not the definition. "28278" # Function appears with no prototype in scope. ) endif() # Warnings disabled to keep it quiet for now, # most of these should be reviewed and re-enabled: list(APPEND MSVC_DISABLED_WARNINGS "4005" # Macro redefinition "4018" # Signed/unsigned mismatch. "4242" # Possible loss of data when returning a value. "4244" # Implicit truncation of data. "4267" # Implicit truncation of data. This really shouldn't be disabled. "4291" # No matching destructor found. "4302" # Pointer casting size difference "4311" # Pointer casting size difference "4312" # Pointer casting size difference "4477" # Parameter to a formatting function isn't the same type as was passed in the format string. "4624" # Destructor was implicitly undefined. "4804" # Unsafe use of type 'bool' in operation. (comparing if bool is <=> scalar) "4805" # Unsafe mix of scalar type and type 'bool' in operation. (comparing if bool is == scalar) ) # Warnings to treat as errors: list(APPEND MSVC_WARNINGS_AS_ERRORS "4099" # Mixed use of struct and class on same type names. This was absolutely everywhere, and can cause errors at link-time if not fixed. "4129" # Unknown escape sequence. This is usually caused by incorrect escaping. "4566" # Character cannot be represented in current charset. This is remedied by prefixing string with "u8". ) # And the extra defines: list(APPEND MSVC_ADDITIONAL_DEFINES "NOMINMAX" # This is needed because, for some absurd reason, one of the windows headers tries to define "min" and "max" as macros, which messes up most uses of std::numeric_limits. "_CRT_NONSTDC_NO_WARNINGS" # Don't deprecate posix names of functions. "_CRT_SECURE_NO_WARNINGS" # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps. "_SCL_SECURE_NO_WARNINGS" # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps. "_WINSOCK_DEPRECATED_NO_WARNINGS" # Don't deprecate pieces of winsock "YY_NO_UNISTD_H" # Because MSVC doesn't have unistd.h, which is requested by the YACC generated code. ) # The options passed to the linker for EXE targets: list(APPEND MSVC_EXE_LINKER_OPTIONS "BASE:0x10000" # Base the program at just over 64k in memory, to play nice with the JIT. "DYNAMICBASE:NO" # Don't randomize the base address. "FIXED" # The program can only be loaded at its preferred base address. "STACK:8388608,8388608" # Set the stack reserve,commit to 8mb. Reserve should probably be higher. "time" # Output some timing information about the link. ) # The options to pass to the compiler for debug builds: list(APPEND MSVC_DEBUG_OPTIONS "Gy-" # Disable function level linking. "GF-" # Disable string pooling. ) # Add /Ob2 if allowing inlining in debug mode: if (MSVC_ENABLE_DEBUG_INLINING) list(APPEND MSVC_DEBUG_OPTIONS "Ob2") endif() # The options to pass to the compiler for release builds: list(APPEND MSVC_RELEASE_OPTIONS "GF" # Enable string pooling. (this is enabled by default by the optimization level, but we enable it here for clarity) "Gw" # Optimize global data. (-fdata-sections) "Gy" # Enable function level linking. (-ffunction-sections) "Qpar" # Enable parallel code generation. HHVM itself doesn't currently use this, but it's dependencies, TBB for instance, might, so enable it. "Oi" # Enable intrinsic functions. "Ot" # Favor fast code. ) # Add /GL to the compiler, and /LTCG to the linker # if link time code generation is enabled. if (MSVC_ENABLE_LTCG) list(APPEND MSVC_RELEASE_OPTIONS "GL") list(APPEND MSVC_RELEASE_LINKER_OPTIONS "LTCG") endif() # The options to pass to the linker for debug builds for EXE targets: list(APPEND MSVC_DEBUG_EXE_LINKER_OPTIONS "OPT:NOREF" # No unreferenced data elimination. (well, mostly) "OPT:NOICF" # No Identical COMDAT folding. ) # The options to pass to the linker for release builds for EXE targets: list(APPEND MSVC_RELEASE_EXE_LINKER_OPTIONS "OPT:REF" # Remove unreferenced functions and data. "OPT:ICF" # Identical COMDAT folding. ) ############################################################ # Now we need to adjust a couple of the default option sets. ############################################################ # We need the static runtime. foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) if (${flag_var} MATCHES "/MD") string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") endif() endforeach() # In order for /Zc:inline, which speeds up the build significantly, to work # we need to remove the /Ob0 parameter that CMake adds by default, because that # would normally disable all inlining. foreach(flag_var CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG) if (${flag_var} MATCHES "/Ob0") string(REGEX REPLACE "/Ob0" "" ${flag_var} "${${flag_var}}") endif() endforeach() # Ignore a warning about an object file not defining any symbols, # these are known, and we don't care. set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") ############################################################ # And finally, we can set all the flags we've built up. ############################################################ foreach(opt ${MSVC_GENERAL_OPTIONS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /${opt}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /${opt}") endforeach() foreach(opt ${MSVC_DISABLED_WARNINGS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd${opt}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${opt}") endforeach() foreach(opt ${MSVC_WARNINGS_AS_ERRORS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we${opt}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we${opt}") endforeach() foreach(opt ${MSVC_ADDITIONAL_DEFINES}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D ${opt}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D ${opt}") endforeach() foreach(opt ${MSVC_EXE_LINKER_OPTIONS}) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /${opt}") endforeach() foreach(opt ${MSVC_RELEASE_LINKER_OPTIONS}) foreach(flag_var CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_EXE_LINKER_FLAGS_MINSIZEREL CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO CMAKE_SHARED_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO CMAKE_STATIC_LINKER_FLAGS_RELEASE CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO) set(${flag_var} "${${flag_var}} /${opt}") endforeach() endforeach() foreach(opt ${MSVC_DEBUG_OPTIONS}) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /${opt}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /${opt}") endforeach() foreach(opt ${MSVC_RELEASE_OPTIONS}) foreach(flag_var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) set(${flag_var} "${${flag_var}} /${opt}") endforeach() endforeach() foreach(opt ${MSVC_DEBUG_EXE_LINKER_OPTIONS}) set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /${opt}") endforeach() foreach(opt ${MSVC_RELEASE_EXE_LINKER_OPTIONS}) set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /${opt}") set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /${opt}") set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /${opt}") endforeach() else() message("Warning: unknown/unsupported compiler, things may go wrong") endif() include(ThinArchives)
CMake
hhvm/CMake/HPHPFindLibs.cmake
# # +----------------------------------------------------------------------+ # | HipHop for PHP | # +----------------------------------------------------------------------+ # | Copyright (c) 2010 Facebook, Inc. (http://www.facebook.com) | # | Copyright (c) 1997-2010 The PHP Group | # +----------------------------------------------------------------------+ # | This source file is subject to version 3.01 of the PHP license, | # | that is bundled with this package in the file LICENSE, and is | # | available through the world-wide-web at the following url: | # | http://www.php.net/license/3_01.txt | # | If you did not receive a copy of the PHP license and are unable to | # | obtain it through the world-wide-web, please send a note to | # | [email protected] so we can mail you a copy immediately. | # +----------------------------------------------------------------------+ # include(CheckFunctionExists) # libdl find_package(LibDL) if (LIBDL_INCLUDE_DIRS) add_definitions("-DHAVE_LIBDL") include_directories(${LIBDL_INCLUDE_DIRS}) if (LIBDL_NEEDS_UNDERSCORE) add_definitions("-DLIBDL_NEEDS_UNDERSCORE") endif() endif() # google-glog find_package(Glog REQUIRED) if (GLOG_STATIC) add_definitions("-DGOOGLE_GLOG_DLL_DECL=") endif() include_directories(${GLOG_INCLUDE_DIR}) # inotify checks find_package(Libinotify) if (LIBINOTIFY_INCLUDE_DIR) include_directories(${LIBINOTIFY_INCLUDE_DIR}) endif() # pcre checks find_package(PCRE) include_directories(${PCRE_INCLUDE_DIR}) # libevent checks find_package(LibEvent REQUIRED) include_directories(${LIBEVENT_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES "${LIBEVENT_LIB}") CHECK_FUNCTION_EXISTS("evhttp_bind_socket_with_fd" HAVE_CUSTOM_LIBEVENT) if(HAVE_CUSTOM_LIBEVENT) message("Using custom LIBEVENT") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_CUSTOM_LIBEVENT") endif() set(CMAKE_REQUIRED_LIBRARIES) # libXed if (ENABLE_XED) find_package(LibXed) if (LibXed_FOUND) include_directories(${LibXed_INCLUDE_DIR}) endif() else() message(STATUS "XED is disabled") endif() # CURL checks find_package(CURL REQUIRED) include_directories(${CURL_INCLUDE_DIR}) if (CURL_STATIC) add_definitions("-DCURL_STATICLIB") endif() # LibXML2 checks find_package(LibXml2 REQUIRED) include_directories(${LIBXML2_INCLUDE_DIR}) add_definitions(${LIBXML2_DEFINITIONS}) # libsqlite3 find_package(LibSQLite REQUIRED) if (LIBSQLITE3_INCLUDE_DIR) include_directories(${LIBSQLITE3_INCLUDE_DIR}) endif () # fastlz find_package(FastLZ) if (FASTLZ_INCLUDE_DIR) include_directories(${FASTLZ_INCLUDE_DIR}) endif() # ICU find_package(ICU REQUIRED) if (ICU_FOUND) if (ICU_VERSION VERSION_LESS "4.2") unset(ICU_FOUND CACHE) unset(ICU_INCLUDE_DIRS CACHE) unset(ICU_LIBRARIES CACHE) message(FATAL_ERROR "ICU is too old, found ${ICU_VERSION} and we need 4.2") endif () include_directories(${ICU_INCLUDE_DIRS}) if (ICU_STATIC) add_definitions("-DU_EXPORT=") add_definitions("-DU_IMPORT=") endif() # Everything is either in the `icu61` namespace or `icu` namespace, depending # on another definition. There's an implicit `using namespace WHATEVER;` in # ICU4c < 61.1, but now that's opt-in rather than opt-out. add_definitions("-DU_USING_ICU_NAMESPACE=1") endif (ICU_FOUND) # jemalloc/tmalloc and profiler if (USE_GOOGLE_HEAP_PROFILER OR USE_GOOGLE_CPU_PROFILER) FIND_LIBRARY(GOOGLE_PROFILER_LIB profiler) FIND_PATH(GOOGLE_PROFILER_INCLUDE_DIR NAMES google/profiler.h) if (GOOGLE_PROFILER_INCLUDE_DIR) include_directories(${GOOGLE_PROFILER_INCLUDE_DIR}) endif() if (GOOGLE_PROFILER_LIB) message(STATUS "Found Google profiler: ${GOOGLE_PROFILER_LIB}") if (USE_GOOGLE_CPU_PROFILER) set(GOOGLE_CPU_PROFILER_ENABLED 1) endif() else() message(STATUS "Can't find Google profiler") endif() endif() if (USE_GOOGLE_HEAP_PROFILER AND GOOGLE_PROFILER_LIB) FIND_LIBRARY(GOOGLE_TCMALLOC_FULL_LIB tcmalloc) if (GOOGLE_TCMALLOC_FULL_LIB) message(STATUS "Found full tcmalloc: ${GOOGLE_TCMALLOC_FULL_LIB}") set(GOOGLE_HEAP_PROFILER_ENABLED 1) set(GOOGLE_TCMALLOC_ENABLED 1) else() message(STATUS "Can't find full tcmalloc - heap profiling is disabled") endif() endif() if(USE_JEMALLOC AND NOT GOOGLE_TCMALLOC_ENABLED) add_definitions(-DUSE_JEMALLOC=1) set(JEMALLOC_ENABLED 1) else() add_definitions(-DNO_JEMALLOC=1) endif() if (USE_TCMALLOC AND NOT JEMALLOC_ENABLED AND NOT GOOGLE_TCMALLOC_ENABLED) FIND_LIBRARY(GOOGLE_TCMALLOC_MIN_LIB tcmalloc_minimal) if (GOOGLE_TCMALLOC_MIN_LIB) message(STATUS "Found minimal tcmalloc: ${GOOGLE_TCMALLOC_MIN_LIB}") set(GOOGLE_TCMALLOC_ENABLED 1) else() message(STATUS "Can't find minimal tcmalloc") endif() endif() if (GOOGLE_TCMALLOC_ENABLED) add_definitions(-DGOOGLE_TCMALLOC=1) else() add_definitions(-DNO_TCMALLOC=1) endif() if (GOOGLE_HEAP_PROFILER_ENABLED) add_definitions(-DGOOGLE_HEAP_PROFILER=1) endif() if (GOOGLE_CPU_PROFILER_ENABLED) add_definitions(-DGOOGLE_CPU_PROFILER=1) endif() # HHProf if (JEMALLOC_ENABLED AND ENABLE_HHPROF) add_definitions(-DENABLE_HHPROF=1) endif() # OpenSSL libs find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) # LibreSSL explicitly refuses to support RAND_egd() SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) INCLUDE(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES("#include <openssl/rand.h> int main() { return RAND_egd(\"/dev/null\"); }" OPENSSL_HAVE_RAND_EGD) if (NOT OPENSSL_HAVE_RAND_EGD) add_definitions("-DOPENSSL_NO_RAND_EGD") endif() CHECK_CXX_SOURCE_COMPILES("#include <openssl/ssl.h> int main() { return SSL_set_alpn_protos(nullptr, nullptr, 0); }" OPENSSL_HAVE_ALPN) SET(CMAKE_REQUIRED_INCLUDES) SET(CMAKE_REQUIRED_LIBRARIES) # ZLIB find_package(ZLIB REQUIRED) include_directories(${ZLIB_INCLUDE_DIR}) # libpthreads find_package(PThread REQUIRED) include_directories(${LIBPTHREAD_INCLUDE_DIRS}) if (LIBPTHREAD_STATIC) add_definitions("-DPTW32_STATIC_LIB") endif() OPTION( NON_DISTRIBUTABLE_BUILD "Use libraries which may result in a binary that can not be legally distributed" OFF ) # Either Readline or Editline (for hphpd) if(NON_DISTRIBUTABLE_BUILD) find_package(Readline) endif() if (NOT READLINE_INCLUDE_DIR) find_package(Editline) endif() if (NON_DISTRIBUTABLE_BUILD AND READLINE_INCLUDE_DIR) if (READLINE_STATIC) add_definitions("-DREADLINE_STATIC") endif() include_directories(${READLINE_INCLUDE_DIR}) elseif (EDITLINE_INCLUDE_DIRS) add_definitions("-DUSE_EDITLINE") include_directories(${EDITLINE_INCLUDE_DIRS}) else() message(FATAL_ERROR "Could not find Readline or Editline") endif() if (NOT WINDOWS) find_package(LibDwarf REQUIRED) include_directories(${LIBDWARF_INCLUDE_DIRS}) if (LIBDWARF_CONST_NAME) add_definitions("-DLIBDWARF_CONST_NAME") endif() if (LIBDWARF_USE_INIT_C) add_definitions("-DLIBDWARF_USE_INIT_C") endif() find_package(LibElf REQUIRED) include_directories(${LIBELF_INCLUDE_DIRS}) if (ELF_GETSHDRSTRNDX) add_definitions("-DHAVE_ELF_GETSHDRSTRNDX") endif() endif() FIND_LIBRARY(CRYPT_LIB NAMES xcrypt crypt crypto) if (LINUX OR FREEBSD) FIND_LIBRARY (RT_LIB rt) endif() if (LINUX) FIND_LIBRARY (CAP_LIB cap) if (NOT CAP_LIB) message(FATAL_ERROR "You need to install libcap") endif() endif() if (LINUX OR APPLE) FIND_LIBRARY (DL_LIB dl) FIND_LIBRARY (RESOLV_LIB resolv) endif() if (FREEBSD) FIND_LIBRARY (EXECINFO_LIB execinfo) if (NOT EXECINFO_LIB) message(FATAL_ERROR "You need to install libexecinfo") endif() endif() if (APPLE) find_library(KERBEROS_LIB NAMES gssapi_krb5) endif() # This is required by Homebrew's libc. See # https://github.com/facebook/hhvm/pull/5728#issuecomment-124290712 # for more info. find_package(Libpam) if (PAM_INCLUDE_PATH) include_directories(${PAM_INCLUDE_PATH}) endif() include_directories(${HPHP_HOME}/hphp) macro(hphp_link target) if (${ARGC} GREATER 1) set(VISIBILITY "${ARGV1}") else () # We actually want PUBLIC, but specifying PUBLIC is an error if there is # another target_link_libraries(${target} ) without PUBLIC/PRIVATE/INTERFACE # anywhere else, so keep this for now for backwards compatibility set(VISIBILITY "") endif () # oniguruma must be linked first for MacOS's linker to do the right thing - # that's handled in HPHPSetup.cmake # # That only handles linking - we still need to make sure that: # - oniguruma is built first, if needed (so we have the header files) # - we build with the header files in the include path if(APPLE) if (NOT "${VISIBILITY}" STREQUAL "INTERFACE") add_dependencies(${target} ${VISIBILITY} onig) target_include_directories(${target} PRIVATE $<TARGET_PROPERTY:onig,INTERFACE_INCLUDE_DIRECTORIES>) endif () else() # Otherwise, the linker does the right thing, which sometimes means putting it after things that use it target_link_libraries(${target} ${VISIBILITY} onig) endif() if (LIBDL_LIBRARIES) target_link_libraries(${target} ${VISIBILITY} ${LIBDL_LIBRARIES}) endif () if (JEMALLOC_ENABLED) target_link_libraries(${target} ${VISIBILITY} jemalloc) endif () if (GOOGLE_HEAP_PROFILER_ENABLED OR GOOGLE_CPU_PROFILER_ENABLED) target_link_libraries(${target} ${VISIBILITY} ${GOOGLE_PROFILER_LIB}) endif() if (GOOGLE_HEAP_PROFILER_ENABLED) target_link_libraries(${target} ${VISIBILITY} ${GOOGLE_TCMALLOC_FULL_LIB}) elseif (GOOGLE_TCMALLOC_ENABLED) target_link_libraries(${target} ${VISIBILITY} ${GOOGLE_TCMALLOC_MIN_LIB}) endif() target_link_libraries(${target} ${VISIBILITY} libsodium) target_link_libraries(${target} ${VISIBILITY} ${PCRE_LIBRARY}) target_link_libraries(${target} ${VISIBILITY} ${ICU_DATA_LIBRARIES} ${ICU_I18N_LIBRARIES} ${ICU_LIBRARIES}) target_link_libraries(${target} ${VISIBILITY} ${LIBEVENT_LIB}) target_link_libraries(${target} ${VISIBILITY} ${CURL_LIBRARIES}) target_link_libraries(${target} ${VISIBILITY} glog::glog) if (LIBINOTIFY_LIBRARY) target_link_libraries(${target} ${VISIBILITY} ${LIBINOTIFY_LIBRARY}) endif() if (LINUX) target_link_libraries(${target} ${VISIBILITY} ${CAP_LIB}) endif() if (LINUX OR APPLE) target_link_libraries(${target} ${VISIBILITY} ${RESOLV_LIB}) target_link_libraries(${target} ${VISIBILITY} ${DL_LIB}) endif() if (FREEBSD) target_link_libraries(${target} ${VISIBILITY} ${EXECINFO_LIB}) endif() if (APPLE) target_link_libraries(${target} ${VISIBILITY} ${LIBINTL_LIBRARIES}) target_link_libraries(${target} ${VISIBILITY} ${KERBEROS_LIB}) endif() if (PAM_LIBRARY) target_link_libraries(${target} ${VISIBILITY} ${PAM_LIBRARY}) endif() if (LIBPTHREAD_LIBRARIES) target_link_libraries(${target} ${VISIBILITY} ${LIBPTHREAD_LIBRARIES}) endif() target_link_libraries(${target} ${VISIBILITY} ${TBB_LIBRARIES}) target_link_libraries(${target} ${VISIBILITY} ${OPENSSL_LIBRARIES}) target_link_libraries(${target} ${VISIBILITY} ${ZLIB_LIBRARIES}) target_link_libraries(${target} ${VISIBILITY} ${LIBXML2_LIBRARIES}) target_link_libraries(${target} ${VISIBILITY} ${LBER_LIBRARIES}) if (CRYPT_LIB) target_link_libraries(${target} ${VISIBILITY} ${CRYPT_LIB}) endif() if (LINUX OR FREEBSD) target_link_libraries(${target} ${VISIBILITY} ${RT_LIB}) endif() if (LIBSQLITE3_FOUND AND LIBSQLITE3_LIBRARY) target_link_libraries(${target} ${VISIBILITY} ${LIBSQLITE3_LIBRARY}) else() target_link_libraries(${target} ${VISIBILITY} sqlite3) endif() target_link_libraries(${target} ${VISIBILITY} lz4) target_link_libraries(${target} ${VISIBILITY} libzip) if (PCRE_LIBRARY) target_link_libraries(${target} ${VISIBILITY} ${PCRE_LIBRARY}) else() target_link_libraries(${target} ${VISIBILITY} pcre) endif() if (LIBFASTLZ_LIBRARY) target_link_libraries(${target} ${VISIBILITY} ${LIBFASTLZ_LIBRARY}) else() target_link_libraries(${target} ${VISIBILITY} fastlz) endif() target_link_libraries(${target} ${VISIBILITY} timelib) target_link_libraries(${target} ${VISIBILITY} folly) target_link_libraries(${target} ${VISIBILITY} jemalloc) target_link_libraries(${target} ${VISIBILITY} wangle) target_link_libraries(${target} ${VISIBILITY} brotli) target_link_libraries(${target} ${VISIBILITY} hhbc_ast_header) target_link_libraries(${target} ${VISIBILITY} compiler_ffi) target_link_libraries(${target} ${VISIBILITY} package_ffi) target_link_libraries(${target} ${VISIBILITY} parser_ffi) target_link_libraries(${target} ${VISIBILITY} hhvm_types_ffi) target_link_libraries(${target} ${VISIBILITY} hhvm_hhbc_defs_ffi) target_link_libraries(${target} ${VISIBILITY} tbb) if (NOT MSVC) target_link_libraries(${target} ${VISIBILITY} afdt) endif() target_link_libraries(${target} ${VISIBILITY} mbfl) if (EDITLINE_LIBRARIES) target_link_libraries(${target} ${VISIBILITY} ${EDITLINE_LIBRARIES}) elseif (READLINE_LIBRARY) target_link_libraries(${target} ${VISIBILITY} ${READLINE_LIBRARY}) endif() if (MSVC) target_link_libraries(${target} ${VISIBILITY} dbghelp.lib dnsapi.lib) endif() # Check whether atomic operations require -latomic or not # See https://github.com/facebook/hhvm/issues/5217 include(CheckCXXSourceCompiles) set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CMAKE_REQUIRED_FLAGS "-std=c++1y") CHECK_CXX_SOURCE_COMPILES(" #include <atomic> #include <iostream> #include <stdint.h> int main() { struct Test { int64_t val1; int64_t val2; }; std::atomic<Test> s; // Do this to stop modern compilers from optimizing away the libatomic // calls in release builds, making this test always pass in release builds, // and incorrectly think that HHVM doesn't need linking against libatomic. bool (std::atomic<Test>::* volatile x)(void) const = &std::atomic<Test>::is_lock_free; std::cout << (s.*x)() << std::endl; } " NOT_REQUIRE_ATOMIC_LINKER_FLAG) if(NOT "${NOT_REQUIRE_ATOMIC_LINKER_FLAG}") message(STATUS "-latomic is required to link hhvm") find_library(ATOMIC_LIBRARY NAMES atomic libatomic.so.1) if (ATOMIC_LIBRARY STREQUAL "ATOMIC_LIBRARY-NOTFOUND") # -latomic should be available for gcc even when libatomic.so.1 is not # in the library search path target_link_libraries(${target} ${VISIBILITY} atomic) else() target_link_libraries(${target} ${VISIBILITY} ${ATOMIC_LIBRARY}) endif() endif() set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) if (ENABLE_XED) if (LibXed_FOUND) target_link_libraries(${target} ${VISIBILITY} ${LibXed_LIBRARY}) else() target_link_libraries(${target} ${VISIBILITY} xed) endif() endif() if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang") # using Clang if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) target_link_libraries(${target} ${VISIBILITY} c++fs) endif() elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1) target_link_libraries(${target} ${VISIBILITY} stdc++fs) endif() endif() endmacro()
CMake
hhvm/CMake/HPHPFunctions.cmake
if (${CMAKE_MAJOR_VERSION} GREATER 2) cmake_policy(SET CMP0026 OLD) endif() include(GNUInstallDirs) function(auto_sources RETURN_VALUE PATTERN SOURCE_SUBDIRS) if ("${SOURCE_SUBDIRS}" STREQUAL "RECURSE") SET(PATH ".") if (${ARGC} EQUAL 4) list(GET ARGV 3 PATH) endif () endif() if ("${SOURCE_SUBDIRS}" STREQUAL "RECURSE") unset(${RETURN_VALUE}) file(GLOB SUBDIR_FILES "${PATH}/${PATTERN}") list(APPEND ${RETURN_VALUE} ${SUBDIR_FILES}) file(GLOB subdirs RELATIVE ${PATH} ${PATH}/*) foreach(DIR ${subdirs}) if (IS_DIRECTORY ${PATH}/${DIR}) if (NOT "${DIR}" STREQUAL "CMakeFiles") file(GLOB_RECURSE SUBDIR_FILES "${PATH}/${DIR}/${PATTERN}") list(APPEND ${RETURN_VALUE} ${SUBDIR_FILES}) endif() endif() endforeach() else () file(GLOB ${RETURN_VALUE} "${PATTERN}") foreach (PATH ${SOURCE_SUBDIRS}) file(GLOB SUBDIR_FILES "${PATH}/${PATTERN}") list(APPEND ${RETURN_VALUE} ${SUBDIR_FILES}) endforeach(PATH ${SOURCE_SUBDIRS}) endif () if (${FILTER_OUT}) list(REMOVE_ITEM ${RETURN_VALUE} ${FILTER_OUT}) endif() set(${RETURN_VALUE} ${${RETURN_VALUE}} PARENT_SCOPE) endfunction(auto_sources) macro(HHVM_SELECT_SOURCES DIR) auto_sources(files "*.cpp" "RECURSE" "${DIR}") foreach(f ${files}) if (NOT (${f} MATCHES "(ext_hhvm|/(old-)?tests?/)")) list(APPEND CXX_SOURCES ${f}) endif() endforeach() auto_sources(files "*.c" "RECURSE" "${DIR}") foreach(f ${files}) if (NOT (${f} MATCHES "(ext_hhvm|/(old-)?tests?/)")) list(APPEND C_SOURCES ${f}) endif() endforeach() if (MSVC) auto_sources(files "*.asm" "RECURSE" "${DIR}") foreach(f ${files}) if (NOT (${f} MATCHES "(ext_hhvm|/(old-)?tests?/)")) list(APPEND ASM_SOURCES ${f}) endif() endforeach() else() auto_sources(files "*.S" "RECURSE" "${DIR}") foreach(f ${files}) if (NOT (${f} MATCHES "(ext_hhvm|/(old-)?tests?/)")) list(APPEND ASM_SOURCES ${f}) endif() endforeach() endif() auto_sources(files "*.h" "RECURSE" "${DIR}") foreach(f ${files}) if (NOT (${f} MATCHES "(/(old-)?tests?/)")) list(APPEND HEADER_SOURCES ${f}) endif() endforeach() endmacro(HHVM_SELECT_SOURCES) function(CONTAINS_STRING FILE SEARCH RETURN_VALUE) file(STRINGS ${FILE} FILE_CONTENTS REGEX ".*${SEARCH}.*") if (FILE_CONTENTS) set(${RETURN_VALUE} True PARENT_SCOPE) endif() endfunction(CONTAINS_STRING) macro(MYSQL_SOCKET_SEARCH) execute_process(COMMAND mysql_config --socket OUTPUT_VARIABLE MYSQL_SOCK OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) if (NOT MYSQL_SOCK) foreach (i /var/run/mysqld/mysqld.sock /var/tmp/mysql.sock /var/run/mysql/mysql.sock /var/lib/mysql/mysql.sock /var/mysql/mysql.sock /usr/local/mysql/var/mysql.sock /Private/tmp/mysql.sock /private/tmp/mysql.sock /tmp/mysql.sock ) if (EXISTS ${i}) set(MYSQL_SOCK ${i}) break() endif() endforeach() endif() if (MYSQL_SOCK) set(MYSQL_UNIX_SOCK_ADDR ${MYSQL_SOCK} CACHE STRING "Path to MySQL Socket") endif() endmacro() function(append_systemlib TARGET SOURCE SECTNAME) if(MSVC) list(APPEND ${TARGET}_SLIBS_NAMES "${SECTNAME}") set(${TARGET}_SLIBS_NAMES ${${TARGET}_SLIBS_NAMES} PARENT_SCOPE) list(APPEND ${TARGET}_SLIBS_SOURCES "${SOURCE}") set(${TARGET}_SLIBS_SOURCES ${${TARGET}_SLIBS_SOURCES} PARENT_SCOPE) else() if (APPLE) set(${TARGET}_SLIBS ${${TARGET}_SLIBS} -Wl,-sectcreate,__text,${SECTNAME},${SOURCE} PARENT_SCOPE) else() set(${TARGET}_SLIBS ${${TARGET}_SLIBS} "--add-section" "${SECTNAME}=${SOURCE}" PARENT_SCOPE) endif() # Add the systemlib file to the "LINK_DEPENDS" for the systemlib, this will cause it # to be relinked and the systemlib re-embedded set_property(TARGET ${TARGET} APPEND PROPERTY LINK_DEPENDS ${SOURCE}) endif() endfunction(append_systemlib) function(embed_sections TARGET DEST) add_custom_command(TARGET ${TARGET} PRE_BUILD # OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/generated-compiler-id.txt" # "${CMAKE_CURRENT_SOURCE_DIR}/generated-compiler-timestamp.txt" # "${CMAKE_CURRENT_SOURCE_DIR}/generated-repo-schema-id.txt" # "${CMAKE_CURRENT_SOURCE_DIR}/generated-build-id.txt" COMMAND "INSTALL_DIR=${CMAKE_BINARY_DIR}/hphp/util" "SOURCE_ROOT=${CMAKE_SOURCE_DIR}" "${HPHP_HOME}/hphp/hhvm/generate-buildinfo.sh" WORKING_DIRECTORY "${HPHP_HOME}/hphp/util" COMMENT "Generating Repo Schema ID and Compiler ID" VERBATIM) if (APPLE) set(COMPILER_ID -Wl,-sectcreate,__text,"compiler_id","${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-id.txt") set(COMPILER_TIMESTAMP -Wl,-sectcreate,__text,"compiler_ts","${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-timestamp.txt") set(REPO_SCHEMA -Wl,-sectcreate,__text,"repo_schema_id","${CMAKE_BINARY_DIR}/hphp/util/generated-repo-schema-id.txt") set(BUILD_ID -Wl,-sectcreate,__text,"build_id","${CMAKE_BINARY_DIR}/hphp/util/generated-build-id.txt") target_link_libraries(${TARGET} ${${TARGET}_SLIBS} ${COMPILER_ID} ${COMPILER_TIMESTAMP} ${REPO_SCHEMA} ${BUILD_ID}) elseif(MSVC) set(RESOURCE_FILE "#pragma code_page(1252)\n") set(RESOURCE_FILE "${RESOURCE_FILE}LANGUAGE 0, 0\n") set(RESOURCE_FILE "${RESOURCE_FILE}\n") set(RESOURCE_FILE "${RESOURCE_FILE}#include \"${CMAKE_BINARY_DIR}/hphp/runtime/version.h\"\n") file(READ "${CMAKE_BINARY_DIR}/hphp/hhvm/hhvm.rc" VERSION_INFO) set(RESOURCE_FILE "${RESOURCE_FILE}compiler_id RCDATA \"${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-id.txt\"\n") set(RESOURCE_FILE "${RESOURCE_FILE}compiler_ts RCDATA \"${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-timestamp.txt\"\n") set(RESOURCE_FILE "${RESOURCE_FILE}repo_schema_id RCDATA \"${CMAKE_BINARY_DIR}/hphp/util/generated-repo-schema-id.txt\"\n") set(RESOURCE_FILE "${RESOURCE_FILE}build_id RCDATA \"${CMAKE_BINARY_DIR}/hphp/util/generated-build-id.txt\"\n") set(RESOURCE_FILE "${RESOURCE_FILE}${VERSION_INFO}\n") set(i 0) foreach (nm ${${TARGET}_SLIBS_NAMES}) list(GET ${TARGET}_SLIBS_SOURCES ${i} source) set(RESOURCE_FILE "${RESOURCE_FILE}${nm} RCDATA \"${source}\"\n") math(EXPR i "${i} + 1") endforeach() file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/embed.rc "${RESOURCE_FILE}") else() add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND "objcopy" ARGS "--add-section" "compiler_id=${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-id.txt" "--add-section" "compiler_ts=${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-timestamp.txt" "--add-section" "repo_schema_id=${CMAKE_BINARY_DIR}/hphp/util/generated-repo-schema-id.txt" "--add-section" "build_id=${CMAKE_BINARY_DIR}/hphp/util/generated-build-id.txt" ${${TARGET}_SLIBS} ${DEST} DEPENDS "${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-id.txt" "${CMAKE_BINARY_DIR}/hphp/util/generated-compiler-timestamp.txt" "${CMAKE_BINARY_DIR}/hphp/util/generated-repo-schema-id.txt" "${CMAKE_BINARY_DIR}/hphp/util/generated-build-id.txt" COMMENT "Embedding php in ${TARGET}") endif() endfunction(embed_sections) macro(embed_systemlib_byname TARGET SLIB) get_filename_component(SLIB_BN ${SLIB} "NAME_WE") string(LENGTH ${SLIB_BN} SLIB_BN_LEN) math(EXPR SLIB_BN_REL_LEN "${SLIB_BN_LEN} - 4") string(SUBSTRING ${SLIB_BN} 4 ${SLIB_BN_REL_LEN} SLIB_EXTNAME) string(MD5 SLIB_HASH_NAME ${SLIB_EXTNAME}) # Some platforms limit section names to 16 characters :( string(SUBSTRING ${SLIB_HASH_NAME} 0 12 SLIB_HASH_NAME_SHORT) if (MSVC) # The dot would be causing the RC lexer to begin a number in the # middle of our resource name, so use an underscore instead. append_systemlib(${TARGET} ${SLIB} "ext_${SLIB_HASH_NAME_SHORT}") else() append_systemlib(${TARGET} ${SLIB} "ext.${SLIB_HASH_NAME_SHORT}") endif() endmacro() function(embed_all_systemlibs TARGET ROOT DEST) add_dependencies(${TARGET} systemlib) append_systemlib(${TARGET} ${ROOT}/system/systemlib.php systemlib) foreach(SLIB ${EXTENSION_SYSTEMLIB_SOURCES} ${EZC_SYSTEMLIB_SOURCES}) embed_systemlib_byname(${TARGET} ${SLIB}) endforeach() embed_sections(${TARGET} ${DEST}) endfunction(embed_all_systemlibs) # Custom install function that doesn't relink, instead it uses chrpath to change it, if # it's available, otherwise, it leaves the chrpath alone function(HHVM_INSTALL TARGET DEST) get_target_property(LOC ${TARGET} LOCATION) get_target_property(TY ${TARGET} TYPE) if (FOUND_CHRPATH) get_target_property(RPATH ${TARGET} INSTALL_RPATH) if (NOT RPATH STREQUAL "RPATH-NOTFOUND") if (RPATH STREQUAL "") install(CODE "execute_process(COMMAND \"${CHRPATH}\" \"-d\" \"${LOC}\" ERROR_QUIET)") else() install(CODE "execute_process(COMMAND \"${CHRPATH}\" \"-r\" \"${RPATH}\" \"${LOC}\" ERROR_QUIET)") endif() endif() endif() string(TOUPPER ${DEST} DEST_UPPER) install(CODE "FILE(INSTALL DESTINATION \"${CMAKE_INSTALL_FULL_${DEST_UPPER}DIR}\" TYPE ${TY} FILES \"${LOC}\")") endfunction(HHVM_INSTALL) function(HHVM_PUBLIC_HEADERS TARGET) install( CODE "INCLUDE(\"${HPHP_HOME}/CMake/HPHPFunctions.cmake\") HHVM_INSTALL_HEADERS(${TARGET} ${HPHP_HOME} \"${CMAKE_INSTALL_FULL_INCLUDEDIR}\" ${ARGN})" COMPONENT dev) endfunction() function(HHVM_INSTALL_HEADERS TARGET SRCROOT DEST) message(STATUS "Installing header files for ${TARGET}") foreach(src_rel ${ARGN}) # Determine the relative directory name so that we can mirror the # directory structure in the output file(RELATIVE_PATH dest_rel ${SRCROOT} ${src_rel}) if (IS_ABSOLUTE ${dest_rel}) message(WARNING "${TARGET}: Header file ${dest_rel} is not inside ${SRCROOT}") else() string(FIND ${dest_rel} / slash_pos REVERSE) if(slash_pos EQUAL -1) set(dest_rel) else() string(SUBSTRING ${dest_rel} 0 ${slash_pos} dest_rel) endif() file(COPY ${src_rel} DESTINATION "$ENV{DESTDIR}${DEST}/${dest_rel}" NO_SOURCE_PERMISSIONS) endif() endforeach() endfunction() macro(HHVM_EXT_OPTION EXTNAME PACKAGENAME) if (NOT DEFINED EXT_${EXTNAME}) # Implicit check find_package(${PACKAGENAME}) elseif (EXT_${EXTNAME} STREQUAL "ON") # Explicit check find_package(${PACKAGENAME} REQUIRED) endif() endmacro() # Remove all files matching a set of patterns, and, # optionally, not matching a second set of patterns, # from a set of lists. # # Example: # This will remove all files in the CPP_SOURCES list # matching "/test/" or "Test.cpp$", but not matching # "BobTest.cpp$". # HHVM_REMOVE_MATCHES_FROM_LISTS(CPP_SOURCES MATCHES "/test/" "Test.cpp$" IGNORE_MATCHES "BobTest.cpp$") # # Parameters: # # [...]: # The names of the lists to remove matches from. # # [MATCHES ...]: # The matches to remove from the lists. # # [IGNORE_MATCHES ...]: # The matches not to remove, even if they match # the main set of matches to remove. function(HHVM_REMOVE_MATCHES_FROM_LISTS) set(LISTS_TO_SEARCH) set(MATCHES_TO_REMOVE) set(MATCHES_TO_IGNORE) set(argumentState 0) foreach (arg ${ARGN}) if ("x${arg}" STREQUAL "xMATCHES") set(argumentState 1) elseif ("x${arg}" STREQUAL "xIGNORE_MATCHES") set(argumentState 2) elseif (argumentState EQUAL 0) list(APPEND LISTS_TO_SEARCH ${arg}) elseif (argumentState EQUAL 1) list(APPEND MATCHES_TO_REMOVE ${arg}) elseif (argumentState EQUAL 2) list(APPEND MATCHES_TO_IGNORE ${arg}) else() message(FATAL_ERROR "Unknown argument state!") endif() endforeach() foreach (theList ${LISTS_TO_SEARCH}) foreach (entry ${${theList}}) foreach (match ${MATCHES_TO_REMOVE}) if (${entry} MATCHES ${match}) set(SHOULD_IGNORE OFF) foreach (ign ${MATCHES_TO_IGNORE}) if (${entry} MATCHES ${ign}) set(SHOULD_IGNORE ON) break() endif() endforeach() if (NOT SHOULD_IGNORE) list(REMOVE_ITEM ${theList} ${entry}) endif() endif() endforeach() endforeach() set(${theList} ${${theList}} PARENT_SCOPE) endforeach() endfunction() # Automatically create source_group directives for the sources passed in. function(auto_source_group rootName rootDir) file(TO_CMAKE_PATH "${rootDir}" rootDir) string(LENGTH "${rootDir}" rootDirLength) set(sourceGroups) foreach (fil ${ARGN}) file(TO_CMAKE_PATH "${fil}" filePath) string(FIND "${filePath}" "/" rIdx REVERSE) if (rIdx EQUAL -1) message(FATAL_ERROR "Unable to locate the final forward slash in '${filePath}'!") endif() string(SUBSTRING "${filePath}" 0 ${rIdx} filePath) string(LENGTH "${filePath}" filePathLength) string(FIND "${filePath}" "${rootDir}" rIdx) if (rIdx EQUAL 0) math(EXPR filePathLength "${filePathLength} - ${rootDirLength}") string(SUBSTRING "${filePath}" ${rootDirLength} ${filePathLength} fileGroup) string(REPLACE "/" "\\" fileGroup "${fileGroup}") set(fileGroup "\\${rootName}${fileGroup}") list(FIND sourceGroups "${fileGroup}" rIdx) if (rIdx EQUAL -1) list(APPEND sourceGroups "${fileGroup}") source_group("${fileGroup}" REGULAR_EXPRESSION "${filePath}/[^/.]+(.(tab|yy))?.(c|cc|cpp|h|hpp|ll|php|tcc|y)$") endif() endif() endforeach() endfunction() function(parse_version PREFIX VERSION) if (NOT ${VERSION} MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+)?(-.+)?$") message(FATAL_ERROR "VERSION must conform to X.Y(.Z)?(-.+)?") endif() string(FIND ${VERSION} "-" SUFFIX_POS) set(SUFFIX "") if (SUFFIX_POS) string(SUBSTRING ${VERSION} ${SUFFIX_POS} -1 SUFFIX) string(SUBSTRING ${VERSION} 0 ${SUFFIX_POS} NUMERIC_VERSION) else() set(NUMERIC_VERSION ${VERSION}) endif() string(REPLACE "." ";" VERSION_LIST "${NUMERIC_VERSION}") list(GET VERSION_LIST 0 MAJOR) list(GET VERSION_LIST 1 MINOR) list(LENGTH VERSION_LIST VERSION_LIST_LENGTH) if (VERSION_LIST_LENGTH GREATER 2) list(GET VERSION_LIST 2 PATCH) else() set(PATCH 0) endif() set(${PREFIX}MAJOR ${MAJOR} PARENT_SCOPE) set(${PREFIX}MINOR ${MINOR} PARENT_SCOPE) set(${PREFIX}PATCH ${PATCH} PARENT_SCOPE) set(${PREFIX}SUFFIX ${SUFFIX} PARENT_SCOPE) endfunction() # MSVC doesn't support a --whole-archive flag, but newer versions # of CMake do support object libraries, which give the same result. # As we can't easily upgrade the normal builds to CMake 3.0, we # will just require CMake 3.0+ for MSVC builds only. function(add_object_library libraryName) if (MSVC) add_library(${libraryName} OBJECT ${ARGN}) else() add_library(${libraryName} STATIC ${ARGN}) endif() endfunction() # Get what might be the objects of the object libraries, if needed. function(get_object_libraries_objects targetVariable) set(OBJECTS) if (MSVC) foreach (fil ${ARGN}) list(APPEND OBJECTS $<TARGET_OBJECTS:${fil}>) endforeach() endif() set(${targetVariable} ${OBJECTS} PARENT_SCOPE) endfunction() # Add the additional link targets for a set of object libraries, # if needed. function(link_object_libraries target) if (MSVC) return() endif() set(WHOLE_ARCHIVE_LIBS) foreach (fil ${ARGN}) list(APPEND WHOLE_ARCHIVE_LIBS ${fil}) endforeach() set(ANCHOR_SYMS) if (APPLE) set(ANCHOR_SYMS -Wl,-pagezero_size,0x00001000 # Set the .text.keep section to be executable. -Wl,-segprot,.text,rx,rx) foreach(lib ${WHOLE_ARCHIVE_LIBS}) # It's important to use -Xlinker and not -Wl here: ${lib} needs to be its # own option on the command line, since target_link_libraries will expand it # from its logical name here into the full .a path. (Eww.) list(APPEND ANCHOR_SYMS -Xlinker -force_load -Xlinker ${lib}) endforeach() else() set(ANCHOR_SYMS -Wl,--whole-archive ${WHOLE_ARCHIVE_LIBS} -Wl,--no-whole-archive) endif() target_link_libraries(${target} ${ANCHOR_SYMS}) endfunction() # This should be called for object libraries, rather than calling # hphp_link directly. function(object_library_hphp_link target) # MSVC can't have it. (see below) if (NOT MSVC) hphp_link(${target}) endif() endfunction() # If a library needs to be linked in to make GNU ld happy, # it should be done by calling this. function(object_library_ld_link_libraries target) if (${ARGC}) # CMake doesn't allow calls to target_link_libraries if the target # is an OBJECT library, so MSVC can't have this. if (NOT MSVC) target_link_libraries(${target} ${ARGN}) endif() endif() endfunction() set( HHVM_THIRD_PARTY_SOURCE_CACHE_PREFIX "" CACHE STRING "URL prefix containing cache of third-party dependencies" ) set( HHVM_THIRD_PARTY_SOURCE_CACHE_SUFFIX "" CACHE STRING "URL suffix for third-party dependency cache" ) set( HHVM_THIRD_PARTY_SOURCE_ONLY_USE_CACHE OFF CACHE BOOL "Do not download sources that are not in cache; may cause build to fail." ) set( HHVM_THIRD_PARTY_SOURCE_URL_LIST_OUTPUT "" CACHE STRING "Path to a text file to put a list of sources that should be in the cache" ) # Usage: # SET_HHVM_THIRD_PARTY_SOURCE_ARGS( # MY_VAR_NAME # SOURCE_URL https://example.com/ # SOURCE_HASH SHA256=deadbeef # ) # ... or ... # SET_HHVM_THIRD_PARTY_SOURCE_ARGS( # MY_VAR_NAME # Linux_URL https://example.com/linux.tar.bz2 # Linux_HASH SHA256=deadbeef # Darwin_URL https://example.com/macos.tar.bz2 # Darwin_HASH SHA256=deadbeef # ) # macro(SET_HHVM_THIRD_PARTY_SOURCE_ARGS VAR_NAME) cmake_parse_arguments( # Prefix (FOO becomes _arg_FOO - trailing _ implied) _arg # No-arg parameter (none): "" # Single-argument parameters "SOURCE_URL;SOURCE_HASH;Linux_URL;Linux_HASH;Darwin_URL;Darwin_HASH;FILENAME_PREFIX" # Multi-argument parameters (none) "" ${ARGN} ) # Try source, but fall back to platform-specific if (NOT "${_arg_SOURCE_URL}" STREQUAL "") set(_URL "${_arg_SOURCE_URL}") set("${VAR_NAME}" URL_HASH "${_arg_SOURCE_HASH}") if (NOT "${HHVM_THIRD_PARTY_SOURCE_URL_LIST_OUTPUT}" STREQUAL "") FILE( APPEND "${HHVM_THIRD_PARTY_SOURCE_URL_LIST_OUTPUT}" "${_arg_SOURCE_URL}\n" ) endif() else() set(_URL "${_arg_${CMAKE_HOST_SYSTEM_NAME}_URL}") set("${VAR_NAME}" URL_HASH "${_arg_${CMAKE_HOST_SYSTEM_NAME}_HASH}") if (NOT "${HHVM_THIRD_PARTY_SOURCE_URL_LIST_OUTPUT}" STREQUAL "") FILE( APPEND "${HHVM_THIRD_PARTY_SOURCE_URL_LIST_OUTPUT}" "${_arg_Linux_URL}\n" "${_arg_Darwin_URL}\n" ) endif() endif() get_filename_component("_URL_NAME" "${_URL}" NAME) if ("${HHVM_THIRD_PARTY_SOURCE_CACHE_PREFIX}" STREQUAL "") list(APPEND ${VAR_NAME} URL "${_URL}") if (${HHVM_THIRD_PARTY_SOURCE_ONLY_USE_CACHE}) message( FATAL_ERROR "HHVM_THIRD_PARTY_ONLY_USE_CACHE is set, but cache is not configured" ) endif() else() list( APPEND "${VAR_NAME}" URL "${HHVM_THIRD_PARTY_SOURCE_CACHE_PREFIX}${_arg_FILENAME_PREFIX}${_URL_NAME}${HHVM_THIRD_PARTY_SOURCE_CACHE_SUFFIX}" ) if (NOT ${HHVM_THIRD_PARTY_SOURCE_ONLY_USE_CACHE}) list(APPEND "${VAR_NAME}" "${_URL}") endif() endif() list(APPEND "${VAR_NAME}" DOWNLOAD_NAME "${_arg_FILENAME_PREFIX}${_URL_NAME}") message(STATUS "Download name: ${_arg_FILENAME_PREFIX}${_URL_NAME}") endmacro()
CMake
hhvm/CMake/HPHPIZEFunctions.cmake
# Functions for use when building extensions dynamically # These functions also exist in CMake/EXTFunctions.cmake # Their signatures should be kept consistent, though their behavior # will differ slightly. include(GNUInstallDirs) function(HHVM_LINK_LIBRARIES EXTNAME) target_link_libraries(${EXTNAME} ${ARGN}) endfunction() function(HHVM_ADD_INCLUDES EXTNAME) include_directories(${ARGN}) endfunction() # Add an extension function(HHVM_EXTENSION EXTNAME) set(EXTENSION_NAME ${EXTNAME} CACHE INTERNAL "") add_library(${EXTNAME} SHARED ${ARGN}) set_target_properties(${EXTNAME} PROPERTIES PREFIX "") set_target_properties(${EXTNAME} PROPERTIES SUFFIX ".so") get_target_property(LOC ${EXTNAME} LOCATION) get_target_property(TY ${EXTNAME} TYPE) # Don't install via target, because it triggers a re-link that doesn't # run the POST_BUILD custom command that embeds the systemlib on Linux. install(CODE "FILE(INSTALL DESTINATION \"${CMAKE_INSTALL_FULL_LIBDIR}/hhvm/extensions/${HHVM_VERSION_BRANCH}\" TYPE ${TY} FILES \"${LOC}\")") endfunction() function(embed_systemlibs TARGET DEST) if (APPLE) target_link_libraries(${TARGET} ${${TARGET}_SLIBS}) elseif (MSVC) message(FATAL_ERROR "Shared extensions are not supported on Windows") else() add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND "objcopy" ARGS ${${TARGET}_SLIBS} ${DEST} COMMENT "Embedding php in ${TARGET}") endif() endfunction(embed_systemlibs) function(HHVM_SYSTEMLIB EXTNAME) foreach (SLIB ${ARGN}) embed_systemlib_byname(${EXTNAME} ${SLIB}) endforeach() embed_systemlibs(${EXTNAME} "${EXTNAME}.so") endfunction() function(HHVM_DEFINE EXTNAME) add_definitions(${ARGN}) endfunction()
CMake
hhvm/CMake/HPHPSetup.cmake
include(Options) include(GNUInstallDirs) set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug DebugOpt RelWithDebInfo) set(HHVM_WHOLE_ARCHIVE_LIBRARIES hphp_runtime_static hphp_runtime_ext ) set(HHVM_WRAP_SYMS) # Oniguruma ('onig') must be first: # # oniguruma has some of its own implementations of POSIX regex functions, # like regcomp() and regexec(). We use onig everywhere, for both its own # special functions and for the POSIX replacements. This means that the # linker needs to pick the implementations of the POSIX regex functions from # onig, not libc. # # On Linux, that works out fine, since the linker sees onig on the link # line before (implicitly) libc. However, on OS X, despite the manpage for # ld claiming otherwise about indirect dylib dependencies, as soon as we # include one of the libs here that pull in libSystem.B, the linker will # pick the implementations of those functions from libc, not from onig. # And since we've included the onig headers, which have very slightly # different definitions for some of the key data structures, things go # quite awry -- this manifests as infinite loops or crashes when calling # the PHP split() function. # # So make sure to link onig first, so its implementations are picked. # # Using the generator expression to explicitly pull the path in early, otherwise # it gets resolved later and put later in the build arguments, and makes # hphp/test/slow/ext_preg segfault. set(HHVM_LINK_LIBRARIES $<TARGET_PROPERTY:onig,INTERFACE_LINK_LIBRARIES> ${HHVM_WRAP_SYMS} hphp_analysis hphp_system hphp_zend hphp_util hphp_hhbbc jit_sort vixl neo) if(ENABLE_FASTCGI) LIST(APPEND HHVM_LINK_LIBRARIES thrift) LIST(APPEND HHVM_LINK_LIBRARIES proxygen) include(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES("#include <pthread.h> int main() { return pthread_mutex_timedlock(); }" PTHREAD_TIMEDLOCK) if (NOT PTHREAD_TIMEDLOCK) add_definitions(-DTHRIFT_MUTEX_EMULATE_PTHREAD_TIMEDLOCK) endif() endif() if(HHVM_DYNAMIC_EXTENSION_DIR) add_definitions(-DHHVM_DYNAMIC_EXTENSION_DIR="${HHVM_DYNAMIC_EXTENSION_DIR}") else() if(UNIX) add_definitions(-DHHVM_DYNAMIC_EXTENSION_DIR="${CMAKE_INSTALL_FULL_LIBDIR}/hhvm/extensions") endif() endif() # Look for the chrpath tool so we can warn if it's not there SET(FOUND_CHRPATH OFF) IF(UNIX AND NOT APPLE) find_program(CHRPATH chrpath) IF (NOT CHRPATH STREQUAL "CHRPATH-NOTFOUND") SET(FOUND_CHRPATH ON) endif() ENDIF(UNIX AND NOT APPLE) LIST(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") if(APPLE) if(EXISTS "/opt/local/var/macports/") LIST (APPEND CMAKE_PREFIX_PATH "/opt/local") LIST (APPEND CMAKE_LIBRARY_PATH "/opt/local/lib/x86_64") endif() endif() include(HPHPCompiler) include(HPHPFunctions) include(HPHPFindLibs) if (HHVM_VERSION_OVERRIDE) parse_version("HHVM_VERSION_" ${HHVM_VERSION_OVERRIDE}) add_definitions("-DHHVM_VERSION_OVERRIDE") add_definitions("-DHHVM_VERSION_MAJOR=${HHVM_VERSION_MAJOR}") add_definitions("-DHHVM_VERSION_MINOR=${HHVM_VERSION_MINOR}") add_definitions("-DHHVM_VERSION_PATCH=${HHVM_VERSION_PATCH}") add_definitions("-DHHVM_VERSION_SUFFIX=\"${HHVM_VERSION_SUFFIX}\"") endif() add_definitions(-D_REENTRANT=1 -D_PTHREADS=1 -D__STDC_FORMAT_MACROS) if (LINUX) add_definitions(-D_GNU_SOURCE) endif() if(MSVC) add_definitions(-DGLOG_NO_ABBREVIATED_SEVERITIES) add_definitions(-DWIN32_LEAN_AND_MEAN) endif() if(CMAKE_CONFIGURATION_TYPES) if(NOT MSVC) message(FATAL_ERROR "Adding the appropriate defines for multi-config targets using anything other than MSVC is not yet supported!") endif() foreach(flag_var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) set(${flag_var} "${${flag_var}} /D NDEBUG") endforeach() elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug" OR ${CMAKE_BUILD_TYPE} MATCHES "DebugOpt") message("Generating DEBUG build") else() add_definitions(-DNDEBUG) message("Generating Release build") endif() if(ALWAYS_ASSERT) add_definitions(-DALWAYS_ASSERT=1) endif() if(APPLE OR FREEBSD OR MSVC) add_definitions(-DSKIP_USER_CHANGE=1) endif() if(ENABLE_TRACE) add_definitions(-DUSE_TRACE=1) endif() if(APPLE) # We have to be a little more permissive in some cases. add_definitions(-fpermissive) # Skip deprecation warnings in OpenSSL. add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_6) # Enable weak linking add_definitions(-DMACOSX_DEPLOYMENT_TARGET=10.6) endif() if(ENABLE_FASTCGI) add_definitions(-DENABLE_FASTCGI=1) endif () if(DISABLE_HARDWARE_COUNTERS OR NOT LINUX) add_definitions(-DNO_HARDWARE_COUNTERS=1) endif () # enable the OSS options if we have any add_definitions(-DHPHP_OSS=1) # later versions of binutils don't play well without automake add_definitions(-DPACKAGE=hhvm -DPACKAGE_VERSION=Release) add_definitions(-DDEFAULT_CONFIG_DIR="${DEFAULT_CONFIG_DIR}") add_definitions(-DHAVE_INTTYPES_H) # Load system tzdata if present # Works on Linux and Mac; given that we don't want to (and basically don't) # update the bundled tzdata, if this doesn't work on some platform, please # blacklist the platform rather than whitelisting others. option(USE_BUNDLED_TZDATA "Use bundled system tzdata instead of /usr/share/zoneinfo" OFF) if (NOT ${USE_BUNDLED_TZDATA}) if (NOT DEFINED HAVE_SYSTEM_TZDATA AND NOT EXISTS /usr/share/zoneinfo) message(FATAL_ERROR "/usr/share/zoneinfo does not exist, and USE_BUNDLED_TZDATA not set") endif() add_definitions(-DHAVE_SYSTEM_TZDATA) endif() include_directories(${TP_DIR}) if (THIRD_PARTY_INCLUDE_PATHS) include_directories(${THIRD_PARTY_INCLUDE_PATHS}) add_definitions(${THIRD_PARTY_DEFINITIONS}) include_directories(${HPHP_HOME}/hphp) include_directories(${HPHP_HOME}) endif() if (ENABLE_SYSTEM_LOCALE_ARCHIVE) add_definitions(-DENABLE_SYSTEM_LOCALE_ARCHIVE) endif()
CMake
hhvm/CMake/MSVCDefaults.cmake
# This file exists because, in order to handle the multi-config environment that # Visual Studio allows, we'd have to modify quite a few of CMake's built-in # scripts for finding specific libraries. Instead of doing that, we just set the # required variables here if the /deps/ directory is present. # We assume in this that, if the directory exists, all libs that are part of # the package are present. if (EXISTS "${HPHP_HOME}/deps/") message(STATUS "Using default paths for MSVC libs.") set(depRoot "${HPHP_HOME}/deps") set(incRoot "${depRoot}/include") set(libRoot "${depRoot}/lib") # First up a few variables to make things configure the first time. # Disable a few extensions that we can't currently build because we can't # compile the library they depend on. set(ENABLE_MCROUTER OFF CACHE BOOL "") set(ENABLE_EXTENSION_MEMCACHE OFF CACHE BOOL "") set(ENABLE_EXTENSION_MEMCACHED OFF CACHE BOOL "") set(ENABLE_EXTENSION_MYSQL OFF CACHE BOOL "") set(ENABLE_EXTENSION_MYSQLI OFF CACHE BOOL "") set(ENABLE_EXTENSION_PDO_MYSQL OFF CACHE BOOL "") set(MYSQL_UNIX_SOCK_ADDR "/dev/null" CACHE PATH "") # We need to link against the static library version of boost targeting the static # runtime, so set the vars required by default. set(BOOST_INCLUDEDIR "${incRoot}" CACHE PATH "") set(BOOST_LIBRARYDIR "${libRoot}/lib64-msvc-14.0" CACHE PATH "") set(Boost_USE_STATIC_LIBS ON CACHE BOOL "") set(Boost_USE_STATIC_RUNTIME ON CACHE BOOL "") # GPerf is needed for proxygen, so a precompiled version of it is included # in the deps package. set(GPERF_EXECUTABLE "${depRoot}/bin/gperf.exe" CACHE STRING "") # And now the actual libs. Please keep them alphabetical, and keep the lib # values with any system libs first, then the debug version, and finally the # release version. Also, when setting the variables, set the include directory # first, then any library variables, and finally any misc. variables. set(BZIP2_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(BZIP2_LIBRARIES "debug;${libRoot}/libbz2MTd.lib;optimized;${libRoot}/libbz2MT.lib" CACHE FILEPATH "") set(CURL_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(CURL_LIBRARY "Wldap32.lib;debug;${libRoot}/libcurlMTd.lib;optimized;${libRoot}/libcurlMT.lib" CACHE FILEPATH "") set(CURL_STATIC ON CACHE BOOL "") set(EXPAT_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(EXPAT_LIBRARY "debug;${libRoot}/expatMTd.lib;optimized;${libRoot}/expatMT.lib" CACHE FILEPATH "") set(EXPAT_STATIC ON CACHE BOOL "") set(FREETYPE_INCLUDE_DIRS "${incRoot}" CACHE PATH "") set(FREETYPE_LIBRARIES "debug;${libRoot}/libfreetypeMTd.lib;optimized;${libRoot}/libfreetypeMT.lib" CACHE FILEPATH "") # Fribidi isn't part of the main package, as the extension isn't supported # under MSVC yet, but we'll set the vars here if it's present. if (EXISTS "${libRoot}/libfribidiMTd.lib") set(FRIBIDI_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(FRIBIDI_LIBRARY "debug;${libRoot}/libfribidiMTd.lib;optimized;${libRoot}/libfribidiMT.lib" CACHE FILEPATH "") endif() set(GMP_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(GMP_LIBRARY "debug;${libRoot}/libgmpMTd.lib;optimized;${libRoot}/libgmpMT.lib" CACHE FILEPATH "") set(ICU_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(ICU_DATA_LIBRARY "debug;${libRoot}/sicudtd.lib;optimized;${libRoot}/sicudt.lib" CACHE FILEPATH "") set(ICU_I18N_LIBRARY "debug;${libRoot}/sicuind.lib;optimized;${libRoot}/sicuin.lib" CACHE FILEPATH "") set(ICU_LIBRARY "debug;${libRoot}/sicuucd.lib;optimized;${libRoot}/sicuuc.lib" CACHE FILEPATH "") set(ICU_STATIC ON CACHE BOOL "") set(LIBEVENT_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(LIBEVENT_LIB "general;Ws2_32.lib;debug;${libRoot}/eventMTd.lib;debug;${libRoot}/event_coreMTd.lib;debug;${libRoot}/event_extraMTd.lib;optimized;${libRoot}/eventMT.lib;optimized;${libRoot}/event_coreMT.lib;optimized;${libRoot}/event_extraMT.lib" CACHE FILEPATH "") set(GLOG_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(GLOG_LIBRARY "debug;${libRoot}/libglogMTd.lib;optimized;${libRoot}/libglogMT.lib" CACHE FILEPATH "") set(GLOG_STATIC ON CACHE BOOL "") set(LIBICONV_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(LIBICONV_LIBRARY "debug;${libRoot}/iconvMTd.lib;optimized;${libRoot}/iconvMT.lib" CACHE FILEPATH "") set(LIBICONV_CONST ON CACHE BOOL "") set(LIBINTL_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(LIBINTL_LIBRARY "debug;${libRoot}/libintlMTd.lib;optimized;${libRoot}/libintlMT.lib" CACHE FILEPATH "") set(LIBJPEG_INCLUDE_DIRS "${incRoot}" CACHE PATH "") set(LIBJPEG_LIBRARIES "debug;${libRoot}/libjpegMTd.lib;optimized;${libRoot}/libjpegMT.lib" CACHE FILEPATH "") # LibMagicWand includes a LOT of dependent libraries, 17 here, and another 3 # that other extensions are dependent on, so are set through those variables. # Specifically, Freetype, libJpeg, and libPng. set(LIBMAGICKWAND_INCLUDE_DIRS "${incRoot}" CACHE PATH "") set(LIBMAGICKCORE_LIBRARIES "debug;${libRoot}/libcairoMTd.lib;debug;${libRoot}/libcodersMTd.lib;debug;${libRoot}/libcrocoMTd.lib;debug;${libRoot}/libexrMTd.lib;debug;${libRoot}/libffiMTd.lib;debug;${libRoot}/libfiltersMTd.lib;debug;${libRoot}/libglibMTd.lib;debug;${libRoot}/libjp2MTd.lib;debug;${libRoot}/liblcmsMTd.lib;debug;${libRoot}/liblqrMTd.lib;debug;${libRoot}/libmagickMTd.lib;debug;${libRoot}/libopenjpegMTd.lib;debug;${libRoot}/libpangoMTd.lib;debug;${libRoot}/libpixmanMTd.lib;debug;${libRoot}/librsvgMTd.lib;debug;${libRoot}/libtiffMTd.lib;debug;${libRoot}/libwebpMTd.lib;optimized;${libRoot}/libcairoMT.lib;optimized;${libRoot}/libcodersMT.lib;optimized;${libRoot}/libcrocoMT.lib;optimized;${libRoot}/libexrMT.lib;optimized;${libRoot}/libffiMT.lib;optimized;${libRoot}/libfiltersMT.lib;optimized;${libRoot}/libglibMT.lib;optimized;${libRoot}/libjp2MT.lib;optimized;${libRoot}/liblcmsMT.lib;optimized;${libRoot}/liblqrMT.lib;optimized;${libRoot}/libmagickMT.lib;optimized;${libRoot}/libopenjpegMT.lib;optimized;${libRoot}/libpangoMT.lib;optimized;${libRoot}/libpixmanMT.lib;optimized;${libRoot}/librsvgMT.lib;optimized;${libRoot}/libtiffMT.lib;optimized;${libRoot}/libwebpMT.lib" CACHE FILEPATH "") set(LIBMAGICKWAND_LIBRARIES "debug;${libRoot}/libwandMTd.lib;optimized;${libRoot}/libwandMT.lib" CACHE FILEPATH "") set(LIBPNG_INCLUDE_DIRS "${incRoot}" CACHE PATH "") set(LIBPNG_LIBRARIES "debug;${libRoot}/libpngMTd.lib;optimized;${libRoot}/libpngMT.lib" CACHE FILEPATH "") set(LIBPTHREAD_INCLUDE_DIRS "${incRoot}" CACHE PATH "") set(LIBPTHREAD_LIBRARIES "debug;${libRoot}/libpthreadMTd.lib;optimized;${libRoot}/libpthreadMT.lib" CACHE FILEPATH "") set(LIBPTHREAD_STATIC ON CACHE BOOL "") set(LIBXML2_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(LIBXML2_LIBRARIES "debug;${libRoot}/libxml2MTd.lib;optimized;${libRoot}/libxml2MT.lib" CACHE FILEPATH "") set(LIBXML2_DEFINITIONS "-DLIBXML_STATIC" CACHE STRING "") # Due to being slightly lazy, exslt is built as part of xslt, so both set both # variables to the same value, and let CMake get rid of the duplicates. set(LIBXSLT_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(LIBXSLT_LIBRARIES "debug;${libRoot}/libxsltMTd.lib;optimized;${libRoot}/libxsltMT.lib" CACHE FILEPATH "") set(LIBXSLT_EXSLT_LIBRARY "debug;${libRoot}/libxsltMTd.lib;optimized;${libRoot}/libxsltMT.lib" CACHE FILEPATH "") set(LIBXSLT_STATIC ON CACHE BOOL "") set(Mcrypt_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(Mcrypt_LIB "debug;${libRoot}/libmcryptMTd.lib;optimized;${libRoot}/libmcryptMT.lib" CACHE FILEPATH "") # Oniguruma is just weird and grumpy, so we set that it's been found explicitly. set(ONIGURUMA_FOUND ON CACHE BOOL "" FORCE) set(ONIGURUMA_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(ONIGURUMA_LIBRARY "debug;${libRoot}/onigMTd.lib;optimized;${libRoot}/onigMT.lib" CACHE FILEPATH "") set(ONIGURUMA_STATIC ON CACHE BOOL "") set(OPENSSL_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(LIB_EAY_DEBUG "${libRoot}/libeay32MTd.lib" CACHE FILEPATH "") set(LIB_EAY_RELEASE "${libRoot}/libeay32MT.lib" CACHE FILEPATH "") set(SSL_EAY_DEBUG "${libRoot}/ssleay32MTd.lib" CACHE FILEPATH "") set(SSL_EAY_RELEASE "${libRoot}/ssleay32MT.lib" CACHE FILEPATH "") set(READLINE_INCLUDE_DIR "${incRoot}" CACHE PATH "") set(READLINE_LIBRARY "debug;${libRoot}/readlineMTd.lib;optimized;${libRoot}/readlineMT.lib" CACHE FILEPATH "") set(READLINE_STATIC ON CACHE BOOL "") # TBB's found detection is weird, so we have to set all of these. set(TBB_INSTALL_DIR "${depRoot}" CACHE PATH "") set(TBB_LIBRARY_DIRS "${depRoot}" CACHE PATH "") set(TBB_LIBRARY "${libRoot}/tbb.lib" CACHE FILEPATH "") set(TBB_LIBRARY_DEBUG "${libRoot}/tbb_debug.lib" CACHE FILEPATH "") set(TBB_MALLOC_LIBRARY "${libRoot}/tbbmalloc.lib" CACHE FILEPATH "") set(TBB_MALLOC_LIBRARY_DEBUG "${libRoot}/tbbmalloc_debug.lib" CACHE FILEPATH "") set(ZLIB_ROOT "${depRoot}" CACHE PATH "") set(ZLIB_LIBRARY "debug;${libRoot}/zlibMTd.lib;optimized;${libRoot}/zlibMT.lib" CACHE FILEPATH "") endif()
CMake
hhvm/CMake/Options.cmake
#set(CMAKE_BUILD_TYPE Debug) option(ALWAYS_ASSERT "Enabled asserts in a release build" OFF) option(ENABLE_SSP "Enabled GCC/LLVM stack-smashing protection" OFF) option(STATIC_CXX_LIB "Statically link libstd++ and libgcc." OFF) option(ENABLE_AVX2 "Enable the use of AVX2 instructions" OFF) option(ENABLE_AARCH64_CRC "Enable the use of CRC instructions" OFF) option(ENABLE_FASTCGI "Enable the FastCGI interface." ON) option(ENABLE_SSE4_2 "Enable SSE4.2 supported code." OFF) option(EXECUTION_PROFILER "Enable the execution profiler" OFF) option(USE_JEMALLOC "Use jemalloc" ON) option(FORCE_TP_JEMALLOC "Always build and statically link jemalloc instead of using system version" OFF) option(ENABLE_HHPROF "Enable HHProf" OFF) option(CLANG_FORCE_LIBSTDCXX "Force libstdc++ when building against Clang/LLVM" OFF) option(USE_TCMALLOC "Use tcmalloc (if jemalloc is not used)" ON) option(USE_GOOGLE_HEAP_PROFILER "Use Google heap profiler" OFF) option(USE_GOOGLE_CPU_PROFILER "Use Google cpu profiler" OFF) option(DISABLE_HARDWARE_COUNTERS "Disable hardware counters (for XenU systems)" OFF) option(ENABLE_TRACE "Enable tracing in release build" OFF) option(CPACK_GENERATOR "Enable build of distribution packages using CPack" OFF) option(ENABLE_COTIRE "Speed up the build by precompiling headers" OFF) include(CheckCXXSymbolExists) # Mcrouter uses Folly's AtomicSharedPtr, which only supports libstdc++ # See https://github.com/facebook/hhvm/blob/156a77d5a301033200601ddefb4dcaf26eb1ff9c/third-party/folly/src/folly/concurrency/detail/AtomicSharedPtr-detail.h#L28-L34 check_cxx_symbol_exists(__GLIBCXX__ cstdlib DEFAULT_STDLIB_IS_LIBSTDCXX) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CLANG_FORCE_LIBSTDCXX OR DEFAULT_STDLIB_IS_LIBSTDCXX) option(ENABLE_MCROUTER "Build the mcrouter library and extension" ON) else() option(ENABLE_MCROUTER "Build the mcrouter library and extension" OFF) endif() option(ENABLE_PROXYGEN_SERVER "Build the Proxygen HTTP server" ON) option(ENABLE_SPLIT_DWARF "Reduce linker memory usage by putting debugging information into .dwo files" OFF) IF (LINUX) option(MAP_TEXT_HUGE_PAGES "Remap hot static code onto huge pages" ON) ENDIF() IF (NOT DEFAULT_CONFIG_DIR) set(DEFAULT_CONFIG_DIR "/etc/hhvm/" CACHE STRING "Default directory to find php.ini") ENDIF() option(ENABLE_XED "Use the XED library for HHVM. If ON, tc-print will be built for X86." OFF) option(ENABLE_SYSTEM_LOCALE_ARCHIVE "Use system locale archive as the default LOCALE_ARCHIVE for nix patched glibc." OFF)
CMake
hhvm/CMake/ThinArchives.cmake
# Copyright (C) 2009 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # # Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. # Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. option(USE_THIN_ARCHIVES "Produce all static libraries as thin archives" ${LINUX}) set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>") if (USE_THIN_ARCHIVES) execute_process(COMMAND ${CMAKE_AR} -V OUTPUT_VARIABLE AR_VERSION) if ("${AR_VERSION}" MATCHES "^GNU ar") set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qT <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>") endif () endif () set(CMAKE_CXX_ARCHIVE_APPEND "${CMAKE_C_ARCHIVE_APPEND}") set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_C_ARCHIVE_CREATE}")
CMake
hhvm/CMake/VisualStudioToolset.cmake
# Due to HHVM's size, we need to use the native 64-bit toolchain to get a decent link time, # and, in fact, it's also needed to be able to link at all in debug mode, due to the size of # the hphp_runtime_static static library. However, Visual Studio defaults to using the 32-bit # hosted cross compiler targeting 64-bit. Unfortunately, CMake doesn't provide us a way to # do this, so we have to resort to a hack-around in order to make this possible. Because the # toolset value is put into the project file unescaped, we can use it to add the PreferredToolArchitecture # value that we need, as long as we make sure to properly close and re-open the current tags. # # To add support for newer MSVC versions, simply adjust the actual toolset value at the start # and end of the string. # # Unfortunately, we can't rely on the MSVC and MSVC14 variables to check if we need to enable # this, due to the fact they are set when the C/CXX languages are enabled, however, this value # needs to be set before the languages are enabled in order to have any effect, so we set it # based directly off of the name of the generator, which is set before configuration even begins. if ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 15( 2017)? Win64") set(CMAKE_GENERATOR_TOOLSET "v141</PlatformToolset><PreferredToolArchitecture>x64</PreferredToolArchitecture><PlatformToolset>v141") endif()
hhvm/hphp/.clang-tidy
# NOTE there must be no spaces before the '-', so put the comma after. # When making changes, be sure to verify the output of the following command to ensure # the desired checks are enabled (run from the directory containing a .clang-tidy file): # `clang-tidy -list-checks` # NOTE: Please don't disable inheritance from the parent to make sure that common checks get propagated. --- InheritParentConfig: true Checks: ' -facebook-hte-FormatPointlessCall_Fmt, -facebook-hte-FormatPointlessCall_Folly, -facebook-hte-InlinedStaticLocalVariableWarning, -facebook-hte-LocalUncheckedArrayBounds, -facebook-hte-MemberUncheckedArrayBounds, -facebook-hte-MissingBraces, -facebook-hte-NullableDereference, -facebook-hte-NullableReturn, -facebook-hte-ParameterUncheckedArrayBounds, -facebook-hte-BadImplicitCast, -facebook-reserve, ' ...
hhvm/hphp/.ctags
--exclude=*.css --exclude=*.js --exclude=*.ml --exclude=*.mli --exclude=*.php --exclude=*.py --exclude=*.sql --exclude=public_tld/* --exclude=test/* --exclude=facebook/push/* --exclude=facebook/hacknative/* --regex-c++=/^\s*(static)?\s*\w+\s+HHVM_FUNCTION\((\w+)/\2/f,function,function definitions/ --regex-c++=/^\s*(static)?\s*\w+\s+HHVM_FUNCTION\((\w+)/f_\2/f,function,function definitions/ --regex-c++=/^\s*(static)?\s*\w+\s+HHVM_METHOD\((\w+)\s*,\s*(\w+)/\3/f,function,function definitions/ --regex-c++=/^\s*(static)?\s*\w+\s+HHVM_METHOD\((\w+)\s*,\s*(\w+)/c_\2_ni_\3/f,function,function definitions/ --regex-c++=/^\s*(static)?\s*\w+\s+HHVM_STATIC_METHOD\((\w+)\s*,\s*(\w+)/\3/f,function,function definitions/ --regex-c++=/^\s*(static)?\s*\w+\s+HHVM_STATIC_METHOD\((\w+)\s*,\s*(\w+)/c_\2_ni_\3/f,function,function definitions/ --regex-c++=/^\s*using\s+(\w+)\s*=/\1/t,type,type definitions/
hhvm/hphp/.gitignore
# HHVM build results *.hhbc *.[oa] /hhvm/hhbbc /hhvm/hhvm /hhvm/hphp /hhvm/php # CMake build artifacts CMakeFiles /CMakeCache.txt cmake_install.cmake Makefile /runtime/ir-opcode-generated.h /util/generated-compiler-id.txt /util/generated-repo-schema-id.txt /util/hphp-config.h # precompiled headers *_cotire.cmake cotire # vim swapfiles .*.swp .*.swo # vim config .vimrc # tags files tags TAGS # logs *.log # git patch files *.diff # OS X .DS_Store ._.DS_Store # gdb .gdb_history tools/gdb/hhvm-gdb