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 )
2019-03-26 21:09:04 +08:00
set ( PYTHON_VERSION_MINOR 7 )
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
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 }
2019-03-26 21:09:04 +08:00
S H A 5 1 2 0 2 3 9 6 0 a 2 f 5 7 0 f e 7 1 7 8 d 3 9 0 1 d f 0 c 3 c 3 3 3 4 6 4 6 6 9 0 6 b 6 d 5 5 c 7 3 e f 7 9 4 7 c 1 9 6 1 9 d b a b 6 2 e f c 4 2 c 7 2 6 2 a 0 5 3 9 b c 5 e 3 1 5 4 3 b 1 1 1 3 e b 7 a 0 8 8 d 4 6 1 5 a d 7 5 5 7 a 0 7 0 7 b d a c a 2 7 9 4 0
2017-05-20 05:31:04 +08:00
H E A D _ R E F m a s t e r
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
# We need per-triplet directories because we need to patch the project files differently based on the linkage
# Because the patches patch the same file, they have to be applied in the correct order
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
2019-09-30 09:58:00 +08:00
file ( GLOB HEADERS ${ SOURCE_PATH } /Include/*.h )
2020-03-11 03:25:18 +08:00
file ( INSTALL
$ { H E A D E R S }
" $ { S O U R C E _ P A T H } / P C / p y c o n f i g . h "
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 } "
)
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..." )
file ( GLOB HEADERS
$ { O U T _ P A T H _ R E L E A S E } / i n c l u d e / * )
file ( INSTALL ${ HEADERS } DESTINATION ${ CURRENT_PACKAGES_DIR } /include
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 lib files..." )
file ( GLOB LIBS
$ { 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 } / * )
file ( INSTALL ${ LIBS } DESTINATION ${ CURRENT_PACKAGES_DIR } /share/python ${ PYTHON_VERSION_MAJOR } /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
)
message ( STATUS "Installing ${TARGET_TRIPLET}-rel share files..." )
file ( GLOB LIBS
$ { O U T _ P A T H _ R E L E A S E } / l i b / p k g c o n f i g / * )
file ( INSTALL ${ LIBS } DESTINATION ${ CURRENT_PACKAGES_DIR } /share/python ${ PYTHON_VERSION_MAJOR }
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
$ { 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 } m . * )
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
$ { 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 m . * )
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 ( )