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-11-21 01:44:51 +08:00
set ( PYTHON_VERSION_MINOR 9 )
set ( PYTHON_VERSION_PATCH 0 )
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-11-21 01:44:51 +08:00
S H A 5 1 2 3 9 d 3 0 4 c a e 1 8 1 6 7 4 c 4 8 7 2 c 6 3 7 6 8 c 0 e 5 a e a c e 2 c 9 2 e b 6 d 5 e a 5 5 0 4 2 8 d 6 5 c 8 5 7 1 b c 6 0 9 2 2 b 3 a 3 d 4 8 4 b 5 1 c 4 6 b 4 6 6 a a d b 7 e 2 7 5 0 0 5 5 9 c a f e c 1 3 a 4 8 9 b 4 8 6 1 3 b b b 3 f e 6 a 5 a 5 d
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 ( )