Use gersemi for CMake formatting (#257)
* Replace `cmake-format` with `gersemi`
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
* Remove .cmake-format.yaml
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
* Update workflow to use gersemi
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
* Update CONTRIBUTING.md
* Update helper scripts
* Don't include `*/external/*` in workflows
---------
Signed-off-by: David Galiffi <David.Galiffi@amd.com>
[ROCm/rocprofiler-systems commit: 122623a929]
Este cometimento está contido em:
cometido por
GitHub
ascendente
0403aaa97f
cometimento
8fcf3a50b0
@@ -18,24 +18,25 @@ set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME python)
|
||||
# ########################################################################################
|
||||
|
||||
function(ROCPROFILER_SYSTEMS_CONFIGURE_PYTARGET _TARGET _VERSION)
|
||||
|
||||
add_library(rocprofiler-systems::${_TARGET} ALIAS ${_TARGET})
|
||||
target_link_libraries(${_TARGET} PRIVATE libpyrocprofiler-systems-interface)
|
||||
add_dependencies(libpyrocprofsys ${_TARGET})
|
||||
|
||||
set_target_properties(
|
||||
${_TARGET}
|
||||
PROPERTIES PREFIX ""
|
||||
OUTPUT_NAME libpyrocprofsys
|
||||
LIBRARY_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
ARCHIVE_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
RUNTIME_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
PDB_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
${EXTRA_PROPERTIES})
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME libpyrocprofsys
|
||||
LIBRARY_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
ARCHIVE_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
RUNTIME_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
PDB_OUTPUT_DIRECTORY
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
${EXTRA_PROPERTIES}
|
||||
)
|
||||
|
||||
set(_PYLIB ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys)
|
||||
if(NOT IS_ABSOLUTE "${_PYLIB}")
|
||||
@@ -45,28 +46,34 @@ function(ROCPROFILER_SYSTEMS_CONFIGURE_PYTARGET _TARGET _VERSION)
|
||||
if(SKBUILD)
|
||||
set(LIB_RELPATH ../../..)
|
||||
else()
|
||||
file(RELATIVE_PATH LIB_RELPATH "${_PYLIB}"
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||
file(
|
||||
RELATIVE_PATH
|
||||
LIB_RELPATH
|
||||
"${_PYLIB}"
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
set_target_properties(${_TARGET} PROPERTIES INSTALL_RPATH
|
||||
"\$ORIGIN:\$ORIGIN/${LIB_RELPATH}")
|
||||
set_target_properties(
|
||||
${_TARGET}
|
||||
PROPERTIES INSTALL_RPATH "\$ORIGIN:\$ORIGIN/${LIB_RELPATH}"
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS ${_TARGET}
|
||||
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
OPTIONAL)
|
||||
install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys OPTIONAL)
|
||||
endfunction()
|
||||
|
||||
# ########################################################################################
|
||||
|
||||
add_library(rocprofiler-systems-python-compile-options INTERFACE)
|
||||
add_library(rocprofiler-systems::rocprofiler-systems-python-compile-options ALIAS
|
||||
rocprofiler-systems-python-compile-options)
|
||||
add_library(
|
||||
rocprofiler-systems::rocprofiler-systems-python-compile-options
|
||||
ALIAS rocprofiler-systems-python-compile-options
|
||||
)
|
||||
add_target_cxx_flag_if_avail(
|
||||
rocprofiler-systems-python-compile-options "-Wno-unused-value"
|
||||
"-Wno-range-loop-analysis" "-Wno-deprecated-declarations"
|
||||
"-Wno-unused-but-set-parameter" "-ftls-model=global-dynamic")
|
||||
"-Wno-unused-but-set-parameter" "-ftls-model=global-dynamic"
|
||||
)
|
||||
|
||||
file(GLOB pyheaders ${CMAKE_CURRENT_LIST_DIR}/libpyrocprofsys*.hpp)
|
||||
set(pysources ${CMAKE_CURRENT_LIST_DIR}/libpyrocprofsys.cpp)
|
||||
@@ -76,32 +83,36 @@ set(pybind_libs pybind11::module)
|
||||
add_library(libpyrocprofiler-systems-interface INTERFACE)
|
||||
target_link_libraries(
|
||||
libpyrocprofiler-systems-interface
|
||||
INTERFACE pybind11::module
|
||||
timemory::timemory-headers
|
||||
rocprofiler-systems::rocprofiler-systems-headers
|
||||
rocprofiler-systems::rocprofiler-systems-compile-options
|
||||
rocprofiler-systems::rocprofiler-systems-static-libgcc-optional
|
||||
rocprofiler-systems::rocprofiler-systems-lto
|
||||
rocprofiler-systems::rocprofiler-systems-dl-library
|
||||
rocprofiler-systems::rocprofiler-systems-user-library
|
||||
rocprofiler-systems::rocprofiler-systems-python
|
||||
rocprofiler-systems::rocprofiler-systems-python-compile-options)
|
||||
INTERFACE
|
||||
pybind11::module
|
||||
timemory::timemory-headers
|
||||
rocprofiler-systems::rocprofiler-systems-headers
|
||||
rocprofiler-systems::rocprofiler-systems-compile-options
|
||||
rocprofiler-systems::rocprofiler-systems-static-libgcc-optional
|
||||
rocprofiler-systems::rocprofiler-systems-lto
|
||||
rocprofiler-systems::rocprofiler-systems-dl-library
|
||||
rocprofiler-systems::rocprofiler-systems-user-library
|
||||
rocprofiler-systems::rocprofiler-systems-python
|
||||
rocprofiler-systems::rocprofiler-systems-python-compile-options
|
||||
)
|
||||
|
||||
rocprofiler_systems_target_compile_definitions(libpyrocprofiler-systems-interface
|
||||
INTERFACE ROCPROFSYS_PYBIND11_SOURCE)
|
||||
INTERFACE ROCPROFSYS_PYBIND11_SOURCE
|
||||
)
|
||||
|
||||
add_custom_target(libpyrocprofsys)
|
||||
|
||||
file(GLOB_RECURSE PYTHON_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys/*.py)
|
||||
foreach(_IN ${PYTHON_FILES})
|
||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys"
|
||||
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys" _OUT
|
||||
"${_IN}")
|
||||
string(
|
||||
REPLACE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys"
|
||||
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys"
|
||||
_OUT
|
||||
"${_IN}"
|
||||
)
|
||||
configure_file(${_IN} ${_OUT} @ONLY)
|
||||
install(
|
||||
FILES ${_OUT}
|
||||
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
|
||||
OPTIONAL)
|
||||
install(FILES ${_OUT} DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys OPTIONAL)
|
||||
endforeach()
|
||||
|
||||
rocprofiler_systems_python_console_script("${BINARY_NAME_PREFIX}-python" "rocprofsys")
|
||||
@@ -113,22 +124,34 @@ foreach(_VERSION ${ROCPROFSYS_PYTHON_VERSIONS})
|
||||
rocprofiler_systems_pybind11_add_module(
|
||||
libpyrocprofiler-systems-${_VERSION} MODULE
|
||||
PYTHON_VERSION ${_VERSION}
|
||||
VISIBILITY "hidden" ${pysources} ${pyheaders})
|
||||
VISIBILITY "hidden" ${pysources} ${pyheaders}
|
||||
)
|
||||
rocprofiler_systems_configure_pytarget(libpyrocprofiler-systems-${_VERSION}
|
||||
${_VERSION})
|
||||
${_VERSION}
|
||||
)
|
||||
|
||||
if(ROCPROFSYS_USE_PYTHON)
|
||||
rocprofiler_systems_python_console_script(
|
||||
"${BINARY_NAME_PREFIX}-python" "rocprofsys"
|
||||
VERSION ${_VERSION}
|
||||
ROOT_DIR "${Python3_ROOT_DIR}")
|
||||
ROOT_DIR "${Python3_ROOT_DIR}"
|
||||
)
|
||||
endif()
|
||||
math(EXPR _INDEX "${_INDEX} + 1")
|
||||
endforeach()
|
||||
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/setup.py.in
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/setup.py @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/setup.cfg.in
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/setup.cfg @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/pyproject.toml
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/pyproject.toml COPYONLY)
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_LIST_DIR}/setup.py.in
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/setup.py
|
||||
@ONLY
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_LIST_DIR}/setup.cfg.in
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/setup.cfg
|
||||
@ONLY
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_LIST_DIR}/pyproject.toml
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/pyproject.toml
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
@@ -8,29 +8,37 @@ include_guard(DIRECTORY)
|
||||
set(Python3_FIND_STRATEGY
|
||||
"LOCATION"
|
||||
CACHE STRING
|
||||
"Stops lookup as soon as a version satisfying version constraints is found")
|
||||
"Stops lookup as soon as a version satisfying version constraints is found"
|
||||
)
|
||||
|
||||
# virtual environment is used before any other standard paths to look-up for the
|
||||
# interpreter
|
||||
set(Python3_FIND_VIRTUALENV
|
||||
"FIRST"
|
||||
CACHE STRING "Virtual environment is used before any other standard paths")
|
||||
CACHE STRING
|
||||
"Virtual environment is used before any other standard paths"
|
||||
)
|
||||
set_property(CACHE Python3_FIND_VIRTUALENV PROPERTY STRINGS "FIRST;LAST;NEVER")
|
||||
|
||||
if(APPLE)
|
||||
set(Python3_FIND_FRAMEWORK
|
||||
"LAST"
|
||||
CACHE STRING
|
||||
"Order of preference between Apple-style and unix-style package components")
|
||||
"Order of preference between Apple-style and unix-style package components"
|
||||
)
|
||||
set_property(CACHE Python3_FIND_FRAMEWORK PROPERTY STRINGS "FIRST;LAST;NEVER")
|
||||
endif()
|
||||
|
||||
# PyPy does not support embedding the interpreter
|
||||
set(Python3_FIND_IMPLEMENTATIONS
|
||||
"CPython"
|
||||
CACHE STRING "Different implementations which will be searched.")
|
||||
set_property(CACHE Python3_FIND_IMPLEMENTATIONS PROPERTY STRINGS
|
||||
"CPython;IronPython;PyPy")
|
||||
CACHE STRING
|
||||
"Different implementations which will be searched."
|
||||
)
|
||||
set_property(
|
||||
CACHE Python3_FIND_IMPLEMENTATIONS
|
||||
PROPERTY STRINGS "CPython;IronPython;PyPy"
|
||||
)
|
||||
|
||||
# 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
|
||||
@@ -41,20 +49,30 @@ set_property(CACHE Python3_FIND_IMPLEMENTATIONS PROPERTY STRINGS
|
||||
# requirements.
|
||||
set(Python3_ARTIFACTS_INTERACTIVE
|
||||
OFF
|
||||
CACHE BOOL "Create CMake cache entries so that users can edit them interactively"
|
||||
FORCE)
|
||||
CACHE BOOL
|
||||
"Create CMake cache entries so that users can edit them interactively"
|
||||
FORCE
|
||||
)
|
||||
|
||||
# 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()
|
||||
|
||||
foreach(_VAR FIND_STRATEGY FIND_VIRTUALENV FIND_FRAMEWORK FIND_IMPLEMENTATIONS
|
||||
ARTIFACTS_INTERACTIVE)
|
||||
foreach(
|
||||
_VAR
|
||||
FIND_STRATEGY
|
||||
FIND_VIRTUALENV
|
||||
FIND_FRAMEWORK
|
||||
FIND_IMPLEMENTATIONS
|
||||
ARTIFACTS_INTERACTIVE
|
||||
)
|
||||
if(DEFINED Python3_${_VAR})
|
||||
set(Python_${_VAR}
|
||||
"${Python3_${_VAR}}"
|
||||
CACHE STRING "Set via Python3_${_VAR} setting (rocprofsys)")
|
||||
CACHE STRING
|
||||
"Set via Python3_${_VAR} setting (rocprofsys)"
|
||||
)
|
||||
mark_as_advanced(Python_${_VAR})
|
||||
mark_as_advanced(Python3_${_VAR})
|
||||
endif()
|
||||
@@ -62,7 +80,8 @@ endforeach()
|
||||
|
||||
# display version
|
||||
rocprofiler_systems_add_feature(ROCPROFSYS_PYTHON_VERSIONS
|
||||
"Python version for rocprofsys" DOC)
|
||||
"Python version for rocprofsys" DOC
|
||||
)
|
||||
|
||||
option(PYBIND11_INSTALL "Enable Pybind11 installation" OFF)
|
||||
|
||||
@@ -73,7 +92,8 @@ if(ROCPROFSYS_BUILD_PYTHON AND NOT TARGET pybind11)
|
||||
RELATIVE_PATH external/pybind11
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||
REPO_URL https://github.com/jrmadsen/pybind11.git
|
||||
REPO_BRANCH omnitrace)
|
||||
REPO_BRANCH omnitrace
|
||||
)
|
||||
|
||||
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
|
||||
@@ -82,13 +102,17 @@ if(ROCPROFSYS_BUILD_PYTHON AND NOT TARGET pybind11)
|
||||
rocprofiler_systems_save_variables(IPO VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/external/pybind11)
|
||||
rocprofiler_systems_restore_variables(IPO
|
||||
VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
||||
VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION
|
||||
)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c
|
||||
"import time ; print('{} {}'.format(time.ctime(), time.tzname[0]))"
|
||||
COMMAND
|
||||
${PYTHON_EXECUTABLE} -c
|
||||
"import time ; print('{} {}'.format(time.ctime(), time.tzname[0]))"
|
||||
OUTPUT_VARIABLE ROCPROFSYS_INSTALL_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
string(REPLACE " " " " ROCPROFSYS_INSTALL_DATE "${ROCPROFSYS_INSTALL_DATE}")
|
||||
|
||||
+22
-8
@@ -70,8 +70,15 @@ if(NOT PyBind11Python_COMPONENTS)
|
||||
endif()
|
||||
|
||||
# Use the Python interpreter to find the libs.
|
||||
find_package(${PyBind11Python_PYTHON} ${PyBind11Python_FIND_VERSION} ${_find_exact} MODULE
|
||||
${_find_required} ${_find_quiet} COMPONENTS ${PyBind11Python_COMPONENTS})
|
||||
find_package(
|
||||
${PyBind11Python_PYTHON}
|
||||
${PyBind11Python_FIND_VERSION}
|
||||
${_find_exact}
|
||||
MODULE
|
||||
${_find_required}
|
||||
${_find_quiet}
|
||||
COMPONENTS ${PyBind11Python_COMPONENTS}
|
||||
)
|
||||
|
||||
# According to
|
||||
# https://stackoverflow.com/questions/646518/python-how-to-detect-debug-interpreter
|
||||
@@ -110,7 +117,8 @@ print(s.get_config_var('MULTIARCH') or '');
|
||||
"
|
||||
RESULT_VARIABLE _PYTHON_SUCCESS
|
||||
OUTPUT_VARIABLE _PYTHON_VALUES
|
||||
ERROR_VARIABLE _PYTHON_ERROR_VALUE)
|
||||
ERROR_VARIABLE _PYTHON_ERROR_VALUE
|
||||
)
|
||||
|
||||
if(NOT _PYTHON_SUCCESS MATCHES 0)
|
||||
if(PyBind11Python_FIND_REQUIRED)
|
||||
@@ -139,13 +147,18 @@ list(GET _PYTHON_VALUES 9 PYTHON_MULTIARCH)
|
||||
|
||||
# Make sure the Python has the same pointer-size as the chosen compiler Skip if
|
||||
# CMAKE_SIZEOF_VOID_P is not defined
|
||||
if(CMAKE_SIZEOF_VOID_P AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL
|
||||
"${CMAKE_SIZEOF_VOID_P}"))
|
||||
if(
|
||||
CMAKE_SIZEOF_VOID_P
|
||||
AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL "${CMAKE_SIZEOF_VOID_P}")
|
||||
)
|
||||
if(PyBind11Python_FIND_REQUIRED)
|
||||
math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8")
|
||||
math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8")
|
||||
message(FATAL_ERROR "Python config failure: Python is ${_PYTHON_BITS}-bit, "
|
||||
"chosen compiler is ${_CMAKE_BITS}-bit")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Python config failure: Python is ${_PYTHON_BITS}-bit, "
|
||||
"chosen compiler is ${_CMAKE_BITS}-bit"
|
||||
)
|
||||
endif()
|
||||
set(PyBind11Python_FOUND FALSE)
|
||||
return()
|
||||
@@ -157,7 +170,8 @@ list(GET _PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
|
||||
list(GET _PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
|
||||
list(GET _PYTHON_VERSION_LIST 2 PYTHON_VERSION_PATCH)
|
||||
set(PYTHON_VERSION
|
||||
"${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}")
|
||||
"${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}"
|
||||
)
|
||||
|
||||
# Make sure all directory separators are '/'
|
||||
string(REGEX REPLACE "\\\\" "/" PYTHON_PREFIX "${PYTHON_PREFIX}")
|
||||
|
||||
@@ -26,34 +26,32 @@ function(ROCPROFILER_SYSTEMS_FIND_PYTHON _VAR)
|
||||
set(Python3_FIND_VIRTUALENV "FIRST")
|
||||
set(Python3_ARTIFACTS_INTERACTIVE OFF)
|
||||
|
||||
find_package(Python3 ${ARG_VERSION} ${_EXACT} ${_QUIET} MODULE ${_FIND_REQUIREMENT}
|
||||
COMPONENTS ${ARG_COMPONENTS})
|
||||
find_package(
|
||||
Python3
|
||||
${ARG_VERSION}
|
||||
${_EXACT}
|
||||
${_QUIET}
|
||||
MODULE
|
||||
${_FIND_REQUIREMENT}
|
||||
COMPONENTS ${ARG_COMPONENTS}
|
||||
)
|
||||
|
||||
set(${_VAR}_FOUND
|
||||
"${Python3_FOUND}"
|
||||
PARENT_SCOPE)
|
||||
set(${_VAR}_FOUND "${Python3_FOUND}" PARENT_SCOPE)
|
||||
if(NOT Python3_FOUND)
|
||||
set(${_VAR}_EXECUTABLE
|
||||
""
|
||||
PARENT_SCOPE)
|
||||
set(${_VAR}_ROOT_DIR
|
||||
""
|
||||
PARENT_SCOPE)
|
||||
set(${_VAR}_VERSION
|
||||
""
|
||||
PARENT_SCOPE)
|
||||
set(${_VAR}_EXECUTABLE "" PARENT_SCOPE)
|
||||
set(${_VAR}_ROOT_DIR "" PARENT_SCOPE)
|
||||
set(${_VAR}_VERSION "" PARENT_SCOPE)
|
||||
return()
|
||||
else()
|
||||
set(${_VAR}_EXECUTABLE
|
||||
"${Python3_EXECUTABLE}"
|
||||
PARENT_SCOPE)
|
||||
set(${_VAR}_EXECUTABLE "${Python3_EXECUTABLE}" PARENT_SCOPE)
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${Python3_EXECUTABLE}" "-c"
|
||||
"import sys; print('.'.join(str(v) for v in [sys.version_info[0], sys.version_info[1]])); print(sys.prefix);"
|
||||
RESULT_VARIABLE _PYTHON_SUCCESS
|
||||
OUTPUT_VARIABLE _PYTHON_VALUES
|
||||
ERROR_VARIABLE _PYTHON_ERROR_VALUE)
|
||||
ERROR_VARIABLE _PYTHON_ERROR_VALUE
|
||||
)
|
||||
|
||||
if(_PYTHON_SUCCESS MATCHES 0)
|
||||
# Convert the process output into a list
|
||||
@@ -61,12 +59,8 @@ function(ROCPROFILER_SYSTEMS_FIND_PYTHON _VAR)
|
||||
string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES})
|
||||
list(GET _PYTHON_VALUES 0 _PYTHON_VERSION_LIST)
|
||||
list(GET _PYTHON_VALUES 1 _PYTHON_PREFIX)
|
||||
set(${_VAR}_ROOT_DIR
|
||||
"${_PYTHON_PREFIX}"
|
||||
PARENT_SCOPE)
|
||||
set(${_VAR}_VERSION
|
||||
"${_PYTHON_VERSION_LIST}"
|
||||
PARENT_SCOPE)
|
||||
set(${_VAR}_ROOT_DIR "${_PYTHON_PREFIX}" PARENT_SCOPE)
|
||||
set(${_VAR}_VERSION "${_PYTHON_VERSION_LIST}" PARENT_SCOPE)
|
||||
else()
|
||||
rocprofiler_systems_message(WARNING "${_PYTHON_ERROR_VALUE}")
|
||||
endif()
|
||||
@@ -80,28 +74,26 @@ function(_ROCPROFSYS_PYBIND11_ADD_LTO_FLAGS target_name prefer_thin_lto)
|
||||
# name for each set of flags: the compilation result will be cached base on the result
|
||||
# variable. If the flags work, sets them in cxxflags_out/linkerflags_out internal
|
||||
# cache variables (in addition to ${result}).
|
||||
function(_PYBIND11_RETURN_IF_CXX_AND_LINKER_FLAGS_WORK result cxxflags linkerflags
|
||||
cxxflags_out linkerflags_out)
|
||||
function(
|
||||
_PYBIND11_RETURN_IF_CXX_AND_LINKER_FLAGS_WORK
|
||||
result
|
||||
cxxflags
|
||||
linkerflags
|
||||
cxxflags_out
|
||||
linkerflags_out
|
||||
)
|
||||
include(CheckCXXCompilerFlag)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${linkerflags})
|
||||
check_cxx_compiler_flag("${cxxflags}" ${result})
|
||||
if(${result})
|
||||
set(${cxxflags_out}
|
||||
"${cxxflags}"
|
||||
CACHE INTERNAL "" FORCE)
|
||||
set(${linkerflags_out}
|
||||
"${linkerflags}"
|
||||
CACHE INTERNAL "" FORCE)
|
||||
set(${cxxflags_out} "${cxxflags}" CACHE INTERNAL "" FORCE)
|
||||
set(${linkerflags_out} "${linkerflags}" CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(NOT DEFINED PYBIND11_LTO_CXX_FLAGS)
|
||||
set(PYBIND11_LTO_CXX_FLAGS
|
||||
""
|
||||
CACHE INTERNAL "")
|
||||
set(PYBIND11_LTO_LINKER_FLAGS
|
||||
""
|
||||
CACHE INTERNAL "")
|
||||
set(PYBIND11_LTO_CXX_FLAGS "" CACHE INTERNAL "")
|
||||
set(PYBIND11_LTO_LINKER_FLAGS "" CACHE INTERNAL "")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
set(cxx_append "")
|
||||
@@ -117,19 +109,22 @@ function(_ROCPROFSYS_PYBIND11_ADD_LTO_FLAGS target_name prefer_thin_lto)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND prefer_thin_lto)
|
||||
_pybind11_return_if_cxx_and_linker_flags_work(
|
||||
HAS_FLTO_THIN "-flto=thin${cxx_append}" "-flto=thin${linker_append}"
|
||||
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
|
||||
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT HAS_FLTO_THIN)
|
||||
_pybind11_return_if_cxx_and_linker_flags_work(
|
||||
HAS_FLTO "-flto${cxx_append}" "-flto${linker_append}"
|
||||
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
|
||||
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS
|
||||
)
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
|
||||
# Intel equivalent to LTO is called IPO
|
||||
_pybind11_return_if_cxx_and_linker_flags_work(
|
||||
HAS_INTEL_IPO "-ipo" "-ipo" PYBIND11_LTO_CXX_FLAGS
|
||||
PYBIND11_LTO_LINKER_FLAGS)
|
||||
PYBIND11_LTO_LINKER_FLAGS
|
||||
)
|
||||
elseif(MSVC)
|
||||
# cmake only interprets libraries as linker flags when they start with a -
|
||||
# (otherwise it converts /LTCG to \LTCG as if it was a Windows path). Luckily
|
||||
@@ -137,7 +132,8 @@ function(_ROCPROFSYS_PYBIND11_ADD_LTO_FLAGS target_name prefer_thin_lto)
|
||||
# non-standard:
|
||||
_pybind11_return_if_cxx_and_linker_flags_work(
|
||||
HAS_MSVC_GL_LTCG "/GL" "-LTCG" PYBIND11_LTO_CXX_FLAGS
|
||||
PYBIND11_LTO_LINKER_FLAGS)
|
||||
PYBIND11_LTO_LINKER_FLAGS
|
||||
)
|
||||
endif()
|
||||
|
||||
if(PYBIND11_LTO_CXX_FLAGS)
|
||||
@@ -146,24 +142,35 @@ function(_ROCPROFSYS_PYBIND11_ADD_LTO_FLAGS target_name prefer_thin_lto)
|
||||
rocprofiler_systems_message(
|
||||
STATUS
|
||||
"${target_name} :: LTO disabled (not supported by the compiler and/or linker)"
|
||||
)
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Enable LTO flags if found, except for Debug builds
|
||||
if(PYBIND11_LTO_CXX_FLAGS)
|
||||
target_compile_options(
|
||||
${target_name} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:${PYBIND11_LTO_CXX_FLAGS}>")
|
||||
${target_name}
|
||||
PRIVATE "$<$<NOT:$<CONFIG:Debug>>:${PYBIND11_LTO_CXX_FLAGS}>"
|
||||
)
|
||||
endif()
|
||||
if(PYBIND11_LTO_LINKER_FLAGS)
|
||||
target_link_libraries(
|
||||
${target_name}
|
||||
PRIVATE "$<$<NOT:$<CONFIG:Debug>>:${PYBIND11_LTO_LINKER_FLAGS}>")
|
||||
PRIVATE "$<$<NOT:$<CONFIG:Debug>>:${PYBIND11_LTO_LINKER_FLAGS}>"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
#
|
||||
function(ROCPROFILER_SYSTEMS_PYBIND11_ADD_MODULE target_name)
|
||||
set(options MODULE SHARED EXCLUDE_FROM_ALL NO_EXTRAS SYSTEM THIN_LTO LTO)
|
||||
set(options
|
||||
MODULE
|
||||
SHARED
|
||||
EXCLUDE_FROM_ALL
|
||||
NO_EXTRAS
|
||||
SYSTEM
|
||||
THIN_LTO
|
||||
LTO
|
||||
)
|
||||
set(args PYTHON_VERSION VISIBILITY CXX_STANDARD)
|
||||
set(kwargs)
|
||||
cmake_parse_arguments(ARG "${options}" "${args}" "${kwargs}" ${ARGN})
|
||||
@@ -202,10 +209,14 @@ function(ROCPROFILER_SYSTEMS_PYBIND11_ADD_MODULE target_name)
|
||||
find_package(PyBind11Python ${ARG_PYTHON_VERSION})
|
||||
|
||||
target_include_directories(
|
||||
${target_name} ${inc_isystem}
|
||||
PRIVATE ${PYBIND11_INCLUDE_DIR} # from project CMakeLists.txt
|
||||
PRIVATE ${pybind11_INCLUDE_DIR} # from pybind11Config
|
||||
PRIVATE ${Python3_INCLUDE_DIRS})
|
||||
${target_name}
|
||||
${inc_isystem}
|
||||
PRIVATE
|
||||
${PYBIND11_INCLUDE_DIR} # from project CMakeLists.txt
|
||||
PRIVATE
|
||||
${pybind11_INCLUDE_DIR} # from pybind11Config
|
||||
PRIVATE ${Python3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Python debug libraries expose slightly different objects
|
||||
# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
|
||||
@@ -223,10 +234,14 @@ function(ROCPROFILER_SYSTEMS_PYBIND11_ADD_MODULE target_name)
|
||||
# force it on everything inside the `pybind11` namespace; also turning it on for a
|
||||
# pybind module compilation here avoids potential warnings or issues from having mixed
|
||||
# hidden/non-hidden types.
|
||||
set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET
|
||||
"${ARG_VISIBILITY}")
|
||||
set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET
|
||||
"${ARG_VISIBILITY}")
|
||||
set_target_properties(
|
||||
${target_name}
|
||||
PROPERTIES CXX_VISIBILITY_PRESET "${ARG_VISIBILITY}"
|
||||
)
|
||||
set_target_properties(
|
||||
${target_name}
|
||||
PROPERTIES CUDA_VISIBILITY_PRESET "${ARG_VISIBILITY}"
|
||||
)
|
||||
|
||||
if(WIN32 OR CYGWIN)
|
||||
# Link against the Python shared library on Windows
|
||||
@@ -253,8 +268,10 @@ function(ROCPROFILER_SYSTEMS_PYBIND11_ADD_MODULE target_name)
|
||||
endif()
|
||||
|
||||
# Make sure C++11/14 are enabled
|
||||
set_target_properties(${target_name} PROPERTIES CXX_STANDARD ${ARG_CXX_STANDARD}
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
set_target_properties(
|
||||
${target_name}
|
||||
PROPERTIES CXX_STANDARD ${ARG_CXX_STANDARD} CXX_STANDARD_REQUIRED ON
|
||||
)
|
||||
|
||||
if(ARG_NO_EXTRAS)
|
||||
return()
|
||||
@@ -271,12 +288,14 @@ function(ROCPROFILER_SYSTEMS_PYBIND11_ADD_MODULE target_name)
|
||||
add_custom_command(
|
||||
TARGET ${target_name}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_STRIP} -x $<TARGET_FILE:${target_name}>)
|
||||
COMMAND ${CMAKE_STRIP} -x $<TARGET_FILE:${target_name}>
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
TARGET ${target_name}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${target_name}>)
|
||||
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${target_name}>
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -295,7 +314,8 @@ function(ROCPROFILER_SYSTEMS_PYBIND11_ADD_MODULE target_name)
|
||||
# build to fail.
|
||||
target_compile_options(
|
||||
${target_name}
|
||||
PRIVATE $<$<NOT:$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/MP>>)
|
||||
PRIVATE $<$<NOT:$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/MP>>
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
Criar uma nova questão referindo esta
Bloquear um utilizador