diff --git a/CMakeLists.txt b/CMakeLists.txt index f6a0a1490f..a920b0b2eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/include/realizations/catchment/AbstractCLibBmiAdapter.hpp b/include/bmi/AbstractCLibBmiAdapter.hpp similarity index 100% rename from include/realizations/catchment/AbstractCLibBmiAdapter.hpp rename to include/bmi/AbstractCLibBmiAdapter.hpp diff --git a/include/realizations/catchment/Bmi_Adapter.hpp b/include/bmi/Bmi_Adapter.hpp similarity index 100% rename from include/realizations/catchment/Bmi_Adapter.hpp rename to include/bmi/Bmi_Adapter.hpp diff --git a/include/realizations/catchment/Bmi_C_Adapter.hpp b/include/bmi/Bmi_C_Adapter.hpp similarity index 100% rename from include/realizations/catchment/Bmi_C_Adapter.hpp rename to include/bmi/Bmi_C_Adapter.hpp diff --git a/include/realizations/catchment/Bmi_Cpp_Adapter.hpp b/include/bmi/Bmi_Cpp_Adapter.hpp similarity index 100% rename from include/realizations/catchment/Bmi_Cpp_Adapter.hpp rename to include/bmi/Bmi_Cpp_Adapter.hpp diff --git a/include/realizations/catchment/Bmi_Fortran_Adapter.hpp b/include/bmi/Bmi_Fortran_Adapter.hpp similarity index 100% rename from include/realizations/catchment/Bmi_Fortran_Adapter.hpp rename to include/bmi/Bmi_Fortran_Adapter.hpp diff --git a/include/realizations/catchment/Bmi_Fortran_Common.h b/include/bmi/Bmi_Fortran_Common.h similarity index 100% rename from include/realizations/catchment/Bmi_Fortran_Common.h rename to include/bmi/Bmi_Fortran_Common.h diff --git a/include/realizations/catchment/Bmi_Py_Adapter.hpp b/include/bmi/Bmi_Py_Adapter.hpp similarity index 100% rename from include/realizations/catchment/Bmi_Py_Adapter.hpp rename to include/bmi/Bmi_Py_Adapter.hpp diff --git a/include/realizations/catchment/State_Exception.hpp b/include/bmi/State_Exception.hpp similarity index 100% rename from include/realizations/catchment/State_Exception.hpp rename to include/bmi/State_Exception.hpp diff --git a/src/realizations/catchment/Bmi_C_Adapter.cpp b/src/bmi/Bmi_C_Adapter.cpp similarity index 100% rename from src/realizations/catchment/Bmi_C_Adapter.cpp rename to src/bmi/Bmi_C_Adapter.cpp diff --git a/src/realizations/catchment/Bmi_Cpp_Adapter.cpp b/src/bmi/Bmi_Cpp_Adapter.cpp similarity index 100% rename from src/realizations/catchment/Bmi_Cpp_Adapter.cpp rename to src/bmi/Bmi_Cpp_Adapter.cpp diff --git a/src/realizations/catchment/Bmi_Fortran_Adapter.cpp b/src/bmi/Bmi_Fortran_Adapter.cpp similarity index 100% rename from src/realizations/catchment/Bmi_Fortran_Adapter.cpp rename to src/bmi/Bmi_Fortran_Adapter.cpp diff --git a/src/realizations/catchment/Bmi_Py_Adapter.cpp b/src/bmi/Bmi_Py_Adapter.cpp similarity index 100% rename from src/realizations/catchment/Bmi_Py_Adapter.cpp rename to src/bmi/Bmi_Py_Adapter.cpp diff --git a/src/bmi/CMakeLists.txt b/src/bmi/CMakeLists.txt new file mode 100644 index 0000000000..ee01a1936e --- /dev/null +++ b/src/bmi/CMakeLists.txt @@ -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 + ) + +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() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 668d30877d..14f4b23d11 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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) diff --git a/src/core/catchment/CMakeLists.txt b/src/core/catchment/CMakeLists.txt index e0017d4d3f..4ba27efc05 100644 --- a/src/core/catchment/CMakeLists.txt +++ b/src/core/catchment/CMakeLists.txt @@ -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 diff --git a/src/core/hydrolocation/CMakeLists.txt b/src/core/hydrolocation/CMakeLists.txt index c6446c8810..4645fd20ed 100644 --- a/src/core/hydrolocation/CMakeLists.txt +++ b/src/core/hydrolocation/CMakeLists.txt @@ -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 diff --git a/src/core/nexus/CMakeLists.txt b/src/core/nexus/CMakeLists.txt index 567ef9a6ea..1ac27a2859 100644 --- a/src/core/nexus/CMakeLists.txt +++ b/src/core/nexus/CMakeLists.txt @@ -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 diff --git a/src/realizations/catchment/CMakeLists.txt b/src/realizations/catchment/CMakeLists.txt index 5d1ea91c79..6e36316a1d 100644 --- a/src/realizations/catchment/CMakeLists.txt +++ b/src/realizations/catchment/CMakeLists.txt @@ -11,6 +11,7 @@ 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 @@ -18,12 +19,6 @@ target_link_libraries(realizations_catchment PUBLIC 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() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b050239c1c..65b35f2b74 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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( @@ -113,6 +116,7 @@ ngen_add_test( NGen::realizations_catchment NGen::core_mediator NGen::forcing + NGen::ngen_bmi testbmicppmodel ) @@ -194,20 +198,21 @@ 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 @@ -215,6 +220,7 @@ ngen_add_test( NGen::realizations_catchment NGen::core_mediator NGen::forcing + NGen::ngen_bmi REQUIRES NGEN_WITH_BMI_C ) @@ -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 ) @@ -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 ) @@ -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 @@ -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 @@ -296,6 +306,7 @@ ngen_add_test( NGen::realizations_catchment NGen::core_mediator NGen::forcing + NGen::ngen_bmi ) ########################## Routing Tests @@ -372,6 +383,7 @@ ngen_add_test( NGen::mdarray NGen::mdframe NGen::logging + NGen::ngen_bmi testbmicppmodel ) @@ -409,5 +421,6 @@ ngen_add_test( NGen::mdarray NGen::mdframe NGen::logging + NGen::ngen_bmi testbmicppmodel ) diff --git a/test/realizations/catchments/Bmi_C_Adapter_Test.cpp b/test/bmi/Bmi_C_Adapter_Test.cpp similarity index 100% rename from test/realizations/catchments/Bmi_C_Adapter_Test.cpp rename to test/bmi/Bmi_C_Adapter_Test.cpp diff --git a/test/realizations/catchments/Bmi_Cpp_Adapter_Test.cpp b/test/bmi/Bmi_Cpp_Adapter_Test.cpp similarity index 100% rename from test/realizations/catchments/Bmi_Cpp_Adapter_Test.cpp rename to test/bmi/Bmi_Cpp_Adapter_Test.cpp diff --git a/test/realizations/catchments/Bmi_Fortran_Adapter_Test.cpp b/test/bmi/Bmi_Fortran_Adapter_Test.cpp similarity index 100% rename from test/realizations/catchments/Bmi_Fortran_Adapter_Test.cpp rename to test/bmi/Bmi_Fortran_Adapter_Test.cpp diff --git a/test/realizations/catchments/Bmi_Py_Adapter_Test.cpp b/test/bmi/Bmi_Py_Adapter_Test.cpp similarity index 100% rename from test/realizations/catchments/Bmi_Py_Adapter_Test.cpp rename to test/bmi/Bmi_Py_Adapter_Test.cpp diff --git a/test/realizations/catchments/Bmi_Testing_Util.hpp b/test/bmi/Bmi_Testing_Util.hpp similarity index 100% rename from test/realizations/catchments/Bmi_Testing_Util.hpp rename to test/bmi/Bmi_Testing_Util.hpp diff --git a/test/realizations/Formulation_Manager_Test.cpp b/test/realizations/Formulation_Manager_Test.cpp index 2b38a1c36a..c062c4717c 100644 --- a/test/realizations/Formulation_Manager_Test.cpp +++ b/test/realizations/Formulation_Manager_Test.cpp @@ -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"