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

Use RavenHydroFramework from official GitHub source #24

Merged
merged 40 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
298876e
Update build configuration to fetch official sources on GitHub
Zeitsperre Aug 25, 2023
ee69641
update version
Zeitsperre Aug 25, 2023
0135c33
Merge branch 'main' into from-official-git
Zeitsperre Jan 11, 2024
0ff953a
remove source files and link to RavenHydroFramework via git submodule…
Zeitsperre Jan 11, 2024
5aa197e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 11, 2024
a4c3d24
add .gitignore
Zeitsperre Jan 11, 2024
6d57914
update pre-commit config
Zeitsperre Jan 11, 2024
9ee484e
pull submodules
Zeitsperre Jan 11, 2024
8950a9c
remove submodule
Zeitsperre Jan 11, 2024
6c3e33e
re-add submodule
Zeitsperre Jan 11, 2024
2e0a3f7
WIP - Optimizations
Zeitsperre Jan 11, 2024
49d63e3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 11, 2024
141fb91
WIP - Not working
Zeitsperre Jan 12, 2024
6b2cc06
Merge remote-tracking branch 'origin/from-official-git' into from-off…
Zeitsperre Jan 12, 2024
0d96ced
add notes about configuration
Zeitsperre Feb 29, 2024
0314164
more adjustments
Zeitsperre Mar 1, 2024
0e356f5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 1, 2024
bc4c888
more adjustments
Zeitsperre Mar 5, 2024
0f85e67
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2024
4177dcf
move some configs around, do not set install dir explicitly
Zeitsperre Mar 5, 2024
88a983e
raise cmake version to find zlib easier
Zeitsperre Mar 5, 2024
f289f18
small adjustments
Zeitsperre Mar 5, 2024
c3c36d3
use pre-commit action
Zeitsperre Mar 5, 2024
2ad808a
zlib not required
Zeitsperre Mar 5, 2024
66158c6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2024
48809eb
add Python3.12, ensure license is packaged
Zeitsperre Mar 5, 2024
bd64676
Merge remote-tracking branch 'origin/from-official-git' into from-off…
Zeitsperre Mar 5, 2024
afb7bff
adjust tests
Zeitsperre Mar 5, 2024
7baf929
renamed _core to libraven. Used libraven.cpp from upstream repo. Use …
huard Mar 5, 2024
dd65500
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2024
093089b
pre-commit adjustments
Zeitsperre Mar 5, 2024
a25d34a
Merge branch 'main' into from-official-git
Zeitsperre Mar 5, 2024
1b15c19
do not track _version in git
Zeitsperre Mar 5, 2024
1210622
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 5, 2024
0a84b28
use newest conventions for scikit-build-core, add setuptools_scm as a…
Zeitsperre Mar 5, 2024
686408a
set later setuptools_scm, exclude benchmarking code
Zeitsperre Mar 5, 2024
e78109d
set fetch-depth in order to properly find version string
Zeitsperre Mar 5, 2024
73c97ee
dependency pinning and minor cleanup
Zeitsperre Mar 5, 2024
5580b54
update CHANGES.md
Zeitsperre Mar 5, 2024
a6ae9f4
Merge branch 'main' into from-official-git
Zeitsperre Mar 5, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python${{ matrix.python-version }}
if: ${{ !matrix.conda }}
id: pyinstalled
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CMake
build

#IDEs
.idea
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "RavenHydroFramework"]
path = RavenHydroFramework
url = https://github.com/CSHS-CWRA/RavenHydroFramework
12 changes: 8 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ repos:
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: 'build/_deps/raven-src'
exclude: 'RavenHydroFramework'
- id: end-of-file-fixer
exclude: 'build/_deps/raven-src'
exclude: 'RavenHydroFramework'
- id: check-toml
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
Expand All @@ -27,7 +27,11 @@ repos:
hooks:
- id: clang-format
args: [ '-i' ]
exclude: 'build/_deps/raven-src'
exclude: 'RavenHydroFramework'
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.1
hooks:
- id: gitleaks
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
Expand All @@ -45,6 +49,6 @@ ci:
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: monthly
autoupdate_schedule: quarterly
skip: [ ]
submodules: false
98 changes: 54 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.24...3.27)
cmake_minimum_required(VERSION 3.22)

# Setup Raven Project
PROJECT(${SKBUILD_PROJECT_NAME} LANGUAGES CXX VERSION ${SKBUILD_PROJECT_VERSION})

SET(raven_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps/raven-src)
# Set the RavenHydroFramework source directory
SET(raven_SOURCE_DIR "RavenHydroFramework/src")

# Remove deprecation warnings for GCC
IF(CMAKE_COMPILER_IS_GNUCXX)
Expand All @@ -36,15 +37,34 @@ IF(NOT EXISTS ${raven_SOURCE_DIR} OR ${ALWAYS_DOWNLOAD})
# Define source library location
FetchContent_Declare(
raven
URL ${RAVEN_URL}
URL_HASH SHA256=${RAVEN_SHA256}
GIT_REPOSITORY ${RAVEN_GIT_REPO}
GIT_TAG ${RAVEN_GIT_TAG}
)
# Fetch remote source files without building them
FetchContent_Populate(raven)
ELSE()
message(STATUS "Sources found: ${raven_SOURCE_DIR}")
ENDIF()

# Add CMake module path
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Find header & source
include_directories(${raven_SOURCE_DIR})
FILE(GLOB HEADER "${raven_SOURCE_DIR}/*.h")
FILE(GLOB SOURCE "${raven_SOURCE_DIR}/*.cpp")

# Add Python files
SET(PYBIND11_NEWPYTHON ON)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(_core MODULE src/main.cpp)

target_compile_definitions(_core PRIVATE RAVEN_VERSION_INFO="${RAVEN_VERSION}" REQUIRED)
target_compile_definitions(_core PRIVATE VERSION_INFO="${PROJECT_VERSION}")
target_compile_features(_core PUBLIC cxx_std_11)

# Add NetCDF support
IF(USE_NETCDF)
# Add NetCDF support flag
add_compile_options(-Dnetcdf)
Expand All @@ -58,59 +78,49 @@ IF(USE_NETCDF)
find_package(ZLIB REQUIRED)
ENDIF()

# Add Python files
SET(PYBIND11_NEWPYTHON ON)
find_package(Python COMPONENTS REQUIRED Interpreter Development)
find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(_core MODULE src/main.cpp)
target_compile_definitions(_core PRIVATE RAVEN_VERSION_INFO=${RAVEN_VERSION} REQUIRED)
target_compile_definitions(_core PRIVATE VERSION_INFO=${PROJECT_VERSION})
# Create executable; File extension is OS dependent (Linux: none, Windows: .exe)
IF(COMPILE_EXE)
add_executable(raven
${HEADER}
${SOURCE}
)
target_include_directories(raven PUBLIC ${raven_SOURCE_DIR})

# Find header & source
FILE(GLOB HEADER "${raven_SOURCE_DIR}/*.h")
FILE(GLOB SOURCE "${raven_SOURCE_DIR}/*.cpp")
# FIXME: The issue is that one of these flags determines which files are included in the build, See RavenMain.cpp
# Add flag to indicate which version of ExitGracefully to use (set in RavenMain.cpp)
target_compile_definitions(raven PUBLIC STANDALONE)
# target_compile_definitions(raven PUBLIC BMI_LIBRARY)

set_target_properties(raven PROPERTIES LINKER_LANGUAGE CXX)
ENDIF()

# Add source files to build
add_executable(raven
${SOURCE}
${HEADER}
)
# Add source files
source_group("Header Files" FILES ${HEADER})
source_group("Source Files" FILES ${SOURCE})

# Link Anaconda environment libraries if available, otherwise use system libraries
# if(NOT "${CONDA_LIBRARY_PATH}" STREQUAL "")
# include_directories(${CONDA_LIBRARY_PATH})
# else()
# include_directories(${NetCDF_INCLUDE_DIRS})
# endif()

IF(USE_NETCDF)
# Link relevant NetCDF libraries to build
include_directories(${NetCDF_INCLUDE_DIRS})
target_link_libraries(raven PUBLIC ${NetCDF_LIBRARIES})
target_link_libraries(_core PUBLIC ${NetCDF_LIBRARIES})
IF(COMPILE_EXE)
target_link_libraries(raven PUBLIC ${NetCDF_LIBRARIES})
ENDIF()
ENDIF()

target_compile_features(raven PUBLIC cxx_std_11)
set_target_properties(raven PROPERTIES LINKER_LANGUAGE CXX)

# Install library to environment Python /lib
INSTALL(TARGETS _core LIBRARY DESTINATION ${SKBUILD_PROJECT_NAME})

# Install binary to environment /bin
IF(WIN32)
install(TARGETS raven DESTINATION ${SKBUILD_SCRIPTS_DIR})
ELSE()
add_custom_command(
TARGET raven POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/raven
${SKBUILD_SCRIPTS_DIR}/raven)
IF(COMPILE_EXE)
IF(WIN32)
INSTALL(TARGETS raven DESTINATION ${SKBUILD_SCRIPTS_DIR})
ELSE()
add_custom_command(
TARGET raven POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/raven ${SKBUILD_SCRIPTS_DIR}/raven)
ENDIF()
ENDIF()

# Add License for Raven after building library
add_custom_command(
TARGET raven POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${raven_SOURCE_DIR}/LICENSE
${SKBUILD_SCRIPTS_DIR}/raven_COPYING)
# Unset CMake variables to avoid polluting the cache
unset(COMPILE_LIB CACHE)
unset(COMPILE_EXE CACHE)
1 change: 1 addition & 0 deletions RavenHydroFramework
Submodule RavenHydroFramework added at 932fec
Loading
Loading