Files
rocm-systems/CMakeLists.txt
T

238 lines
7.9 KiB
CMake
Raw Normal View History

2021-08-06 13:08:57 -05:00
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
2021-09-20 11:12:06 -05:00
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND CMAKE_CURRENT_SOURCE_DIR STREQUAL
CMAKE_SOURCE_DIR)
2021-08-06 13:08:57 -05:00
set(MSG "")
message(STATUS "Warning! Building from the source directory is not recommended")
message(STATUS "If unintented, please remove 'CMakeCache.txt' and 'CMakeFiles'")
message(STATUS "and build from a separate directory")
message(AUTHOR_WARNING "In-source build")
endif()
if(NOT UNIX OR APPLE)
message(
AUTHOR_WARNING
2021-11-24 04:59:59 -06:00
"omnitrace only supports Linux. Configure and/or build is likely to fail")
endif()
2021-11-24 04:59:59 -06:00
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" FULL_VERSION_STRING LIMIT_COUNT 1)
string(REGEX REPLACE "(\n|\r)" "" FULL_VERSION_STRING "${FULL_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+)\.([0-9]+)\.([0-9]+)(.*)" "\\1.\\2.\\3" OMNITRACE_VERSION
"${FULL_VERSION_STRING}")
2021-08-06 13:08:57 -05:00
project(
2021-11-24 04:59:59 -06:00
omnitrace
2021-08-17 17:34:34 -05:00
LANGUAGES C CXX
2021-11-24 04:59:59 -06:00
VERSION ${OMNITRACE_VERSION}
DESCRIPTION "CPU/GPU Application tracing with static/dynamic binary instrumentation"
HOMEPAGE_URL "https://github.com/AARInternal/omnitrace")
2021-08-06 13:08:57 -05:00
2021-09-20 11:12:06 -05:00
message(
STATUS
"[${PROJECT_NAME}] version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/cmake/Modules
${CMAKE_MODULE_PATH})
2021-09-20 11:12:06 -05:00
set(BUILD_SHARED_LIBS
ON
CACHE BOOL "Build shared libraries")
set(BUILD_STATIC_LIBS
OFF
CACHE BOOL "Build static libraries")
set(CMAKE_POSITION_INDEPENDENT_CODE
ON
CACHE BOOL "Build position independent code")
2021-08-06 13:08:57 -05:00
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
2021-09-20 11:12:06 -05:00
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Build type" FORCE)
2021-08-06 13:08:57 -05:00
endif()
2021-09-20 11:12:06 -05:00
include(GNUInstallDirs) # install directories
include(MacroUtilities) # various functions and macros
include(Compilers) # compiler identification
include(BuildSettings) # compiler flags
2021-08-06 13:08:57 -05:00
2021-09-20 11:12:06 -05:00
set(CMAKE_CXX_STANDARD
17
CACHE STRING "CXX language standard")
2021-11-24 04:59:59 -06:00
omnitrace_add_feature(CMAKE_CXX_STANDARD "CXX language standard")
omnitrace_add_feature(CMAKE_BUILD_TYPE "Build optimization level")
2021-11-24 04:59:59 -06:00
omnitrace_add_option(CMAKE_CXX_STANDARD_REQUIRED "Require C++ language standard" ON)
omnitrace_add_option(CMAKE_CXX_EXTENSIONS "Compiler specific language extensions" OFF)
omnitrace_add_option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "Enable rpath to linked libraries"
ON)
2021-11-24 04:59:59 -06:00
omnitrace_add_option(OMNITRACE_USE_CLANG_TIDY "Enable clang-tidy" OFF)
omnitrace_add_option(OMNITRACE_USE_MPI "Enable MPI support" OFF)
omnitrace_add_option(OMNITRACE_USE_HIP "Enable HIP support" ON)
omnitrace_add_option(OMNITRACE_USE_ROCTRACER "Enable roctracer support"
${OMNITRACE_USE_HIP})
2022-02-08 17:42:17 -06:00
omnitrace_add_option(
OMNITRACE_USE_ROCM_SMI "Enable rocm-smi support for power/temp/etc. sampling"
${OMNITRACE_USE_HIP})
2021-11-24 04:59:59 -06:00
omnitrace_add_option(OMNITRACE_USE_MPI_HEADERS
"Enable wrapping MPI functions w/o enabling MPI dependency" OFF)
2022-03-07 20:40:48 -06:00
omnitrace_add_option(OMNITRACE_USE_OMPT "Enable OpenMP tools support" OFF)
omnitrace_add_option(OMNITRACE_BUILD_DYNINST "Build dyninst from submodule" OFF)
2022-03-07 20:40:48 -06:00
omnitrace_add_option(OMNITRACE_BUILD_EXAMPLES "Enable building the examples" OFF)
omnitrace_add_option(OMNITRACE_BUILD_TESTING "Enable building the testing suite" OFF)
omnitrace_add_option(OMNITRACE_CUSTOM_DATA_SOURCE "Enable custom data source" OFF)
omnitrace_add_option(OMNITRACE_BUILD_HIDDEN_VISIBILITY
"Build with hidden visibility (disable for Debug builds)" ON)
2022-02-25 03:56:41 -06:00
omnitrace_add_option(OMNITRACE_BUILD_CI "Enable internal asserts, etc." OFF ADVANCED
NO_FEATURE)
if(NOT "$ENV{OMNITRACE_CI}" STREQUAL "")
message(
AUTHOR_WARNING
"OMNITRACE_CI environment variable ($ENV{OMNITRACE_CI}) is overridding the OMNITRACE_BUILD_CI cache value"
)
set(OMNITRACE_BUILD_CI
"$ENV{OMNITRACE_CI}"
CACHE BOOL "Enable internal asserts, etc" FORCE)
endif()
if(NOT OMNITRACE_USE_HIP)
set(OMNITRACE_USE_ROCTRACER
OFF
CACHE BOOL "Disabled via OMNITRACE_USE_HIP=OFF" FORCE)
endif()
2022-03-07 20:40:48 -06:00
if(OMNITRACE_BUILD_TESTING)
set(OMNITRACE_BUILD_EXAMPLES
ON
CACHE BOOL "Enable building the examples" FORCE)
endif()
include(ProcessorCount)
2021-11-24 04:59:59 -06:00
processorcount(OMNITRACE_PROCESSOR_COUNT)
math(EXPR OMNITRACE_THREAD_COUNT "16 * ${OMNITRACE_PROCESSOR_COUNT}")
if(OMNITRACE_THREAD_COUNT LESS 128)
set(OMNITRACE_THREAD_COUNT 128)
endif()
2021-11-24 04:59:59 -06:00
set(OMNITRACE_MAX_THREADS
"${OMNITRACE_THREAD_COUNT}"
CACHE
STRING
"Maximum number of threads in the host application. Likely only needs to be increased if host app does not use thread-pool but creates many threads"
)
2021-11-24 04:59:59 -06:00
omnitrace_add_feature(
OMNITRACE_MAX_THREADS
"Maximum number of total threads supported in the host application (default: max of 128 or 16 * nproc)"
)
2021-09-02 13:14:58 -05:00
# default visibility settings
set(CMAKE_C_VISIBILITY_PRESET
"default"
CACHE STRING "Visibility preset for non-inline C functions")
set(CMAKE_CXX_VISIBILITY_PRESET
"default"
CACHE STRING "Visibility preset for non-inline C++ functions/objects")
set(CMAKE_VISIBILITY_INLINES_HIDDEN
OFF
CACHE BOOL "Visibility preset for inline functions")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(Formatting) # format target
2021-09-20 11:12:06 -05:00
include(Packages) # finds third-party libraries
2021-08-06 13:08:57 -05:00
if(OMNITRACE_USE_HIP OR OMNITRACE_USE_ROCTRACER)
find_package(HIP QUIET)
if(HIP_VERSION_MAJOR GREATER_EQUAL 4 AND HIP_VERSION_MINOR GREATER 3)
set(roctracer_kfdwrapper_LIBRARY)
endif()
else()
set(HIP_VERSION "0.0.0")
set(HIP_VERSION_MAJOR 0)
set(HIP_VERSION_MINOR 0)
set(HIP_VERSION_PATCH 0)
endif()
2021-11-24 04:59:59 -06:00
omnitrace_activate_clang_tidy()
2021-08-06 13:08:57 -05:00
# custom visibility settings
if(OMNITRACE_BUILD_HIDDEN_VISIBILITY)
2022-02-19 02:00:59 -06:00
set(CMAKE_C_VISIBILITY_PRESET "internal")
set(CMAKE_CXX_VISIBILITY_PRESET "internal")
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
endif()
2021-09-15 16:45:49 -05:00
2022-03-22 15:51:57 -05:00
if(OMNITRACE_BUILD_TESTING OR "$ENV{OMNITRACE_CI}" MATCHES "[1-9]+|ON|on|y|yes")
2022-03-07 20:40:48 -06:00
include(CTest)
enable_testing()
endif()
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
2022-02-19 02:00:59 -06:00
# library and executables
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
2022-02-19 02:00:59 -06:00
add_subdirectory(source)
2021-08-06 13:08:57 -05:00
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-09-02 13:14:58 -05:00
#
2021-09-20 11:12:06 -05:00
# miscellaneous installs
2021-09-02 13:14:58 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-09-02 13:14:58 -05:00
configure_file(${PROJECT_SOURCE_DIR}/scripts/setup-env.sh.in
${PROJECT_BINARY_DIR}/scripts/setup-env.sh @ONLY)
2021-09-02 13:14:58 -05:00
install(
2021-11-24 04:59:59 -06:00
PROGRAMS ${PROJECT_SOURCE_DIR}/scripts/omnitrace-merge.jl
2021-09-02 13:14:58 -05:00
DESTINATION ${CMAKE_INSTALL_BINDIR}
OPTIONAL)
install(
2021-09-20 11:12:06 -05:00
FILES ${PROJECT_SOURCE_DIR}/roctrace.cfg
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
OPTIONAL)
install(
FILES ${PROJECT_BINARY_DIR}/scripts/setup-env.sh
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
2021-09-02 13:14:58 -05:00
OPTIONAL)
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# examples
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
2022-02-08 17:42:17 -06:00
if(OMNITRACE_BUILD_LTO)
omnitrace_restore_variables(LTO VARIABLES CMAKE_INTERPROCEDURAL_OPTIMIZATION)
endif()
2022-03-07 20:40:48 -06:00
if(OMNITRACE_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
2021-08-06 13:08:57 -05:00
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# tests
2021-08-06 13:08:57 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:08:57 -05:00
if(OMNITRACE_BUILD_TESTING)
add_subdirectory(tests)
endif()
2021-08-06 13:29:09 -05:00
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:29:09 -05:00
#
2021-09-20 11:12:06 -05:00
# packaging
2021-08-06 13:29:09 -05:00
#
2021-09-20 11:12:06 -05:00
# ------------------------------------------------------------------------------#
2021-08-06 13:29:09 -05:00
include(ConfigCPack)
# ------------------------------------------------------------------------------#
#
# config info
#
# ------------------------------------------------------------------------------#
2021-11-24 04:59:59 -06:00
omnitrace_print_features()