diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index b4ad40e4..835a9c2e 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -29,6 +29,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y liblapack-dev libblas-dev + - uses: actions/setup-python@v5 - run: pip install -r python/requirements.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b203c4d..a69d73e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,11 +89,6 @@ endif() ################################################################################ # Dependencies -include(musica_util) - -# Add submodules -checkout_submodules() - include(dependencies) ################################################################################ diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 0da5845f..061ef184 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -31,28 +31,37 @@ endif() # MICM if (MUSICA_ENABLE_MICM) - FetchContent_Declare(json - GIT_REPOSITORY https://github.com/nlohmann/json.git - GIT_TAG v3.11.2 + FetchContent_Declare(micm + GIT_REPOSITORY https://github.com/NCAR/micm.git + GIT_TAG v3.5.0-release-candidate ) - FetchContent_MakeAvailable(json) + FetchContent_MakeAvailable(micm) endif() ################################################################################ # TUV-x if (MUSICA_ENABLE_TUVX) - FetchContent_Declare( - yaml-cpp - GIT_REPOSITORY https://github.com/jbeder/yaml-cpp/ - GIT_TAG 0.8.0 + FetchContent_Declare(tuvx + GIT_REPOSITORY https://github.com/NCAR/tuv-x.git + GIT_TAG v0.8.0 ) - FetchContent_MakeAvailable(yaml-cpp) + FetchContent_MakeAvailable(tuvx) endif() ################################################################################ # pybind11 if(MUSICA_ENABLE_PYTHON_LIBRARY) set(PYBIND11_NEWPYTHON ON) - add_subdirectory(${CMAKE_SOURCE_DIR}/lib/pybind11) + + FetchContent_Declare(pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11 + GIT_TAG v2.12.0 + ) + + FetchContent_GetProperties(pybind11) + if(NOT pybind11_POPULATED) + FetchContent_Populate(pybind11) + add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR}) + endif() endif() \ No newline at end of file diff --git a/cmake/musica_util.cmake b/cmake/musica_util.cmake deleted file mode 100644 index 80999bc3..00000000 --- a/cmake/musica_util.cmake +++ /dev/null @@ -1,45 +0,0 @@ -function(checkout_submodules) - find_package(Git) - if(GIT_FOUND) - message(STATUS "Source dir: ${CMAKE_CURRENT_LIST_DIR}") - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git") - # Update submodules as needed - option(GIT_SUBMODULE "Check submodules during build" ON) - if(GIT_SUBMODULE) - message(STATUS "Submodule update") - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - RESULT_VARIABLE GIT_SUBMOD_RESULT) - if(NOT GIT_SUBMOD_RESULT EQUAL "0") - message(WARNING "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") - endif() - endif() - else() - message(WARNING "Unable to find .git directory and cannot checkout submodules") - endif() - else() - message(WARNING "Git was not found") - endif() -endfunction(checkout_submodules) - -function(combine_archives output_archive list_of_input_archives) - set(mri_file ${CMAKE_BINARY_DIR}/${output_archive}.mri) - set(FULL_OUTPUT_PATH ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib${output_archive}.a) - file(WRITE ${mri_file} "create ${FULL_OUTPUT_PATH}\n") - FOREACH(in_archive ${list_of_input_archives}) - file(APPEND ${mri_file} "addlib ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/lib${in_archive}.a\n") - ENDFOREACH() - file(APPEND ${mri_file} "save\n") - file(APPEND ${mri_file} "end\n") - - set(output_archive_dummy_file ${CMAKE_BINARY_DIR}/${output_archive}.dummy) - add_custom_command(OUTPUT ${output_archive_dummy_file} - COMMAND touch ${output_archive_dummy_file} - DEPENDS ${list_of_input_archives}) - - add_library(${output_archive} STATIC ${output_archive_dummy_file}) - set_target_properties(${output_archive} PROPERTIES LINKER_LANGUAGE Fortran) - add_custom_command(TARGET ${output_archive} - POST_BUILD - COMMAND ar -M < ${mri_file}) -endfunction(combine_archives) \ No newline at end of file diff --git a/docker/Dockerfile.fortran-gcc b/docker/Dockerfile.fortran-gcc index bcd6be9e..75f76b5c 100644 --- a/docker/Dockerfile.fortran-gcc +++ b/docker/Dockerfile.fortran-gcc @@ -6,16 +6,17 @@ RUN dnf -y update \ curl \ gcc \ gcc-c++ \ - gdb \ gcc-gfortran \ + gdb \ git \ + hdf5-devel \ + json-devel \ + lapack-devel \ lcov \ libcurl-devel \ - hdf5-devel \ - netcdf-fortran-devel \ m4 \ make \ - json-devel \ + netcdf-fortran-devel \ valgrind \ vim \ zlib-devel \ @@ -35,7 +36,6 @@ RUN cd musica \ && cmake -S . \ -B build \ -D CMAKE_BUILD_TYPE=Release \ - -D MUSICA_ENABLE_TESTS=ON \ -D MUSICA_BUILD_FORTRAN_INTERFACE=ON \ -D MUSICA_ENABLE_MICM=ON \ && cd build \ diff --git a/docker/Dockerfile.fortran-gcc.integration b/docker/Dockerfile.fortran-gcc.integration index 34a45edb..eb679bf1 100644 --- a/docker/Dockerfile.fortran-gcc.integration +++ b/docker/Dockerfile.fortran-gcc.integration @@ -6,16 +6,17 @@ RUN dnf -y update \ curl \ gcc \ gcc-c++ \ - gdb \ gcc-gfortran \ + gdb \ git \ + hdf5-devel \ + json-devel \ + lapack-devel \ lcov \ libcurl-devel \ - hdf5-devel \ - netcdf-fortran-devel \ m4 \ make \ - json-devel \ + netcdf-fortran-devel \ valgrind \ vim \ zlib-devel \ diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index 4a91e20f..11f6d457 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -35,7 +35,7 @@ target_include_directories(musica-fortran ) target_link_libraries(musica-fortran - INTERFACE + PUBLIC musica::musica ) @@ -53,40 +53,15 @@ endif() #################### # TUV-x if (MUSICA_ENABLE_TUVX) - set(TUVX_MOD_DIR ${MUSICA_MOD_DIR}) - set(TUVX_LIB_DIR ${MUSICA_LIB_DIR}) - - add_subdirectory(${CMAKE_SOURCE_DIR}/lib/tuv-x/src ${MUSICA_LIB_DIR}/tuv-x/src) - - # for yaml-cpp - target_compile_features(tuvx_object PRIVATE cxx_std_20) - - set_target_properties(tuvx_object PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY ${MUSICA_LIB_DIR} - Fortran_MODULE_DIRECTORY ${MUSICA_MOD_DIR} - ) - - target_include_directories(tuvx_object - PUBLIC - $ - $ - ) - - target_link_libraries(tuvx_object - PUBLIC - musicacore_object - ) - - target_link_libraries(musica-fortran - PUBLIC - yaml-cpp::yaml-cpp - ) - # add the sources to musica target_sources(musica-fortran PRIVATE $ ) + target_link_libraries(musica-fortran + PUBLIC + tuvx + ) endif() @@ -95,4 +70,11 @@ endif() if(MUSICA_ENABLE_TESTS) add_subdirectory(test) +endif() + +################################################################################ +# installation + +if(MUSICA_ENABLE_INSTALL AND NOT MUSICA_ENABLE_PYTHON_LIBRARY) + add_subdirectory(packaging) endif() \ No newline at end of file diff --git a/fortran/packaging/CMakelists.txt b/fortran/packaging/CMakeLists.txt similarity index 96% rename from fortran/packaging/CMakelists.txt rename to fortran/packaging/CMakeLists.txt index ed4eccd5..779b9dea 100644 --- a/fortran/packaging/CMakelists.txt +++ b/fortran/packaging/CMakeLists.txt @@ -3,6 +3,8 @@ include(CMakePackageConfigHelpers) install( TARGETS musica-fortran + tuvx + yaml-cpp EXPORT musica_fortran_Exports LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -13,6 +15,7 @@ install( install( DIRECTORY ${MUSICA_MOD_DIR}/ + ${tuvx_BINARY_DIR}/include DESTINATION ${MUSICA_INSTALL_INCLUDE_DIR}/musica/fortran FILES_MATCHING PATTERN "*.mod" @@ -62,4 +65,4 @@ if(NOT TARGET uninstall) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) -endif() \ No newline at end of file +endif() diff --git a/lib/micm b/lib/micm deleted file mode 160000 index a833afc6..00000000 --- a/lib/micm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a833afc625df0d697d817a1e56bba239ba7ada80 diff --git a/lib/pybind11 b/lib/pybind11 deleted file mode 160000 index 8b03ffa7..00000000 --- a/lib/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8b03ffa7c06cd9c8a38297b1c8923695d1ff1b07 diff --git a/lib/tuv-x b/lib/tuv-x deleted file mode 160000 index d43b16d2..00000000 --- a/lib/tuv-x +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d43b16d29e26ee1b29085b3c0b6f5d56ec122751 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index f00efc14..9711a941 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -11,7 +11,7 @@ set_target_properties(musica_python PROPERTIES OUTPUT_NAME musica) target_include_directories(musica_python PUBLIC - $ + $ $ ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb52c7f3..ccf959fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,15 +62,7 @@ target_sources(musica #################### # MICM if(MUSICA_ENABLE_MICM) - target_compile_features(musica PUBLIC cxx_std_20) - - target_include_directories(musica - PUBLIC - $ - $ - ) - - target_link_libraries(musica PUBLIC nlohmann_json::nlohmann_json) + target_link_libraries(musica PUBLIC musica::micm) add_subdirectory(micm) endif() diff --git a/src/packaging/CMakeLists.txt b/src/packaging/CMakeLists.txt index 81b5945e..f367ae29 100644 --- a/src/packaging/CMakeLists.txt +++ b/src/packaging/CMakeLists.txt @@ -4,6 +4,7 @@ install( TARGETS musica nlohmann_json + micm EXPORT musica_Exports LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -28,7 +29,7 @@ install( if (MUSICA_ENABLE_MICM) install( DIRECTORY - ${CMAKE_SOURCE_DIR}/lib/micm/include/ + ${micm_SOURCE_DIR}/include/ DESTINATION ${MUSICA_INSTALL_INCLUDE_DIR}/musica ) diff --git a/src/test/connections/micm_c_api.cpp b/src/test/connections/micm_c_api.cpp index a687133b..726957dd 100644 --- a/src/test/connections/micm_c_api.cpp +++ b/src/test/connections/micm_c_api.cpp @@ -68,12 +68,8 @@ TEST_F(MicmCApiTest, GetSpeciesProperty) { ASSERT_STREQ(e.what(), "Species 'bad species' not found"); throw; }}, std::runtime_error); - ASSERT_THROW({ - try { - get_species_property_double(micm, "O3", "bad property"); - } catch (const std::runtime_error& e) { - ASSERT_STREQ(e.what(), "Species property 'bad property' not found for species 'O3'"); - throw; - }}, std::runtime_error); + EXPECT_ANY_THROW( + get_species_property_double(micm, "O3", "bad property") + ); #endif } \ No newline at end of file