Файли
rocm-systems/source/python/CMakeLists.txt
T

135 рядки
5.4 KiB
CMake
Неформатований Звичайний вигляд Історія

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)
2022-04-05 00:24:34 -05:00
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}
PROPERTIES PREFIX ""
OUTPUT_NAME libpyrocprofsys
2022-04-25 17:00:52 -05:00
LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
2022-04-25 17:00:52 -05:00
ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
2022-04-25 17:00:52 -05:00
RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
2022-04-25 17:00:52 -05:00
PDB_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
2022-04-05 00:24:34 -05:00
${EXTRA_PROPERTIES})
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()
file(RELATIVE_PATH LIB_RELPATH "${_PYLIB}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
2022-08-01 14:19:19 -05:00
set_target_properties(${_TARGET} PROPERTIES INSTALL_RPATH
"\$ORIGIN:\$ORIGIN/${LIB_RELPATH}")
2022-04-05 00:24:34 -05:00
install(
TARGETS ${_TARGET}
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
2022-04-05 00:24:34 -05:00
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)
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"
"-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
2022-08-28 03:56:13 -05: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
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})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/rocprofsys"
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/rocprofsys" _OUT
2022-04-25 17:00:52 -05:00
"${_IN}")
2022-04-21 21:36:07 -05:00
configure_file(${_IN} ${_OUT} @ONLY)
install(
FILES ${_OUT}
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/rocprofsys
2022-04-21 21:36:07 -05:00
OPTIONAL)
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}
VISIBILITY "hidden" ${pysources} ${pyheaders})
rocprofiler_systems_configure_pytarget(libpyrocprofiler-systems-${_VERSION}
${_VERSION})
2022-04-21 21:36:07 -05:00
if(ROCPROFSYS_USE_PYTHON)
rocprofiler_systems_python_console_script(
"${BINARY_NAME_PREFIX}-python" "rocprofsys"
2022-04-21 21:36:07 -05:00
VERSION ${_VERSION}
ROOT_DIR "${Python3_ROOT_DIR}")
endif()
math(EXPR _INDEX "${_INDEX} + 1")
endforeach()
2022-04-05 00:24:34 -05:00
2022-04-25 17:00:52 -05:00
configure_file(${CMAKE_CURRENT_LIST_DIR}/setup.py.in
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/setup.py @ONLY)
2022-04-25 17:00:52 -05:00
configure_file(${CMAKE_CURRENT_LIST_DIR}/setup.cfg.in
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/setup.cfg @ONLY)
2022-04-25 17:00:52 -05:00
configure_file(${CMAKE_CURRENT_LIST_DIR}/pyproject.toml
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}/pyproject.toml COPYONLY)