vcpkg/scripts/ports.cmake

156 lines
6.7 KiB
CMake
Raw Normal View History

2016-09-18 20:50:08 -07:00
cmake_minimum_required(VERSION 3.5)
macro(debug_message)
if(DEFINED PORT_DEBUG AND PORT_DEBUG)
message(STATUS "[DEBUG] ${ARGN}")
endif()
endmacro()
2019-08-22 21:55:50 +00:00
#Detect .vcpkg-root to figure VCPKG_ROOT_DIR, starting from triplet folder.
set(VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR})
if(DEFINED VCPKG_ROOT_PATH)
set(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_PATH})
else()
message(FATAL_ERROR [[
Your vcpkg executable is outdated and is not compatible with the current CMake scripts.
Please re-build vcpkg by running bootstrap-vcpkg.
]])
endif()
# fixup Windows drive letter to uppercase.
get_filename_component(VCPKG_ROOT_DIR_CANDIDATE ${VCPKG_ROOT_DIR_CANDIDATE} ABSOLUTE)
# Validate VCPKG_ROOT_DIR_CANDIDATE
if (NOT EXISTS "${VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root")
message(FATAL_ERROR "Could not find .vcpkg-root")
endif()
set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE})
2016-09-18 20:50:08 -07:00
2019-08-22 21:55:50 +00:00
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
2016-09-18 20:50:08 -07:00
set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages")
set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools")
set(SCRIPTS ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "Location to stored scripts")
2016-09-18 20:50:08 -07:00
set(PACKAGES_DIR ${VCPKG_ROOT_DIR}/packages CACHE PATH "Location to store package images")
set(BUILDTREES_DIR ${VCPKG_ROOT_DIR}/buildtrees CACHE PATH "Location to perform actual extract+config+build")
if(PORT)
set(CURRENT_BUILDTREES_DIR ${BUILDTREES_DIR}/${PORT})
set(CURRENT_PACKAGES_DIR ${PACKAGES_DIR}/${PORT}_${TARGET_TRIPLET})
endif()
if(CMD MATCHES "^BUILD$")
set(CMAKE_TRIPLET_FILE ${TARGET_TRIPLET_FILE})
if(NOT EXISTS ${CMAKE_TRIPLET_FILE})
message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}")
endif()
2016-09-18 20:50:08 -07:00
if(NOT DEFINED CURRENT_PORT_DIR)
2016-09-18 20:50:08 -07:00
message(FATAL_ERROR "CURRENT_PORT_DIR was not defined")
endif()
set(TO_CMAKE_PATH "${CURRENT_PORT_DIR}" CURRENT_PORT_DIR)
if(NOT EXISTS ${CURRENT_PORT_DIR})
message(FATAL_ERROR "Cannot find port: ${PORT}\n Directory does not exist: ${CURRENT_PORT_DIR}")
endif()
if(NOT EXISTS ${CURRENT_PORT_DIR}/portfile.cmake)
message(FATAL_ERROR "Port is missing portfile: ${CURRENT_PORT_DIR}/portfile.cmake")
endif()
if(NOT EXISTS ${CURRENT_PORT_DIR}/CONTROL)
message(FATAL_ERROR "Port is missing control file: ${CURRENT_PORT_DIR}/CONTROL")
endif()
unset(PACKAGES_DIR)
unset(BUILDTREES_DIR)
if(EXISTS ${CURRENT_PACKAGES_DIR})
file(GLOB FILES_IN_CURRENT_PACKAGES_DIR "${CURRENT_PACKAGES_DIR}/*")
if(FILES_IN_CURRENT_PACKAGES_DIR)
file(REMOVE_RECURSE ${FILES_IN_CURRENT_PACKAGES_DIR})
file(GLOB FILES_IN_CURRENT_PACKAGES_DIR "${CURRENT_PACKAGES_DIR}/*")
if(FILES_IN_CURRENT_PACKAGES_DIR)
message(FATAL_ERROR "Unable to empty directory: ${CURRENT_PACKAGES_DIR}\n Files are likely in use.")
endif()
endif()
2016-09-18 20:50:08 -07:00
endif()
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR})
include(${CMAKE_TRIPLET_FILE})
[vcpkg] Add Supports: field. Use contents of triplets instead of names for dependency resolution. (#8601) * remove unfinished "supports" tag * extract "supports" from control files But do nothing with the value * Start `Supports` documentation * Use Supports in a bunch of control files I only tried matching the already existing logic in the portfile.cmake. * Cmake var provider (#8) * Cmake var provider (#9) * fix windows build (#10) * Add missing files to build * Fix test (#11) * adding hooks for cmake variables in expressions * Adding hooks for 'supports' in CI test * Fix test (#12) * Add overrides to evaluation environment * use "supported" tag in CI testing * cleanup comment * Fix issues with PR * [var_provider] Get library linkage variables from triplet * Fix compilation errors in tests * Add unimplemented functions * Fix unit tests part 1 * Fix issue when buildtrees dir does not exist * Change binary output hash * Fix handling of * feature * Add core feature when using * * Do not add Default-Features when installing 'core' * [vcpkg] WIP. 6 failing tests. * [vcpkg] WIP. 1 failing tests. * [vcpkg] WIP. 0 failing tests. * [vcpkg] Removed 'remove_graph'. 0 failing tests. * [vcpkg] Removed 'install_graph'. 0 failing tests. * [vcpkg] Remove AnyAction; replace with ActionPlan * [vcpkg] Minor cleanup. * [vcpkg][z3][qt5-connectivity][qt5-purchasing] Improve error messages while parsing. Fix a few trivial port issues. * [vcpkg] Work around ICE with MSVC v140 * [vcpkg] Add purge on fail to decompress for CI * [vcpkg] Fix parsing of nested parentheses in qualifiers * [vcpkg] Fix Linux builds (explicit qualification in declaration) * [vcpkg] Fix Build-Depends implying default features. Fix qualified dependencies regression. * [mmx] Add to skip list and full rebuild -- mmx causes problems by installing 'sched.h' * [libpqxx][mqtt-cpp] Prevent installing include/CMakeLists.txt * [cppitertools] Fix installed include namespace (should be include/cppitertools) * [libsoundio] Move headers into soundio/ subdirectory as per original cmake * [ci.baseline] Temporarily skip charls due to conflict with dcmtk * [vcpkg] Add restricted include files post build check -- bump global abi version * [libsoundio] Hotfix stray line in portfile * [vcpkg] Fix regression: CMake information was not being displayed for build-and-install actions * [jsonnet] Fix installation of internal headers; use system nlohmann-json * [grpc][upb] Teach grpc to use packaged upb. Add find_package(upb). Remove inappropriate upb features. * [zfp] Move problematic 'include/bitstream.h' to 'include/zfp/bitstream.h' * [x265] Bump control version to trigger rebuild after zfp conflict * [akali] Disable parallel configure * [dirent][dlfcn-win32][getopt-win32][pthreads] Grandfather into VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS * [ci.baseline] Update baseline for improved upb support * [tgui] Disable parallel configure * [libiconv] Enable VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS * [aws-sdk-cpp] Disable parallel configure * [vcpkg] Implement policy VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS * [aws-sdk-cpp] Fix amount of escaping semicolons -- Note: I do not know the root cause requiring this change * [libodb-sqlite] Fix configuring into source directory * [gettext] Grandfather into VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS * [libodb] DISABLE_PARALLEL_CONFIGURE * [vcpkg] Add 'config.h' and 'local.h' to restricted header list * [mcpp] Remove unused and problematic include 'config.h' from installed files * [teemo] Move installed headers into subdirectory to prevent conflicts with x265 * [ci.baseline] Update current OSX. Skip libmesh on all platforms due to heavy conflicts. * [vcpkg] Add 'slice.h' as a restricted header * [osg] Improve accuracy of dependencies (disable some, add some to Depends) * [vcpkg] Skip invoking a subprocess for 0 specs in load_tag_vars * [ci.baseline] Skip mongo-c-driver on osx due to flakiness * [teemo] Fix incorrect include file read * [osg] Fix dependency typo: glut -> freeglut * [vcpkg] Recover some lost performance with the addition of vcpkg_get_tags. A huge performance cost was loading the triplet files over and over; instead, we splice the sources into a macro and load it once, then just call that macro for each port. Remove use of hashing because we aren't cross-process-safe anyway (global static will do instead). * [vcpkg] Change Supports atom 'windows' to include UWP. Improve Supports field documentation. * [vcpkg] Add docs for VCPKG_ENV_PASSTHROUGH and VCPKG_DEP_INFO_OVERRIDE_VARS * Fix typo Co-authored-by: Curtis J Bezault <curtbezault@gmail.com> Co-authored-by: Victor Romero <romerosanchezv@gmail.com> Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
2020-02-03 14:22:52 -08:00
if (DEFINED VCPKG_PORT_CONFIGS)
foreach(VCPKG_PORT_CONFIG ${VCPKG_PORT_CONFIGS})
include(${VCPKG_PORT_CONFIG})
endforeach()
endif()
set(TRIPLET_SYSTEM_ARCH ${VCPKG_TARGET_ARCHITECTURE})
include(${SCRIPTS}/cmake/vcpkg_common_definitions.cmake)
include(${SCRIPTS}/cmake/vcpkg_common_functions.cmake)
2016-09-18 20:50:08 -07:00
include(${CURRENT_PORT_DIR}/portfile.cmake)
set(BUILD_INFO_FILE_PATH ${CURRENT_PACKAGES_DIR}/BUILD_INFO)
file(WRITE ${BUILD_INFO_FILE_PATH} "CRTLinkage: ${VCPKG_CRT_LINKAGE}\n")
2017-01-31 18:31:19 -08:00
file(APPEND ${BUILD_INFO_FILE_PATH} "LibraryLinkage: ${VCPKG_LIBRARY_LINKAGE}\n")
if (DEFINED VCPKG_POLICY_DLLS_WITHOUT_LIBS)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsWithoutLIBs: ${VCPKG_POLICY_DLLS_WITHOUT_LIBS}\n")
endif()
if (DEFINED VCPKG_POLICY_DLLS_WITHOUT_EXPORTS)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsWithoutExports: ${VCPKG_POLICY_DLLS_WITHOUT_EXPORTS}\n")
endif()
2017-02-07 17:02:57 -08:00
if (DEFINED VCPKG_POLICY_EMPTY_PACKAGE)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyPackage: ${VCPKG_POLICY_EMPTY_PACKAGE}\n")
endif()
2017-03-03 19:09:24 -08:00
if (DEFINED VCPKG_POLICY_ONLY_RELEASE_CRT)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyOnlyReleaseCRT: ${VCPKG_POLICY_ONLY_RELEASE_CRT}\n")
2017-03-03 19:00:48 -08:00
endif()
if (DEFINED VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyAllowObsoleteMsvcrt: ${VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT}\n")
endif()
if (DEFINED VCPKG_POLICY_EMPTY_INCLUDE_FOLDER)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyEmptyIncludeFolder: ${VCPKG_POLICY_EMPTY_INCLUDE_FOLDER}\n")
endif()
[vcpkg] Add Supports: field. Use contents of triplets instead of names for dependency resolution. (#8601) * remove unfinished "supports" tag * extract "supports" from control files But do nothing with the value * Start `Supports` documentation * Use Supports in a bunch of control files I only tried matching the already existing logic in the portfile.cmake. * Cmake var provider (#8) * Cmake var provider (#9) * fix windows build (#10) * Add missing files to build * Fix test (#11) * adding hooks for cmake variables in expressions * Adding hooks for 'supports' in CI test * Fix test (#12) * Add overrides to evaluation environment * use "supported" tag in CI testing * cleanup comment * Fix issues with PR * [var_provider] Get library linkage variables from triplet * Fix compilation errors in tests * Add unimplemented functions * Fix unit tests part 1 * Fix issue when buildtrees dir does not exist * Change binary output hash * Fix handling of * feature * Add core feature when using * * Do not add Default-Features when installing 'core' * [vcpkg] WIP. 6 failing tests. * [vcpkg] WIP. 1 failing tests. * [vcpkg] WIP. 0 failing tests. * [vcpkg] Removed 'remove_graph'. 0 failing tests. * [vcpkg] Removed 'install_graph'. 0 failing tests. * [vcpkg] Remove AnyAction; replace with ActionPlan * [vcpkg] Minor cleanup. * [vcpkg][z3][qt5-connectivity][qt5-purchasing] Improve error messages while parsing. Fix a few trivial port issues. * [vcpkg] Work around ICE with MSVC v140 * [vcpkg] Add purge on fail to decompress for CI * [vcpkg] Fix parsing of nested parentheses in qualifiers * [vcpkg] Fix Linux builds (explicit qualification in declaration) * [vcpkg] Fix Build-Depends implying default features. Fix qualified dependencies regression. * [mmx] Add to skip list and full rebuild -- mmx causes problems by installing 'sched.h' * [libpqxx][mqtt-cpp] Prevent installing include/CMakeLists.txt * [cppitertools] Fix installed include namespace (should be include/cppitertools) * [libsoundio] Move headers into soundio/ subdirectory as per original cmake * [ci.baseline] Temporarily skip charls due to conflict with dcmtk * [vcpkg] Add restricted include files post build check -- bump global abi version * [libsoundio] Hotfix stray line in portfile * [vcpkg] Fix regression: CMake information was not being displayed for build-and-install actions * [jsonnet] Fix installation of internal headers; use system nlohmann-json * [grpc][upb] Teach grpc to use packaged upb. Add find_package(upb). Remove inappropriate upb features. * [zfp] Move problematic 'include/bitstream.h' to 'include/zfp/bitstream.h' * [x265] Bump control version to trigger rebuild after zfp conflict * [akali] Disable parallel configure * [dirent][dlfcn-win32][getopt-win32][pthreads] Grandfather into VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS * [ci.baseline] Update baseline for improved upb support * [tgui] Disable parallel configure * [libiconv] Enable VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS * [aws-sdk-cpp] Disable parallel configure * [vcpkg] Implement policy VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS * [aws-sdk-cpp] Fix amount of escaping semicolons -- Note: I do not know the root cause requiring this change * [libodb-sqlite] Fix configuring into source directory * [gettext] Grandfather into VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS * [libodb] DISABLE_PARALLEL_CONFIGURE * [vcpkg] Add 'config.h' and 'local.h' to restricted header list * [mcpp] Remove unused and problematic include 'config.h' from installed files * [teemo] Move installed headers into subdirectory to prevent conflicts with x265 * [ci.baseline] Update current OSX. Skip libmesh on all platforms due to heavy conflicts. * [vcpkg] Add 'slice.h' as a restricted header * [osg] Improve accuracy of dependencies (disable some, add some to Depends) * [vcpkg] Skip invoking a subprocess for 0 specs in load_tag_vars * [ci.baseline] Skip mongo-c-driver on osx due to flakiness * [teemo] Fix incorrect include file read * [osg] Fix dependency typo: glut -> freeglut * [vcpkg] Recover some lost performance with the addition of vcpkg_get_tags. A huge performance cost was loading the triplet files over and over; instead, we splice the sources into a macro and load it once, then just call that macro for each port. Remove use of hashing because we aren't cross-process-safe anyway (global static will do instead). * [vcpkg] Change Supports atom 'windows' to include UWP. Improve Supports field documentation. * [vcpkg] Add docs for VCPKG_ENV_PASSTHROUGH and VCPKG_DEP_INFO_OVERRIDE_VARS * Fix typo Co-authored-by: Curtis J Bezault <curtbezault@gmail.com> Co-authored-by: Victor Romero <romerosanchezv@gmail.com> Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
2020-02-03 14:22:52 -08:00
if (DEFINED VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyAllowRestrictedHeaders: ${VCPKG_POLICY_ALLOW_RESTRICTED_HEADERS}\n")
endif()
if (DEFINED VCPKG_POLICY_SKIP_DUMPBIN_CHECKS)
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicySkipDumpbinChecks: ${VCPKG_POLICY_SKIP_DUMPBIN_CHECKS}\n")
endif()
if (DEFINED VCPKG_HEAD_VERSION)
file(APPEND ${BUILD_INFO_FILE_PATH} "Version: ${VCPKG_HEAD_VERSION}\n")
endif()
elseif(CMD MATCHES "^CREATE$")
file(TO_NATIVE_PATH ${VCPKG_ROOT_DIR} NATIVE_VCPKG_ROOT_DIR)
file(TO_NATIVE_PATH ${DOWNLOADS} NATIVE_DOWNLOADS)
if(EXISTS ports/${PORT}/portfile.cmake)
message(FATAL_ERROR "Portfile already exists: '${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\portfile.cmake'")
endif()
if(NOT FILENAME)
get_filename_component(FILENAME "${URL}" NAME)
endif()
string(REGEX REPLACE "(\\.(zip|gz|tar|tgz|bz2))+\$" "" ROOT_NAME ${FILENAME})
if(EXISTS ${DOWNLOADS}/${FILENAME})
message(STATUS "Using pre-downloaded: ${NATIVE_DOWNLOADS}\\${FILENAME}")
message(STATUS "If this is not desired, delete the file and ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}")
else()
include(vcpkg_download_distfile)
set(_VCPKG_INTERNAL_NO_HASH_CHECK "TRUE")
vcpkg_download_distfile(ARCHIVE
URLS ${URL}
FILENAME ${FILENAME}
)
set(_VCPKG_INTERNAL_NO_HASH_CHECK "FALSE")
endif()
file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512)
file(MAKE_DIRECTORY ports/${PORT})
configure_file(${SCRIPTS}/templates/portfile.in.cmake ports/${PORT}/portfile.cmake @ONLY)
configure_file(${SCRIPTS}/templates/CONTROL.in ports/${PORT}/CONTROL @ONLY)
message(STATUS "Generated portfile: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\portfile.cmake")
message(STATUS "Generated CONTROL: ${NATIVE_VCPKG_ROOT_DIR}\\ports\\${PORT}\\CONTROL")
message(STATUS "To launch an editor for these new files, run")
2017-05-08 11:16:49 +02:00
message(STATUS " .\\vcpkg edit ${PORT}")
2016-09-18 20:50:08 -07:00
endif()