-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpython.cmake
More file actions
46 lines (40 loc) · 1.33 KB
/
python.cmake
File metadata and controls
46 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Linux prereqs:
# https://devguide.python.org/getting-started/setup-building/index.html#build-dependencies
# prereqs
foreach(l IN ITEMS bzip2 expat ffi lzma ssl zlib)
include(${l}.cmake)
endforeach()
# Python build
set(python_args
--prefix=${CMAKE_INSTALL_PREFIX}
CC=${CMAKE_C_COMPILER}
CXX=${CMAKE_CXX_COMPILER}
)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
list(APPEND python_args --enable-optimizations)
endif()
if(python_jit AND python_version VERSION_GREATER_EQUAL "3.13")
list(APPEND python_args --enable-experimental-jit)
endif()
set(python_cflags "${CMAKE_C_FLAGS}")
set(python_ldflags "${LDFLAGS}")
# https://docs.python.org/3/using/configure.html
if(OPENSSL_FOUND)
cmake_path(GET OPENSSL_INCLUDE_DIR PARENT_PATH openssl_dir)
else()
set(openssl_dir ${CMAKE_INSTALL_PREFIX})
endif()
list(APPEND python_args --with-openssl=${openssl_dir})
message(STATUS "Python configure args: ${python_args}")
message(STATUS "Python CFLAGS: ${python_cflags}")
message(STATUS "Python LDFLAGS: ${python_ldflags}")
ExternalProject_Add(python
URL ${python_url}
CONFIGURE_COMMAND <SOURCE_DIR>/configure ${python_args} CFLAGS=${python_cflags} LDFLAGS=${python_ldflags}
BUILD_COMMAND ${MAKE_EXECUTABLE} -j${Ncpu}
INSTALL_COMMAND ${MAKE_EXECUTABLE} install
TEST_COMMAND ""
CONFIGURE_HANDLED_BY_BUILD ON
DEPENDS "bzip2;expat;ffi;ssl;xz;zlib"
${terminal_verbose}
)