Skip to content
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

JDBetteridge/pip install #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ jobs:
cd ..
python -m venv test
source test/bin/activate
pip install rtree>=1.2
pip install "rtree>=1.2"

- name: CMake
shell: bash
run: |
source ../test/bin/activate
cd build
unset pythonLocation
unset Python_ROOT_DIR
unset Python2_ROOT_DIR
unset Python3_ROOT_DIR
cmake .. \
-DBUILD_SHARED_LIBS=ON \
-DMPI_C_COMPILER=$MPICH_DIR/mpicc \
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Contributors to libsupermesh:
* Dr. Patrick E. Farrell, Mathematical Institute, University of Oxford, UK,
and Center for Biomedical Computing, Simula Research Laboratory, Oslo, Norway
* Mr. Matteo Croci, Mathematical Institute, University of Oxford, UK
* Dr. Jack Betteridge, Department of Mathematics, Imperial College London, UK
96 changes: 65 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ set(CMAKE_Fortran_MODULE_DIRECTORY ${LIBSUPERMESH_BINARY_DIR}/include)
include_directories(${LIBSUPERMESH_SOURCE_DIR}/include)
include_directories(${LIBSUPERMESH_BINARY_DIR}/include)
include_directories(${LIBSUPERMESH_BINARY_DIR}/include_local)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
if(${SKBUILD} STREQUAL 2)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
else()
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
endif()

find_package(MPI REQUIRED)
set(link_libraries ${MPI_Fortran_LIBRARIES})
Expand Down Expand Up @@ -126,7 +130,8 @@ message(STATUS "MPIEXEC_EXECUTABLE=${MPIEXEC_EXECUTABLE}")
message(STATUS "")

# Python is not required, but we want to add pip packages to spatialindex search path
find_package(Python)
set(Python_FIND_VIRTUALENV "FIRST")
find_package(Python COMPONENTS Interpreter Development.Module)
if(Python_FOUND)
message(STATUS "Python_VERSION_MAJOR " ${Python_VERSION_MAJOR})
message(STATUS "Python_VERSION_MINOR " ${Python_VERSION_MINOR})
Expand Down Expand Up @@ -183,35 +188,58 @@ if(spatialindexheaders)
endif()

file(GLOB source_files ${LIBSUPERMESH_SOURCE_DIR}/src/*.F90 ${LIBSUPERMESH_SOURCE_DIR}/src/*.c ${LIBSUPERMESH_SOURCE_DIR}/src/*.cpp)
add_library(supermesh ${source_files})
if(${SKBUILD} STREQUAL 2)
python_add_library(supermesh MODULE WITH_SOABI ${source_files})
else()
add_library(supermesh ${source_files})
endif()

set(test_main ${LIBSUPERMESH_SOURCE_DIR}/src/tests/test_main.cpp)
file(GLOB unittest_files ${LIBSUPERMESH_SOURCE_DIR}/src/tests/*.F90)
set(unittests "")
foreach(unittest_file ${unittest_files})
get_filename_component(unittest ${unittest_file} NAME_WE)
add_executable(${unittest} ${unittest_file} ${test_main})
list(APPEND unittests ${unittest})
set_property(TARGET ${unittest} PROPERTY COMPILE_DEFINITIONS "TESTNAME=${unittest}")
if(unittest MATCHES parallel)
add_test(${unittest} ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} ./${unittest} ${MPIEXEC_POSTFLAGS})
else()
add_test(${unittest} ${unittest})
endif()
set_tests_properties(${unittest} PROPERTIES FAIL_REGULAR_EXPRESSION "Fail:")
endforeach()
target_link_libraries(supermesh PUBLIC ${link_libraries})
#~ set_target_properties(supermesh PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
#~ set_target_properties(supermesh PROPERTIES INSTALL_RPATH ${link_libraries})
set_target_properties(supermesh PROPERTIES LINK_FLAGS "${MPI_Fortran_LINK_FLAGS}")
if(${SKBUILD} STREQUAL 2)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)

set(test_link_libraries supermesh ${link_libraries} ${MPI_CXX_LIBRARIES})
target_link_libraries(supermesh ${link_libraries})
set_target_properties(supermesh PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
foreach(test ${unittests})
target_link_libraries(${test} ${test_link_libraries})
endforeach()
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

set_target_properties(supermesh PROPERTIES LINK_FLAGS "${MPI_Fortran_LINK_FLAGS}")
foreach(unittest ${unittests})
set_target_properties(${unittest} PROPERTIES LINK_FLAGS "${MPI_Fortran_LINK_FLAGS} ${MPI_CXX_LINK_FLAGS}")
endforeach()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()

# Only build tests if not built by scikit-build-core
if(NOT ${SKBUILD} STREQUAL 2)
set(test_main ${LIBSUPERMESH_SOURCE_DIR}/src/tests/test_main.cpp)
file(GLOB unittest_files ${LIBSUPERMESH_SOURCE_DIR}/src/tests/*.F90)
set(unittests "")
foreach(unittest_file ${unittest_files})
get_filename_component(unittest ${unittest_file} NAME_WE)
add_executable(${unittest} ${unittest_file} ${test_main})
list(APPEND unittests ${unittest})
set_property(TARGET ${unittest} PROPERTY COMPILE_DEFINITIONS "TESTNAME=${unittest}")
if(unittest MATCHES parallel)
add_test(${unittest} ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} ./${unittest} ${MPIEXEC_POSTFLAGS})
else()
add_test(${unittest} ${unittest})
endif()
set_tests_properties(${unittest} PROPERTIES FAIL_REGULAR_EXPRESSION "Fail:")
endforeach()

set(test_link_libraries supermesh ${link_libraries} ${MPI_CXX_LIBRARIES})
foreach(test ${unittests})
target_link_libraries(${test} ${test_link_libraries})
endforeach()

foreach(unittest ${unittests})
set_target_properties(${unittest} PROPERTIES LINK_FLAGS "${MPI_Fortran_LINK_FLAGS} ${MPI_CXX_LINK_FLAGS}")
endforeach()
endif()

configure_file (
"${LIBSUPERMESH_SOURCE_DIR}/config/libsupermesh.pc.in"
Expand Down Expand Up @@ -245,9 +273,15 @@ if(ENABLE_DOCS)
FORCE_PDF EXCLUDE_FROM_ALL BIBFILES doc/bibliography.bib)
endif()

install(TARGETS supermesh DESTINATION lib)
install(DIRECTORY ${LIBSUPERMESH_BINARY_DIR}/include DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${LIBSUPERMESH_BINARY_DIR}/config/libsupermesh.pc DESTINATION lib/pkgconfig)
if(${SKBUILD} STREQUAL 2)
install(TARGETS supermesh DESTINATION supermesh)
install(DIRECTORY ${LIBSUPERMESH_BINARY_DIR}/include DESTINATION supermesh)
install(FILES ${LIBSUPERMESH_BINARY_DIR}/config/libsupermesh.pc DESTINATION supermesh/lib/pkgconfig)
else()
install(TARGETS supermesh DESTINATION lib)
install(DIRECTORY ${LIBSUPERMESH_BINARY_DIR}/include DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${LIBSUPERMESH_BINARY_DIR}/config/libsupermesh.pc DESTINATION lib/pkgconfig)
endif()

file(GLOB data_files ${LIBSUPERMESH_SOURCE_DIR}/src/tests/data/*.ele
${LIBSUPERMESH_SOURCE_DIR}/src/tests/data/*.node)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ libsupermesh is available under the [GNU Lesser General Public License version 2
* Dr. Patrick E. Farrell, Mathematical Institute, University of Oxford, UK,
and Center for Biomedical Computing, Simula Research Laboratory, Oslo, Norway
* Mr. Matteo Croci, Mathematical Institute, University of Oxford, UK
* Dr. Jack Betteridge, Department of Mathematics, Imperial College London, UK
32 changes: 32 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[project]
name = "libsupermesh"
version = "1.0.1"
description = "A parallel supermeshing library"
readme = "README.md"
authors = [
{name = "James R. Maddison", email = "[email protected]"},
{name = "Iakovos Panourgias", email = ""},
{name = "Patrick E. Farrell", email = ""},
{name = "Matteo Croci", email = ""},
{name = "Jack Betteridge", email = "[email protected]"},
]
maintainers = [
{name = "Jack Betteridge", email = "[email protected]"},
]
dependencies = [
"rtree>=1.2",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
"Programming Language :: Python",
"Operating System :: OS Independent"
]

[project.urls]
Repository = "https://github.com/firedrakeproject/libsupermesh"

[build-system]
requires = ["scikit-build-core", "rtree>=1.2"]
build-backend = "scikit_build_core.build"

Loading