Files
rocm-systems/projects/rocprofiler-systems/source/python/cmake/ConfigPython.cmake
T

119 lines
3.6 KiB
CMake
Raw Normal View History

2022-04-05 00:24:34 -05:00
# Python configuration
#
# include guard
include_guard(DIRECTORY)
# Stops lookup as soon as a version satisfying version constraints is found.
set(Python3_FIND_STRATEGY
"LOCATION"
CACHE STRING
2025-06-22 10:44:33 -04:00
"Stops lookup as soon as a version satisfying version constraints is found"
)
2022-04-05 00:24:34 -05:00
# virtual environment is used before any other standard paths to look-up for the
# interpreter
set(Python3_FIND_VIRTUALENV
"FIRST"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Virtual environment is used before any other standard paths"
)
2022-04-05 00:24:34 -05:00
set_property(CACHE Python3_FIND_VIRTUALENV PROPERTY STRINGS "FIRST;LAST;NEVER")
if(APPLE)
set(Python3_FIND_FRAMEWORK
"LAST"
CACHE STRING
2025-06-22 10:44:33 -04:00
"Order of preference between Apple-style and unix-style package components"
)
2022-04-05 00:24:34 -05:00
set_property(CACHE Python3_FIND_FRAMEWORK PROPERTY STRINGS "FIRST;LAST;NEVER")
endif()
# PyPy does not support embedding the interpreter
set(Python3_FIND_IMPLEMENTATIONS
"CPython"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Different implementations which will be searched."
)
set_property(
CACHE Python3_FIND_IMPLEMENTATIONS
PROPERTY STRINGS "CPython;IronPython;PyPy"
)
2022-04-05 00:24:34 -05:00
# variable is a 3-tuple specifying, in order, pydebug (d), pymalloc (m) and unicode (u)
# set(Python3_FIND_ABI "OFF" "OFF" "OFF" CACHE STRING "variable is a 3-tuple specifying
# pydebug (d), pymalloc (m) and unicode (u)")
# Create CMake cache entries for the above artifact specification variables so that users
# can edit them interactively. This disables support for multiple version/component
# requirements.
set(Python3_ARTIFACTS_INTERACTIVE
2022-04-21 21:36:07 -05:00
OFF
2025-06-22 10:44:33 -04:00
CACHE BOOL
"Create CMake cache entries so that users can edit them interactively"
FORCE
)
2022-04-05 00:24:34 -05:00
# if("${Python3_USE_STATIC_LIBS}" STREQUAL "ANY") set(Python3_USE_STATIC_LIBS "OFF" CACHE
# STRING "If ON, only static libs; if OFF, only shared libs; if ANY, shared then static")
# set_property(CACHE Python3_USE_STATIC_LIBS PROPERTY STRINGS "ON;OFF;ANY") else()
# unset(Python3_USE_STATIC_LIBS) endif()
2025-06-22 10:44:33 -04:00
foreach(
_VAR
FIND_STRATEGY
FIND_VIRTUALENV
FIND_FRAMEWORK
FIND_IMPLEMENTATIONS
ARTIFACTS_INTERACTIVE
)
2022-04-05 00:24:34 -05:00
if(DEFINED Python3_${_VAR})
set(Python_${_VAR}
"${Python3_${_VAR}}"
2025-06-22 10:44:33 -04:00
CACHE STRING
"Set via Python3_${_VAR} setting (rocprofsys)"
)
2022-04-05 00:24:34 -05:00
mark_as_advanced(Python_${_VAR})
mark_as_advanced(Python3_${_VAR})
endif()
endforeach()
# display version
rocprofiler_systems_add_feature(ROCPROFSYS_PYTHON_VERSIONS
2025-06-22 10:44:33 -04:00
"Python version for rocprofsys" DOC
)
2022-04-05 00:24:34 -05:00
option(PYBIND11_INSTALL "Enable Pybind11 installation" OFF)
if(ROCPROFSYS_BUILD_PYTHON AND NOT TARGET pybind11)
2022-04-05 00:24:34 -05:00
# checkout PyBind11 if not checked out
rocprofiler_systems_checkout_git_submodule(
2022-04-05 00:24:34 -05:00
RECURSIVE
RELATIVE_PATH external/pybind11
2022-04-21 21:36:07 -05:00
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
2022-04-05 00:24:34 -05:00
REPO_URL https://github.com/jrmadsen/pybind11.git
2025-06-22 10:44:33 -04:00
REPO_BRANCH omnitrace
)
2022-04-05 00:24:34 -05:00
2022-04-21 21:36:07 -05:00
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
endif()
set(PYBIND11_NOPYTHON ON)
rocprofiler_systems_save_variables(IPO VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION)
2022-04-21 21:36:07 -05:00
add_subdirectory(${PROJECT_SOURCE_DIR}/external/pybind11)
rocprofiler_systems_restore_variables(IPO
2025-06-22 10:44:33 -04:00
VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION
)
2022-04-05 00:24:34 -05:00
endif()
execute_process(
2025-06-22 10:44:33 -04:00
COMMAND
${PYTHON_EXECUTABLE} -c
"import time ; print('{} {}'.format(time.ctime(), time.tzname[0]))"
OUTPUT_VARIABLE ROCPROFSYS_INSTALL_DATE
2025-06-22 10:44:33 -04:00
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
2022-04-05 00:24:34 -05:00
string(REPLACE " " " " ROCPROFSYS_INSTALL_DATE "${ROCPROFSYS_INSTALL_DATE}")