-
Notifications
You must be signed in to change notification settings - Fork 74
cmake: Use upstream helpers for the Config.cmake file #124
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
Open
LecrisUT
wants to merge
3
commits into
Reference-ScaLAPACK:master
Choose a base branch
from
LecrisUT:cmake/refactor/cmake-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
cmake_minimum_required(VERSION 3.17...4.0) | ||
|
||
@PACKAGE_INIT@ | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/scalapackTargets.cmake) | ||
|
||
# Deprecated compatibility shims | ||
if(TARGET scalapack::scalapack) | ||
add_library(scalapack INTERFACE IMPORTED) | ||
target_link_libraries(scalapack INTERFACE scalapack::scalapack) | ||
set_target_properties(scalapack PROPERTIES | ||
DEPRECATION "Target scalapack is deprecated, use scalapack::scalapack instead." | ||
) | ||
endif() | ||
if(TARGET scalapack::scalapack-F) | ||
add_library(scalapack-F INTERFACE IMPORTED) | ||
target_link_libraries(scalapack-F INTERFACE scalapack::scalapack-F) | ||
set_target_properties(scalapack-F PROPERTIES | ||
DEPRECATION "Target scalapack-F is deprecated, use scalapack::scalapack-F instead." | ||
) | ||
endif() |
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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
cmake_minimum_required(VERSION 3.26...4.0) | ||
|
||
## Old test-suite to be modernized | ||
# include only if this is included via `add_subdirectory` | ||
project(scalapack-tests | ||
LANGUAGES C Fortran | ||
) | ||
|
||
if(DEFINED SCALAPACK_SOURCE_DIR) | ||
add_subdirectory(traditional) | ||
if(NOT TARGET scalapack::scalapack) | ||
find_package(scalapack REQUIRED CONFIG) | ||
endif() | ||
|
||
## Modern test-suite is an independent project | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
include(scalapack_tests_helpers) | ||
|
||
# TODO: Add the implementations | ||
project(scalapack-tests | ||
LANGUAGES C Fortran | ||
) | ||
enable_testing() | ||
|
||
# Old test-suite | ||
add_subdirectory(traditional) | ||
|
||
# Packaging tests | ||
add_subdirectory(package) |
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,77 @@ | ||
cmake_minimum_required(VERSION 3.26...4.0) | ||
include_guard() | ||
|
||
function(scalapack_add_test test) | ||
#[===[.md | ||
# scalapack_add_test | ||
|
||
Internal helper for adding functional tests of entire CMake projects | ||
|
||
## Synopsis | ||
```cmake | ||
scalapack_add_test(<name> | ||
[TEST_NAME <test_name>] | ||
[CMAKE_ARGS <arg1> ...] | ||
[LABELS <label1> ...] | ||
) | ||
``` | ||
|
||
## Options | ||
|
||
`<name>` | ||
: Test project to be configured | ||
|
||
This is a subfolder relative to `${CMAKE_CURRENT_SOURCE_DIR}` containing the | ||
test project with `CMakeLists.txt` | ||
|
||
`TEST_NAME` [Default: `<name>`] | ||
: Unique name of the ctest test name being created | ||
|
||
`CMAKE_ARGS` | ||
: Additional CMake args passed to the configure step | ||
]===] | ||
|
||
set(ARGS_Options) | ||
set(ARGS_OneValue | ||
TEST_NAME | ||
) | ||
set(ARGS_MultiValue | ||
CMAKE_ARGS | ||
LABELS | ||
) | ||
cmake_parse_arguments(PARSE_ARGV 1 ARGS "${ARGS_Options}" "${ARGS_OneValue}" "${ARGS_MultiValue}") | ||
# Check required/optional arguments | ||
if(NOT DEFINED ARGS_TEST_NAME) | ||
set(ARGS_TEST_NAME ${test}) | ||
endif() | ||
|
||
if(SCALAPACK_SOURCE_DIR) | ||
# If scalapack is built as part of the same project, use the build artifacts | ||
list(APPEND ARGS_CMAKE_ARGS | ||
-Dscalapack_ROOT=${SCALAPACK_BINARY_DIR} | ||
) | ||
else() | ||
# Otherwise use `scalapack_DIR` which is created after the `find_package` | ||
list(APPEND ARGS_CMAKE_ARGS | ||
-Dscalapack_ROOT=${scalapack_DIR} | ||
) | ||
endif() | ||
# Propagate the compilers used | ||
list(APPEND ARGS_CMAKE_ARGS | ||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | ||
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} | ||
) | ||
|
||
add_test(NAME ${ARGS_TEST_NAME} | ||
COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test ${CMAKE_CURRENT_SOURCE_DIR}/${test} | ||
${CMAKE_CURRENT_BINARY_DIR}/${test} | ||
# Use the same build environment as the current runner | ||
--build-generator "${CMAKE_GENERATOR}" | ||
--build-options | ||
${ARGS_CMAKE_ARGS} | ||
--test-command ${CMAKE_CTEST_COMMAND} | ||
--test-dir ${CMAKE_CURRENT_BINARY_DIR}/${test} | ||
--no-tests=ignore | ||
--output-on-failure | ||
) | ||
endfunction() |
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,2 @@ | ||
scalapack_add_test(find_package) | ||
scalapack_add_test(deprecated_targets) |
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,14 @@ | ||
cmake_minimum_required(VERSION 3.26...4.0) | ||
|
||
project(test_find_package | ||
LANGUAGES C Fortran | ||
) | ||
|
||
find_package(scalapack REQUIRED CONFIG) | ||
|
||
# TODO: Add a proper smoke test | ||
if(NOT TARGET scalapack) | ||
message(FATAL_ERROR "scalapack target not present") | ||
endif() | ||
|
||
enable_testing() |
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,14 @@ | ||
cmake_minimum_required(VERSION 3.26...4.0) | ||
|
||
project(test_find_package | ||
LANGUAGES C Fortran | ||
) | ||
|
||
find_package(scalapack REQUIRED CONFIG) | ||
|
||
# TODO: Add a proper smoke test | ||
if(NOT TARGET scalapack::scalapack) | ||
message(FATAL_ERROR "scalapack::scalapack target not present") | ||
endif() | ||
|
||
enable_testing() |
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
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.
I don't remember why I set this one. But if anyone sees an issue with it just ping me. It might have been related to
add_library(INTERFACE IMPORTED)
or something else in the parts below.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.
Does that mean 4.0 is the max? There is already a 4.1 release candiate.
Uh oh!
There was an error while loading. Please reload this page.
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.
No, it means use policies up to version 4.0 as
NEW
. Read it as we have tested this part with "all cmakes" between<min>...<max>
. The comment is about why I chose3.17
as the minimum. ForConfig.cmake
files, the minimum should be as low as possible.