aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/ports.cmake85
1 files changed, 43 insertions, 42 deletions
diff --git a/scripts/ports.cmake b/scripts/ports.cmake
index fbe80cc20..44cb386be 100644
--- a/scripts/ports.cmake
+++ b/scripts/ports.cmake
@@ -1,5 +1,11 @@
cmake_minimum_required(VERSION 3.5)
+macro(debug_message)
+ if(DEFINED PORT_DEBUG AND PORT_DEBUG)
+ message(STATUS "[DEBUG] ${ARGN}")
+ endif()
+endmacro()
+
#Detect .vcpkg-root to figure VCPKG_ROOT_DIR
SET(VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR})
while(IS_DIRECTORY ${VCPKG_ROOT_DIR_CANDIDATE} AND NOT EXISTS "${VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root")
@@ -13,14 +19,6 @@ endwhile()
set(VCPKG_ROOT_DIR ${VCPKG_ROOT_DIR_CANDIDATE})
-string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET})
-string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET})
-
-set(CMAKE_TRIPLET_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake)
-if(NOT EXISTS ${CMAKE_TRIPLET_FILE})
- message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}")
-endif()
-
list(APPEND CMAKE_MODULE_PATH ${VCPKG_ROOT_DIR}/scripts/cmake)
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")
@@ -32,43 +30,16 @@ if(PORT)
set(CURRENT_PACKAGES_DIR ${PACKAGES_DIR}/${PORT}_${TARGET_TRIPLET})
endif()
-macro(debug_message)
- if(DEFINED PORT_DEBUG AND PORT_DEBUG)
- message(STATUS "[DEBUG] ${ARGN}")
- endif()
-endmacro()
-if(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)
- file(DOWNLOAD ${URL} ${DOWNLOADS}/${FILENAME} STATUS error_code)
- if(NOT error_code MATCHES "0;")
- message(FATAL_ERROR "Error downloading file: ${error_code}")
- endif()
- endif()
- file(SHA512 ${DOWNLOADS}/${FILENAME} SHA512)
+if(CMD MATCHES "^BUILD$")
+ string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET})
+ string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET})
- 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)
+ set(CMAKE_TRIPLET_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake)
+ if(NOT EXISTS ${CMAKE_TRIPLET_FILE})
+ message(FATAL_ERROR "Unsupported target triplet. Triplet file does not exist: ${CMAKE_TRIPLET_FILE}")
+ endif()
- 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")
- message(STATUS " vcpkg edit ${PORT}")
-elseif(CMD MATCHES "^BUILD$")
if(NOT DEFINED CURRENT_PORT_DIR)
message(FATAL_ERROR "CURRENT_PORT_DIR was not defined")
endif()
@@ -100,4 +71,34 @@ elseif(CMD MATCHES "^BUILD$")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR})
include(${CURRENT_PORT_DIR}/portfile.cmake)
+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)
+ file(DOWNLOAD ${URL} ${DOWNLOADS}/${FILENAME} STATUS error_code)
+ if(NOT error_code MATCHES "0;")
+ message(FATAL_ERROR "Error downloading file: ${error_code}")
+ endif()
+ 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")
+ message(STATUS " vcpkg edit ${PORT}")
endif()