2017-05-20 16:58:30 +08:00
if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic AND VCPKG_CRT_LINKAGE STREQUAL static )
message ( STATUS "Warning: Dynamic library with static CRT is not supported. Building static library." )
set ( VCPKG_LIBRARY_LINKAGE static )
endif ( )
2018-01-05 00:55:01 +08:00
set ( PYTHON_VERSION_MAJOR 3 )
2020-06-12 13:23:26 +08:00
set ( PYTHON_VERSION_MINOR 8 )
2019-03-26 21:09:04 +08:00
set ( PYTHON_VERSION_PATCH 3 )
2018-01-05 00:55:01 +08:00
set ( PYTHON_VERSION ${ PYTHON_VERSION_MAJOR } . ${ PYTHON_VERSION_MINOR } . ${ PYTHON_VERSION_PATCH } )
2017-05-20 05:31:04 +08:00
2020-06-12 13:23:26 +08:00
if ( VCPKG_TARGET_IS_WINDOWS )
if ( VCPKG_LIBRARY_LINKAGE STREQUAL static )
list ( APPEND PATCHES ${ CMAKE_CURRENT_LIST_DIR } /0001-static-library.patch )
endif ( )
if ( VCPKG_CRT_LINKAGE STREQUAL static )
list ( APPEND PATCHES ${ CMAKE_CURRENT_LIST_DIR } /0002-static-crt.patch )
endif ( )
endif ( )
2017-05-20 05:31:04 +08:00
vcpkg_from_github (
O U T _ S O U R C E _ P A T H T E M P _ S O U R C E _ P A T H
R E P O p y t h o n / c p y t h o n
2018-01-05 00:55:01 +08:00
R E F v $ { P Y T H O N _ V E R S I O N }
2020-06-12 13:23:26 +08:00
S H A 5 1 2 e b 2 6 4 a 8 5 8 e f 5 5 f 2 f 6 1 b 5 3 f 6 6 3 4 5 4 b e 6 e 9 9 f f e 9 0 3 5 d 8 f c d b 3 3 6 6 d 7 a 0 8 f d 3 b 2 9 5 6 1 3 e 5 d 1 5 e 9 3 e 2 e 4 b 9 b 1 8 a d 2 9 7 d 8 c 1 7 1 3 9 b d e 5 e 9 0 e 3 9 6 d b 0 4 f e 0 4 c 6 f 4 4 1 a 4 4 3 f d 2
2017-05-20 05:31:04 +08:00
H E A D _ R E F m a s t e r
2020-06-12 13:23:26 +08:00
P A T C H E S $ { P A T C H E S }
2018-03-18 19:31:30 +08:00
)
2020-03-11 03:25:18 +08:00
if ( "enable-shared" IN_LIST FEATURES )
set ( _ENABLED_SHARED --enable-shared )
2020-05-22 02:39:48 +08:00
if ( VCPKG_TARGET_IS_LINUX )
message ( WARNING "Feature enable-shared requires libffi-devel from the system package manager, please install it on Ubuntu system via sudo apt-get install libffi-dev." )
endif ( )
2020-03-11 03:25:18 +08:00
else ( )
unset ( _ENABLED_SHARED )
endif ( )
2019-09-30 09:58:00 +08:00
if ( VCPKG_TARGET_IS_WINDOWS )
2020-03-11 03:25:18 +08:00
if ( DEFINED _ENABLED_SHARED )
message ( WARNING "enable-shared requested, by Windows build already produce a shared library by default" )
endif ( )
2020-01-17 05:56:28 +08:00
set ( SOURCE_PATH "${TEMP_SOURCE_PATH}-Lib-Win" )
2019-09-30 09:58:00 +08:00
file ( REMOVE_RECURSE ${ SOURCE_PATH } )
file ( RENAME "${TEMP_SOURCE_PATH}" ${ SOURCE_PATH } )
2020-03-11 03:25:18 +08:00
2019-09-30 09:58:00 +08:00
if ( VCPKG_TARGET_ARCHITECTURE MATCHES "x86" )
set ( BUILD_ARCH "Win32" )
set ( OUT_DIR "win32" )
elseif ( VCPKG_TARGET_ARCHITECTURE MATCHES "x64" )
set ( BUILD_ARCH "x64" )
set ( OUT_DIR "amd64" )
else ( )
message ( FATAL_ERROR "Unsupported architecture: ${VCPKG_TARGET_ARCHITECTURE}" )
endif ( )
2017-05-20 05:31:04 +08:00
2019-09-30 09:58:00 +08:00
vcpkg_build_msbuild (
P R O J E C T _ P A T H $ { S O U R C E _ P A T H } / P C B u i l d / p y t h o n c o r e . v c x p r o j
P L A T F O R M $ { B U I L D _ A R C H } )
2018-04-21 08:53:57 +08:00
2020-03-11 03:25:18 +08:00
file ( INSTALL
2020-06-12 13:23:26 +08:00
" $ { S O U R C E _ P A T H } / I n c l u d e / "
2020-03-11 03:25:18 +08:00
" $ { S O U R C E _ P A T H } / P C / p y c o n f i g . h "
2020-06-12 13:23:26 +08:00
D E S T I N A T I O N " $ { C U R R E N T _ P A C K A G E S _ D I R } / i n c l u d e / p y t h o n $ { P Y T H O N _ V E R S I O N _ M A J O R } . $ { P Y T H O N _ V E R S I O N _ M I N O R } "
F I L E S _ M A T C H I N G P A T T E R N * . h
2020-03-11 03:25:18 +08:00
)
file ( INSTALL
" $ { S O U R C E _ P A T H } / L i b "
D E S T I N A T I O N
" $ { C U R R E N T _ P A C K A G E S _ D I R } / s h a r e / p y t h o n $ { P Y T H O N _ V E R S I O N _ M A J O R } "
)
file ( INSTALL
" $ { S O U R C E _ P A T H } / P C B u i l d / $ { O U T _ D I R } / p y t h o n $ { P Y T H O N _ V E R S I O N _ M A J O R } $ { P Y T H O N _ V E R S I O N _ M I N O R } . l i b "
D E S T I N A T I O N
" $ { C U R R E N T _ P A C K A G E S _ D I R } / l i b "
)
2019-11-19 06:04:25 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
2020-03-11 03:25:18 +08:00
file ( INSTALL "${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.lib" DESTINATION ${ CURRENT_PACKAGES_DIR } /debug/lib )
2019-11-19 06:04:25 +08:00
endif ( )
2019-02-07 09:21:23 +08:00
2019-09-30 09:58:00 +08:00
if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic )
2020-03-11 03:25:18 +08:00
file ( INSTALL "${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.dll" DESTINATION ${ CURRENT_PACKAGES_DIR } /bin )
2019-11-19 06:04:25 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
2020-03-11 03:25:18 +08:00
file ( INSTALL "${SOURCE_PATH}/PCBuild/${OUT_DIR}/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.dll" DESTINATION ${ CURRENT_PACKAGES_DIR } /debug/bin )
2019-11-19 06:04:25 +08:00
endif ( )
endif ( )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
vcpkg_copy_pdbs ( )
2019-09-30 09:58:00 +08:00
endif ( )
# Handle copyright
2020-03-11 03:25:18 +08:00
file ( INSTALL ${ SOURCE_PATH } /LICENSE DESTINATION ${ CURRENT_PACKAGES_DIR } /share/python ${ PYTHON_VERSION_MAJOR } RENAME copyright )
2019-11-19 06:04:25 +08:00
2019-09-30 09:58:00 +08:00
elseif ( VCPKG_TARGET_IS_LINUX OR VCPKG_TARGET_IS_OSX )
2019-11-19 06:04:25 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
set ( SOURCE_PATH_DEBUG "${TEMP_SOURCE_PATH}-${TARGET_TRIPLET}-debug" )
endif ( )
2019-09-30 09:58:00 +08:00
set ( SOURCE_PATH_RELEASE "${TEMP_SOURCE_PATH}-${TARGET_TRIPLET}-release" )
file ( REMOVE_RECURSE ${ SOURCE_PATH_RELEASE } )
file ( GLOB FILES ${ TEMP_SOURCE_PATH } /* )
file ( COPY ${ FILES } DESTINATION ${ SOURCE_PATH_RELEASE } )
2019-11-19 06:04:25 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
file ( REMOVE_RECURSE ${ SOURCE_PATH_DEBUG } )
file ( RENAME "${TEMP_SOURCE_PATH}" ${ SOURCE_PATH_DEBUG } )
endif ( )
2019-09-30 09:58:00 +08:00
find_program ( MAKE make )
if ( NOT MAKE )
message ( FATAL_ERROR "MAKE not found" )
endif ( )
2020-03-11 03:25:18 +08:00
2019-09-30 09:58:00 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release" )
################
# Release build
################
message ( STATUS "Configuring ${TARGET_TRIPLET}-rel" )
set ( OUT_PATH_RELEASE ${ SOURCE_PATH_RELEASE } /../../make-build- ${ TARGET_TRIPLET } -release )
file ( MAKE_DIRECTORY ${ OUT_PATH_RELEASE } )
2020-03-11 03:25:18 +08:00
2019-09-30 09:58:00 +08:00
if ( VCPKG_TARGET_IS_OSX )
vcpkg_execute_build_process (
2020-03-11 03:25:18 +08:00
C O M M A N D
" $ { S O U R C E _ P A T H _ R E L E A S E } / c o n f i g u r e "
$ { _ E N A B L E D _ S H A R E D }
- - p r e f i x = $ { O U T _ P A T H _ R E L E A S E }
- - w i t h - o p e n s s l = $ { C U R R E N T _ I N S T A L L E D _ D I R }
" C P P F L A G S = - I $ { C U R R E N T _ I N S T A L L E D _ D I R } / i n c l u d e - f r a m e w o r k C o r e F o u n d a t i o n " " L D F L A G S = - L $ { C U R R E N T _ I N S T A L L E D _ D I R } / l i b " " L I B S = - l i c o n v "
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H _ R E L E A S E }
L O G N A M E c o n f i g - $ { T A R G E T _ T R I P L E T } - r e l
2019-09-30 09:58:00 +08:00
)
else ( )
vcpkg_execute_build_process (
2020-03-11 03:25:18 +08:00
C O M M A N D
" $ { S O U R C E _ P A T H _ R E L E A S E } / c o n f i g u r e "
$ { _ E N A B L E D _ S H A R E D }
- - p r e f i x = $ { O U T _ P A T H _ R E L E A S E }
- - w i t h - o p e n s s l = $ { C U R R E N T _ I N S T A L L E D _ D I R }
" C P P F L A G S = - I $ { C U R R E N T _ I N S T A L L E D _ D I R } / i n c l u d e " " L D F L A G S = - L $ { C U R R E N T _ I N S T A L L E D _ D I R } / l i b "
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H _ R E L E A S E }
L O G N A M E c o n f i g - $ { T A R G E T _ T R I P L E T } - r e l
2019-09-30 09:58:00 +08:00
)
endif ( )
message ( STATUS "Building ${TARGET_TRIPLET}-rel" )
2019-11-19 06:04:25 +08:00
2019-09-30 09:58:00 +08:00
vcpkg_execute_build_process (
2020-04-17 02:57:59 +08:00
C O M M A N D m a k e i n s t a l l - j $ { V C P K G _ C O N C U R R E N C Y }
N O _ P A R A L L E L _ C O M M A N D m a k e i n s t a l l
2019-09-30 09:58:00 +08:00
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H _ R E L E A S E }
L O G N A M E m a k e - b u i l d - $ { T A R G E T _ T R I P L E T } - r e l e a s e
)
2020-03-11 03:25:18 +08:00
message ( STATUS "Installing ${TARGET_TRIPLET}-rel headers..." )
2020-06-12 13:23:26 +08:00
file ( INSTALL "${OUT_PATH_RELEASE}/include/"
D E S T I N A T I O N $ { C U R R E N T _ P A C K A G E S _ D I R } / i n c l u d e
F I L E S _ M A T C H I N G P A T T E R N * . h
2020-03-11 03:25:18 +08:00
)
message ( STATUS "Installing ${TARGET_TRIPLET}-rel lib files..." )
2020-09-05 13:23:57 +08:00
file ( GLOB PY_LIBS
2020-03-11 03:25:18 +08:00
$ { O U T _ P A T H _ R E L E A S E } / l i b / p y t h o n $ { P Y T H O N _ V E R S I O N _ M A J O R } . $ { P Y T H O N _ V E R S I O N _ M I N O R } / * )
2020-09-05 13:23:57 +08:00
file ( INSTALL ${ PY_LIBS } DESTINATION ${ CURRENT_PACKAGES_DIR } /share/python ${ PYTHON_VERSION_MAJOR } /Lib
2020-03-11 03:25:18 +08:00
P A T T E R N " * . p y c " E X C L U D E
P A T T E R N " * _ _ p y c a c h e _ _ * " E X C L U D E
)
message ( STATUS "Installing ${TARGET_TRIPLET}-rel share files..." )
2020-09-05 13:23:57 +08:00
file ( GLOB PKGCFG ${ OUT_PATH_RELEASE } /lib/pkgconfig/* )
file ( INSTALL ${ PKGCFG } DESTINATION ${ CURRENT_PACKAGES_DIR } /share/python ${ PYTHON_VERSION_MAJOR }
2020-03-11 03:25:18 +08:00
P A T T E R N " * . p y c " E X C L U D E
P A T T E R N " * _ _ p y c a c h e _ _ * " E X C L U D E
)
message ( STATUS "Installing ${TARGET_TRIPLET}-rel Python library files..." )
file ( GLOB LIBS
2020-06-12 13:23:26 +08:00
$ { O U T _ P A T H _ R E L E A S E } / l i b / l i b p y t h o n $ { P Y T H O N _ V E R S I O N _ M A J O R } . $ { P Y T H O N _ V E R S I O N _ M I N O R } . * )
2020-09-05 13:23:57 +08:00
if ( NOT LIBS )
file ( GLOB LIBS ${ OUT_PATH_RELEASE } /lib64/* )
endif ( )
2020-03-11 03:25:18 +08:00
file ( INSTALL ${ LIBS } DESTINATION ${ CURRENT_PACKAGES_DIR } /lib
P A T T E R N " * . p y c " E X C L U D E
P A T T E R N " * _ _ p y c a c h e _ _ * " E X C L U D E
)
2019-09-30 09:58:00 +08:00
message ( STATUS "Installing ${TARGET_TRIPLET}-rel done" )
2019-11-19 06:04:25 +08:00
2019-09-30 09:58:00 +08:00
endif ( )
2017-05-20 05:31:04 +08:00
2019-09-30 09:58:00 +08:00
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
################
# Debug build
################
message ( STATUS "Configuring ${TARGET_TRIPLET}-dbg" )
set ( OUT_PATH_DEBUG ${ SOURCE_PATH_DEBUG } /../../make-build- ${ TARGET_TRIPLET } -debug )
file ( MAKE_DIRECTORY ${ OUT_PATH_DEBUG } )
2019-11-19 06:04:25 +08:00
2019-09-30 09:58:00 +08:00
if ( VCPKG_TARGET_IS_OSX )
vcpkg_execute_build_process (
2020-03-11 03:25:18 +08:00
C O M M A N D
" $ { S O U R C E _ P A T H _ D E B U G } / c o n f i g u r e "
- - w i t h - p y d e b u g
$ { _ E N A B L E D _ S H A R E D }
- - p r e f i x = $ { O U T _ P A T H _ D E B U G }
- - w i t h - o p e n s s l = $ { C U R R E N T _ I N S T A L L E D _ D I R } / d e b u g
" C P P F L A G S = - I $ { C U R R E N T _ I N S T A L L E D _ D I R } / i n c l u d e - f r a m e w o r k C o r e F o u n d a t i o n " " L D F L A G S = - L $ { C U R R E N T _ I N S T A L L E D _ D I R } / d e b u g / l i b " " L I B S = - l i c o n v "
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H _ D E B U G }
L O G N A M E c o n f i g - $ { T A R G E T _ T R I P L E T } - d e b u g
2019-09-30 09:58:00 +08:00
)
else ( )
vcpkg_execute_build_process (
2020-03-11 03:25:18 +08:00
C O M M A N D
" $ { S O U R C E _ P A T H _ D E B U G } / c o n f i g u r e "
- - w i t h - p y d e b u g
$ { _ E N A B L E D _ S H A R E D }
- - p r e f i x = $ { O U T _ P A T H _ D E B U G }
- - w i t h - o p e n s s l = $ { C U R R E N T _ I N S T A L L E D _ D I R } / d e b u g
" C P P F L A G S = - I $ { C U R R E N T _ I N S T A L L E D _ D I R } / i n c l u d e " " L D F L A G S = - L $ { C U R R E N T _ I N S T A L L E D _ D I R } / d e b u g / l i b "
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H _ D E B U G }
L O G N A M E c o n f i g - $ { T A R G E T _ T R I P L E T } - d e b u g
2019-09-30 09:58:00 +08:00
)
endif ( )
message ( STATUS "Building ${TARGET_TRIPLET}-dbg" )
vcpkg_execute_build_process (
2020-04-17 02:57:59 +08:00
C O M M A N D m a k e i n s t a l l - j $ { V C P K G _ C O N C U R R E N C Y }
N O _ P A R A L L E L _ C O M M A N D m a k e i n s t a l l
2019-09-30 09:58:00 +08:00
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ P A T H _ D E B U G }
L O G N A M E m a k e - b u i l d - $ { T A R G E T _ T R I P L E T } - d e b u g
)
2020-03-11 03:25:18 +08:00
message ( STATUS "Installing ${TARGET_TRIPLET}-dbg Python library files..." )
file ( GLOB LIBS
2020-06-12 13:23:26 +08:00
$ { O U T _ P A T H _ D E B U G } / l i b / l i b p y t h o n $ { P Y T H O N _ V E R S I O N _ M A J O R } . $ { P Y T H O N _ V E R S I O N _ M I N O R } d . * )
2020-09-05 13:23:57 +08:00
if ( NOT LIBS )
file ( GLOB LIBS
$ { O U T _ P A T H _ D E B U G } / l i b 6 4 / * )
endif ( )
2020-03-11 03:25:18 +08:00
file ( INSTALL ${ LIBS } DESTINATION ${ CURRENT_PACKAGES_DIR } /debug/lib
P A T T E R N " * . p y c " E X C L U D E
P A T T E R N " * _ _ p y c a c h e _ _ * " E X C L U D E
)
2019-09-30 09:58:00 +08:00
message ( STATUS "Installing ${TARGET_TRIPLET}-dbg done" )
2019-11-19 06:04:25 +08:00
2019-09-30 09:58:00 +08:00
endif ( )
# Handle copyright
2020-03-11 03:25:18 +08:00
file ( INSTALL ${ SOURCE_PATH_RELEASE } /LICENSE DESTINATION ${ CURRENT_PACKAGES_DIR } /share/python ${ PYTHON_VERSION_MAJOR } RENAME copyright )
2019-11-19 06:04:25 +08:00
2019-09-30 09:58:00 +08:00
endif ( )