aboutsummaryrefslogtreecommitdiff
path: root/ports/boost-python/b2-options.cmake
blob: f9f2e0f6ae7f8cb09217b047fb6c1e38b63e69ab (plain)
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
set(build_python_versions)

if("python2" IN_LIST FEATURES)
    # Find Python2 libraries. Can't use find_package here, but we already know where everything is
    file(GLOB python2_include_dir "${CURRENT_INSTALLED_DIR}/include/python2.*")
    string(REGEX REPLACE ".*python([0-9\.]+).*" "\\1" python2_version "${python2_include_dir}")

    string(APPEND USER_CONFIG_EXTRA_LINES
        "using python : ${python2_version} : : \"${python2_include_dir}\" : \"${CURRENT_INSTALLED_DIR}/lib\" ;\n"
        "using python : ${python2_version} : : \"${python2_include_dir}\" : \"${CURRENT_INSTALLED_DIR}/debug/lib\" : <python-debugging>on ;\n")
    list(APPEND build_python_versions "${python2_version}")
endif()

if("python3" IN_LIST FEATURES)
    # Find Python3 libraries. Can't use find_package here, but we already know where everything is
    file(GLOB python3_include_dir "${CURRENT_INSTALLED_DIR}/include/python3.*")
    string(REGEX REPLACE ".*python([0-9\.]+).*" "\\1" python3_version "${python3_include_dir}")

    string(APPEND USER_CONFIG_EXTRA_LINES
        "using python : ${python3_version} : : \"${python3_include_dir}\" : \"${CURRENT_INSTALLED_DIR}/lib\" ;\n"
        "using python : ${python3_version} : : \"${python3_include_dir}\" : \"${CURRENT_INSTALLED_DIR}/debug/lib\" : <python-debugging>on ;\n")
    list(APPEND build_python_versions "${python3_version}")
endif()

if(NOT build_python_versions)
    message(FATAL_ERROR "Boost.Python requires at least one Python specified as a feature.")
endif()

string(REPLACE ";" "," build_python_versions "${build_python_versions}")
list(APPEND B2_OPTIONS
    python=${build_python_versions}
)

if(CMAKE_CXX_FLAGS_DEBUG MATCHES "BOOST_DEBUG_PYTHON" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
    list(APPEND B2_OPTIONS
        python-debugging=on
    )
endif()