-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[OpenMP] Add ompTest library to OpenMP #147381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
##===----------------------------------------------------------------------===## | ||
# | ||
# Build OMPT unit testing library: ompTest | ||
# | ||
##===----------------------------------------------------------------------===## | ||
|
||
cmake_minimum_required(VERSION 3.22) | ||
project(omptest LANGUAGES CXX) | ||
|
||
option(LIBOMPTEST_BUILD_STANDALONE | ||
"Build ompTest 'standalone', i.e. w/o GoogleTest." | ||
${OPENMP_STANDALONE_BUILD}) | ||
option(LIBOMPTEST_BUILD_UNITTESTS | ||
"Build ompTest's unit tests, requires GoogleTest." OFF) | ||
|
||
# In absence of corresponding OMPT support: exit early | ||
if(NOT ${LIBOMP_OMPT_SUPPORT}) | ||
return() | ||
endif() | ||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
set(OMPTEST_HEADERS | ||
./include/AssertMacros.h | ||
./include/InternalEvent.h | ||
./include/InternalEventCommon.h | ||
./include/Logging.h | ||
./include/OmptAliases.h | ||
./include/OmptAsserter.h | ||
./include/OmptAssertEvent.h | ||
./include/OmptCallbackHandler.h | ||
./include/OmptTester.h | ||
./include/OmptTesterGlobals.h | ||
) | ||
|
||
add_library(omptest | ||
SHARED | ||
|
||
${OMPTEST_HEADERS} | ||
./src/InternalEvent.cpp | ||
./src/InternalEventOperators.cpp | ||
./src/Logging.cpp | ||
./src/OmptAsserter.cpp | ||
./src/OmptAssertEvent.cpp | ||
./src/OmptCallbackHandler.cpp | ||
./src/OmptTester.cpp | ||
) | ||
|
||
# Target: ompTest library | ||
# On (implicit) request of GoogleTest, link against the one provided with LLVM. | ||
if ((NOT LIBOMPTEST_BUILD_STANDALONE) OR LIBOMPTEST_BUILD_UNITTESTS) | ||
# Check if standalone build was requested together with unittests | ||
if (LIBOMPTEST_BUILD_STANDALONE) | ||
# Emit warning: this build actually depends on LLVM's GoogleTest | ||
message(Warning "LIBOMPTEST_BUILD_STANDALONE and LIBOMPTEST_BUILD_UNITTESTS" | ||
" requested simultaneously.\n" | ||
"Linking against LLVM's GoogleTest library archives.\n" | ||
"Disable LIBOMPTEST_BUILD_UNITTESTS to perform an actual" | ||
" standalone build.") | ||
# Explicitly disable LIBOMPTEST_BUILD_STANDALONE | ||
set(LIBOMPTEST_BUILD_STANDALONE OFF) | ||
endif() | ||
|
||
# Use LLVM's gtest library archive | ||
set(GTEST_LIB "${LLVM_BINARY_DIR}/lib/libllvm_gtest.a") | ||
|
||
# Link gtest as whole-archive to expose required symbols | ||
set(GTEST_LINK_CMD "-Wl,--whole-archive" ${GTEST_LIB} | ||
"-Wl,--no-whole-archive" LLVMSupport) | ||
|
||
# Add GoogleTest-based header | ||
target_sources(omptest PRIVATE ./include/OmptTesterGoogleTest.h) | ||
|
||
# Add LLVM-provided GoogleTest include directories. | ||
target_include_directories(omptest PRIVATE | ||
${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include) | ||
|
||
# TODO: Re-visit ABI breaking checks, disable for now. | ||
target_compile_definitions(omptest PUBLIC | ||
-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) | ||
|
||
# Link against gtest and gtest_main | ||
target_link_libraries(omptest PRIVATE ${GTEST_LINK_CMD}) | ||
else() | ||
# Add 'standalone' compile definitions | ||
target_compile_definitions(omptest PRIVATE | ||
-DOPENMP_LIBOMPTEST_BUILD_STANDALONE) | ||
|
||
# Add 'standalone' source files | ||
target_sources(omptest PRIVATE | ||
./include/OmptTesterStandalone.h | ||
./src/OmptTesterStandalone.cpp) | ||
endif() | ||
|
||
# Add common include directories. | ||
target_include_directories(omptest PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${LIBOMP_HEADERS_INSTALL_PATH}/omptest> | ||
) | ||
|
||
target_compile_features(omptest PRIVATE cxx_std_17) | ||
|
||
# Create and install package configuration files. | ||
configure_package_config_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/omptest-config.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/cmake/omptest-config.cmake | ||
INSTALL_DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest" | ||
) | ||
|
||
install(FILES ${omptest_BINARY_DIR}/cmake/omptest-config.cmake | ||
DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest") | ||
|
||
# Install libomptest header files: Copy header-files from include dir | ||
install(DIRECTORY ./include/ | ||
DESTINATION "${LIBOMP_HEADERS_INSTALL_PATH}/omptest" | ||
FILES_MATCHING PATTERN "*.h") | ||
|
||
# Install library and export targets. | ||
# Note: find_package(omptest) may require setting of PATH_SUFFIXES | ||
# Example: "lib/cmake/openmp/omptest", this is due to the install location | ||
install(TARGETS omptest | ||
EXPORT OPENMPomptest | ||
LIBRARY COMPONENT omptest | ||
DESTINATION "${OPENMP_INSTALL_LIBDIR}" | ||
INCLUDES DESTINATION "${LIBOMP_HEADERS_INSTALL_PATH}/omptest") | ||
|
||
# Allow to link omptest by using: target_link_libraries( ... omptest::omptest) | ||
# Additionally, it automatically propagates the include directory. | ||
install(EXPORT OPENMPomptest | ||
DESTINATION "${OPENMP_INSTALL_LIBDIR}/cmake/openmp/omptest" | ||
NAMESPACE omptest:: | ||
FILE omptest-targets.cmake) | ||
|
||
# Discover unit tests (added to check-openmp) | ||
if(LIBOMPTEST_BUILD_UNITTESTS) | ||
add_subdirectory(test) | ||
endif() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this being installed? If I understand correctly, this is a testing library for implementors (i.e. for use by LLVM developers) not for openmp users, so I would not expect it to get installed, just like other testing libraries and binaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhalk I agree, it should not be installed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agreed, I'll guard it so it is only installed when people actively request it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out, PR is up: #155433