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

refactor bmi adapters into their own library #672

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ target_include_directories(ngen PUBLIC "${NGEN_INC_DIR}")

add_subdirectory("src/core")
add_subdirectory("src/geojson")
add_subdirectory("src/bmi")
add_subdirectory("src/realizations/catchment")
add_subdirectory("src/forcing")
add_subdirectory("src/utilities/mdarray")
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions src/bmi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include(${PROJECT_SOURCE_DIR}/cmake/dynamic_sourced_library.cmake)
dynamic_sourced_cxx_library(ngen_bmi "${CMAKE_CURRENT_SOURCE_DIR}")

add_library(NGen::ngen_bmi ALIAS ngen_bmi)

target_include_directories(ngen_bmi PUBLIC
${PROJECT_SOURCE_DIR}/include/
${PROJECT_SOURCE_DIR}/include/bmi
${PROJECT_SOURCE_DIR}/include/geojson
${PROJECT_SOURCE_DIR}/include/core/mediator
PhilMiller marked this conversation as resolved.
Show resolved Hide resolved
)

target_link_libraries(ngen_bmi PUBLIC
${CMAKE_DL_LIBS}
NGen::logging
)

if(NGEN_WITH_PYTHON)
target_link_libraries(ngen_bmi PUBLIC pybind11::embed)
endif()

if(NGEN_WITH_BMI_FORTRAN)
target_link_libraries(ngen_bmi PUBLIC bmi_fortran_iso_c)
endif()
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ target_include_directories(core PUBLIC
${PROJECT_SOURCE_DIR}/include/forcing
${PROJECT_SOURCE_DIR}/include/utilities
${PROJECT_SOURCE_DIR}/extern/pybind11/include
${PROJECT_SOURCE_DIR}/include/realizations/catchment
${PROJECT_SOURCE_DIR}/include/bmi
)

if (NGEN_WITH_PYTHON)
Expand Down
1 change: 1 addition & 0 deletions src/core/catchment/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ target_include_directories(core_catchment PUBLIC
${PROJECT_SOURCE_DIR}/include/core/catchment
${PROJECT_SOURCE_DIR}/include/forcing
${PROJECT_SOURCE_DIR}/include/utilities
${PROJECT_SOURCE_DIR}/include/realizations/catchment
)

target_link_libraries(core_catchment PUBLIC
Expand Down
2 changes: 2 additions & 0 deletions src/core/hydrolocation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ target_include_directories(core_hydrolocation PUBLIC
${PROJECT_SOURCE_DIR}/include/core/catchment
${PROJECT_SOURCE_DIR}/include/forcing
${PROJECT_SOURCE_DIR}/include/utilities
${PROJECT_SOURCE_DIR}/include/realizations/catchment
${PROJECT_SOURCE_DIR}/include/geojson
)

target_link_libraries(core_hydrolocation PUBLIC
Expand Down
2 changes: 2 additions & 0 deletions src/core/nexus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ target_include_directories(core_nexus PUBLIC
${PROJECT_SOURCE_DIR}/include/core/catchment
${PROJECT_SOURCE_DIR}/include/forcing
${PROJECT_SOURCE_DIR}/include/utilities
${PROJECT_SOURCE_DIR}/include/realizations/catchment
${PROJECT_SOURCE_DIR}/include/geojson
)

target_link_libraries(core_nexus PUBLIC
Expand Down
9 changes: 2 additions & 7 deletions src/realizations/catchment/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@ target_include_directories(realizations_catchment PUBLIC
${PROJECT_SOURCE_DIR}/include/simulation_time
${PROJECT_SOURCE_DIR}/include/utilities
${PROJECT_SOURCE_DIR}/include/geojson
${PROJECT_SOURCE_DIR}/include/bmi
)

target_link_libraries(realizations_catchment PUBLIC
${CMAKE_DL_LIBS}
NGen::core_catchment
NGen::geojson
NGen::logging
NGen::ngen_bmi
)

if(NGEN_WITH_PYTHON)
target_link_libraries(realizations_catchment PUBLIC pybind11::embed)
endif()

if(NGEN_WITH_BMI_FORTRAN)
target_link_libraries(realizations_catchment PUBLIC bmi_fortran_iso_c)
endif()
27 changes: 20 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ function(ngen_add_test TESTNAME)

if(NGEN_TEST_CREATE)
add_executable(${TESTNAME} ${NGEN_TEST_OBJECTS})
target_include_directories(${TESTNAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/bmi
)
target_link_libraries(${TESTNAME} PUBLIC gtest gtest_main ${NGEN_TEST_LIBRARIES})
set_target_properties(${TESTNAME} PROPERTIES FOLDER test)
gtest_discover_tests(
Expand Down Expand Up @@ -113,6 +116,7 @@ ngen_add_test(
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
NGen::ngen_bmi
testbmicppmodel

)
Expand Down Expand Up @@ -194,27 +198,29 @@ ngen_add_test(
ngen_add_test(
test_bmi_cpp
OBJECTS
realizations/catchments/Bmi_Cpp_Adapter_Test.cpp
bmi/Bmi_Cpp_Adapter_Test.cpp
realizations/catchments/Bmi_Cpp_Formulation_Test.cpp
LIBRARIES
NGen::core
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
NGen::ngen_bmi
)

########################## BMI C Tests
ngen_add_test(
test_bmi_c
OBJECTS
realizations/catchments/Bmi_C_Adapter_Test.cpp
bmi/Bmi_C_Adapter_Test.cpp
realizations/catchments/Bmi_C_Formulation_Test.cpp
LIBRARIES
gmock
NGen::core
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
NGen::ngen_bmi
REQUIRES
NGEN_WITH_BMI_C
)
Expand All @@ -223,13 +229,14 @@ ngen_add_test(
ngen_add_test(
test_bmi_fortran
OBJECTS
realizations/catchments/Bmi_Fortran_Adapter_Test.cpp
bmi/Bmi_Fortran_Adapter_Test.cpp
realizations/catchments/Bmi_Fortran_Formulation_Test.cpp
LIBRARIES
NGen::core
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
NGen::ngen_bmi
REQUIRES
NGEN_WITH_BMI_FORTRAN
)
Expand All @@ -238,13 +245,14 @@ ngen_add_test(
ngen_add_test(
test_bmi_python
OBJECTS
realizations/catchments/Bmi_Py_Adapter_Test.cpp
bmi/Bmi_Py_Adapter_Test.cpp
realizations/catchments/Bmi_Py_Formulation_Test.cpp
LIBRARIES
NGen::core
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
NGen::ngen_bmi
REQUIRES
NGEN_WITH_PYTHON
)
Expand All @@ -260,17 +268,18 @@ ngen_add_test(
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
NGen::ngen_bmi
)

########################## All BMI Unit Tests
ngen_add_test(
test_bmi_unit_all
OBJECTS
realizations/catchments/Bmi_C_Adapter_Test.cpp
bmi/Bmi_C_Adapter_Test.cpp
realizations/catchments/Bmi_C_Formulation_Test.cpp
realizations/catchments/Bmi_Fortran_Adapter_Test.cpp
bmi/Bmi_Fortran_Adapter_Test.cpp
realizations/catchments/Bmi_Fortran_Formulation_Test.cpp
realizations/catchments/Bmi_Py_Adapter_Test.cpp
bmi/Bmi_Py_Adapter_Test.cpp
realizations/catchments/Bmi_Py_Formulation_Test.cpp
realizations/catchments/Bmi_Multi_Formulation_Test.cpp
LIBRARIES
Expand All @@ -279,6 +288,7 @@ ngen_add_test(
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
NGen::ngen_bmi
REQUIRES
NGEN_WITH_BMI_C
NGEN_WITH_BMI_FORTRAN
Expand All @@ -296,6 +306,7 @@ ngen_add_test(
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
NGen::ngen_bmi
)

########################## Routing Tests
Expand Down Expand Up @@ -372,6 +383,7 @@ ngen_add_test(
NGen::mdarray
NGen::mdframe
NGen::logging
NGen::ngen_bmi
testbmicppmodel

)
Expand Down Expand Up @@ -409,5 +421,6 @@ ngen_add_test(
NGen::mdarray
NGen::mdframe
NGen::logging
NGen::ngen_bmi
testbmicppmodel
)
2 changes: 1 addition & 1 deletion test/realizations/Formulation_Manager_Test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "catchments/Bmi_Testing_Util.hpp"
#include "Bmi_Testing_Util.hpp"
#include "Bmi_Cpp_Formulation.hpp"
#include "DataProvider.hpp"
#include "DataProviderSelectors.hpp"
Expand Down
Loading