Dosyalar

.git-blame-ignore-revs dosyasındaki sürümler yok sayılıyor. Bunun yerine normal sorumlu görüntüsü için buraya tıklayın.

150 satır
5.1 KiB
CMake
Ham Kalıcı Bağlantı Normal Görünüm Geçmiş

2022-04-05 00:24:34 -05:00
# ########################################################################################
#
# rocprofsys (Python)
2022-04-05 00:24:34 -05:00
#
# ########################################################################################
if(ROCPROFSYS_BUILD_STATIC_LIBSTDCXX)
# rocprofiler_systems_message(FATAL_ERROR "static libstdc++ is not compatible with
# python bindings")
endif()
2022-04-05 00:24:34 -05:00
# if set, will screw up loading library
unset(CMAKE_DEBUG_POSTFIX)
set(CMAKE_CXX_CLANG_TIDY)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
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})
2022-04-05 00:24:34 -05:00
set_target_properties(
${_TARGET}
2025-06-22 10:44:33 -04:00
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}
)
2022-04-05 00:24:34 -05:00
set(_PYLIB ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys)
2022-04-05 00:24:34 -05:00
if(NOT IS_ABSOLUTE "${_PYLIB}")
set(_PYLIB ${CMAKE_INSTALL_PREFIX}/${_PYLIB})
endif()
if(SKBUILD)
set(LIB_RELPATH ../../..)
2022-04-05 00:24:34 -05:00
else()
2025-06-22 10:44:33 -04:00
file(
RELATIVE_PATH
LIB_RELPATH
"${_PYLIB}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
)
2022-04-05 00:24:34 -05:00
endif()
2025-06-22 10:44:33 -04:00
set_target_properties(
${_TARGET}
PROPERTIES INSTALL_RPATH "\$ORIGIN:\$ORIGIN/${LIB_RELPATH}"
)
2022-04-05 00:24:34 -05:00
2025-06-22 10:44:33 -04:00
install(TARGETS ${_TARGET} DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys OPTIONAL)
2022-04-05 00:24:34 -05:00
endfunction()
# ########################################################################################
add_library(rocprofiler-systems-python-compile-options INTERFACE)
2025-06-22 10:44:33 -04:00
add_library(
rocprofiler-systems::rocprofiler-systems-python-compile-options
ALIAS rocprofiler-systems-python-compile-options
)
2022-05-08 04:40:10 -05:00
add_target_cxx_flag_if_avail(
rocprofiler-systems-python-compile-options "-Wno-unused-value"
"-Wno-range-loop-analysis" "-Wno-deprecated-declarations"
2025-06-22 10:44:33 -04:00
"-Wno-unused-but-set-parameter" "-ftls-model=global-dynamic"
)
2022-04-05 00:24:34 -05:00
file(GLOB pyheaders ${CMAKE_CURRENT_LIST_DIR}/libpyrocprofsys*.hpp)
set(pysources ${CMAKE_CURRENT_LIST_DIR}/libpyrocprofsys.cpp)
2022-04-05 00:24:34 -05:00
set(pybind_libs pybind11::module)
add_library(libpyrocprofiler-systems-interface INTERFACE)
2022-04-05 00:24:34 -05:00
target_link_libraries(
libpyrocprofiler-systems-interface
2025-06-22 10:44:33 -04:00
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
)
2022-04-05 00:24:34 -05:00
rocprofiler_systems_target_compile_definitions(libpyrocprofiler-systems-interface
2025-06-22 10:44:33 -04:00
INTERFACE ROCPROFSYS_PYBIND11_SOURCE
)
2022-04-05 00:24:34 -05:00
add_custom_target(libpyrocprofsys)
2022-05-08 01:40:56 -05:00
file(GLOB_RECURSE PYTHON_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys/*.py)
2022-04-21 21:36:07 -05:00
foreach(_IN ${PYTHON_FILES})
2025-06-22 10:44:33 -04:00
string(
REPLACE
"${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys"
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys"
_OUT
"${_IN}"
)
2022-04-21 21:36:07 -05:00
configure_file(${_IN} ${_OUT} @ONLY)
2025-06-22 10:44:33 -04:00
install(FILES ${_OUT} DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys OPTIONAL)
2022-04-21 21:36:07 -05:00
endforeach()
rocprofiler_systems_python_console_script("${BINARY_NAME_PREFIX}-python" "rocprofsys")
2022-04-21 21:36:07 -05:00
set(_INDEX 0)
foreach(_VERSION ${ROCPROFSYS_PYTHON_VERSIONS})
# add_library(libpyrocprofsys MODULE ${pysources} ${pyheaders})
list(GET ROCPROFSYS_PYTHON_ROOT_DIRS ${_INDEX} Python3_ROOT_DIR)
rocprofiler_systems_pybind11_add_module(
libpyrocprofiler-systems-${_VERSION} MODULE
2022-04-21 21:36:07 -05:00
PYTHON_VERSION ${_VERSION}
2025-06-22 10:44:33 -04:00
VISIBILITY "hidden" ${pysources} ${pyheaders}
)
rocprofiler_systems_configure_pytarget(libpyrocprofiler-systems-${_VERSION}
2025-06-22 10:44:33 -04:00
${_VERSION}
)
2022-04-21 21:36:07 -05:00
math(EXPR _INDEX "${_INDEX} + 1")
endforeach()
2022-04-05 00:24:34 -05:00
2025-06-22 10:44:33 -04:00
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
)