Files
rocm-systems/external/otf2/CMakeLists.txt
T
lancesix 9f3cffc39a external/otf2/CMakeLists: Do not pass LDFLAGS from env (#1010)
When configuring the otf2 dependency, CFLAGS, CXXFLAGS, CC and CXX are
explicitly specified, but LDFLAGS is not.  As a consequence, LDFLAGS is
picked up from the environment (if set).  In some build configurations,
the LDFLAG from the environment is not compatible with the rest of the
compiler/linker configuration options specified in CMakeLists.txt,
resulting in the configure script failing.

This patch make sure to specify an empty LDFLAGS when configuring otf2
build to avoid such issues.

Bug: SWDEV-477693
2024-08-09 11:17:22 -05:00

73 řádky
2.3 KiB
CMake

# ======================================================================================
# Builds OTF2
# ======================================================================================
set(ROCPROFILER_BINARY_DIR ${PROJECT_BINARY_DIR})
set(OTF2_VERSION
"3.0.3"
CACHE STRING "OTF2 version")
set(OTF2_URL_HASH
"SHA256=18a3905f7917340387e3edc8e5766f31ab1af41f4ecc5665da6c769ca21c4ee8"
CACHE STRING "OTF2 URL download hash")
project(
OTF2
LANGUAGES C
VERSION ${OTF2_VERSION}
DESCRIPTION "Open Trace Format v2"
HOMEPAGE_URL "https://perftools.pages.jsc.fz-juelich.de/cicd/otf2")
include(FetchContent)
include(ExternalProject)
include(ProcessorCount)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW)
endif()
set(FETCHCONTENT_BASE_DIR ${ROCPROFILER_BINARY_DIR}/external/packages)
fetchcontent_declare(
otf2-source
URL https://perftools.pages.jsc.fz-juelich.de/cicd/otf2/tags/otf2-${OTF2_VERSION}/otf2-${OTF2_VERSION}.tar.gz
URL_HASH ${OTF2_URL_HASH})
fetchcontent_getproperties(ot2f-source)
if(NOT ot2f-source_POPULATED)
message(STATUS "Downloading OTF2...")
fetchcontent_populate(otf2-source)
endif()
set(_otf2_root ${ROCPROFILER_BINARY_DIR}/external/otf2)
set(_otf2_inc_dirs $<BUILD_INTERFACE:${_otf2_root}/include>)
set(_otf2_lib_dirs $<BUILD_INTERFACE:${_otf2_root}/lib>)
set(_otf2_libs $<BUILD_INTERFACE:${_otf2_root}/lib/libotf2${CMAKE_STATIC_LIBRARY_SUFFIX}>)
set(_otf2_build_byproducts "${_otf2_root}/lib/libotf2${CMAKE_STATIC_LIBRARY_SUFFIX}")
find_program(
MAKE_COMMAND
NAMES make gmake
PATH_SUFFIXES bin REQUIRED)
externalproject_add(
otf2-build
PREFIX ${_otf2_root}
SOURCE_DIR ${otf2-source_SOURCE_DIR}
BUILD_IN_SOURCE 1
DOWNLOAD_COMMAND ""
PATCH_COMMAND
${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
<SOURCE_DIR>/configure -q --prefix=${_otf2_root} CFLAGS=-fPIC\ -O3\ -g
CXXFLAGS=-fPIC\ -O3\ -g LDFLAGS= PYTHON=: SPHINX=:
CONFIGURE_COMMAND ${MAKE_COMMAND} install -s
BUILD_COMMAND ""
BUILD_BYPRODUCTS "${_otf2_build_byproducts}"
INSTALL_COMMAND "")
add_library(otf2 INTERFACE)
add_library(otf2::otf2 ALIAS otf2)
target_include_directories(otf2 SYSTEM INTERFACE ${_otf2_inc_dirs})
target_link_directories(otf2 INTERFACE ${_otf2_lib_dirs})
target_link_libraries(otf2 INTERFACE ${_otf2_libs})