Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
More tweaks to build files in order to reliably get all shared librar…
Browse files Browse the repository at this point in the history
…ies and executables into the right places in the wheels
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Sep 13, 2023
1 parent 1c69766 commit de68a73
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ IF (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27")
CMAKE_POLICY(SET CMP0148 OLD)
ENDIF ()

INCLUDE(GNUInstallDirs)
# Add our local modules to the module path
FILE(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" LOCAL_MODULE_PATH)
LIST(APPEND CMAKE_MODULE_PATH ${LOCAL_MODULE_PATH})
Expand Down Expand Up @@ -73,12 +74,9 @@ ENDIF(WIN32)
# Make sure paths are correct for Unix or Windows style
FILE(TO_CMAKE_PATH ${SRC} SRC)
FILE(TO_CMAKE_PATH ${PY} PY)
FILE(TO_CMAKE_PATH "bin" CMAKE_INSTALL_BINDIR)
FILE(TO_CMAKE_PATH "lib" CMAKE_INSTALL_LIBDIR)
FILE(TO_CMAKE_PATH "include" CMAKE_INSTALL_INCLUDEDIR)

# Have the .mod files placed in the include folder
SET(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_SOURCE_DIR}/${CMAKE_INSTALL_INCLUDEDIR})
SET(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_INCLUDEDIR})

# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
Expand All @@ -102,15 +100,12 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Set the name of the swiftest library
SET(SWIFTEST_LIBRARY swiftest)
SET(SWIFTEST_LIBRARY ${SKBUILD_PROJECT_NAME})

# The source for the SWIFTEST binary and have it placed in the bin folder

ADD_SUBDIRECTORY(${SRC} ${CMAKE_INSTALL_BINDIR})

ADD_SUBDIRECTORY(${PY})


# Add a distclean target to the Makefile
ADD_CUSTOM_TARGET(distclean
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_SOURCE_DIR}/distclean.cmake"
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ build-backend = "scikit_build_core.build"
[tool.scikit-build]
cmake.args = ["-DUSE_SIMD=OFF"]
sdist.include = ["src/globals/globals_module.f90.in","swiftest/*.py","swiftest/*.pyx","swiftest/*.h"]
build-dir = "build/{wheel_tag}"
cmake.verbose = true
logging.level = "INFO"

[tool.cibuildwheel]
test-command = "pytest {package}/tests"
Expand Down Expand Up @@ -95,7 +98,7 @@ RANLIB="/usr/bin/ranlib"
[tool.cibuildwheel.macos]
before-all = [
"brew install coreutils",
"LIBS=\"\" buildscripts/build_dependencies.sh -p ${PREFIX} -d ${TMPDIR}/swiftest.build -m ${MACOSX_DEPLOYMENT_TARGET}"
"LIBS=\"\" buildscripts/build_dependencies.sh -p ${PREFIX} -d ${PREFIX}/build -m ${MACOSX_DEPLOYMENT_TARGET}"
]

[tool.cibuildwheel.linux]
Expand Down
13 changes: 6 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ SET(SWIFTEST_DRIVER swiftest_driver)
ADD_EXECUTABLE(${SWIFTEST_DRIVER} ${DRIVER_src})

# Be sure the executable gets packaged with the wheel
SET_PROPERTY(TARGET ${SWIFTEST_DRIVER} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${SKBUILD_SCRIPTS_DIR})
#SET_PROPERTY(TARGET ${SWIFTEST_DRIVER} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${SKBUILD_SCRIPTS_DIR})

#####################################################
# Add the needed libraries
Expand Down Expand Up @@ -208,7 +208,6 @@ ELSE ()
MESSAGE(STATUS "Quad precision real is not supported")
ENDIF ()


# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
Expand All @@ -222,9 +221,9 @@ IF("${isSystemDir}" STREQUAL "-1")
INSTALL_RPATH "${lib_path}")
endif("${isSystemDir}" STREQUAL "-1")

INSTALL(TARGETS ${SWIFTEST_DRIVER} ${SWIFTEST_LIBRARY}
RUNTIME DESTINATION ${CMAKE_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_SOURCE_DIR}/${CMAKE_INSTALL_INCLUDEDIR}
INSTALL(TARGETS ${SWIFTEST_DRIVER} ${SWIFTEST_LIBRARY}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
2 changes: 1 addition & 1 deletion swiftest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ ENDIF()
PYTHON_EXTENSION_MODULE(${SWIFTEST_BINDINGS})
TARGET_INCLUDE_DIRECTORIES(${SWIFTEST_BINDINGS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_INSTALL_INCLUDEDIR} ${NETCDF_INCLUDE_DIR})

INSTALL(TARGETS ${SWIFTEST_BINDINGS} LIBRARY DESTINATION ${lib_path})
INSTALL(TARGETS ${SWIFTEST_BINDINGS} LIBRARY DESTINATION ${PYTHON_RELATIVE_SITE_PACKAGES_DIR}/${SKBUILD_PROJECT_NAME})

0 comments on commit de68a73

Please sign in to comment.