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

Commit

Permalink
Major restructuring of build system. Switched to scikit-build-core fo…
Browse files Browse the repository at this point in the history
…r futureproofing, which means getting rid of setup.py and relying on pyproject.toml. Working on making the Linux build more efficient
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Sep 7, 2023
1 parent 3357312 commit 2eba89b
Show file tree
Hide file tree
Showing 15 changed files with 1,967 additions and 122 deletions.
25 changes: 2 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0...3.27.1)

# Get version stored in text file
FILE(READ "version.txt" VERSION)
PROJECT(swiftest VERSION ${VERSION} LANGUAGES C Fortran)
PROJECT(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran VERSION ${VERSION})

IF (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
SET(COMPILER_OPTIONS "Intel" CACHE STRING "Compiler identified as Intel")
Expand All @@ -37,28 +37,7 @@ IF(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
ENDIF()

# Ensure scikit-build modules
FIND_PACKAGE(Python3 COMPONENTS Interpreter Development.Module REQUIRED)
IF (NOT SKBUILD)
EXECUTE_PROCESS(
COMMAND "${Python3_EXECUTABLE}"
-c "import os, skbuild; print(os.path.dirname(skbuild.__file__))"
OUTPUT_VARIABLE SKBLD_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
FILE(TO_CMAKE_PATH ${SKBLD_DIR} SKBLD_DIR)
LIST(APPEND CMAKE_MODULE_PATH "${SKBLD_DIR}/resources/cmake")
MESSAGE(STATUS "Looking in ${SKBLD_DIR}/resources/cmake for CMake modules")
ENDIF()

# Detect when building against a conda environment set the _using_conda variable
# for use both in this file and in the parent
GET_FILENAME_COMPONENT(_python_bin_dir ${Python3_EXECUTABLE} DIRECTORY)
IF(EXISTS "${_python_bin_dir}/../conda-meta")
MESSAGE("-- Detected conda environment, setting INSTALL_RPATH_USE_LINK_PATH")
SET(_using_conda On)
ELSE()
SET(_using_conda Off)
ENDIF()
FIND_PACKAGE(Python COMPONENTS Interpreter Development.Module REQUIRED)

# Add our local modules to the module path
FILE(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" LOCAL_MODULE_PATH)
Expand Down
3 changes: 0 additions & 3 deletions buildscripts/build_hdf5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,3 @@ if [ $? -ne 0 ]; then
printf "hdf5 could not be compiled.\n"
exit 1
fi

make distclean

4 changes: 1 addition & 3 deletions buildscripts/build_netcdf-c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ fi
if [ $? -ne 0 ]; then
printf "netcdf-c could not be compiled."\n
exit 1
fi

make distclean
fi
5 changes: 1 addition & 4 deletions buildscripts/build_netcdf-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,4 @@ fi
if [ $? -ne 0 ]; then
printf "netcdf-fortran could not be compiled.\n"
exit 1
fi

make distclean

fi
4 changes: 1 addition & 3 deletions buildscripts/build_zlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,4 @@ fi
if [ $? -ne 0 ]; then
printf "zlib could not be compiled.\n"
exit 1
fi

make distclean
fi
3 changes: 1 addition & 2 deletions cmake/Modules/FindCython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#
#=============================================================================
# Copyright 2011 Kitware, Inc.
# Modified 2023 by David A. Minton (daminton@purdue.edu)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,7 +56,7 @@ else()
endif()

if(CYTHON_EXECUTABLE)
set(CYTHON_version_command "${CYTHON_EXECUTABLE} --version") # Added quotes to prevent the string from having a ; inserted in the space
set(CYTHON_version_command ${CYTHON_EXECUTABLE} --version)

execute_process(COMMAND ${CYTHON_version_command}
OUTPUT_VARIABLE CYTHON_version_output
Expand Down
15 changes: 7 additions & 8 deletions cmake/Modules/FindNETCDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@

# - Finds the NetCDF libraries

FILE(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/_dependencies/${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}_${COMPILER_OPTIONS}" NXPREFIX_CANDIDATE)
IF (EXISTS ${NXPREFIX_CANDIDATE})
SET(NCPREFIX_DIR ${NXPREFIX_CANDIDATE} CACHE PATH "Location of provided NetCDF-C dependencies")
SET(NFPREFIX_DIR ${NXPREFIX_CANDIDATE} CACHE PATH "Location of provided NetCDF-Fortran dependencies")
SET(H5PREFIX_DIR ${NXPREFIX_CANDIDATE} CACHE PATH "Location of provided HDF5 dependencies")
SET(ZPREFIX_DIR ${NXPREFIX_CANDIDATE} CACHE PATH "Location of provided zlib dependencies")
SET(NFINCLUDE_DIR "${NFPREFIX_DIR}/include" CACHE PATH "Location of provided netcdf.mod")
ELSEIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
SET(NFPREFIX_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Location of provided NetCDF-Fortran dependencies")
SET(NFINCLUDE_DIR "${NFPREFIX_DIR}/include" CACHE PATH "Location of provided netcdf.mod")
IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
FIND_PATH(NFBIN
NAMES nf-config
HINTS
NFPREFIX_DIR
ENV NETCDF_FORTRAN_HOME
ENV PATH
PATH_SUFFIXES
Expand Down Expand Up @@ -75,6 +71,9 @@ MESSAGE(STATUS "NetCDF-Fortran include directory: ${NETCDF_INCLUDE_DIR}")
IF (BUILD_SHARED_LIBS)
SET(NETCDFF "netcdff")
ELSE ()
SET(NCPREFIX_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Location of provided NetCDF-C dependencies")
SET(H5PREFIX_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Location of provided HDF5 dependencies")
SET(ZPREFIX_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Location of provided zlib dependencies")
IF (CMAKE_SYSTEM_NAME STREQUAL "Windows")
SET(NETCDFF "netcdff.lib")
SET(NETCDF "netcdf.lib")
Expand Down
Loading

0 comments on commit 2eba89b

Please sign in to comment.