├── .github ├── ci-config.yml ├── ci-hpc-config.yml └── workflows │ ├── check-release-version.yml │ ├── ci-single.yml │ ├── ci.yml │ └── sync.yml ├── .gitignore ├── .readthedocs.yml ├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── INSTALL.rst ├── LICENSE ├── NOTICE ├── README.rst ├── VERSION ├── bamboo ├── env.sh └── flags.cmake ├── bin ├── CMakeLists.txt └── ecbuild ├── cmake ├── CMakeLists.txt ├── FindARMPL.cmake ├── FindCMath.cmake ├── FindDl.cmake ├── FindFFTW.cmake ├── FindJemalloc.cmake ├── FindLEX.cmake ├── FindMKL.cmake ├── FindNVPL.cmake ├── FindNetCDF.cmake ├── FindTcmalloc.cmake ├── FindYACC.cmake ├── Findecbuild.cmake ├── VERSION ├── compat │ ├── FindNAG.cmake │ ├── FindNetCDF3.cmake │ ├── README.rst │ ├── ecbuild_add_cxx11_flags.cmake │ ├── ecbuild_add_extra_search_paths.cmake │ ├── ecbuild_check_cxx11.cmake │ ├── ecbuild_compat.cmake │ ├── ecbuild_compat_require.cmake │ ├── ecbuild_compat_setversion.cmake │ ├── ecbuild_compat_tplconfig.cmake │ ├── ecbuild_generate_rpc.cmake │ ├── ecbuild_list_extra_search_paths.cmake │ ├── ecbuild_use_package.cmake │ ├── ecmwf_git.cmake │ └── netcdf_compat.cmake ├── compiler_flags │ ├── Clang_C.cmake │ ├── Clang_CXX.cmake │ ├── Cray_C.cmake │ ├── Cray_CXX.cmake │ ├── Cray_Fortran.cmake │ ├── GNU_C.cmake │ ├── GNU_CXX.cmake │ ├── GNU_Fortran.cmake │ ├── Intel_C.cmake │ ├── Intel_CXX.cmake │ ├── Intel_Fortran.cmake │ ├── PGI_C.cmake │ ├── PGI_CXX.cmake │ └── PGI_Fortran.cmake ├── contrib │ ├── FindEigen3.cmake │ ├── FindNetCDF4.cmake │ ├── GetGitRevisionDescription.cmake │ └── GetGitRevisionDescription.cmake.in ├── ecbuild-config-version.cmake ├── ecbuild-config.cmake ├── ecbuild.cmake ├── ecbuild_add_c_flags.cmake ├── ecbuild_add_cxx_flags.cmake ├── ecbuild_add_executable.cmake ├── ecbuild_add_fortran_flags.cmake ├── ecbuild_add_lang_flags.cmake ├── ecbuild_add_large_file_support.cmake ├── ecbuild_add_library.cmake ├── ecbuild_add_option.cmake ├── ecbuild_add_persistent.cmake ├── ecbuild_add_resources.cmake ├── ecbuild_add_test.cmake ├── ecbuild_append_to_rpath.cmake ├── ecbuild_bundle.cmake ├── ecbuild_cache.cmake ├── ecbuild_check_c_source_return.cmake ├── ecbuild_check_compiler.cmake ├── ecbuild_check_cxx_source_return.cmake ├── ecbuild_check_fortran.cmake ├── ecbuild_check_fortran_source_return.cmake ├── ecbuild_check_os.cmake ├── ecbuild_check_urls.cmake ├── ecbuild_compiler_flags.cmake ├── ecbuild_config.h.in ├── ecbuild_configure_file.cmake ├── ecbuild_declare_project.cmake ├── ecbuild_define_build_types.cmake ├── ecbuild_define_options.cmake ├── ecbuild_define_paths.cmake ├── ecbuild_define_properties.cmake ├── ecbuild_dont_pack.cmake ├── ecbuild_download_resource.cmake ├── ecbuild_echo_targets.cmake ├── ecbuild_enable_fortran.cmake ├── ecbuild_evaluate_dynamic_condition.cmake ├── ecbuild_features.cmake ├── ecbuild_filter_list.cmake ├── ecbuild_find_fortranlibs.cmake ├── ecbuild_find_lexyacc.cmake ├── ecbuild_find_mpi.cmake ├── ecbuild_find_omp.cmake ├── ecbuild_find_package.cmake ├── ecbuild_find_package_search_hints.cmake ├── ecbuild_find_perl.cmake ├── ecbuild_find_python.cmake ├── ecbuild_generate_config_headers.cmake ├── ecbuild_generate_fortran_interfaces.cmake ├── ecbuild_generate_project_config.cmake ├── ecbuild_generate_yy.cmake ├── ecbuild_get_cxx11_flags.cmake ├── ecbuild_get_date.cmake ├── ecbuild_get_resources.cmake ├── ecbuild_get_test_data.cmake ├── ecbuild_git.cmake ├── ecbuild_install_project.cmake ├── ecbuild_list_add_pattern.cmake ├── ecbuild_list_exclude_pattern.cmake ├── ecbuild_list_macros.cmake ├── ecbuild_log.cmake ├── ecbuild_parse_version.cmake ├── ecbuild_pkgconfig.cmake ├── ecbuild_policies.cmake ├── ecbuild_print_summary.cmake ├── ecbuild_project.cmake ├── ecbuild_project_files.cmake ├── ecbuild_regex_escape.cmake ├── ecbuild_remove_fortran_flags.cmake ├── ecbuild_requires_macro_version.cmake ├── ecbuild_separate_sources.cmake ├── ecbuild_setup_test_framework.cmake ├── ecbuild_source_flags.cmake ├── ecbuild_system.cmake ├── ecbuild_target_flags.cmake ├── ecbuild_target_fortran_module_directory.cmake ├── ecbuild_test_endiness.cmake ├── ecbuild_try_run.cmake ├── ecbuild_version.h.in ├── ecbuild_warn_unused_files.cmake ├── ecbuild_windows_replace_symlinks.sh ├── fcm-make-interfaces.cfg.in ├── fortran_features │ ├── CheckFortranFeatures.cmake │ ├── c_size_t.F90 │ ├── c_sizeof.F90 │ ├── derivedtype_interface.F90 │ ├── derivedtype_io.F90 │ ├── finalization.F90 │ └── submodules.F90 ├── gen_source_flags.py ├── md5.in ├── pkg-config.cmake.in ├── pkg-config.pc.in ├── project-config.cmake.in ├── pymain.c ├── sg.pl └── sha1.in ├── doc ├── CMakeLists.txt ├── cmake.py ├── conf.py ├── contrib.rst ├── find.rst ├── generate.py ├── index.rst ├── macros.rst ├── requirements.txt ├── static │ ├── cmake-favicon.ico │ ├── cmake-logo-16.png │ ├── cmake.css │ ├── ecbuild-logo-16.png │ └── ecbuild.ico └── templates │ └── layout.html ├── ecbuild-post-import.cmake.in ├── ecbuild.sublime-project ├── ecbuild_3.0_release_notes.rst ├── ecbuild_3.4_release_notes.rst ├── examples ├── README.rst ├── boost-python-lib │ ├── CMakeLists.txt │ ├── README.md │ ├── mypython.py │ ├── pythonlib.cpp │ └── pythonlib.hpp ├── config-bundle │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── general_config.cmake │ ├── subproj1 │ │ └── CMakeLists.txt │ ├── subproj2 │ │ └── CMakeLists.txt │ └── subproj2_config.cmake ├── cpp-bundle-nested │ ├── CMakeLists.txt │ ├── README.md │ ├── bar │ │ ├── CMakeLists.txt │ │ ├── bar.c │ │ ├── bar.h │ │ ├── foo │ │ │ ├── CMakeLists.txt │ │ │ ├── foo.c │ │ │ ├── foo.h │ │ │ ├── main.cc │ │ │ └── test.cc │ │ ├── main.cc │ │ └── test.cc │ └── baz │ │ ├── CMakeLists.txt │ │ ├── baz.c │ │ ├── baz.h │ │ ├── main.cc │ │ └── test.cc ├── cpp-bundle │ ├── CMakeLists.txt │ ├── README.md │ ├── bar │ │ ├── CMakeLists.txt │ │ ├── bar.c │ │ ├── bar.h │ │ ├── baz.c │ │ ├── baz.h │ │ ├── main.cc │ │ ├── test.cc │ │ ├── zingo.c │ │ └── zingo.h │ └── foo │ │ ├── CMakeLists.txt │ │ ├── foo.c │ │ ├── foo.h │ │ ├── main.cc │ │ └── test.cc ├── cxx11 │ ├── CMakeLists.txt │ ├── README.md │ └── compute.cc ├── find_package │ ├── README │ ├── build.sh │ ├── find_cuda.sh │ ├── find_fftw.sh │ ├── find_fftw_MKL.sh │ ├── find_fftw_NO-MKL-1.sh │ ├── find_fftw_NO-MKL-2.sh │ ├── find_hdf5.sh │ ├── find_jemalloc.sh │ ├── find_lapack.sh │ ├── find_lapack_MKL.sh │ ├── find_netcdf.sh │ ├── find_proj4.sh │ ├── find_tcmalloc.sh │ └── projects │ │ ├── cuda │ │ ├── CMakeLists.txt │ │ ├── add.cu │ │ ├── add.h │ │ ├── kernel_add.cu │ │ ├── kernel_add.h │ │ └── main.cc │ │ ├── fftw │ │ ├── CMakeLists.txt │ │ └── test_fftw.cc │ │ ├── hdf5 │ │ ├── CMakeLists.txt │ │ └── hdf5_examples │ │ │ ├── COPYRIGHT │ │ │ ├── h5_subset.c │ │ │ ├── h5_subset.f90 │ │ │ ├── hl_ex_lite1.c │ │ │ └── hl_exlite.f90 │ │ ├── jemalloc │ │ ├── CMakeLists.txt │ │ ├── main.F90 │ │ └── main.c │ │ ├── lapack │ │ ├── CMakeLists.txt │ │ └── test_dgemm.cc │ │ ├── netcdf │ │ ├── CMakeLists.txt │ │ └── netcdf_examples │ │ │ ├── COPYRIGHT │ │ │ ├── test_netcdf_c.c │ │ │ ├── test_netcdf_cxx.cc │ │ │ ├── test_netcdf_cxx_legacy.cc │ │ │ ├── test_netcdf_f77.F │ │ │ └── test_netcdf_fortran.F90 │ │ ├── proj4 │ │ ├── CMakeLists.txt │ │ └── example.c │ │ └── tcmalloc │ │ ├── CMakeLists.txt │ │ ├── main.F90 │ │ └── main.c ├── fortran-compile-options │ ├── CMakeLists.txt │ └── main.F90 ├── fortran │ ├── CMakeLists.txt │ ├── README.md │ ├── api │ │ ├── area │ │ │ └── area.F90 │ │ └── volume │ │ │ └── volume.F90 │ ├── area_circle.f90 │ ├── area_circle.h │ ├── circle.f90 │ ├── cmake │ │ └── fcm-make-interfaces.cfg │ ├── constants.f90 │ ├── lolo.f95 │ ├── main.F90 │ └── old_circle.f90 ├── mix │ ├── CMakeLists.txt │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ └── foo.cc │ ├── flags.json │ └── fort │ │ ├── CMakeLists.txt │ │ ├── bar │ │ └── bar.f90 │ │ └── baz │ │ └── baz.f90 ├── override-compile-flags │ ├── CMakeLists.txt │ ├── README.md │ ├── bar │ │ ├── CMakeLists.txt │ │ └── bar.c │ └── foo │ │ ├── CMakeLists.txt │ │ ├── flags-cray-8.4.1-debug.json │ │ ├── flags-cray-8.4.1-release.json │ │ ├── flags-cray-debug.json │ │ ├── flags-cray-release.json │ │ ├── flags.cmake │ │ ├── foo.c │ │ ├── foo.f90 │ │ ├── foo_contiguous.f90 │ │ ├── foo_intolerant.f90 │ │ ├── foo_ivybridge.f90 │ │ └── foo_no_debug_symbols.f90 ├── simple │ ├── CMakeLists.txt │ ├── README.md │ ├── circle │ │ ├── CMakeLists.txt │ │ ├── area.f90 │ │ └── test_area.c │ ├── compute │ │ ├── CMakeLists.txt │ │ └── compute.cc │ └── project_summary.cmake └── transitive-dependencies │ ├── README.md │ ├── build-and-run.sh │ ├── clean.sh │ ├── projectA │ ├── CMakeLists.txt │ ├── libraryA.cc │ ├── libraryA.h │ └── libraryA_Private.cc │ ├── projectB │ ├── CMakeLists.txt │ ├── libraryB.cc │ ├── libraryB.h │ └── projectb-import.cmake.in │ └── projectC │ ├── CMakeLists.txt │ ├── libraryC.cc │ ├── libraryC.h │ └── main.cc ├── lib └── cmake │ └── ecbuild │ ├── ecbuild-config-version.cmake │ └── ecbuild-config.cmake ├── project_summary.cmake ├── regressions ├── CMakeLists.txt ├── ECBUILD_359 │ ├── CMakeLists.txt │ ├── run-test.sh.in │ └── test-CMakeLists.txt ├── ECBUILD_399 │ ├── CMakeLists.txt │ ├── buildfail-CMakeLists.txt.in │ ├── buildfail.sh.in │ ├── ld-origin.sh.in │ └── ld-origin │ │ ├── CMakeLists.txt │ │ ├── dso1.c │ │ ├── dso2.c │ │ └── main.c ├── ECBUILD_401 │ ├── CMakeLists.txt │ ├── clean.sh │ ├── projectA │ │ ├── CMakeLists.txt │ │ ├── libraryA.cc │ │ └── libraryA.h │ ├── projectB │ │ ├── CMakeLists.txt │ │ └── main.cc │ └── run-test.sh.in ├── ECBUILD_407 │ ├── CMakeLists.txt │ ├── mybundle │ │ ├── CMakeLists.txt │ │ ├── myexe │ │ │ └── CMakeLists.txt │ │ └── mylib │ │ │ ├── CMakeLists.txt │ │ │ └── mylib-import.cmake.in │ └── run-test.sh.in ├── ECBUILD_415 │ ├── CMakeLists.txt │ └── test_path_append.cmake ├── ECBUILD_433 │ ├── CMakeLists.txt │ ├── proj │ │ ├── CMakeLists.txt │ │ ├── myexe.c │ │ └── mylib.c │ └── run.sh.in ├── ECBUILD_495 │ ├── CMakeLists.txt │ ├── proj │ │ ├── CMakeLists.txt │ │ └── cmake │ │ │ └── FindBar.cmake │ └── run.sh.in ├── ECBUILD_509 │ ├── CMakeLists.txt │ ├── proj │ │ ├── CMakeLists.txt │ │ ├── myexe.c │ │ └── mylib.c │ └── run.sh.in └── ECBUILD_511 │ ├── CMakeLists.txt │ ├── bundleAB │ ├── CMakeLists.txt │ ├── projectA │ │ ├── CMakeLists.txt │ │ ├── libraryA.c │ │ └── libraryA.h │ └── projectB │ │ ├── CMakeLists.txt │ │ ├── libraryB.c │ │ ├── libraryB.h │ │ └── projectb-import.cmake.in │ ├── clean.sh │ ├── projectC │ ├── CMakeLists.txt │ └── main.c │ └── run-test.sh.in ├── share ├── CMakeLists.txt ├── ecbuild │ ├── check_linker │ │ ├── CMakeLists.txt │ │ ├── dso1.c │ │ ├── dso2.c │ │ └── main.c │ └── cmake └── ecmwf_license_header.txt ├── tests ├── CMakeLists.txt ├── bundle_options │ ├── CMakeLists.txt │ ├── clean.sh │ ├── configure.sh │ └── projx │ │ ├── CMakeLists.txt │ │ ├── proja │ │ └── CMakeLists.txt │ │ └── projb │ │ └── CMakeLists.txt ├── bundle_override_features │ ├── CMakeLists.txt │ ├── bundle │ │ ├── CMakeLists.txt │ │ ├── project_a │ │ │ └── CMakeLists.txt │ │ └── project_b │ │ │ └── CMakeLists.txt │ └── run-test.sh.in ├── bundle_subdir │ ├── CMakeLists.txt │ ├── mybundle │ │ ├── CMakeLists.txt │ │ └── myexe │ │ │ └── CMakeLists.txt.in │ ├── mylib.in │ │ ├── CMakeLists.txt │ │ └── mylib-import.cmake.in │ └── run-test.sh.in ├── bundle_subproj │ ├── CMakeLists.txt │ ├── mybundle │ │ ├── CMakeLists.txt │ │ ├── ecbuild │ │ └── mylib │ │ │ ├── CMakeLists.txt │ │ │ └── mylib-import.cmake.in │ └── run-test.sh.in ├── ecbuild_add_flags │ ├── CMakeLists.txt │ ├── run-test.sh.in │ └── test_ecbuild_add_flags.cmake ├── ecbuild_add_option │ ├── CMakeLists.txt │ ├── build-and-run.sh │ ├── clean.sh │ └── test_project │ │ ├── CMakeLists.txt │ │ └── cmake │ │ ├── Findbar.cmake │ │ └── Findfoo.cmake ├── ecbuild_add_option_multiproject_defaults │ ├── CMakeLists.txt │ ├── clean.sh │ ├── configure.sh │ └── test_project │ │ ├── CMakeLists.txt │ │ ├── proja │ │ └── CMakeLists.txt │ │ ├── projb │ │ └── CMakeLists.txt │ │ └── projc │ │ └── CMakeLists.txt ├── ecbuild_find_package │ ├── CMakeLists.txt │ ├── README.md │ ├── build-and-run.sh │ ├── clean.sh │ ├── projectA │ │ ├── CMakeLists.txt │ │ ├── libraryA.cc │ │ ├── libraryA.h │ │ ├── libraryA_Private.cc │ │ └── projecta-import.cmake.in │ ├── projectB │ │ ├── CMakeLists.txt │ │ ├── libraryB.cc │ │ ├── libraryB.h │ │ └── projectb-import.cmake.in │ └── projectC │ │ ├── CMakeLists.txt │ │ ├── cmake │ │ └── FindprojectB.cmake │ │ ├── libraryC.cc │ │ ├── libraryC.h │ │ └── main.cc ├── ecbuild_override_compiler_flags │ ├── CMakeLists.txt │ ├── compiler_flags.cmake │ ├── emptyfile.F90 │ ├── emptyfile.c │ ├── emptyfile.cxx │ ├── run-test.sh.in │ └── test_ecbuild_override_compiler_flags.cmake ├── ecbuild_regex_escape │ ├── CMakeLists.txt │ └── test_ecbuild_regex_escape.cmake ├── ecbuild_remove_fortran_flags │ ├── CMakeLists.txt │ └── test_ecbuild_remove_fortran_flags.cmake ├── ecbuild_shared_libs │ ├── CMakeLists.txt │ ├── build-and-run.sh │ ├── clean.sh │ └── test_project │ │ ├── CMakeLists.txt │ │ └── dummy_src.F90 ├── find_ecbuild │ ├── CMakeLists.txt │ ├── run-test.sh.in │ └── test-CMakeLists.txt ├── interface_library │ ├── .gitignore │ ├── CMakeLists.txt │ ├── build-and-run.sh │ ├── clean.sh │ └── test_project │ │ └── CMakeLists.txt ├── project_import │ ├── CMakeLists.txt │ ├── projectA │ │ ├── CMakeLists.txt │ │ ├── libA.c │ │ ├── projecta-import.cmake.in │ │ └── projecta-post-import.cmake.in │ ├── projectB │ │ ├── CMakeLists.txt │ │ ├── libB.c │ │ ├── projectb-import.cmake │ │ └── projectb-post-import.cmake │ ├── projectC │ │ └── CMakeLists.txt │ └── run-test.sh.in ├── project_options │ ├── CMakeLists.txt │ ├── clean.sh │ ├── configure.sh │ └── test_project │ │ └── CMakeLists.txt ├── project_options_cached │ ├── CMakeLists.txt │ ├── clean.sh │ ├── configure.sh │ └── test_project │ │ └── CMakeLists.txt ├── project_options_cached_multiproject │ ├── CMakeLists.txt │ ├── clean.sh │ ├── configure.sh │ └── test_project │ │ ├── CMakeLists.txt │ │ ├── proja │ │ └── CMakeLists.txt │ │ └── projb │ │ └── CMakeLists.txt ├── project_summary │ ├── CMakeLists.txt │ ├── clean.sh │ ├── configure.sh │ └── test_project │ │ ├── CMakeLists.txt │ │ ├── proja │ │ └── CMakeLists.txt │ │ ├── projb │ │ └── CMakeLists.txt │ │ └── projc │ │ └── CMakeLists.txt ├── test_properties │ ├── CMakeLists.txt │ ├── build-and-run.sh │ └── test_project │ │ └── CMakeLists.txt ├── test_requires_complex │ ├── CMakeLists.txt │ ├── build-and-run.sh │ └── test_project │ │ └── CMakeLists.txt └── test_requires_simple │ ├── CMakeLists.txt │ ├── build-and-run.sh │ └── test_project │ └── CMakeLists.txt ├── tools ├── CMakeLists.txt ├── apply_license.sh ├── check_install.sh ├── git-meld ├── git-mproj └── license.pl └── tox.ini /.github/ci-config.yml: -------------------------------------------------------------------------------- 1 | dependency_branch: develop 2 | parallelism_factor: 8 3 | -------------------------------------------------------------------------------- /.github/ci-hpc-config.yml: -------------------------------------------------------------------------------- 1 | build: 2 | modules: 3 | - ninja 4 | parallel: 64 5 | 6 | -------------------------------------------------------------------------------- /.github/workflows/check-release-version.yml: -------------------------------------------------------------------------------- 1 | name: Check VERSION file 2 | 3 | on: 4 | push: 5 | branches: 6 | - "release/**" 7 | - "hotfix/**" 8 | 9 | jobs: 10 | check_version: 11 | uses: ecmwf/reusable-workflows/.github/workflows/check-release-version.yml@v2 12 | -------------------------------------------------------------------------------- /.github/workflows/ci-single.yml: -------------------------------------------------------------------------------- 1 | name: ci-single 2 | 3 | # Controls when the workflow will run 4 | on: 5 | 6 | # Trigger the workflow on all pushes, except on tag creation 7 | push: 8 | branches: 9 | - '**' 10 | tags-ignore: 11 | - '**' 12 | 13 | # Trigger the workflow on all pull requests 14 | pull_request: ~ 15 | 16 | # Allow workflow to be dispatched on demand 17 | workflow_dispatch: ~ 18 | 19 | jobs: 20 | 21 | # Calls a reusable CI workflow to build & test the current repository. 22 | # We skip jobs that will result in duplicate artifacts, since the code does not depend on the compiler. 23 | ci: 24 | name: ci 25 | uses: ecmwf/reusable-workflows/.github/workflows/ci.yml@v2 26 | with: 27 | skip_matrix_jobs: | 28 | clang@rocky-8.6 29 | -------------------------------------------------------------------------------- /.github/workflows/sync.yml: -------------------------------------------------------------------------------- 1 | name: sync 2 | 3 | # Controls when the workflow will run 4 | on: 5 | 6 | # Trigger the workflow on all pushes 7 | push: 8 | branches: 9 | - '**' 10 | tags: 11 | - '**' 12 | 13 | # Trigger the workflow when a branch or tag is deleted 14 | delete: ~ 15 | 16 | # Allow workflow to be dispatched on demand 17 | workflow_dispatch: ~ 18 | 19 | jobs: 20 | 21 | # Calls a reusable CI workflow to sync the current with a remote repository. 22 | # It will correctly handle addition of any new and removal of existing Git objects. 23 | sync: 24 | name: sync 25 | uses: ecmwf/reusable-workflows/.github/workflows/sync.yml@v2 26 | secrets: 27 | target_repository: ecsdk/ecbuild 28 | target_username: ClonedDuck 29 | target_token: ${{ secrets.BITBUCKET_PAT }} 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *sublime-workspace 2 | CMakeLists.txt.user* 3 | *.log 4 | *.py[cdo] 5 | *.swp 6 | *~ 7 | doc/contrib 8 | doc/find 9 | doc/macros 10 | build 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | 2 | version: 2 3 | 4 | # Set the OS, Python version and other tools you might need 5 | build: 6 | os: ubuntu-22.04 7 | tools: 8 | python: "3.12" 9 | 10 | # Build documentation in the "doc/" directory with Sphinx 11 | sphinx: 12 | configuration: doc/conf.py 13 | 14 | # Define the requirements required to build the documentation 15 | python: 16 | install: 17 | - requirements: doc/requirements.txt -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | eckit Authors 2 | ============= 3 | 4 | eckit is mainly developed at the "European Centre for Medium-Range Weather Forecasts" (ECMWF, http://www.ecmwf.int). 5 | See attached LICENSE file for copyright. 6 | 7 | Developers: 8 | =========== 9 | 10 | Tiago Quintino 11 | Baudouin Raoult 12 | Willem Deconinck 13 | Florian Rathgeber 14 | -------------------------------------------------------------------------------- /INSTALL.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Installing ecBuild 3 | ================== 4 | 5 | Bootstrap and install 6 | ===================== 7 | 8 | :: 9 | 10 | git clone https://github.com/ecmwf/ecbuild 11 | 12 | cd ecbuild 13 | 14 | mkdir bootstrap 15 | 16 | cd bootstrap 17 | 18 | ../bin/ecbuild --prefix=/path/to/install/ecbuild .. 19 | 20 | ctest 21 | 22 | make install 23 | 24 | Generating documentation 25 | ======================== 26 | 27 | The documentation is generated using Sphinx. Make sure that ``sphinx-build`` 28 | can be located using ``PATH`` or ``CMAKE_PREFIX_PATH``. You can either add the 29 | ``-DSPHINX_HTML=ON`` option (as well as ``-DCMAKE_PREFIX_PATH=...`` if needed) 30 | to the above ``ecbuild`` command, or re-run ecBuild:: 31 | 32 | cd ecbuild/bootstrap 33 | 34 | ../bin/ecbuild -DSPHINX_HTML=ON .. 35 | 36 | make documentation 37 | 38 | The documentation tree will be available in ``doc/html``. 39 | 40 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Notice 2 | ------ 3 | 4 | 1. The files FindLex and FindYacc are based on the FindBison and FindFlex 5 | macros from the original CMake code base. 6 | As requested, the License text has been preserved. The modifications are 7 | governed by the Apache License as described in COPYING. 8 | 9 | 2. FindEigen3 is based on a macro from Montel Laurent and others and 10 | distributed under the BSD 2-Clause License. 11 | 12 | 3. FindNetCDF4 is based on the macro FindNetCDF from project UCLALES from 13 | Max-Planck-Institut für Meteorologie and distributed under the Academic 14 | Free License v3.0. 15 | 16 | 4. GetGitRevisionDescription macros are based on the macro with smae name from 17 | Ryan Pavlik and Iowa State University, and 18 | distributed under Boost license. 19 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | cmake/VERSION -------------------------------------------------------------------------------- /bamboo/env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #[[ $(uname) == "Darwin" ]] && return # no module environment on the Mac 4 | 5 | # initialise module environment if it is not 6 | #if [[ ! $(command -v module > /dev/null 2>&1) ]]; then 7 | # . /usr/local/apps/module/init/bash 8 | #fi 9 | 10 | #module load cmake/new 11 | -------------------------------------------------------------------------------- /bamboo/flags.cmake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecmwf/ecbuild/f518c27f126db6c53aed2eb91505c60f70b688c3/bamboo/flags.cmake -------------------------------------------------------------------------------- /bin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install( PROGRAMS ecbuild DESTINATION ${INSTALL_BIN_DIR} ) 2 | -------------------------------------------------------------------------------- /cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | file( GLOB_RECURSE ecbuild_support_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" ) 10 | 11 | ecbuild_add_resources( TARGET ${PROJECT_NAME}_ecbuild_support_files 12 | SOURCES_PACK 13 | ${ecbuild_support_files} ) 14 | -------------------------------------------------------------------------------- /cmake/FindCMath.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | #Sets: 10 | # CMATH_LIBRARIES = the library to link against (RT etc) 11 | 12 | IF(UNIX) 13 | if( DEFINED CMATH_PATH ) 14 | find_library(CMATH_LIBRARIES m PATHS ${CMATH_PATH}/lib NO_DEFAULT_PATH ) 15 | endif() 16 | 17 | find_library(CMATH_LIBRARIES m ) 18 | 19 | include(FindPackageHandleStandardArgs) 20 | 21 | # handle the QUIET and REQUIRED arguments and set CMATH_FOUND to TRUE 22 | # if all listed variables are TRUE 23 | # Note: capitalisation of the package name must be the same as in the file name 24 | find_package_handle_standard_args(CMath DEFAULT_MSG CMATH_LIBRARIES ) 25 | 26 | ENDIF(UNIX) 27 | -------------------------------------------------------------------------------- /cmake/FindDl.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | #Sets: 10 | # DL_LIBRARIES = the library to link against (RT etc) 11 | 12 | if( DEFINED DL_PATH ) 13 | find_library(DL_LIBRARIES dl PATHS ${DL_PATH}/lib NO_DEFAULT_PATH ) 14 | endif() 15 | 16 | find_library(DL_LIBRARIES dl ) 17 | 18 | include(FindPackageHandleStandardArgs) 19 | 20 | # handle the QUIET and REQUIRED arguments and set DL_FOUND to TRUE 21 | # if all listed variables are TRUE 22 | # Note: capitalisation of the package name must be the same as in the file name 23 | find_package_handle_standard_args(Dl DEFAULT_MSG DL_LIBRARIES ) 24 | -------------------------------------------------------------------------------- /cmake/VERSION: -------------------------------------------------------------------------------- 1 | 3.10.0 2 | -------------------------------------------------------------------------------- /cmake/compat/README.rst: -------------------------------------------------------------------------------- 1 | ============================= 2 | ecbuild 2 compatibility layer 3 | ============================= 4 | 5 | The files in this directory here emulate the behaviour of ecbuild 2.x in order 6 | to ensure smooth transition to ecbuild 3. As such, they are deprecated by 7 | definition. 8 | 9 | The compatibility layer is enabled by default. To disable it, set the 10 | ``ECBUILD_2_COMPAT`` option to ``OFF``. To output deprecation warnings instead, 11 | set the ``ECBUILD_2_COMPAT_DEPRECATE`` option to ``ON``. 12 | -------------------------------------------------------------------------------- /cmake/compat/ecbuild_add_cxx11_flags.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | ############################################################################## 10 | #.rst: 11 | # 12 | # ecbuild_add_cxx11_flags 13 | # ======================= 14 | # 15 | # Add cxx11 flags to CXX compilation flags. :: 16 | # 17 | # ecbuild_add_cxx11_flags() 18 | # 19 | # DEPRECATED. Please set CMAKE_CXX_STANDARD or use target_compile_features 20 | # instead. 21 | # 22 | ############################################################################## 23 | 24 | macro( ecbuild_add_cxx11_flags ) 25 | 26 | if( ECBUILD_2_COMPAT_DEPRECATE ) 27 | ecbuild_deprecate("ecbuild_add_cxx11_flags is deprecated and will be " 28 | "removed in a future version. Please set CMAKE_CXX_STANDARD or use " 29 | "target_compile_features instead.") 30 | endif() 31 | 32 | if( NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 11 ) 33 | set( CMAKE_CXX_STANDARD 11 ) 34 | set( CMAKE_CXX_STANDARD_REQUIRED ON ) 35 | endif() 36 | 37 | endmacro( ecbuild_add_cxx11_flags ) 38 | -------------------------------------------------------------------------------- /cmake/compat/ecbuild_add_extra_search_paths.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | ############################################################################### 10 | # 11 | # macro for adding search paths to CMAKE_PREFIX_PATH 12 | # for example the ECMWF /usr/local/apps paths 13 | # 14 | # usage: ecbuild_add_extra_search_paths( netcdf4 ) 15 | 16 | function( ecbuild_add_extra_search_paths pkg ) 17 | 18 | ecbuild_deprecate( " ecbuild_add_extra_search_paths modifies CMAKE_PREFIX_PATH," 19 | " which can affect future package discovery if not undone by the caller." 20 | " The current CMAKE_PREFIX_PATH is being backed up as _CMAKE_PREFIX_PATH" 21 | " so it can later be restored." ) 22 | 23 | # Back up current CMAKE_PREFIX_PATH so the caller can reset it 24 | set( _CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE ) 25 | 26 | string( TOUPPER ${pkg} _PKG ) 27 | 28 | ecbuild_list_extra_search_paths( ${pkg} CMAKE_PREFIX_PATH ) 29 | 30 | set( CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE ) 31 | # ecbuild_debug_var( CMAKE_PREFIX_PATH ) 32 | 33 | endfunction() 34 | -------------------------------------------------------------------------------- /cmake/compat/ecbuild_check_cxx11.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | ############################################################################## 10 | #.rst: 11 | # 12 | # ecbuild_check_cxx11 13 | # =================== 14 | # 15 | # REMOVED 16 | ############################################################################## 17 | 18 | function(ecbuild_check_cxx11) 19 | 20 | if(ECBUILD_COMPAT_DEPRECATE) 21 | ecbuild_deprecate("The ecbuild_check_cxx11 has been removed. Please use " 22 | "CMake facilities for C++11 features") 23 | endif() 24 | 25 | endfunction(ecbuild_check_cxx11) 26 | -------------------------------------------------------------------------------- /cmake/compiler_flags/Clang_C.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "C compiler flags for Release builds" FORCE ) 10 | set( CMAKE_C_FLAGS_BIT "-O2 -DNDEBUG" CACHE STRING "C compiler flags for Bit-reproducible builds" FORCE ) 11 | set( CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "C compiler flags for Debug builds" FORCE ) 12 | set( CMAKE_C_FLAGS_PRODUCTION "-O3 -g" CACHE STRING "C compiler flags for Production builds." FORCE ) 13 | set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "C compiler flags for RelWithDebInfo builds." FORCE ) 14 | -------------------------------------------------------------------------------- /cmake/compiler_flags/Clang_CXX.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "C++ compiler flags for Release builds" FORCE ) 10 | set( CMAKE_CXX_FLAGS_BIT "-O2 -DNDEBUG" CACHE STRING "C++ compiler flags for Bit-reproducible builds" FORCE ) 11 | set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "C++ compiler flags for Debug builds" FORCE ) 12 | set( CMAKE_CXX_FLAGS_PRODUCTION "-O3 -g" CACHE STRING "C++ compiler flags for Production builds." FORCE ) 13 | set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "C++ compiler flags for RelWithDebInfo builds." FORCE ) 14 | -------------------------------------------------------------------------------- /cmake/compiler_flags/Cray_C.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( CMAKE_C_FLAGS_RELEASE "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" CACHE STRING "Release C flags" FORCE ) 10 | set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -hfp1 -G2 -DNDEBUG" CACHE STRING "Release-with-debug-info C flags" FORCE ) 11 | set( CMAKE_C_FLAGS_PRODUCTION "-O2 -hfp1 -G2" CACHE STRING "Production C flags" FORCE ) 12 | set( CMAKE_C_FLAGS_BIT "-O2 -hfp1 -G2 -hflex_mp=conservative -DNDEBUG" CACHE STRING "Bit-reproducible C flags" FORCE ) 13 | set( CMAKE_C_FLAGS_DEBUG "-O0 -G0" CACHE STRING "Debug Cflags" FORCE ) 14 | -------------------------------------------------------------------------------- /cmake/compiler_flags/Cray_CXX.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( CMAKE_CXX_FLAGS_RELEASE "-O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" CACHE STRING "Release C++ flags" FORCE ) 10 | set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -hfp1 -G2 -DNDEBUG" CACHE STRING "Release-with-debug-info C++ flags" FORCE ) 11 | set( CMAKE_CXX_FLAGS_PRODUCTION "-O2 -hfp1" CACHE STRING "Production C++ flags" FORCE ) 12 | set( CMAKE_CXX_FLAGS_BIT "-O2 -hfp1 -hflex_mp=conservative -DNDEBUG" CACHE STRING "Bit-reproducible C++ flags" FORCE ) 13 | set( CMAKE_CXX_FLAGS_DEBUG "-G0 -O0" CACHE STRING "Debug CXX flags" FORCE ) 14 | -------------------------------------------------------------------------------- /cmake/compiler_flags/Cray_Fortran.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | # -emf activates .mods and uses lower case 10 | # -rmoid produces a listing file 11 | set( CMAKE_Fortran_FLAGS_RELEASE "-emf -rmoid -N 1023 -O3 -hfp3 -hscalar3 -hvector3 -DNDEBUG" CACHE STRING "Release Fortran flags" FORCE ) 12 | set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-emf -rmoid -N 1023 -O2 -hfp1 -G2 -DNDEBUG" CACHE STRING "Release-with-debug-info Fortran flags" FORCE ) 13 | set( CMAKE_Fortran_FLAGS_PRODUCTION "-emf -rmoid -N 1023 -O2 -hfp1 -G2" CACHE STRING "Production Fortran flags" FORCE ) 14 | set( CMAKE_Fortran_FLAGS_BIT "-emf -rmoid -N 1023 -O2 -hfp1 -G2 -hflex_mp=conservative -hadd_paren -DNDEBUG" CACHE STRING "Bit-reproducible Fortran flags" FORCE ) 15 | set( CMAKE_Fortran_FLAGS_DEBUG "-emf -rmoid -N 1023 -O0 -G0" CACHE STRING "Debug Fortran flags" FORCE ) 16 | -------------------------------------------------------------------------------- /cmake/compiler_flags/GNU_C.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "C compiler flags for Release builds" FORCE ) 10 | set( CMAKE_C_FLAGS_BIT "-O2 -DNDEBUG" CACHE STRING "C compiler flags for Bit-reproducible builds" FORCE ) 11 | set( CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "C compiler flags for Debug builds" FORCE ) 12 | set( CMAKE_C_FLAGS_PRODUCTION "-O2 -g" CACHE STRING "C compiler flags for Production builds." FORCE ) 13 | set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "C compiler flags for RelWithDebInfo builds." FORCE ) 14 | 15 | # NOTE: gcc does not guarrante that -O3 performs better than -O2 16 | # -- it can perform worse due to assembly code bloating. 17 | # Moreover for gcc 4.1.2 we found that -O3 remove the parser code generated from Lex/Yacc 18 | # and therefore in production mode we downgrade to -O2 if the compiler is GCC (for all versions). 19 | -------------------------------------------------------------------------------- /cmake/compiler_flags/GNU_CXX.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "C++ compiler flags for Release builds" FORCE ) 10 | set( CMAKE_CXX_FLAGS_BIT "-O2 -DNDEBUG" CACHE STRING "C++ compiler flags for Bit-reproducible builds" FORCE ) 11 | set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "C++ compiler flags for Debug builds" FORCE ) 12 | set( CMAKE_CXX_FLAGS_PRODUCTION "-O2 -g" CACHE STRING "C++ compiler flags for Production builds." FORCE ) 13 | set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "C++ compiler flags for RelWithDebInfo builds." FORCE ) 14 | 15 | # NOTE: gcc does not guarrante that -O3 performs better than -O2 16 | # -- it can perform worse due to assembly code bloating. 17 | # Moreover for gcc 4.1.2 we found that -O3 remove the parser code generated from Lex/Yacc 18 | # and therefore in production mode we downgrade to -O2 if the compiler is GCC (for all versions). 19 | -------------------------------------------------------------------------------- /cmake/compiler_flags/Intel_C.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Release C compiler flags" FORCE ) 10 | set( CMAKE_C_FLAGS_BIT "-O2 -DNDEBUG" CACHE STRING "Bit-reproducible C compiler flags" FORCE ) 11 | set( CMAKE_C_FLAGS_DEBUG "-O0 -g -traceback" CACHE STRING "Debug C compiler flags" FORCE ) 12 | set( CMAKE_C_FLAGS_PRODUCTION "-O3 -g" CACHE STRING "Production C compiler flags" FORCE ) 13 | set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "Release-with-debug-info C compiler flags" FORCE ) 14 | -------------------------------------------------------------------------------- /cmake/compiler_flags/Intel_CXX.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Release C++ compiler flags" FORCE ) 10 | set( CMAKE_CXX_FLAGS_BIT "-O2 -DNDEBUG" CACHE STRING "Bit-reproducible C++ compiler flags" FORCE ) 11 | set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g -traceback" CACHE STRING "Debug C++ compiler flags" FORCE ) 12 | set( CMAKE_CXX_FLAGS_PRODUCTION "-O3 -g" CACHE STRING "Production C++ compiler flags" FORCE ) 13 | set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "Release-with-debug-info C++ compiler flags" FORCE ) 14 | -------------------------------------------------------------------------------- /cmake/compiler_flags/PGI_C.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | set( CMAKE_C_FLAGS_RELEASE "-fast -O3 -DNDEBUG" CACHE STRING "Release C compiler flags" FORCE ) 10 | 11 | set( CMAKE_C_LINK_FLAGS "" CACHE STRING "" ) 12 | -------------------------------------------------------------------------------- /cmake/compiler_flags/PGI_CXX.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | set( CMAKE_CXX_FLAGS_RELEASE "-fast -O3 -DNDEBUG" CACHE STRING "Release C++ compiler flags" FORCE ) 10 | 11 | set( CMAKE_CXX_LINK_FLAGS "" CACHE STRING "" ) 12 | -------------------------------------------------------------------------------- /cmake/compiler_flags/PGI_Fortran.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | set( CMAKE_Fortran_FLAGS_RELEASE "-fast -O3" CACHE STRING "Release Fortran compiler flags" FORCE ) 10 | 11 | set( CMAKE_Fortran_LINK_FLAGS "" CACHE STRING "" ) 12 | -------------------------------------------------------------------------------- /cmake/ecbuild-config-version.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/ecbuild_parse_version.cmake) 2 | ecbuild_parse_version_file(${CMAKE_CURRENT_LIST_DIR}/VERSION PREFIX PACKAGE) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/ecbuild-config.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2019- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | get_filename_component(ecbuild_MACROS_DIR ${CMAKE_CURRENT_LIST_DIR} ABSOLUTE) 10 | cmake_policy( PUSH ) 11 | cmake_policy( SET CMP0057 NEW ) 12 | if(NOT ${ecbuild_MACROS_DIR} IN_LIST CMAKE_MODULE_PATH) 13 | list(INSERT CMAKE_MODULE_PATH 0 ${ecbuild_MACROS_DIR}) 14 | endif() 15 | cmake_policy( POP ) 16 | include(ecbuild) 17 | 18 | -------------------------------------------------------------------------------- /cmake/ecbuild.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2019- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | if( NOT ECBUILD_PROJECT_${CMAKE_CURRENT_SOURCE_DIR} ) 10 | set( ECBUILD_PROJECT_${CMAKE_CURRENT_SOURCE_DIR} TRUE ) 11 | 12 | ######################################################################################################## 13 | # compatibility with ecbuild 2 14 | 15 | if ( NOT DEFINED ECBUILD_2_COMPAT_VALUE ) 16 | set( ECBUILD_2_COMPAT_VALUE OFF ) 17 | endif() 18 | if ( NOT DEFINED ECBUILD_2_COMPAT_DEPRECATE_VALUE ) 19 | set( ECBUILD_2_COMPAT_DEPRECATE_VALUE ON ) 20 | endif() 21 | 22 | option( ECBUILD_2_COMPAT "Keep compatibility with ecbuild 2" ${ECBUILD_2_COMPAT_VALUE} ) 23 | option( ECBUILD_2_COMPAT_DEPRECATE "Emit deprecation warnings in the compatibility layer" ${ECBUILD_2_COMPAT_DEPRECATE_VALUE} ) 24 | 25 | if( ECBUILD_2_COMPAT_DEPRECATE ) 26 | set( CMAKE_WARN_DEPRECATED ON ) 27 | endif() 28 | 29 | ######################################################################################################## 30 | 31 | include( ecbuild_project ) 32 | 33 | ######################################################################################################## 34 | 35 | endif() 36 | -------------------------------------------------------------------------------- /cmake/ecbuild_configure_file.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2018- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | function(ecbuild_configure_file _PAR_TEMPLATE _PAR_FILENAME) 10 | get_filename_component(config_file ${_PAR_FILENAME} NAME) 11 | set(tmp_file "${CMAKE_CURRENT_BINARY_DIR}/${config_file}.ecbuild") 12 | 13 | configure_file( ${_PAR_TEMPLATE} ${tmp_file} ${ARGN}) 14 | 15 | file(STRINGS "${tmp_file}" content) 16 | string(REGEX MATCH "\\$ ${${_outVar}}") 35 | set( ${_outVar} ${${_outVar}} PARENT_SCOPE ) 36 | endfunction() 37 | -------------------------------------------------------------------------------- /cmake/ecbuild_regex_escape.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2019- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | ############################################################################## 10 | #.rst: 11 | # 12 | # ecbuild_regex_escape 13 | # ==================== 14 | # 15 | # Escape regular expression special characters from the input string. :: 16 | # 17 | # ecbuild_regex_escape( ) 18 | # 19 | ############################################################################## 20 | function(ecbuild_regex_escape input outvar) 21 | 22 | string(REGEX REPLACE "[][.*+?|()\\^$]" "\\\\\\0" output "${input}") 23 | set(${outvar} "${output}" PARENT_SCOPE) 24 | 25 | endfunction(ecbuild_regex_escape) 26 | -------------------------------------------------------------------------------- /cmake/ecbuild_requires_macro_version.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | ############################################################################## 10 | #.rst: 11 | # 12 | # ecbuild_requires_macro_version 13 | # ============================== 14 | # 15 | # Check that the ecBuild version satisfied a given minimum version or fail. :: 16 | # 17 | # ecbuild_requires_macro_version( ) 18 | # 19 | ############################################################################## 20 | 21 | macro( ecbuild_requires_macro_version req_vrs ) 22 | 23 | if( ecbuild_VERSION VERSION_LESS ${req_vrs} ) 24 | ecbuild_critical( "${PROJECT_NAME} needs ecbuild macro version >= ${req_vrs}" ) 25 | endif() 26 | 27 | endmacro() 28 | -------------------------------------------------------------------------------- /cmake/ecbuild_source_flags.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( __gen_source_flags ${CMAKE_CURRENT_LIST_DIR}/gen_source_flags.py ) 10 | 11 | # Calls gen_source_flags.py to generate a CMake file with the per 12 | # source file flags for a given target. 13 | function( ecbuild_source_flags OUT TARGET DEFAULT_FLAGS SOURCES ) 14 | 15 | if( NOT PYTHONINTERP_FOUND OR PYTHON_VERSION VERSION_LESS 2.7 ) 16 | find_package( PythonInterp 2.7 REQUIRED ) 17 | endif() 18 | 19 | set( OUTFILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_source_flags.cmake ) 20 | 21 | if( ECBUILD_LOG_LEVEL LESS 11) 22 | set( __debug "--debug" ) 23 | endif() 24 | execute_process( COMMAND ${PYTHON_EXECUTABLE} ${__gen_source_flags} 25 | ${ECBUILD_SOURCE_FLAGS} ${OUTFILE} "${DEFAULT_FLAGS}" 26 | ${SOURCES} "${__debug}" 27 | RESULT_VARIABLE __res ) 28 | 29 | if( __res GREATER 0 ) 30 | ecbuild_error( "ecbuild_source_flags: failed generating source flags for target ${TARGET} from ${ECBUILD_SOURCE_FLAGS}" ) 31 | endif() 32 | set( ${OUT} ${OUTFILE} PARENT_SCOPE ) 33 | 34 | endfunction() 35 | -------------------------------------------------------------------------------- /cmake/ecbuild_test_endiness.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | ############################################################################################ 10 | # check endiness 11 | 12 | function(ecbuild_test_endiness) 13 | 14 | test_big_endian( _BIG_ENDIAN ) 15 | 16 | if( _BIG_ENDIAN ) 17 | set( EC_BIG_ENDIAN 1 ) 18 | set( EC_LITTLE_ENDIAN 0 ) 19 | else() 20 | set( EC_BIG_ENDIAN 0 ) 21 | set( EC_LITTLE_ENDIAN 1 ) 22 | endif() 23 | 24 | set( EC_BIG_ENDIAN ${EC_BIG_ENDIAN} PARENT_SCOPE ) 25 | set( EC_LITTLE_ENDIAN ${EC_LITTLE_ENDIAN} PARENT_SCOPE ) 26 | 27 | endfunction(ecbuild_test_endiness) 28 | 29 | -------------------------------------------------------------------------------- /cmake/ecbuild_version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2011- ECMWF. 3 | * 4 | * This software is licensed under the terms of the Apache Licence Version 2.0 5 | * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 6 | * In applying this licence, ECMWF does not waive the privileges and immunities 7 | * granted to it by virtue of its status as an intergovernmental organisation nor 8 | * does it submit to any jurisdiction. 9 | */ 10 | 11 | #ifndef ecbuild_version_h 12 | #define ecbuild_version_h 13 | 14 | #define ECBUILD_VERSION "@ecbuild_VERSION@" 15 | 16 | #define ECBUILD_MAJOR_VERSION @ecbuild_VERSION_MAJOR@ 17 | #define ECBUILD_MINOR_VERSION @ecbuild_VERSION_MINOR@ 18 | #define ECBUILD_PATCH_VERSION @ecbuild_VERSION_PATCH@ 19 | 20 | #endif // ecbuild_version_h 21 | -------------------------------------------------------------------------------- /cmake/ecbuild_windows_replace_symlinks.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Bash script to replace all symlinks with copies on Windows. 3 | # 4 | # Cmake on non-cygwin windows will completely ignore symlinks, causing install to fail for any repos 5 | # with symlinks in the source (e.g. ecCodes). See SystemTools::CreateSymlink [0], which at time of 6 | # writing is: 7 | # 8 | # ``` 9 | # #if defined(_WIN32) && !defined(__CYGWIN__) 10 | # bool SystemTools::CreateSymlink(const std::string&, const std::string&) 11 | # { 12 | # return false; 13 | # } 14 | # ``` 15 | # 16 | # [0] https://github.com/Kitware/CMake/blob/master/Source/kwsys/SystemTools.cxx#L2969 17 | # 18 | echo "" 19 | echo "=======================" 20 | echo " REMOVING ALL SYMLINKS " 21 | echo "=======================" 22 | echo "" 23 | 24 | for link in `find . -type l -not -path './build/*'` 25 | do 26 | if [ -e $link ] 27 | then 28 | echo "removing link $link" 29 | target=$(readlink -f $link) 30 | # Remove the symlink before copying (rather than passing --remove-destination to cp) 31 | # to prevent cp complaining about overwriting a symlink with a directory. 32 | rm -r $link 33 | cp -rTL $target $link 34 | else 35 | echo "ignoring broken link $link" 36 | fi 37 | done 38 | -------------------------------------------------------------------------------- /cmake/fcm-make-interfaces.cfg.in: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | # FCM configuration file used to auto-generate interface files 10 | # for F77 and F90 files. 11 | # Interface files will have the extention "@P_SUFFIX@" 12 | # Results will be in a directory "interfaces/include" relative to cwd 13 | 14 | # Usage: fcm make --config-file= \ 15 | # interfaces.ns-incl="" 16 | 17 | $SRC{?} = $HERE 18 | 19 | step.class[interfaces] = build 20 | steps = interfaces 21 | 22 | interfaces.target{task} = ext-iface 23 | 24 | interfaces.source = $SRC 25 | 26 | # Exclude all 27 | interfaces.ns-excl = / 28 | 29 | # Include some 30 | # interfaces.ns-incl = 31 | 32 | # Extention of interface files 33 | interfaces.prop{file-ext.f90-interface} = @P_SUFFIX@ 34 | 35 | # Do not follow includes 36 | interfaces.prop{no-dep.f.module} = * 37 | interfaces.prop{no-dep.include} = * 38 | 39 | -------------------------------------------------------------------------------- /cmake/fortran_features/c_size_t.F90: -------------------------------------------------------------------------------- 1 | ! (C) Copyright 2011- ECMWF. 2 | ! 3 | ! This software is licensed under the terms of the Apache Licence Version 2.0 4 | ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | ! In applying this licence, ECMWF does not waive the privileges and immunities 6 | ! granted to it by virtue of its status as an intergovernmental organisation nor 7 | ! does it submit to any jurisdiction. 8 | 9 | program test_c_sizeof 10 | use, intrinsic :: iso_c_binding, only : c_size_t, c_int, c_long 11 | 12 | write(0,*) "c_int = ",c_int 13 | write(0,*) "c_long = ",c_long 14 | write(0,*) "c_size_t = ",c_size_t 15 | 16 | end program -------------------------------------------------------------------------------- /cmake/fortran_features/c_sizeof.F90: -------------------------------------------------------------------------------- 1 | ! (C) Copyright 2011- ECMWF. 2 | ! 3 | ! This software is licensed under the terms of the Apache Licence Version 2.0 4 | ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | ! In applying this licence, ECMWF does not waive the privileges and immunities 6 | ! granted to it by virtue of its status as an intergovernmental organisation nor 7 | ! does it submit to any jurisdiction. 8 | 9 | program test_c_sizeof 10 | use, intrinsic :: iso_c_binding, only : c_sizeof 11 | end program -------------------------------------------------------------------------------- /cmake/fortran_features/submodules.F90: -------------------------------------------------------------------------------- 1 | ! (C) Copyright 2011- ECMWF. 2 | ! 3 | ! This software is licensed under the terms of the Apache Licence Version 2.0 4 | ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | ! In applying this licence, ECMWF does not waive the privileges and immunities 6 | ! granted to it by virtue of its status as an intergovernmental organisation nor 7 | ! does it submit to any jurisdiction. 8 | 9 | module sb_module 10 | implicit none 11 | integer :: a = 1 12 | 13 | interface 14 | module subroutine sb 15 | end subroutine 16 | end interface 17 | 18 | contains 19 | end module sb_module 20 | 21 | ! ------------------------------------------------------- 22 | 23 | submodule (sb_module) sb_submod1 24 | implicit none 25 | integer :: b = 2 26 | 27 | contains 28 | 29 | module subroutine sb() 30 | a = b 31 | end subroutine 32 | 33 | end submodule sb_submod1 34 | 35 | ! ------------------------------------------------------- 36 | 37 | program test_submodule 38 | use sb_module 39 | implicit none 40 | write(0,*) a 41 | call sb() 42 | write(0,*) a 43 | end program -------------------------------------------------------------------------------- /cmake/md5.in: -------------------------------------------------------------------------------- 1 | @_p_MD5@ @_p_NAME@ 2 | -------------------------------------------------------------------------------- /cmake/pkg-config.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | file(READ @CMAKE_CURRENT_BINARY_DIR@/@_PAR_FILENAME@.tmp _content) 3 | 4 | string(REPLACE "@CMAKE_BINARY_DIR@/lib" "\${libdir}" _content "${_content}") 5 | if(NOT "@INSTALL_LIB_DIR@" STREQUAL "lib") 6 | string(REPLACE "@CMAKE_BINARY_DIR@/@INSTALL_LIB_DIR@" "\${libdir}" _content "${_content}") 7 | endif() 8 | string(REPLACE "@CMAKE_INSTALL_PREFIX@/@INSTALL_LIB_DIR@" "\${libdir}" _content "${_content}") 9 | 10 | string(REGEX REPLACE "%SHORTEN:lib" "%SHORTEN:" _content "${_content}") 11 | string(REGEX REPLACE "\\.(a|so|dylib|dll|lib)(\\.[0-9]+)*%" "%" _content "${_content}") 12 | string(REGEX REPLACE "%SHORTEN:([^%]+)%" "\\1" _content "${_content}") 13 | 14 | file(WRITE @PKGCONFIG_DIR@/@_PAR_FILENAME@ "${_content}") 15 | -------------------------------------------------------------------------------- /cmake/pkg-config.pc.in: -------------------------------------------------------------------------------- 1 | # This pkg-config file is generated by ecbuild_pkgconfig() 2 | # with template ecbuild/cmake/pkg-config.pc.in 3 | 4 | git_tag=@PKGCONFIG_GIT_TAG@ 5 | 6 | prefix=${pcfiledir}/../.. 7 | exec_prefix=${prefix} 8 | libdir=${prefix}/@INSTALL_LIB_DIR@ 9 | includedir=${prefix}/@INSTALL_INCLUDE_DIR@ 10 | bindir=${prefix}/@INSTALL_BIN_DIR@ 11 | fmoddir=${prefix}/@INSTALL_INCLUDE_DIR@ 12 | 13 | CC=@CMAKE_C_COMPILER@ 14 | CXX=@CMAKE_CXX_COMPILER@ 15 | FC=@CMAKE_Fortran_COMPILER@ 16 | 17 | libs=@PKGCONFIG_LIBS@ 18 | 19 | libs_private=@PKGCONFIG_LIBS_PRIVATE@ 20 | 21 | cflags=@PKGCONFIG_INCLUDE@ @PKGCONFIG_CFLAGS@ 22 | @PKGCONFIG_VARIABLES@ 23 | #==================================================================== 24 | Name: @PKGCONFIG_NAME@ 25 | Description: @PKGCONFIG_DESCRIPTION@ 26 | URL: @PKGCONFIG_URL@ 27 | Version: @PKGCONFIG_VERSION@ 28 | Libs: ${libs} 29 | Libs.private: ${libs_private} 30 | Requires: @PKGCONFIG_REQUIRES@ 31 | Requires.private: @PKGCONFIG_REQUIRES_PRIVATE@ 32 | Cflags: ${cflags} 33 | #==================================================================== 34 | -------------------------------------------------------------------------------- /cmake/pymain.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /cmake/sha1.in: -------------------------------------------------------------------------------- 1 | @_p_SHA1@ @_p_NAME@ 2 | -------------------------------------------------------------------------------- /doc/contrib.rst: -------------------------------------------------------------------------------- 1 | ecBuild third party scripts 2 | ########################### 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | :glob: 7 | 8 | contrib/* 9 | -------------------------------------------------------------------------------- /doc/find.rst: -------------------------------------------------------------------------------- 1 | ecBuild find package helpers 2 | ############################ 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | :glob: 7 | 8 | find/* 9 | -------------------------------------------------------------------------------- /doc/generate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Generate sphinx documentation tree for ecBuild CMake macros.""" 4 | 5 | from glob import glob 6 | from os import makedirs, path 7 | import sys 8 | 9 | TOC = [('macros', 'ecbuild*.cmake'), 10 | ('find', 'Find*.cmake'), 11 | ('contrib', 'contrib/*.cmake')] 12 | 13 | CWD = path.abspath(path.dirname(__file__)) 14 | 15 | 16 | def generate(basedir): 17 | for section, pattern in TOC: 18 | section = path.join(CWD, section) 19 | if not path.exists(section): 20 | makedirs(section) 21 | for m in sorted(glob(path.join(basedir, pattern))): 22 | base = path.splitext(path.basename(m))[0] 23 | with open(path.join(section, base) + '.rst', 'w') as c: 24 | c.write('.. cmake-module :: %s\n' % path.relpath(m, section)) 25 | 26 | if __name__ == '__main__': 27 | generate(sys.argv[1]) 28 | -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | .. title:: ecBuild Documentation 2 | 3 | ecBuild Documentation 4 | +++++++++++++++++++++ 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | macros 10 | find 11 | contrib 12 | 13 | .. only:: html 14 | 15 | Index and Search 16 | ################ 17 | 18 | * :ref:`genindex` 19 | * :ref:`search` 20 | -------------------------------------------------------------------------------- /doc/macros.rst: -------------------------------------------------------------------------------- 1 | ecBuild macros 2 | ############## 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | :glob: 7 | 8 | macros/* 9 | -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | # These are the requirements for readthedoc 2 | docutils 3 | Sphinx>=4.4.0 4 | setuptools>=51.0.0 5 | sphinx-rtd-theme>=0.5.0 6 | -------------------------------------------------------------------------------- /doc/static/cmake-favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecmwf/ecbuild/f518c27f126db6c53aed2eb91505c60f70b688c3/doc/static/cmake-favicon.ico -------------------------------------------------------------------------------- /doc/static/cmake-logo-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecmwf/ecbuild/f518c27f126db6c53aed2eb91505c60f70b688c3/doc/static/cmake-logo-16.png -------------------------------------------------------------------------------- /doc/static/cmake.css: -------------------------------------------------------------------------------- 1 | /* Import the Sphinx theme style. */ 2 | @import url("default.css"); 3 | 4 | /* Wrap sidebar content even within words so that long 5 | document names do not escape sidebar borders. */ 6 | div.sphinxsidebarwrapper { 7 | word-wrap: break-word; 8 | } 9 | -------------------------------------------------------------------------------- /doc/static/ecbuild-logo-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecmwf/ecbuild/f518c27f126db6c53aed2eb91505c60f70b688c3/doc/static/ecbuild-logo-16.png -------------------------------------------------------------------------------- /doc/static/ecbuild.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecmwf/ecbuild/f518c27f126db6c53aed2eb91505c60f70b688c3/doc/static/ecbuild.ico -------------------------------------------------------------------------------- /doc/templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | {% block rootrellink %} 3 |
  • 4 | ecBuild 6 |
  • 7 |
  • 8 | ecBuild{{ reldelim1 }} 9 |
  • 10 |
  • 11 | {{ shorttitle|e }}{{ reldelim1 }} 12 |
  • 13 | {% endblock %} 14 | 15 | {# Put some context in the html title element. Workaround for #} 16 | {# https://bitbucket.org/birkenfeld/sphinx/issue/1492/qthelp-generate-html-title-element-should #} 17 | {% block htmltitle %} 18 | {{ title|striptags|e }} {{ "—"|safe }} {{ docstitle|e }} 19 | {% endblock %} 20 | -------------------------------------------------------------------------------- /ecbuild-post-import.cmake.in: -------------------------------------------------------------------------------- 1 | if(@PROJECT_NAME@_IS_BUILD_DIR_EXPORT) 2 | set(ecbuild_MACROS_DIR @ECBUILD_MACROS_DIR@) 3 | else() 4 | set(ecbuild_MACROS_DIR ${ecbuild_BASE_DIR}/share/ecbuild/cmake) 5 | endif() 6 | if(NOT ${ecbuild_MACROS_DIR} IN_LIST CMAKE_MODULE_PATH) 7 | list(INSERT CMAKE_MODULE_PATH 0 ${ecbuild_MACROS_DIR}) 8 | endif() 9 | include(ecbuild) 10 | -------------------------------------------------------------------------------- /ecbuild.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "file_exclude_patterns": [".tags", ".tags_sorted_by_file", ".gemtags","CMakeLists.txt.user*"], 6 | "follow_symlinks": true, 7 | "path": "." 8 | } 9 | ], 10 | "build_systems": [ 11 | { 12 | "working_dir": "${project_path}/../../build/ecbuild", 13 | "cmd": [ 14 | "make" 15 | ], 16 | "file_regex": "([/\\w\\-\\.]+):(\\d+):(\\d+:)?", 17 | "name": "ecbuild" 18 | } 19 | ], 20 | "SublimeLinter": 21 | { 22 | "linters": 23 | { 24 | "cpplint": { 25 | "filter": "-whitespace/line_length,-whitespace/blank_line,-runtime/references" 26 | }, 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/README.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Examples 3 | ======== 4 | 5 | This directory contains examples of some useful features of ecBuild: 6 | 7 | * `simple/ `_ - A simple ecBuild project 8 | * `fortran/ `_ - A Fortran project 9 | * `cxx11/ `_ - A C++11-enabled project 10 | * `transitive-dependencies/ `_ - Propagating 11 | dependencies across several projects 12 | * `find_package/ `_ - Using some popular third-party libraries 13 | * `cpp-bundle/ `_ - Bundling projects together 14 | * `cpp-bundle-nested/ `_ - Nested bundles 15 | * `boost-python-lib/ `_ - Using Boost::Python 16 | * `mix/ `_ - Mixing C++ and Fortran 17 | * `override-compile-flags/ `_ - Overriding 18 | compile flags on a per-file basis 19 | * `config-bundle/ `_ - Providing project-specific 20 | configuration 21 | 22 | -------------------------------------------------------------------------------- /examples/boost-python-lib/README.md: -------------------------------------------------------------------------------- 1 | # Boost::python example 2 | 3 | This example shows how to use Boost::python with ecbuild to build a python library. 4 | 5 | ## Usage 6 | 7 | ecbuild examples/boost-python-lib 8 | 9 | -------------------------------------------------------------------------------- /examples/boost-python-lib/mypython.py: -------------------------------------------------------------------------------- 1 | """ 2 | API for the C++ module using boost::python 3 | 4 | mypython.py: 5 | This file can be used to do some python actions at import 6 | 7 | Module description: 8 | ... 9 | """ 10 | from libmypython import * -------------------------------------------------------------------------------- /examples/boost-python-lib/pythonlib.cpp: -------------------------------------------------------------------------------- 1 | #include "pythonlib.hpp" 2 | 3 | BOOST_PYTHON_MODULE(libmypython) 4 | { 5 | boost::python::scope().attr("__doc__") = "Python API for my python project"; 6 | } 7 | -------------------------------------------------------------------------------- /examples/boost-python-lib/pythonlib.hpp: -------------------------------------------------------------------------------- 1 | #ifndef pythonlib_hpp 2 | #define pythonlib_hpp 3 | 4 | #include 5 | 6 | #endif -------------------------------------------------------------------------------- /examples/config-bundle/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /examples/config-bundle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package(ecbuild REQUIRED) 12 | project( config_bundle VERSION 0.1 LANGUAGES C ) 13 | 14 | ecbuild_bundle_initialize() 15 | 16 | # Use command "make update" to update branches to latest develop version 17 | ecbuild_bundle( PROJECT subproj1 ) 18 | ecbuild_bundle( PROJECT subproj2 ) 19 | 20 | # Finalize 21 | ecbuild_bundle_finalize() 22 | -------------------------------------------------------------------------------- /examples/config-bundle/README.md: -------------------------------------------------------------------------------- 1 | # Config-bundle with separate configuration for subproj2 2 | 3 | SRC_DIR=$(pwd) 4 | BUILD_DIR=$(pwd)/build 5 | mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} 6 | 7 | ../../../bin/ecbuild --build=debug --log=debug --config=${SRC_DIR}/general_config.cmake -- -DSUBPROJ2_CONFIG=${SRC_DIR}/subproj2_config.cmake ${SRC_DIR} 8 | -------------------------------------------------------------------------------- /examples/config-bundle/general_config.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( ECBUILD_TRUST_FLAGS TRUE ) 10 | set( ECBUILD_C_FLAGS "-common" ) 11 | set( ECBUILD_C_FLAGS_DEBUG "-debugopts" ) 12 | 13 | set( ENABLE_LARGE_FILE_SUPPORT OFF CACHE BOOL "" ) 14 | -------------------------------------------------------------------------------- /examples/config-bundle/subproj1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package(ecbuild REQUIRED) 12 | project( subproj_1 VERSION 0.1 LANGUAGES C ) 13 | 14 | ecbuild_debug_var( CMAKE_C_FLAGS ) 15 | ecbuild_debug_var( CMAKE_C_FLAGS_DEBUG ) 16 | -------------------------------------------------------------------------------- /examples/config-bundle/subproj2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package(ecbuild REQUIRED) 12 | 13 | if( SUBPROJ2_CONFIG ) 14 | set( ECBUILD_CONFIG ${SUBPROJ2_CONFIG} ) 15 | endif() 16 | 17 | project( subproj_2 VERSION 0.2 LANGUAGES C ) 18 | 19 | ecbuild_debug_var( CMAKE_C_FLAGS ) 20 | ecbuild_debug_var( CMAKE_C_FLAGS_DEBUG ) 21 | -------------------------------------------------------------------------------- /examples/config-bundle/subproj2_config.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | set( ECBUILD_TRUST_FLAGS TRUE ) 10 | set( ECBUILD_C_FLAGS "-common2" ) 11 | set( ECBUILD_C_FLAGS_DEBUG "-debugopts2") 12 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package( ecbuild REQUIRED ) 12 | project( cpp_bundle_nested VERSION 0.10.0 LANGUAGES C CXX ) 13 | 14 | ecbuild_bundle_initialize() 15 | 16 | ecbuild_bundle( PROJECT bar ) 17 | ecbuild_bundle( PROJECT baz ) 18 | 19 | ecbuild_bundle_finalize() 20 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/README.md: -------------------------------------------------------------------------------- 1 | # C++ bundle example with nested sub-projects 2 | 3 | Same as ../cpp-bundle, but with a sub-project inside a sub-project. 4 | 5 | # Usage 6 | 7 | ecbuild examples/cpp-bundle-nested 8 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package( ecbuild REQUIRED ) 12 | project( bar VERSION 1.0.0 LANGUAGES C CXX ) 13 | 14 | ### targets 15 | 16 | ecbuild_bundle( PROJECT foo ) 17 | 18 | ecbuild_add_library( TARGET bar 19 | PUBLIC_LIBS foo 20 | SOURCES bar.h bar.c 21 | PUBLIC_INCLUDES 22 | $ ) 23 | 24 | ecbuild_add_executable( 25 | TARGET master_bar 26 | SOURCES main.cc 27 | LIBS bar 28 | ) 29 | 30 | ecbuild_add_test( 31 | TARGET test_bar 32 | SOURCES test.cc 33 | LIBS bar 34 | ) 35 | 36 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 37 | 38 | ecbuild_print_summary() 39 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/bar.c: -------------------------------------------------------------------------------- 1 | #include "foo.h" 2 | 3 | int bar() { 4 | return foo() * foo(); 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/bar.h: -------------------------------------------------------------------------------- 1 | #ifndef bar_h 2 | #define bar_h 3 | 4 | int bar(); 5 | 6 | #endif -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/foo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( foo VERSION 1.0.0 LANGUAGES C CXX ) 5 | 6 | ### targets 7 | 8 | ecbuild_add_library(TARGET foo 9 | SOURCES foo.h foo.c 10 | INSTALL_HEADERS LISTED 11 | PUBLIC_INCLUDES 12 | $ ) 13 | 14 | ecbuild_add_executable( 15 | TARGET master_foo 16 | SOURCES main.cc 17 | LIBS foo ) 18 | 19 | ecbuild_add_test( 20 | TARGET test_foo 21 | SOURCES test.cc 22 | LIBS foo ) 23 | 24 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 25 | 26 | ecbuild_print_summary() 27 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/foo/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { 2 | return 42; 3 | } 4 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/foo/foo.h: -------------------------------------------------------------------------------- 1 | #ifndef foo_h 2 | #define foo_h 3 | 4 | int foo(); 5 | 6 | #endif -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/foo/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "foo.h" 5 | } 6 | 7 | int main() { 8 | std::cout << "foo is " << foo() << std::endl; 9 | } 10 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/foo/test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "foo.h" 5 | } 6 | 7 | int main() { 8 | if( foo() == 42) 9 | std::cout << "ok" << std::endl; 10 | else 11 | std::cout << "failed" << std::endl; 12 | } 13 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "foo.h" 5 | #include "bar.h" 6 | } 7 | 8 | int main() 9 | { 10 | std::cout << "foo is " << foo() << std::endl; 11 | std::cout << "bar is " << bar() << std::endl; 12 | } 13 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/bar/test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "bar.h" 5 | } 6 | 7 | int main() { 8 | if( bar() == 42*42 ) 9 | std::cout << "ok" << std::endl; 10 | else 11 | std::cout << "failed" << std::endl; 12 | } 13 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/baz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( baz VERSION 1.0.0 LANGUAGES C CXX ) 5 | 6 | ### targets 7 | 8 | ecbuild_find_package( NAME foo REQUIRED ) 9 | 10 | ecbuild_add_library( TARGET baz 11 | SOURCES baz.h baz.c 12 | PUBLIC_LIBS foo 13 | PUBLIC_INCLUDES 14 | $ ) 15 | 16 | ecbuild_add_executable( 17 | TARGET master_baz 18 | SOURCES main.cc 19 | LIBS baz 20 | ) 21 | 22 | ecbuild_add_test( 23 | TARGET test_baz 24 | SOURCES test.cc 25 | LIBS baz 26 | ) 27 | 28 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 29 | 30 | ecbuild_print_summary() 31 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/baz/baz.c: -------------------------------------------------------------------------------- 1 | #include "foo.h" 2 | 3 | int baz() { 4 | return foo() * foo() * foo(); 5 | } 6 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/baz/baz.h: -------------------------------------------------------------------------------- 1 | #ifndef baz_h 2 | #define baz_h 3 | 4 | int baz(); 5 | 6 | #endif -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/baz/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "foo.h" 5 | #include "baz.h" 6 | } 7 | 8 | int main() 9 | { 10 | std::cout << "foo is " << foo() << std::endl; 11 | std::cout << "baz is " << baz() << std::endl; 12 | } 13 | -------------------------------------------------------------------------------- /examples/cpp-bundle-nested/baz/test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "baz.h" 5 | } 6 | 7 | int main() { 8 | if( baz() == 42*42*42 ) 9 | std::cout << "ok" << std::endl; 10 | else 11 | std::cout << "failed" << std::endl; 12 | } 13 | -------------------------------------------------------------------------------- /examples/cpp-bundle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package(ecbuild REQUIRED) 12 | project( cpp_bundle VERSION 0.10.0 LANGUAGES C CXX ) 13 | 14 | ecbuild_bundle_initialize() 15 | 16 | ecbuild_bundle( PROJECT foo ) 17 | ecbuild_bundle( PROJECT bar ) 18 | 19 | ecbuild_bundle_finalize() 20 | -------------------------------------------------------------------------------- /examples/cpp-bundle/README.md: -------------------------------------------------------------------------------- 1 | # C++ bundle example 2 | 3 | A bundle is an ecbuild project that gathers sub-projects. ecbuild provides 4 | facilities to retrieve such sub-projects from git repositories. 5 | 6 | # Usage 7 | 8 | ecbuild examples/cpp-bundle 9 | -------------------------------------------------------------------------------- /examples/cpp-bundle/bar/bar.c: -------------------------------------------------------------------------------- 1 | #include "foo.h" 2 | 3 | int bar() 4 | { 5 | return foo() * foo(); 6 | } -------------------------------------------------------------------------------- /examples/cpp-bundle/bar/bar.h: -------------------------------------------------------------------------------- 1 | #ifndef bar_h 2 | #define bar_h 3 | 4 | int bar(); 5 | 6 | #endif -------------------------------------------------------------------------------- /examples/cpp-bundle/bar/baz.c: -------------------------------------------------------------------------------- 1 | #include "foo.h" 2 | 3 | int baz() 4 | { 5 | return foo() * foo() * foo(); 6 | } -------------------------------------------------------------------------------- /examples/cpp-bundle/bar/baz.h: -------------------------------------------------------------------------------- 1 | #ifndef baz_h 2 | #define baz_h 3 | 4 | int baz(); 5 | 6 | #endif -------------------------------------------------------------------------------- /examples/cpp-bundle/bar/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "bar.h" 5 | #include "baz.h" 6 | #include "zingo.h" 7 | } 8 | 9 | int main() 10 | { 11 | std::cout << "bar is " << bar() << std::endl; 12 | std::cout << "baz is " << baz() << std::endl; 13 | std::cout << "zingo is " << zingo() << std::endl; 14 | } 15 | -------------------------------------------------------------------------------- /examples/cpp-bundle/bar/test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "bar.h" 5 | #include "zingo.h" 6 | } 7 | 8 | int main() 9 | { 10 | if( bar() == 42*42 ) 11 | std::cout << "ok" << std::endl; 12 | else 13 | std::cout << "failed" << std::endl; 14 | 15 | if( zingo() == 41*42 ) 16 | std::cout << "ok" << std::endl; 17 | else 18 | std::cout << "failed" << std::endl; 19 | } -------------------------------------------------------------------------------- /examples/cpp-bundle/bar/zingo.c: -------------------------------------------------------------------------------- 1 | #include "foo.h" 2 | 3 | int zingo() 4 | { 5 | return (foo() - 1) * foo(); 6 | } -------------------------------------------------------------------------------- /examples/cpp-bundle/bar/zingo.h: -------------------------------------------------------------------------------- 1 | #ifndef zingo_h 2 | #define zingo_h 3 | 4 | int zingo(); 5 | 6 | #endif -------------------------------------------------------------------------------- /examples/cpp-bundle/foo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild REQUIRED) 4 | project( foo VERSION 1.0.0 LANGUAGES C CXX ) 5 | 6 | ### targets 7 | 8 | set( FOO_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ) 9 | 10 | ecbuild_add_library( 11 | TARGET foo 12 | SOURCES foo.h foo.c 13 | INSTALL_HEADERS LISTED 14 | PUBLIC_INCLUDES 15 | $ 16 | $ ) 17 | 18 | ecbuild_add_executable( 19 | TARGET master_foo 20 | SOURCES main.cc 21 | LIBS foo ) 22 | 23 | ecbuild_add_test( 24 | TARGET test_foo 25 | SOURCES test.cc 26 | LIBS foo ) 27 | 28 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 29 | 30 | ecbuild_print_summary() 31 | 32 | -------------------------------------------------------------------------------- /examples/cpp-bundle/foo/foo.c: -------------------------------------------------------------------------------- 1 | int foo() 2 | { 3 | return 42; 4 | } -------------------------------------------------------------------------------- /examples/cpp-bundle/foo/foo.h: -------------------------------------------------------------------------------- 1 | #ifndef foo_h 2 | #define foo_h 3 | 4 | int foo(); 5 | 6 | #endif -------------------------------------------------------------------------------- /examples/cpp-bundle/foo/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "foo.h" 5 | } 6 | 7 | int main() 8 | { 9 | std::cout << "foo is " << foo() << std::endl; 10 | } 11 | -------------------------------------------------------------------------------- /examples/cpp-bundle/foo/test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | #include "foo.h" 5 | } 6 | 7 | int main() 8 | { 9 | if( foo() == 42) 10 | std::cout << "ok" << std::endl; 11 | else 12 | std::cout << "failed" << std::endl; 13 | } -------------------------------------------------------------------------------- /examples/cxx11/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package(ecbuild REQUIRED) 12 | project( cxx11 VERSION 0.0.1 LANGUAGES CXX ) 13 | 14 | ### definitions 15 | 16 | set(CMAKE_CXX_STANDARD 11) 17 | 18 | ### targets 19 | 20 | ecbuild_add_executable( TARGET compute 21 | SOURCES compute.cc ) 22 | 23 | ### finalize project 24 | 25 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 26 | 27 | ecbuild_print_summary() 28 | -------------------------------------------------------------------------------- /examples/cxx11/README.md: -------------------------------------------------------------------------------- 1 | Simple example demonstrating the use of C++11 features with a fallback. 2 | 3 | Usage: 4 | ===== 5 | 6 | ecbuild examples/cxx11 7 | -------------------------------------------------------------------------------- /examples/cxx11/compute.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if __cplusplus > 199711L 4 | 5 | #pragma message "C++11 enabled" 6 | #include 7 | #define __set std::unordered_set 8 | 9 | #else 10 | 11 | #pragma message "C++11 disabled" 12 | #include 13 | #define __set std::set 14 | 15 | #endif 16 | 17 | int main() { 18 | 19 | __set s; 20 | 21 | s.insert(7); 22 | s.insert(5); 23 | s.insert(3); 24 | 25 | for(__set::const_iterator it = s.begin(); it != s.end(); ++it) 26 | std::cout << *it << std::endl; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /examples/find_package/README: -------------------------------------------------------------------------------- 1 | find_package test projects 2 | 3 | The projects/ directory contains test projects for specific libraries. They 4 | serve as examples but can also be used to check these libraries by running the 5 | find_*.sh scripts. 6 | -------------------------------------------------------------------------------- /examples/find_package/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e -o pipefail 3 | 4 | { set +x; } 2>/dev/null 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | function cleanup { 8 | EXIT_CODE=$? 9 | { set +ex; } 2>/dev/null 10 | if [[ -n $BUILD_DIR ]]; then 11 | set -x 12 | rm -Rf $BUILD_DIR 13 | fi 14 | exit $EXIT_CODE 15 | } 16 | 17 | trap cleanup EXIT 18 | 19 | function build() { 20 | echo "build" 21 | export ecbuild_DIR=${HERE}/../.. 22 | 23 | _NAME="$1" 24 | _SRC="$2" 25 | _CMAKE_FLAGS="$3" 26 | 27 | echo Building project ${_NAME} 28 | 29 | TMPDIR="${TMPDIR:-$(pwd)}" 30 | BUILD_DIR="${TMPDIR}/build_${_NAME}_$(date +%Y-%m-%d_%H-%M-%S)" 31 | 32 | set -x 33 | mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} 34 | cmake ${_CMAKE_FLAGS} ${HERE}/${_SRC} 35 | make ${MAKE_ARGS} 36 | ctest 37 | } 38 | -------------------------------------------------------------------------------- /examples/find_package/find_cuda.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build cuda projects/cuda 5 | -------------------------------------------------------------------------------- /examples/find_package/find_fftw.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build fftw projects/fftw 5 | -------------------------------------------------------------------------------- /examples/find_package/find_fftw_MKL.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build fftw_mkl projects/fftw -DFFTW_ENABLE_MKL=ON 5 | -------------------------------------------------------------------------------- /examples/find_package/find_fftw_NO-MKL-1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build fftw projects/fftw -DFFTW_ENABLE_MKL=OFF 5 | -------------------------------------------------------------------------------- /examples/find_package/find_fftw_NO-MKL-2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build fftw projects/fftw "-DENABLE_MKL=OFF" 5 | -------------------------------------------------------------------------------- /examples/find_package/find_hdf5.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build hdf5 projects/hdf5 5 | -------------------------------------------------------------------------------- /examples/find_package/find_jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build jemalloc projects/jemalloc -DENABLE_JEMALLOC=ON 5 | -------------------------------------------------------------------------------- /examples/find_package/find_lapack.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build lapack projects/lapack "-DENABLE_MKL=OFF" 5 | -------------------------------------------------------------------------------- /examples/find_package/find_lapack_MKL.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build lapack_mkl projects/lapack "-DENABLE_MKL=ON" 5 | -------------------------------------------------------------------------------- /examples/find_package/find_netcdf.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build netcdf projects/netcdf 5 | -------------------------------------------------------------------------------- /examples/find_package/find_proj4.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build proj4 projects/proj4 5 | -------------------------------------------------------------------------------- /examples/find_package/find_tcmalloc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 3 | source ${HERE}/build.sh 4 | build tcmalloc projects/tcmalloc -DENABLE_TCMALLOC=ON 5 | -------------------------------------------------------------------------------- /examples/find_package/projects/cuda/add.cu: -------------------------------------------------------------------------------- 1 | #include "add.h" 2 | #include "kernel_add.h" 3 | 4 | void add(int n, float* x, float* y) { 5 | kernel_add<<<1, 1>>>(n, x, y); 6 | } -------------------------------------------------------------------------------- /examples/find_package/projects/cuda/add.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void add(int n, float* x, float* y); -------------------------------------------------------------------------------- /examples/find_package/projects/cuda/kernel_add.cu: -------------------------------------------------------------------------------- 1 | #include "kernel_add.h" 2 | 3 | // CUDA Kernel function to add the elements of two arrays on the GPU 4 | __global__ void kernel_add(int n, float *x, float *y) 5 | { 6 | for (int i = 0; i < n; i++) 7 | y[i] = x[i] + y[i]; 8 | } 9 | -------------------------------------------------------------------------------- /examples/find_package/projects/cuda/kernel_add.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // CUDA Kernel function to add the elements of two arrays on the GPU 4 | __global__ void kernel_add(int n, float *x, float *y); 5 | -------------------------------------------------------------------------------- /examples/find_package/projects/cuda/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "add.h" 5 | 6 | int main(void) 7 | { 8 | int N = 1<<20; 9 | float *x, *y; 10 | 11 | // Allocate Unified Memory – accessible from CPU or GPU 12 | cudaMallocManaged(&x, N*sizeof(float)); 13 | cudaMallocManaged(&y, N*sizeof(float)); 14 | 15 | // initialize x and y arrays on the host 16 | for (int i = 0; i < N; i++) { 17 | x[i] = 1.0f; 18 | y[i] = 2.0f; 19 | } 20 | 21 | // Run kernel on 1M elements on the GPU 22 | add(N,x,y); 23 | 24 | // Wait for GPU to finish before accessing on host 25 | cudaDeviceSynchronize(); 26 | 27 | // Check for errors (all values should be 3.0f) 28 | float maxError = 0.0f; 29 | for (int i = 0; i < N; i++) 30 | maxError = fmax(maxError, fabs(y[i]-3.0f)); 31 | printf("Max error: %.4f\n"); 32 | 33 | // Free memory 34 | cudaFree(x); 35 | cudaFree(y); 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /examples/find_package/projects/fftw/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild 3.4 REQUIRED ) 4 | project( find_fftw VERSION 0.0.0 LANGUAGES CXX ) 5 | 6 | # Provide FFTW_ENABLE_MKL=ON to force MKL implementation 7 | # Provide FFTW_ENABLE_MKL=OFF to force no MKL implementation 8 | # Not providing FFTW_ENABLE_MKL will prefer MKL implementation and fall back to official FFTW 9 | 10 | ecbuild_find_package( NAME FFTW REQUIRED COMPONENTS single ) 11 | 12 | ### Try to link executable with FFTW_LIBRARIES 13 | 14 | ecbuild_add_test( TARGET test_fftw 15 | SOURCES test_fftw.cc 16 | LIBS FFTW::fftw3f ) 17 | -------------------------------------------------------------------------------- /examples/find_package/projects/jemalloc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild 3.0.0 REQUIRED ) 4 | project( find_jecmalloc VERSION 0.0.0 LANGUAGES C Fortran ) 5 | 6 | ecbuild_add_option( FEATURE JEMALLOC 7 | DEFAULT OFF 8 | DESCRIPTION "jemalloc memory handling" 9 | REQUIRED_PACKAGES Jemalloc ) 10 | if( HAVE_JEMALLOC ) 11 | # Automatically link all executables with tcmalloc 12 | set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,${JEMALLOC_LIBRARY_DIR}" ) 13 | set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${JEMALLOC_LIBRARIES}" ) 14 | endif() 15 | 16 | ecbuild_add_executable( TARGET main SOURCES main.c ) 17 | ecbuild_add_executable( TARGET main_f SOURCES main.F90 ) 18 | 19 | # Run executables as test 20 | ecbuild_add_test( TARGET test_main COMMAND main ) 21 | ecbuild_add_test( TARGET test_main_f COMMAND main_f ) 22 | -------------------------------------------------------------------------------- /examples/find_package/projects/jemalloc/main.F90: -------------------------------------------------------------------------------- 1 | program main 2 | implicit none 3 | real(8), allocatable :: a(:) 4 | allocate(a(32)) 5 | a(:)=1. 6 | write(6,'(F8.6)') a(1) 7 | end program -------------------------------------------------------------------------------- /examples/find_package/projects/jemalloc/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | int length = 32; 5 | double* array = (double*) malloc( sizeof(double) * length ); 6 | for( int i=0; i 9 | #include 10 | 11 | static const char* trans = "N"; 12 | static const int inc = 1; 13 | static const double alpha = 1.; 14 | static const double beta = 0.; 15 | 16 | int main(int argc, char* argv[] ) { 17 | int err_code = 0; 18 | double A[] = { 1., -2., -4., 2. }; 19 | double B[] = { 1., -2., -4., 2. }; 20 | double C[] = { 0., 0., 0., 0. }; 21 | double C_expected[] = { 9., -6., -12., 12. }; 22 | 23 | int m = 2; // A.rows() 24 | int n = 2; // B.cols() 25 | int k = 2; // A.cols() 26 | dgemm_( trans, trans, &m, &n, &k, &alpha, A, &m, B, &k, &beta, C, &m); 27 | 28 | for( int i=0; i<2; ++i ) { 29 | for( int j=0; j<2; ++j ) { 30 | int idx = i*2+j; 31 | if( std::abs( C[idx] - C_expected[idx] ) > 1.e-10 ) { 32 | err_code=1; 33 | std::cout << "C("< 2 | #include 3 | int main() { 4 | int length = 32; 5 | double* array = (double*) malloc( sizeof(double) * length ); 6 | for( int i=0; i \ 7 | # interfaces.ns-incl="" 8 | 9 | $SRC{?} = $HERE 10 | 11 | step.class[interfaces] = build 12 | steps = interfaces 13 | 14 | interfaces.target{task} = ext-iface 15 | 16 | interfaces.source = $SRC 17 | 18 | # Exclude all 19 | interfaces.ns-excl = / 20 | 21 | # Include some 22 | # interfaces.ns-incl = 23 | 24 | # Extention of interface files 25 | interfaces.prop{file-ext.f90-interface} = .intfb.h 26 | 27 | # Do not follow includes 28 | interfaces.prop{no-dep.f.module} = * 29 | interfaces.prop{no-dep.include} = * 30 | -------------------------------------------------------------------------------- /examples/fortran/constants.f90: -------------------------------------------------------------------------------- 1 | MODULE Constants 2 | !--------------------------------------------------------------------- 3 | ! 4 | ! Module containing definitions of variables needed to 5 | ! compute the area of a circle of radius r 6 | ! 7 | !--------------------------------------------------------------------- 8 | REAL, PARAMETER :: ZOOM = 1 9 | END MODULE Constants 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/fortran/lolo.f95: -------------------------------------------------------------------------------- 1 | !-----Area_Circle---------------------------------------------------- 2 | ! 3 | ! Function to compute the area of a circle of given radius 4 | ! 5 | !--------------------------------------------------------------------- 6 | FUNCTION Area_Circle(r) 7 | USE Circle, ONLY : Pi 8 | 9 | IMPLICIT NONE 10 | REAL :: Area_Circle 11 | REAL, INTENT(IN) :: r 12 | 13 | Area_Circle = Pi * r * r 14 | 15 | END FUNCTION Area_Circle -------------------------------------------------------------------------------- /examples/fortran/main.F90: -------------------------------------------------------------------------------- 1 | PROGRAM Area 2 | !--------------------------------------------------------------------- 3 | ! 4 | ! This program computes the area of a circle given the input radius 5 | ! 6 | ! Uses: MODULE Circle 7 | ! FUNCTION Area_Circle (r) 8 | ! 9 | !--------------------------------------------------------------------- 10 | 11 | USE Circle, ONLY : radius 12 | IMPLICIT NONE 13 | 14 | #include "area_circle.h" 15 | 16 | ! Prompt user for radius of circle 17 | write(*, '(A)', ADVANCE = "NO") "Enter the radius of the circle: " 18 | read(*,*) radius 19 | 20 | ! Write out area of circle using function call 21 | write(*,100) "Area of circle with radius", radius, " is", & 22 | Area_Circle(radius) 23 | 100 format (A, 2x, F6.2, A, 2x, F11.2) 24 | 25 | END PROGRAM Area -------------------------------------------------------------------------------- /examples/fortran/old_circle.f90: -------------------------------------------------------------------------------- 1 | !-----Area_Circle---------------------------------------------------- 2 | ! 3 | ! Function to compute the area of a circle of given radius 4 | ! 5 | !--------------------------------------------------------------------- 6 | FUNCTION Area_Circle(r) 7 | USE Circle, ONLY : Pi 8 | 9 | IMPLICIT NONE 10 | REAL :: Area_Circle 11 | REAL, INTENT(IN) :: r 12 | 13 | Area_Circle = Pi * r * r 14 | 15 | END FUNCTION Area_Circle -------------------------------------------------------------------------------- /examples/mix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package( ecbuild REQUIRED ) 12 | project( mix VERSION 0.10.0 LANGUAGES CXX Fortran ) 13 | 14 | ### targets 15 | 16 | add_subdirectory( fort ) 17 | 18 | add_subdirectory( cpp ) 19 | 20 | ### pkgconfig exports 21 | 22 | ecbuild_pkgconfig( NAME fortbar DESCRIPTION "A fortran library bar" LIBRARIES fortbar ) 23 | ecbuild_pkgconfig( NAME fortbaz DESCRIPTION "A fortran library baz" LIBRARIES fortbaz ) 24 | 25 | ### finalize project 26 | 27 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 28 | 29 | ecbuild_print_summary() 30 | -------------------------------------------------------------------------------- /examples/mix/README.md: -------------------------------------------------------------------------------- 1 | Usage: 2 | ===== 3 | 4 | ecbuild -DECBUILD_SOURCE_FLAGS=flags.json examples/mix 5 | 6 | -------------------------------------------------------------------------------- /examples/mix/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | ecbuild_add_executable( TARGET capp SOURCES foo.cc LIBS fortbaz fortbar ) 10 | -------------------------------------------------------------------------------- /examples/mix/cpp/foo.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | extern "C" 6 | { 7 | void ir2_(int*,int *); 8 | int if3_(int *); 9 | 10 | void dr2_(double*,double *); 11 | double df3_(double *); 12 | 13 | void lir2_(int*,int *); 14 | int lif3_(int *); 15 | 16 | void ldr2_(double*,double *); 17 | double ldf3_(double *); 18 | } 19 | 20 | int main() 21 | { 22 | cout << "INT" << endl; 23 | 24 | int n = 10; 25 | int n2 = 0; 26 | int n3 = 0; 27 | 28 | ir2_(&n,&n2); 29 | cout << n << "^2 = " << n2 << endl; 30 | 31 | n3 = if3_(&n); 32 | cout << n << "^3 = " << n3 << endl; 33 | 34 | cout << "DOUBLE" << endl; 35 | 36 | double d = 4.4; 37 | double d2 = 0; 38 | double d3 = 0; 39 | 40 | dr2_(&d,&d2); 41 | cout << d << "^2 = " << d2 << endl; 42 | 43 | d3 = df3_(&d); 44 | cout << d << "^3 = " << d3 << endl; 45 | 46 | return 0; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /examples/mix/flags.json: -------------------------------------------------------------------------------- 1 | { 2 | "*" : [ "+", "-g0" ], 3 | 4 | "*.cxx" : [ "+", "-cxx11" ], 5 | "*.f90" : [ "+", "-pipe" ], 6 | 7 | "foo.c" : [ "+", "-O0" ], 8 | "foo.cc" : [ "+", "-O2", "-pipe" ], 9 | 10 | "bar/*": { 11 | "*.f90" : [ "=", "-O1" ] 12 | }, 13 | 14 | "baz/*": { 15 | "*.f90" : [ "/", "-pipe" ], 16 | "*.f90" : [ "/", "-O2" ], 17 | "*.f90" : [ "+", "-O3" ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/mix/fort/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ecbuild_add_library( TARGET fortbar TYPE STATIC SOURCES bar/bar.f90 ) 2 | 3 | ecbuild_add_library( TARGET fortbaz TYPE SHARED SOURCES baz/baz.f90 ) 4 | -------------------------------------------------------------------------------- /examples/mix/fort/bar/bar.f90: -------------------------------------------------------------------------------- 1 | SUBROUTINE ir2(N,M) 2 | M=N*N 3 | RETURN 4 | END 5 | 6 | INTEGER FUNCTION if3(N) 7 | if3=N*N*N 8 | RETURN 9 | END 10 | 11 | SUBROUTINE dr2(N,M) 12 | REAL*8, INTENT(IN) :: N 13 | REAL*8, INTENT(OUT) :: M 14 | M=N*N 15 | RETURN 16 | END 17 | 18 | REAL*8 FUNCTION df3(N) 19 | REAL*8, INTENT(IN) :: N 20 | df3=N*N*N 21 | RETURN 22 | END 23 | -------------------------------------------------------------------------------- /examples/mix/fort/baz/baz.f90: -------------------------------------------------------------------------------- 1 | SUBROUTINE lir2(N,M) 2 | M=N*N 3 | RETURN 4 | END 5 | 6 | INTEGER FUNCTION lif3(N) 7 | lif3=N*N*N 8 | RETURN 9 | END 10 | 11 | SUBROUTINE ldr2(N,M) 12 | REAL*8, INTENT(IN) :: N 13 | REAL*8, INTENT(OUT) :: M 14 | M=N*N 15 | RETURN 16 | END 17 | 18 | REAL*8 FUNCTION ldf3(N) 19 | REAL*8, INTENT(IN) :: N 20 | ldf3=N*N*N 21 | RETURN 22 | END 23 | -------------------------------------------------------------------------------- /examples/override-compile-flags/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package( ecbuild REQUIRED ) 12 | 13 | project( override_compile_flags VERSION 0.1 LANGUAGES C Fortran ) 14 | 15 | ecbuild_bundle_initialize() 16 | 17 | ecbuild_bundle( PROJECT bar ) 18 | ecbuild_bundle( PROJECT foo ) 19 | 20 | ecbuild_bundle_finalize() 21 | -------------------------------------------------------------------------------- /examples/override-compile-flags/README.md: -------------------------------------------------------------------------------- 1 | An example of a bundle containing two sub-projects, bar and foo, where foo 2 | needs to override compile flags of several source files. 3 | 4 | # Setup 5 | 6 | SRC_DIR=$(pwd) 7 | BUILD_DIR=$(pwd)/build 8 | mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} 9 | 10 | # Standard build using preset compile flags: 11 | 12 | ecbuild --build=Debug ${SRC_DIR} 13 | make VERBOSE=1 14 | 15 | # Use custom compile flags defined in JSON data file: 16 | 17 | ecbuild --build=Debug -DFOO_ECBUILD_SOURCE_FLAGS=${SRC_DIR}/foo/flags-cray-debug.json ${SRC_DIR} 18 | make VERBOSE=1 19 | 20 | module switch cdt cdt/15.11 21 | ecbuild --build=Debug -DFOO_ECBUILD_SOURCE_FLAGS=${SRC_DIR}/foo/flags-cray-8.4.1-debug.json ${SRC_DIR} 22 | make VERBOSE=1 23 | 24 | # Use custom compile flags defined in CMake script: 25 | 26 | ecbuild --build=Debug -DFOO_ECBUILD_COMPILE_FLAGS=${SRC_DIR}/foo/flags.cmake ${SRC_DIR} 27 | make VERBOSE=1 28 | -------------------------------------------------------------------------------- /examples/override-compile-flags/bar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package( ecbuild REQUIRED ) 12 | project( bar VERSION 0.2 LANGUAGES C ) 13 | 14 | ### targets 15 | 16 | ecbuild_add_library( TARGET bar SOURCES bar.c ) 17 | 18 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 19 | 20 | ecbuild_print_summary() 21 | -------------------------------------------------------------------------------- /examples/override-compile-flags/bar/bar.c: -------------------------------------------------------------------------------- 1 | void bar() {} 2 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package( ecbuild REQUIRED ) 12 | project( foo VERSION 0.1 LANGUAGES Fortran C ) 13 | 14 | ecbuild_enable_fortran ( REQUIRED MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/module ) 15 | 16 | ecbuild_find_package( NAME bar REQUIRED ) 17 | 18 | ### targets 19 | 20 | ecbuild_add_library( TARGET foo 21 | SOURCES foo.c 22 | foo.f90 23 | foo_contiguous.f90 24 | foo_intolerant.f90 25 | foo_ivybridge.f90 26 | foo_no_debug_symbols.f90 27 | PRIVATE_LIBS bar ) 28 | 29 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 30 | 31 | ecbuild_print_summary() 32 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/flags-cray-8.4.1-debug.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.f90" : [ "=", "-G0 -ram -emf -hadd_paren -hflex_mp=conservative -hfp0" ], 3 | "*.c" : [ "=", "-g -O0 -fPIC" ], 4 | "*foo_contiguous.f90" : [ "+", "-hcontiguous" ], 5 | "*foo_intolerant.f90" : [ "=", "-G0 -ram -emf -hadd_paren -hflex_mp=intolerant -hfp0" ], 6 | "*foo_ivybridge.f90" : [ "+", "-hcpu=ivybridge" ], 7 | "*foo_no_debug_symbols.f90" : [ "=", "-ram -emf -hadd_paren -hflex_mp=conservative -hfp0" ] 8 | } 9 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/flags-cray-8.4.1-release.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.f90" : [ "=", "-ram -emf -hadd_paren -Othread1 -hflex_mp=conservative -hfp1" ], 3 | "*.c" : [ "=", "-O0 -fPIC" ], 4 | "*foo_contiguous.f90" : [ "+", "-hcontiguous" ], 5 | "*foo_intolerant.f90" : [ "=", "-ram -emf -hadd_paren -hflex_mp=intolerant -hfp1" ], 6 | "*foo_ivybridge.f90" : [ "+", "-hcpu=ivybridge" ] 7 | } 8 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/flags-cray-debug.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.f90" : [ "=", "-G0 -ram -emf -hadd_paren -hflex_mp=conservative -hfp0" ], 3 | "*.c" : [ "=", "-g -O0 -fPIC" ], 4 | "*foo_contiguous.f90" : [ "+", "-hcontiguous" ], 5 | "*foo_intolerant.f90" : [ "=", "-G0 -ram -emf -hadd_paren -hflex_mp=intolerant -hfp0" ] 6 | } 7 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/flags-cray-release.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.f90" : [ "=", "-ram -emf -hadd_paren -Othread1 -hflex_mp=conservative -hfp1" ], 3 | "*.c" : [ "=", "-O0 -fPIC" ], 4 | "*foo_contiguous.f90" : [ "+", "-hcontiguous" ], 5 | "*foo_intolerant.f90" : [ "=", "-ram -emf -hadd_paren -hflex_mp=intolerant -hfp1" ] 6 | } 7 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/foo.c: -------------------------------------------------------------------------------- 1 | void foo() {} 2 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/foo.f90: -------------------------------------------------------------------------------- 1 | subroutine foo 2 | end subroutine 3 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/foo_contiguous.f90: -------------------------------------------------------------------------------- 1 | subroutine foo_contiguous 2 | end subroutine 3 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/foo_intolerant.f90: -------------------------------------------------------------------------------- 1 | subroutine foo_intolerant 2 | end subroutine 3 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/foo_ivybridge.f90: -------------------------------------------------------------------------------- 1 | subroutine foo_ivybridge 2 | end subroutine 3 | -------------------------------------------------------------------------------- /examples/override-compile-flags/foo/foo_no_debug_symbols.f90: -------------------------------------------------------------------------------- 1 | subroutine foo_no_debug_symbols 2 | end subroutine 3 | -------------------------------------------------------------------------------- /examples/simple/README.md: -------------------------------------------------------------------------------- 1 | # Simple ecBuild project 2 | 3 | ## Contents 4 | 5 | The project contains two directories. The `circle` directory contains a Fortran 6 | library and a C test of the library. The `compute` directory contains a C++ 7 | executable linking to the `circle` library as well as to LAPACK and GSL, if 8 | they can be found on the system. 9 | 10 | ## Pointing to the libraries 11 | 12 | The FindLAPACK macro provided by CMake looks for LAPACK in the system dynamic 13 | linker environment variables: 14 | * `DYLD_LIBRARY_PATH` on Apple 15 | * `LIB` on Windows 16 | * `LD_LIBRARY_PATH` otherwise 17 | 18 | The FindGSL macro provided by CMake looks for the `GSL_ROOT_DIR` environment 19 | variable. The libraries are expected to be in `$GSL_ROOT_DIR/lib` and the 20 | headers in `$GSL_ROOT_DIR/include/gsl`. On Unix, the 21 | `$GSL_ROOT_DIR/bin/gsl-config` tool will be used if it exists. 22 | 23 | ## Usage 24 | 25 | ``` 26 | SRC_DIR=$PWD # Source directory containing the main CMakeLists.txt 27 | BUILD_DIR=$PWD/build # Out-of-source build directory 28 | cd $BUILD_DIR 29 | ecbuild $SRC_DIR 30 | make -j 31 | ctest 32 | ``` 33 | -------------------------------------------------------------------------------- /examples/simple/circle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ecbuild_add_library( 2 | TARGET circle 3 | TYPE SHARED 4 | SOURCES area.f90 5 | ) 6 | 7 | 8 | ecbuild_add_test( 9 | TARGET test_area 10 | SOURCES test_area.c 11 | LIBS circle 12 | ) -------------------------------------------------------------------------------- /examples/simple/circle/area.f90: -------------------------------------------------------------------------------- 1 | FUNCTION area_circle(r) 2 | IMPLICIT NONE 3 | 4 | REAL*8, PARAMETER :: Pi = 3.1415927 5 | REAL*8, INTENT(IN) :: r 6 | REAL*8 :: area_circle 7 | 8 | area_circle = Pi * r * r 9 | RETURN 10 | 11 | END FUNCTION area_circle -------------------------------------------------------------------------------- /examples/simple/circle/test_area.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "math.h" 3 | 4 | double area_circle_(double *); 5 | 6 | int main() { 7 | 8 | double r = 10.; 9 | double a = area_circle_(&r); 10 | 11 | printf("%le %le %le\n", r, a, fabs(a - 100*M_PI)); 12 | 13 | if( fabs(a - 100*M_PI) > 1E-5 ) 14 | return -1; 15 | else 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /examples/simple/compute/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if( HAVE_MATRIX ) 2 | set( compute_defs HAVE_MATRIX_LAPACK ) 3 | endif() 4 | 5 | ecbuild_add_executable( 6 | 7 | TARGET 8 | compute 9 | 10 | SOURCES 11 | compute.cc 12 | 13 | DEFINITIONS 14 | "${compute_defs}" 15 | 16 | LIBS 17 | circle 18 | ) 19 | if( GSL_FOUND ) 20 | target_compile_definitions(compute PRIVATE HAVE_GSL) 21 | target_include_directories(compute PRIVATE ${GSL_INCLUDE_DIRS}) 22 | target_link_libraries(compute ${GSL_LIBRARIES}) 23 | endif() 24 | if( LAPACK_FOUND ) 25 | target_link_libraries(compute ${LAPACK_LIBRARIES}) 26 | endif() 27 | -------------------------------------------------------------------------------- /examples/simple/compute/compute.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifdef HAVE_GSL 5 | #include 6 | #endif 7 | 8 | using namespace std; 9 | 10 | extern "C" 11 | { 12 | double area_circle_(double *); 13 | 14 | void dgetrf_( int* m, int* n, double* a, int* lda, int* ipiv, int *info ); 15 | void dgetrs_( char* trans, int* n, int* nrhs, const double* a, int* lda, const int* ipiv,double* b, int* ldb, int *info ); 16 | } 17 | 18 | int main() { 19 | 20 | double x = 12.; 21 | std::cout << "x = " << x << std::endl; 22 | 23 | double ca = area_circle_(&x); 24 | 25 | std::cout << "area_circle = " << ca << std::endl; 26 | 27 | #ifdef HAVE_GSL 28 | double cb = gsl_sf_bessel_J0(x); 29 | std::cout << "Bessel J0 = " << cb << std::endl; 30 | #endif 31 | 32 | 33 | #ifdef HAVE_MATRIX_LAPACK 34 | 35 | char TRANS = 'N'; 36 | int INFO=3; 37 | int LDA = 3; 38 | int LDB = 3; 39 | int N = 3; 40 | int NRHS = 1; 41 | int IPIV[3] ; 42 | 43 | double A[9] = 44 | { 45 | 1, 2, 3, 46 | 2, 3, 4, 47 | 3, 4, 1 48 | }; 49 | 50 | double B[3] = 51 | { 52 | -4, 53 | -1, 54 | -2 55 | }; 56 | 57 | dgetrf_(&N,&N,A,&LDA,IPIV,&INFO); 58 | 59 | dgetrs_(&TRANS,&N,&NRHS,A,&LDA,IPIV,B,&LDB,&INFO); 60 | 61 | std::cout << "[" << B[0] << ", " << B[1] <<", " << B[2] << "]" << std::endl; 62 | 63 | #endif 64 | 65 | return 0; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /examples/simple/project_summary.cmake: -------------------------------------------------------------------------------- 1 | message( STATUS "---------------------------------------------------------" ) 2 | 3 | if( LAPACK_FOUND ) 4 | ecbuild_info( " LAPACK : [${LAPACK_LIBRARIES}]" ) 5 | endif() 6 | 7 | if( GSL_FOUND ) 8 | ecbuild_info( " GSL include : [${GSL_INCLUDE_DIRS}]" ) 9 | ecbuild_info( " libs : [${GSL_LIBRARIES}]" ) 10 | endif() 11 | 12 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/README.md: -------------------------------------------------------------------------------- 1 | # Transitive dependencies across projects 2 | 3 | This example contains 3 projects, where projectB depends on projectA, and 4 | projectC depends on projectB. Since projectB requires linking against projectA, 5 | the `projectB/projectb-import.cmake.in` file propagates the dependency (it gets 6 | included when a package calls `find_package(projectB)`). It also demonstrates 7 | PRIVATE (build requirements) and PUBLIC (usage requirements) dependency 8 | keywords. 9 | 10 | ## Usage 11 | 12 | ./build-and-run.sh 13 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/build-and-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | # Add ecbuild to path 8 | export PATH=$HERE/../../bin:$PATH 9 | 10 | # --------------------- cleanup ------------------------ 11 | $HERE/clean.sh 12 | 13 | # ----------------- build projectA --------------------- 14 | cd $HERE/projectA 15 | 16 | mkdir build 17 | cd build 18 | ecbuild --prefix=../install -- -DINSTALL_LIB_DIR=lib -Wno-deprecated ../ 19 | make install 20 | 21 | # ----------------- build projectB --------------------- 22 | cd $HERE/projectB 23 | 24 | mkdir build 25 | cd build 26 | ecbuild --prefix=../install -- \ 27 | -DprojectA_DIR=$HERE/projectA/install/lib/cmake/projectA \ 28 | -DINSTALL_LIB_DIR=lib -Wno-deprecated ../ 29 | make install 30 | 31 | # ----------------- build projectC --------------------- 32 | cd $HERE/projectC 33 | 34 | mkdir build 35 | cd build 36 | ecbuild --prefix=../install -- \ 37 | -DprojectA_DIR=$HERE/projectA/install/lib/cmake/projectA \ 38 | -DprojectB_DIR=$HERE/projectB/install/lib/cmake/projectB \ 39 | -DINSTALL_LIB_DIR=lib -Wno-deprecated ../ 40 | make install 41 | 42 | # ----------------- Run --------------------- 43 | 44 | cd $HERE 45 | projectC/install/bin/main-C 46 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | # --------------------- cleanup ------------------------ 8 | 9 | rm -rf projectA/build 10 | rm -rf projectA/install 11 | rm -rf projectB/build 12 | rm -rf projectB/install 13 | rm -rf projectC/build 14 | rm -rf projectC/install 15 | 16 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectA/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( projectA VERSION 1.1.0 LANGUAGES CXX ) 5 | 6 | ecbuild_add_library( TARGET projectA_Private SOURCES libraryA_Private.cc PRIVATE_DEFINITIONS A_PRIVATE PUBLIC_DEFINITIONS A_PUBLIC ) 7 | 8 | ecbuild_add_library( TARGET projectA SOURCES libraryA.h libraryA.cc INSTALL_HEADERS LISTED PRIVATE_LIBS projectA_Private PUBLIC_DEFINITIONS A_EXPORT ) 9 | 10 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 11 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectA/libraryA.cc: -------------------------------------------------------------------------------- 1 | #include "libraryA.h" 2 | 3 | #ifdef A_PRIVATE 4 | #error A_PRIVATE should not be exported by target projectA_private 5 | #endif 6 | #ifndef A_PUBLIC 7 | #error A_PUBLIC should have been exported by target projectA_private 8 | #endif 9 | #ifndef A_EXPORT 10 | #error A_EXPORT should be defined 11 | #endif 12 | 13 | extern int libraryA_Private(); 14 | 15 | int libraryA() { 16 | return libraryA_Private(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectA/libraryA.h: -------------------------------------------------------------------------------- 1 | int libraryA(); -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectA/libraryA_Private.cc: -------------------------------------------------------------------------------- 1 | #ifndef A_PRIVATE 2 | #error A_PRIVATE should be defined 3 | #endif 4 | #ifndef A_PUBLIC 5 | #error A_PUBLIC should be defined 6 | #endif 7 | 8 | int libraryA_Private() { 9 | return 1; 10 | } -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectB/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( projectB VERSION 0.1.0 LANGUAGES CXX ) 5 | 6 | find_package( projectA REQUIRED ) 7 | 8 | ecbuild_add_library( TARGET projectB SOURCES libraryB.cc libraryB.h INSTALL_HEADERS LISTED PUBLIC_LIBS projectA ) 9 | 10 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 11 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectB/libraryB.cc: -------------------------------------------------------------------------------- 1 | #ifdef A_PRIVATE 2 | #error A_PRIVATE should not be exported by target projectA_private 3 | #endif 4 | #ifdef A_PUBLIC 5 | #error A_PUBLIC should not be exported by target projectA 6 | #endif 7 | #ifndef A_EXPORT 8 | #error A_EXPORT should have been exported by target projectA 9 | #endif 10 | 11 | #include "libraryB.h" 12 | 13 | extern int libraryA(); 14 | 15 | int libraryB() { 16 | return libraryA(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectB/libraryB.h: -------------------------------------------------------------------------------- 1 | int libraryB(); -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectB/projectb-import.cmake.in: -------------------------------------------------------------------------------- 1 | include( CMakeFindDependencyMacro ) 2 | find_dependency( projectA REQUIRED ) 3 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( projectC VERSION 0.1.0 LANGUAGES CXX ) 5 | 6 | find_package( projectB REQUIRED ) 7 | 8 | ecbuild_add_library( TARGET projectC SOURCES libraryC.cc libraryC.h INSTALL_HEADERS LISTED PRIVATE_LIBS projectB ) 9 | 10 | ecbuild_add_executable( TARGET main-C SOURCES main.cc LIBS projectC ) 11 | 12 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 13 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectC/libraryC.cc: -------------------------------------------------------------------------------- 1 | #ifndef A_EXPORT 2 | #error A_EXPORT should be exported by projectA via projectB 3 | #endif 4 | 5 | extern int libraryB(); 6 | 7 | int libraryC() { 8 | return libraryB(); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectC/libraryC.h: -------------------------------------------------------------------------------- 1 | int libraryC(); -------------------------------------------------------------------------------- /examples/transitive-dependencies/projectC/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libraryC.h" 3 | int main(int argc, char* argv[]) { 4 | 5 | std::cout << "libraryC = " << libraryC() << std::endl; 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /lib/cmake/ecbuild/ecbuild-config-version.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/../../../cmake/ecbuild_parse_version.cmake) 2 | ecbuild_parse_version_file(${CMAKE_CURRENT_LIST_DIR}/../../../VERSION PREFIX PACKAGE) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /lib/cmake/ecbuild/ecbuild-config.cmake: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2019- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation nor 7 | # does it submit to any jurisdiction. 8 | 9 | get_filename_component(ecbuild_MACROS_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../cmake ABSOLUTE) 10 | cmake_policy( PUSH ) 11 | cmake_policy( SET CMP0057 NEW ) 12 | if(NOT ${ecbuild_MACROS_DIR} IN_LIST CMAKE_MODULE_PATH) 13 | list(INSERT CMAKE_MODULE_PATH 0 ${ecbuild_MACROS_DIR}) 14 | endif() 15 | cmake_policy( POP ) 16 | include(ecbuild) 17 | 18 | -------------------------------------------------------------------------------- /project_summary.cmake: -------------------------------------------------------------------------------- 1 | message( STATUS "---------------------------------------------------------" ) 2 | 3 | ecbuild_info( "[Generic]" ) 4 | 5 | if( PERL_EXECUTABLE ) 6 | ecbuild_info( " Perl : [${PERL_EXECUTABLE}] (${PERL_VERSION})" ) 7 | endif() 8 | 9 | if(PYTHONINTERP_FOUND) 10 | ecbuild_info( " Python : [${PYTHON_EXECUTABLE}] (${PYTHON_VERSION})" ) 11 | endif() 12 | 13 | if(PYTHONLIBS_FOUND) 14 | ecbuild_info( " Python include : [${PYTHON_INCLUDE_DIRS}]" ) 15 | ecbuild_info( " libs : [${PYTHON_LIBRARIES}]" ) 16 | endif() 17 | 18 | if( DEFINED FORTRAN_LIBRARIES ) 19 | ecbuild_info( "Fortan libs : [${FORTRAN_LIBRARIES}]" ) 20 | endif() 21 | 22 | -------------------------------------------------------------------------------- /regressions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( ECBUILD_359 ) 2 | add_subdirectory( ECBUILD_401 ) 3 | add_subdirectory( ECBUILD_407 ) 4 | add_subdirectory( ECBUILD_415 ) 5 | add_subdirectory( ECBUILD_433 ) 6 | add_subdirectory( ECBUILD_495 ) 7 | add_subdirectory( ECBUILD_509 ) 8 | add_subdirectory( ECBUILD_511 ) 9 | 10 | if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) 11 | add_subdirectory( ECBUILD_399 ) 12 | endif() 13 | -------------------------------------------------------------------------------- /regressions/ECBUILD_359/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | configure_file(run-test.sh.in run-test.sh @ONLY) 3 | configure_file(test-CMakeLists.txt CMakeLists.txt COPYONLY) 4 | 5 | ecbuild_add_test( 6 | TARGET ECBUILD-359 7 | TYPE SCRIPT 8 | COMMAND run-test.sh 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /regressions/ECBUILD_359/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # (C) Copyright 2011- ECMWF. 4 | # 5 | # This software is licensed under the terms of the Apache Licence Version 2.0 6 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 7 | # In applying this licence, ECMWF does not waive the privileges and immunities 8 | # granted to it by virtue of its status as an intergovernmental organisation 9 | # nor does it submit to any jurisdiction. 10 | 11 | set -e 12 | 13 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 14 | 15 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 16 | EXAMPLES_DIR=@CMAKE_SOURCE_DIR@/examples 17 | SRC_DIR=@CMAKE_CURRENT_SOURCE_DIR@ 18 | 19 | # Add ecbuild to path 20 | export PATH=$ECBUILD_PATH:$PATH 21 | 22 | # Cleanup previous builds 23 | rm -rf $HERE/build $HERE/bundle 24 | 25 | # Build and install bundle 26 | mkdir -p $HERE/bundle/build 27 | cd $HERE/bundle/build 28 | ecbuild --prefix=$HERE/bundle/install $EXAMPLES_DIR/cpp-bundle 29 | make install 30 | 31 | # Build project that uses subproject bar of bundle 32 | mkdir -p $HERE/build 33 | cd $HERE/build 34 | ecbuild -DBAR_PATH=$HERE/bundle/install ../ 35 | -------------------------------------------------------------------------------- /regressions/ECBUILD_359/test-CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 10 | 11 | find_package(ecbuild REQUIRED) 12 | project(kata VERSION 0.0 LANGUAGES CXX) 13 | 14 | ecbuild_find_package(NAME bar REQUIRED) 15 | -------------------------------------------------------------------------------- /regressions/ECBUILD_399/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | configure_file( ld-origin.sh.in ld-origin.sh @ONLY ) 3 | 4 | ecbuild_add_test( 5 | TARGET ECBUILD-399-ld-origin 6 | TYPE SCRIPT 7 | COMMAND ld-origin.sh 8 | CONDITION UNIX 9 | ) 10 | 11 | #[=[ 12 | Description of the bug: the linker fix check (look for test_ld_origin in 13 | cmake/ecbuild_check_os.cmake) makes the build fail if two different versions of 14 | ecbuild are used in the same build directory. 15 | #]=] 16 | 17 | configure_file( buildfail.sh.in buildfail.sh @ONLY ) 18 | configure_file( buildfail-CMakeLists.txt.in buildfail/CMakeLists.txt @ONLY ) 19 | 20 | ecbuild_add_test( 21 | TARGET ECBUILD-399-buildfail 22 | TYPE SCRIPT 23 | COMMAND buildfail.sh 24 | CONDITION UNIX 25 | ) 26 | 27 | -------------------------------------------------------------------------------- /regressions/ECBUILD_399/buildfail-CMakeLists.txt.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild QUIET) 4 | project( dummy VERSION 0.1 LANGUAGES NONE ) 5 | 6 | include( ecbuild_system NO_POLICY_SCOPE ) 7 | 8 | ecbuild_requires_macro_version( 2.9 ) 9 | ecbuild_declare_project() 10 | 11 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 12 | -------------------------------------------------------------------------------- /regressions/ECBUILD_399/buildfail.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 8 | 9 | # Add ecbuild to path 10 | export PATH=$ECBUILD_PATH:$PATH 11 | 12 | cd buildfail 13 | 14 | # ---------------------- cleanup ----------------------- 15 | rm -rf build 16 | 17 | # ----------------------- build ------------------------ 18 | mkdir build 19 | cd build 20 | ecbuild -- .. 21 | 22 | # -------------------- contaminate --------------------- 23 | # In practice, this may be caused by using two different 24 | # installations of ecbuild 25 | echo "CMAKE_HOME_DIRECTORY:INTERNAL=/non/existent" \ 26 | >ecbuild_tmp/check_linker/CMakeCache.txt 27 | 28 | # ---------------------- rebuild ----------------------- 29 | ecbuild -- .. 30 | -------------------------------------------------------------------------------- /regressions/ECBUILD_399/ld-origin.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 8 | SRC_DIR=@CMAKE_CURRENT_SOURCE_DIR@ 9 | 10 | # Add ecbuild to path 11 | export PATH=$ECBUILD_PATH:$PATH 12 | 13 | # --------------------- cleanup ------------------------ 14 | rm -rf $HERE/ld-origin 15 | 16 | # ------------------ build project --------------------- 17 | mkdir -p $HERE/ld-origin 18 | cd $HERE/ld-origin 19 | 20 | ecbuild -- $SRC_DIR/ld-origin 21 | make 22 | 23 | -------------------------------------------------------------------------------- /regressions/ECBUILD_399/ld-origin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | project(test_ld_origin VERSION 1.0 LANGUAGES C) 4 | include(ecbuild_system NO_POLICY_SCOPE) 5 | 6 | ecbuild_requires_macro_version( 2.9 ) 7 | ecbuild_declare_project() 8 | 9 | # Allow RPATH to be overridden at build time 10 | # This allows to recreate the bug without having to install a dummy project 11 | set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 12 | 13 | ecbuild_add_library(TARGET dso1 SOURCES dso1.c) 14 | 15 | ecbuild_add_library(TARGET dso2 SOURCES dso2.c) 16 | target_link_libraries(dso2 PRIVATE dso1) 17 | ecbuild_target_rpath(dso2 REPLACE "../lib") 18 | 19 | ecbuild_add_executable(TARGET main SOURCES main.c) 20 | target_link_libraries(main PRIVATE dso2) 21 | ecbuild_target_rpath(main REPLACE "../lib") 22 | 23 | ecbuild_install_project(NAME ${PROJECT_NAME}) 24 | -------------------------------------------------------------------------------- /regressions/ECBUILD_399/ld-origin/dso1.c: -------------------------------------------------------------------------------- 1 | void fun1(void) {} 2 | 3 | -------------------------------------------------------------------------------- /regressions/ECBUILD_399/ld-origin/dso2.c: -------------------------------------------------------------------------------- 1 | void fun1(void); 2 | void fun2(void) { fun1(); } 3 | 4 | -------------------------------------------------------------------------------- /regressions/ECBUILD_399/ld-origin/main.c: -------------------------------------------------------------------------------- 1 | void fun2(void); 2 | int main(void) { 3 | fun2(); 4 | return 0; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /regressions/ECBUILD_401/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( ec401_res clean.sh ) 3 | 4 | configure_file( run-test.sh.in run-test.sh @ONLY ) 5 | 6 | ecbuild_add_test( 7 | TARGET ECBUILD-401 8 | TYPE SCRIPT 9 | COMMAND run-test.sh 10 | RESOURCES ${ec401_res} 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /regressions/ECBUILD_401/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | rm -rf projectA/build 6 | rm -rf projectA/install 7 | rm -rf projectB/build 8 | rm -rf projectB/install 9 | 10 | -------------------------------------------------------------------------------- /regressions/ECBUILD_401/projectA/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild QUIET) 4 | project( projectA VERSION 0.1.0 LANGUAGES CXX ) 5 | 6 | include( ecbuild_system NO_POLICY_SCOPE ) 7 | 8 | ecbuild_requires_macro_version( 2.9.5 ) 9 | ecbuild_declare_project() 10 | 11 | ecbuild_add_library( TARGET projectA SOURCES libraryA.h libraryA.cc INSTALL_HEADERS LISTED ) 12 | 13 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 14 | -------------------------------------------------------------------------------- /regressions/ECBUILD_401/projectA/libraryA.cc: -------------------------------------------------------------------------------- 1 | #include "libraryA.h" 2 | 3 | int libraryA() { 4 | return 4; 5 | } 6 | -------------------------------------------------------------------------------- /regressions/ECBUILD_401/projectA/libraryA.h: -------------------------------------------------------------------------------- 1 | int libraryA(); 2 | -------------------------------------------------------------------------------- /regressions/ECBUILD_401/projectB/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild QUIET) 4 | project( projectB VERSION 0.1.0 LANGUAGES CXX ) 5 | 6 | include( ecbuild_system NO_POLICY_SCOPE ) 7 | 8 | ecbuild_requires_macro_version( 2.9.5 ) 9 | ecbuild_declare_project() 10 | 11 | find_package( projectA REQUIRED ) 12 | 13 | ecbuild_add_executable( TARGET main SOURCES main.cc ) 14 | target_link_libraries( main projectA ) 15 | 16 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 17 | -------------------------------------------------------------------------------- /regressions/ECBUILD_401/projectB/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char* argv[]) { 5 | std::cout << "libraryA = " << libraryA() << std::endl; 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /regressions/ECBUILD_401/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 8 | SRC_DIR=@CMAKE_CURRENT_SOURCE_DIR@ 9 | 10 | # Add ecbuild to path 11 | export PATH=$ECBUILD_PATH:$PATH 12 | 13 | # --------------------- cleanup ------------------------ 14 | $HERE/clean.sh 15 | 16 | # ----------------- build projectA --------------------- 17 | mkdir -p $HERE/projectA 18 | cd $HERE/projectA 19 | 20 | mkdir build 21 | cd build 22 | ecbuild --prefix=../install -- -DINSTALL_LIB_DIR=lib $SRC_DIR/projectA 23 | make install 24 | 25 | # ----------------- build projectB --------------------- 26 | mkdir -p $HERE/projectB 27 | cd $HERE/projectB 28 | 29 | mkdir build 30 | cd build 31 | ecbuild --prefix=../install -- -DINSTALL_LIB_DIR=lib -DprojectA_DIR=$HERE/projectA/install/lib/cmake/projectA $SRC_DIR/projectB 32 | make install 33 | 34 | # ----------------- run --------------------- 35 | cd $HERE 36 | 37 | projectB/install/bin/main >projectB_main.log 38 | grep -qF "libraryA = 4" projectB_main.log 39 | -------------------------------------------------------------------------------- /regressions/ECBUILD_407/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | configure_file( run-test.sh.in run-test.sh @ONLY ) 3 | 4 | ecbuild_add_test( 5 | TARGET ECBUILD-407 6 | TYPE SCRIPT 7 | COMMAND run-test.sh 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /regressions/ECBUILD_407/mybundle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild QUIET) 4 | include( ecbuild_bundle ) 5 | 6 | project( mybundle VERSION 0.1.0.0 LANGUAGES NONE ) 7 | 8 | ecbuild_bundle_initialize() 9 | 10 | ecbuild_requires_macro_version( 2.9.5 ) 11 | 12 | ecbuild_bundle( PROJECT mylib ) 13 | ecbuild_bundle( PROJECT myexe ) 14 | 15 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 16 | -------------------------------------------------------------------------------- /regressions/ECBUILD_407/mybundle/myexe/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | project( myexe VERSION 0.1.0 LANGUAGES NONE ) 4 | include( ecbuild_system NO_POLICY_SCOPE ) 5 | 6 | ecbuild_requires_macro_version( 2.9.5 ) 7 | ecbuild_declare_project() 8 | 9 | ecbuild_find_package( NAME mylib REQUIRED ) 10 | 11 | if( NOT DEFINED mylib_FOO ) 12 | message( FATAL_ERROR "mylib_FOO is not defined" ) 13 | endif() 14 | 15 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 16 | -------------------------------------------------------------------------------- /regressions/ECBUILD_407/mybundle/mylib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild QUIET) 4 | project( mylib VERSION 0.1.0 LANGUAGES NONE ) 5 | 6 | include( ecbuild_system NO_POLICY_SCOPE ) 7 | 8 | ecbuild_requires_macro_version( 2.9.5 ) 9 | ecbuild_declare_project() 10 | 11 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 12 | -------------------------------------------------------------------------------- /regressions/ECBUILD_407/mybundle/mylib/mylib-import.cmake.in: -------------------------------------------------------------------------------- 1 | set( mylib_FOO 1 ) 2 | -------------------------------------------------------------------------------- /regressions/ECBUILD_407/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 8 | SRC_DIR=@CMAKE_CURRENT_SOURCE_DIR@ 9 | 10 | # Add ecbuild to path 11 | export PATH=$ECBUILD_PATH:$PATH 12 | 13 | # --------------------- cleanup ------------------------ 14 | rm -rf build 15 | 16 | # ----------------- build --------------------- 17 | mkdir build 18 | cd build 19 | ecbuild -- $SRC_DIR/mybundle 20 | -------------------------------------------------------------------------------- /regressions/ECBUILD_415/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET ECBUILD-415 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_COMMAND} 6 | ARGS -DCMAKE_MODULE_PATH=${ECBUILD_MACROS_DIR} 7 | -P ${CMAKE_CURRENT_SOURCE_DIR}/test_path_append.cmake 8 | ) 9 | -------------------------------------------------------------------------------- /regressions/ECBUILD_415/test_path_append.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | include( ecbuild_append_to_rpath ) 5 | 6 | unset( SOME_PATH ) 7 | 8 | ecbuild_path_append( SOME_PATH "/usr/local/foo" ) 9 | 10 | message( "${SOME_PATH}" ) 11 | 12 | ecbuild_path_append( SOME_PATH "/usr/bar" ) 13 | 14 | message( "${SOME_PATH}" ) 15 | 16 | ecbuild_path_append( SOME_PATH "/system/baz" ) 17 | 18 | message( "${SOME_PATH}" ) 19 | 20 | if( NOT "${SOME_PATH}" STREQUAL "/usr/local/foo;/usr/bar;/system/baz" ) 21 | message( FATAL_ERROR "ecbuild_path_append() not working as expected" ) 22 | endif() 23 | -------------------------------------------------------------------------------- /regressions/ECBUILD_433/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | configure_file( run.sh.in run.sh @ONLY ) 3 | 4 | ecbuild_add_test( 5 | TARGET ECBUILD-433 6 | TYPE SCRIPT 7 | COMMAND run.sh 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /regressions/ECBUILD_433/proj/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.0 QUIET) 4 | 5 | project(myproj VERSION 0.1.0 LANGUAGES C) 6 | 7 | ecbuild_add_library(TARGET mylib SOURCES mylib.c) 8 | 9 | ecbuild_add_executable(TARGET myexe SOURCES myexe.c LIBS mylib) 10 | 11 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 12 | -------------------------------------------------------------------------------- /regressions/ECBUILD_433/proj/myexe.c: -------------------------------------------------------------------------------- 1 | extern void hello(void); 2 | 3 | int main(int argc, char **argv) { 4 | hello(); 5 | return 0; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /regressions/ECBUILD_433/proj/mylib.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void hello(void) { 4 | printf("Hello!\n"); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /regressions/ECBUILD_433/run.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 8 | SRC_DIR=@CMAKE_CURRENT_SOURCE_DIR@/proj 9 | 10 | # Add ecbuild to path 11 | export PATH=$ECBUILD_PATH:$PATH 12 | 13 | cd $HERE 14 | 15 | # ---------------------- cleanup ----------------------- 16 | rm -rf build build2 17 | 18 | # ----------------------- build ------------------------ 19 | mkdir build 20 | cd build 21 | ecbuild -- $SRC_DIR 22 | make 23 | 24 | # ---------------------- relocate ---------------------- 25 | cd $HERE 26 | mv build build2 27 | 28 | # ------------------------ run ------------------------- 29 | build2/bin/myexe >myexe.out 30 | 31 | # -------------------- check output -------------------- 32 | grep -q "^Hello!$" myexe.out 33 | -------------------------------------------------------------------------------- /regressions/ECBUILD_495/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | configure_file( run.sh.in run.sh @ONLY ) 3 | 4 | ecbuild_add_test( 5 | TARGET ECBUILD-495 6 | TYPE SCRIPT 7 | COMMAND run.sh 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /regressions/ECBUILD_495/proj/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.4 REQUIRED) 4 | project(foo VERSION 0.1 LANGUAGES NONE) 5 | 6 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR/cmake}) 7 | 8 | ecbuild_find_package(Bar REQUIRED) 9 | -------------------------------------------------------------------------------- /regressions/ECBUILD_495/proj/cmake/FindBar.cmake: -------------------------------------------------------------------------------- 1 | message(STATUS "Found Bar: ${CMAKE_CURRENT_LIST_FILE}") 2 | set(Bar_FOUND TRUE) 3 | -------------------------------------------------------------------------------- /regressions/ECBUILD_495/run.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@PROJECT_SOURCE_DIR@/bin 8 | SRC_DIR=@CMAKE_CURRENT_SOURCE_DIR@/proj 9 | 10 | # Add ecbuild to path 11 | export PATH=$ECBUILD_PATH:$PATH 12 | 13 | cd $HERE 14 | 15 | # ---------------------- cleanup ----------------------- 16 | rm -rf build 17 | 18 | # --------------------- configure ---------------------- 19 | mkdir build 20 | cd build 21 | ecbuild -- \ 22 | -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ 23 | -DCMAKE_FIND_ROOT_PATH=/invalid \ 24 | $SRC_DIR 25 | -------------------------------------------------------------------------------- /regressions/ECBUILD_509/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | configure_file( run.sh.in run.sh @ONLY ) 3 | 4 | ecbuild_add_test( 5 | TARGET ECBUILD-509 6 | TYPE SCRIPT 7 | COMMAND run.sh 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /regressions/ECBUILD_509/proj/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.6 QUIET) 4 | project(myproj VERSION 0.1.0 LANGUAGES C) 5 | 6 | ecbuild_add_library(TARGET mylib SOURCES mylib.c) 7 | 8 | ecbuild_add_test( 9 | TARGET myexe 10 | SOURCES myexe.c 11 | PROPERTIES TIMEOUT 60 12 | LIBS mylib 13 | ) 14 | 15 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 16 | -------------------------------------------------------------------------------- /regressions/ECBUILD_509/proj/myexe.c: -------------------------------------------------------------------------------- 1 | extern void hello(void); 2 | 3 | int main(int argc, char **argv) { 4 | hello(); 5 | return 0; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /regressions/ECBUILD_509/proj/mylib.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void hello(void) { 4 | printf("Hello!\n"); 5 | } 6 | 7 | -------------------------------------------------------------------------------- /regressions/ECBUILD_509/run.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 8 | SRC_DIR=@CMAKE_CURRENT_SOURCE_DIR@/proj 9 | 10 | # Add ecbuild to path 11 | export PATH=$ECBUILD_PATH:$PATH 12 | 13 | cd $HERE 14 | 15 | # ---------------------- cleanup ----------------------- 16 | rm -rf build 17 | 18 | # ----------------------- build ------------------------ 19 | mkdir build 20 | cd build 21 | ecbuild -- $SRC_DIR 22 | make 23 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( ec511_res clean.sh ) 3 | 4 | configure_file( run-test.sh.in run-test.sh @ONLY ) 5 | 6 | ecbuild_add_test( 7 | TARGET ECBUILD-511 8 | TYPE SCRIPT 9 | COMMAND run-test.sh 10 | RESOURCES ${ec511_res} 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/bundleAB/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.4 REQUIRED) 4 | project(bundleAB VERSION 0.1.0 LANGUAGES C) 5 | 6 | ecbuild_bundle(PROJECT projectA) 7 | ecbuild_bundle(PROJECT projectB) 8 | 9 | ecbuild_install_project(NAME ${PROJECT_NAME}) 10 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/bundleAB/projectA/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.4 REQUIRED) 4 | project(projectA VERSION 0.1.0 LANGUAGES C) 5 | 6 | ecbuild_add_library( 7 | TARGET projectA 8 | SOURCES libraryA.h libraryA.c 9 | PUBLIC_INCLUDES $ 10 | INSTALL_HEADERS LISTED) 11 | 12 | ecbuild_install_project(NAME ${PROJECT_NAME}) 13 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/bundleAB/projectA/libraryA.c: -------------------------------------------------------------------------------- 1 | #include "libraryA.h" 2 | 3 | int libraryA() { 4 | return 4; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/bundleAB/projectA/libraryA.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBRARYA_H_ 2 | #define _LIBRARYA_H_ 3 | int libraryA(); 4 | #endif /* _LIBRARYA_H_ */ 5 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/bundleAB/projectB/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.4 REQUIRED) 4 | project(projectB VERSION 0.1.0 LANGUAGES C) 5 | 6 | find_package(projectA REQUIRED) 7 | 8 | ecbuild_add_library( 9 | TARGET projectB 10 | SOURCES libraryB.h libraryB.c 11 | PUBLIC_LIBS projectA 12 | PUBLIC_INCLUDES $ 13 | INSTALL_HEADERS LISTED) 14 | 15 | ecbuild_install_project(NAME ${PROJECT_NAME}) 16 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/bundleAB/projectB/libraryB.c: -------------------------------------------------------------------------------- 1 | #include "libraryB.h" 2 | #include "libraryA.h" 3 | 4 | int libraryB() { 5 | return libraryA() + 1; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/bundleAB/projectB/libraryB.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBRARYB_H_ 2 | #define _LIBRARYB_H_ 3 | #include "libraryA.h" 4 | int libraryB(); 5 | #endif /* _LIBRARYB_H_ */ 6 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/bundleAB/projectB/projectb-import.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | find_dependency(projectA) 3 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | rm -rf bundleAB/build 6 | rm -rf bundleAB/install 7 | rm -rf projectC/build 8 | rm -rf projectC/install 9 | 10 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/projectC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.4 REQUIRED) 4 | project(projectC VERSION 0.1.0 LANGUAGES C) 5 | 6 | find_package(projectB REQUIRED) 7 | 8 | ecbuild_add_executable( 9 | TARGET main 10 | SOURCES main.c 11 | LIBS projectB) 12 | 13 | ecbuild_install_project(NAME ${PROJECT_NAME}) 14 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/projectC/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "libraryA.h" 4 | #include "libraryB.h" 5 | 6 | int main(int argc, char* argv[]) { 7 | printf("libraryA = %d\n", libraryA()); 8 | printf("libraryB = %d\n", libraryB()); 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /regressions/ECBUILD_511/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 8 | SRC_DIR=@CMAKE_CURRENT_SOURCE_DIR@ 9 | 10 | # Add ecbuild to path 11 | export PATH=$ECBUILD_PATH:$PATH 12 | 13 | # --------------------- cleanup ------------------------ 14 | $HERE/clean.sh 15 | 16 | # ----------------- build projectAB --------------------- 17 | mkdir -p $HERE/bundleAB 18 | cd $HERE/bundleAB 19 | 20 | mkdir build 21 | cd build 22 | ecbuild --prefix=../install -- -DINSTALL_LIB_DIR=lib $SRC_DIR/bundleAB 23 | make install 24 | 25 | cd .. 26 | rm -rfv build 27 | 28 | # ----------------- build projectC --------------------- 29 | mkdir -p $HERE/projectC 30 | cd $HERE/projectC 31 | 32 | mkdir build 33 | cd build 34 | ecbuild --prefix=../install -- -DINSTALL_LIB_DIR=lib \ 35 | -DprojectA_DIR=$HERE/bundleAB/install/lib/cmake/projectA \ 36 | -DprojectB_DIR=$HERE/bundleAB/install/lib/cmake/projectB \ 37 | $SRC_DIR/projectC 38 | make install 39 | 40 | cd .. 41 | rm -rfv build 42 | 43 | # ----------------- run --------------------- 44 | cd $HERE 45 | 46 | projectC/install/bin/main | tee projectC_main.log 47 | grep -qF "libraryA = 4" projectC_main.log 48 | grep -qF "libraryB = 5" projectC_main.log 49 | -------------------------------------------------------------------------------- /share/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | # ecbuild_add_resources( TARGET ecbuild_share 10 | # SOURCE_PACK ecmwf_license_header.txt 11 | # DONT_PACK_DIRS ecbuild ) 12 | 13 | # install( DIRECTORY ecbuild/toolchains USE_SOURCE_PERMISSIONS DESTINATION ${INSTALL_DATA_DIR} ) 14 | install( DIRECTORY ecbuild/check_linker DESTINATION ${INSTALL_DATA_DIR} ) 15 | -------------------------------------------------------------------------------- /share/ecbuild/check_linker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | #[=[ 4 | From https://sourceware.org/bugzilla/show_bug.cgi?id=20535 5 | 6 | > $ cat dso1.c 7 | > void fun1(void) {} 8 | > 9 | > $ cat dso2.c 10 | > void fun1(void); 11 | > void fun2(void) { fun1(); } 12 | > 13 | > $ cat main.c 14 | > void fun2(void); 15 | > int main(void) { 16 | > fun2(); 17 | > return 0; 18 | > } 19 | > 20 | > $ mkdir dsos 21 | > $ gcc -shared -fPIC -o dsos/libdso1.so dso1.c 22 | > $ gcc -shared -fPIC -o dsos/libdso2.so -Wl,-rpath='$ORIGIN' dso2.c -Ldsos -ldso1 23 | > $ gcc -Wl,-rpath='$ORIGIN/dsos' main.c -Ldsos -ldso2 24 | #]=] 25 | 26 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) 27 | set(CMAKE_SKIP_BUILD_RPATH FALSE) 28 | set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 29 | 30 | project(test_ld_origin VERSION 1.0 LANGUAGES C) 31 | 32 | add_library(dso1 SHARED dso1.c) 33 | 34 | add_library(dso2 SHARED dso2.c) 35 | target_link_libraries(dso2 PRIVATE dso1) 36 | set_target_properties(dso2 PROPERTIES 37 | INSTALL_RPATH "$ORIGIN") 38 | 39 | add_executable(main main.c) 40 | target_link_libraries(main dso2) 41 | set_target_properties(main PROPERTIES 42 | INSTALL_RPATH "$ORIGIN/../lib") 43 | 44 | set_target_properties(dso1 dso2 main PROPERTIES 45 | LIBRARY_OUTPUT_DIRECTORY lib 46 | RUNTIME_OUTPUT_DIRECTORY bin) 47 | 48 | install(TARGETS dso1 dso2 main 49 | LIBRARY DESTINATION lib 50 | RUNTIME DESTINATION bin) 51 | -------------------------------------------------------------------------------- /share/ecbuild/check_linker/dso1.c: -------------------------------------------------------------------------------- 1 | void fun1(void) {} 2 | 3 | -------------------------------------------------------------------------------- /share/ecbuild/check_linker/dso2.c: -------------------------------------------------------------------------------- 1 | void fun1(void); 2 | void fun2(void) { fun1(); } 3 | 4 | -------------------------------------------------------------------------------- /share/ecbuild/check_linker/main.c: -------------------------------------------------------------------------------- 1 | void fun2(void); 2 | int main(void) { 3 | fun2(); 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /share/ecbuild/cmake: -------------------------------------------------------------------------------- 1 | ../../cmake -------------------------------------------------------------------------------- /share/ecmwf_license_header.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2011- ECMWF. 3 | * 4 | * This software is licensed under the terms of the Apache Licence Version 2.0 5 | * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. In 6 | * applying this licence, ECMWF does not waive the privileges and immunities 7 | * granted to it by virtue of its status as an intergovernmental organisation 8 | * nor does it submit to any jurisdiction. 9 | */ 10 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory( bundle_options ) 2 | add_subdirectory( bundle_subdir ) 3 | add_subdirectory( bundle_subproj ) # ECBUILD-460 4 | add_subdirectory( bundle_override_features ) # ECBUILD-486 5 | add_subdirectory( ecbuild_regex_escape ) 6 | add_subdirectory( ecbuild_remove_fortran_flags ) # ECBUILD-484 7 | add_subdirectory( ecbuild_find_package ) 8 | add_subdirectory( ecbuild_add_option ) 9 | add_subdirectory( ecbuild_add_option_multiproject_defaults ) 10 | add_subdirectory( ecbuild_add_flags ) 11 | add_subdirectory( find_ecbuild ) 12 | add_subdirectory( ecbuild_shared_libs ) 13 | add_subdirectory( interface_library ) 14 | add_subdirectory( project_import ) 15 | add_subdirectory( project_options ) 16 | add_subdirectory( project_options_cached ) 17 | add_subdirectory( project_options_cached_multiproject ) 18 | add_subdirectory( project_summary ) 19 | add_subdirectory( ecbuild_override_compiler_flags ) 20 | add_subdirectory( test_properties ) 21 | add_subdirectory( test_requires_simple ) 22 | add_subdirectory( test_requires_complex ) 23 | -------------------------------------------------------------------------------- /tests/bundle_options/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_bundle_options 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/bundle_options/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build_* 10 | -------------------------------------------------------------------------------- /tests/bundle_options/projx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild 3.4 REQUIRED ) 4 | project( projx LANGUAGES NONE VERSION 0.1 ) 5 | 6 | add_subdirectory( proja ) 7 | add_subdirectory( projb ) 8 | 9 | ecbuild_print_summary() -------------------------------------------------------------------------------- /tests/bundle_options/projx/proja/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( proja LANGUAGES NONE VERSION 0.1 ) 5 | ecbuild_add_option( 6 | FEATURE FEATURE_A 7 | DEFAULT ON 8 | ) 9 | -------------------------------------------------------------------------------- /tests/bundle_options/projx/projb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( projb LANGUAGES NONE VERSION 0.2 ) 5 | ecbuild_add_option( 6 | FEATURE FEATURE_A 7 | DEFAULT OFF 8 | CONDITION SOME_PACKAGE_FOUND 9 | ) 10 | -------------------------------------------------------------------------------- /tests/bundle_override_features/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( _ref ${CMAKE_CURRENT_BINARY_DIR} ) 3 | 4 | set( bundle_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bundle ) 5 | configure_file( run-test.sh.in ${_ref}/run-test.sh @ONLY ) 6 | 7 | ecbuild_add_test( 8 | TARGET bundle-override-features 9 | TYPE SCRIPT 10 | COMMAND ${_ref}/run-test.sh 11 | ) 12 | -------------------------------------------------------------------------------- /tests/bundle_override_features/bundle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | 5 | set( ENABLE_TESTS ON CACHE BOOL "" ) 6 | set( PROJECT_A_ENABLE_TESTS OFF CACHE BOOL "" ) 7 | 8 | set( PROJECT_B_ENABLE_X OFF CACHE BOOL "" ) 9 | 10 | set(ENABLE_Y ON CACHE BOOL "" ) 11 | set(ENABLE_Z OFF CACHE BOOL "" ) 12 | 13 | project( bundle VERSION 0.0.0 LANGUAGES C ) 14 | 15 | add_subdirectory( project_a ) 16 | add_subdirectory( project_b ) 17 | 18 | -------------------------------------------------------------------------------- /tests/bundle_override_features/bundle/project_a/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | 5 | project( project_a VERSION 0.0.0 LANGUAGES C ) 6 | 7 | if( HAVE_TESTS ) 8 | ecbuild_error( "Tests should be disabled, as PROJECT_A_ENABLE_TESTS=${PROJECT_A_ENABLE_TESTS}," 9 | " even though ENABLE_TESTS=${ENABLE_TESTS}" ) 10 | endif() 11 | 12 | if( DEFINED ENABLE_X ) 13 | if( NOT _configured_before ) 14 | ecbuild_error( "This test is designed to have ENABLE_X undefined (upon first run at least)" ) 15 | set( _configured_before TRUE CACHE BOOL INTERNAL ) 16 | endif() 17 | endif() 18 | 19 | ecbuild_add_option( FEATURE X DEFAULT ON ) 20 | 21 | if( NOT HAVE_X ) 22 | ecbuild_error( "Feature X should be default-enabled as ENABLE_X is undefined" ) 23 | endif() 24 | 25 | ecbuild_add_option( FEATURE Y DEFAULT ON ) 26 | 27 | if( NOT HAVE_Y ) 28 | ecbuild_error( "Feature Y should be enabled, with ENABLE_Y=${ENABLE_Y} as set at bundle level" ) 29 | endif() 30 | 31 | ecbuild_add_option( FEATURE Z DEFAULT OFF ) 32 | 33 | if( HAVE_Z ) 34 | ecbuild_error( "Feature Y should be disabled, with ENABLE_Z=${ENABLE_Z} as set at bundle level" ) 35 | endif() -------------------------------------------------------------------------------- /tests/bundle_override_features/bundle/project_b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | 5 | project( project_b VERSION 0.0.0 LANGUAGES C ) 6 | 7 | if( NOT HAVE_TESTS ) 8 | ecbuild_error( "Tests should be enabled" ) 9 | endif() 10 | 11 | if( NOT DEFINED PROJECT_B_ENABLE_X ) 12 | ecbuild_error( "This test is designed to have PROJECT_B_ENABLE_X=OFF" ) 13 | endif() 14 | 15 | ecbuild_add_option( FEATURE X DEFAULT ON ) 16 | 17 | if( HAVE_X ) 18 | ecbuild_error( "Feature X should be disabled, as PROJECT_B_ENABLE_X=${PROJECT_B_ENABLE_X}," 19 | " even though ENABLE_X=OFF" ) 20 | endif() 21 | 22 | ecbuild_add_option( FEATURE Y DEFAULT OFF ) 23 | 24 | if( NOT HAVE_Y ) 25 | ecbuild_error( "Feature Y should be enabled, as ENABLE_Y=${ENABLE_Y} as set at bundle level" ) 26 | endif() 27 | 28 | ecbuild_add_option( FEATURE Z DEFAULT OFF ) 29 | 30 | if( HAVE_Z ) 31 | ecbuild_error( "Feature Y should be disabled, with ENABLE_Z=${ENABLE_Z} as set at bundle level" ) 32 | endif() -------------------------------------------------------------------------------- /tests/bundle_override_features/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | # --------------------- cleanup ------------------------ 8 | rm -rf $HERE/build 9 | 10 | # ---------------- build the bundle -------------------- 11 | cd $HERE 12 | 13 | export ecbuild_DIR=@PROJECT_BINARY_DIR@ 14 | 15 | mkdir build 16 | cd build 17 | cmake @bundle_SOURCE_DIR@ 18 | -------------------------------------------------------------------------------- /tests/bundle_subdir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( _funcs std ecbfind ) 3 | foreach( _func ${_funcs} ) 4 | set( _ref ${CMAKE_CURRENT_BINARY_DIR}/${_func} ) 5 | set( _FUNC ${_func} ) 6 | 7 | configure_file( run-test.sh.in ${_ref}/run-test.sh @ONLY ) 8 | 9 | file( COPY mybundle/CMakeLists.txt DESTINATION ${_ref}/mybundle/ ) 10 | configure_file( mybundle/myexe/CMakeLists.txt.in ${_ref}/mybundle/myexe/CMakeLists.txt @ONLY ) 11 | 12 | set( _confs SYSTEM BUNDLE ) 13 | set( _dir_SYSTEM ${_ref} ) 14 | set( _dir_BUNDLE ${_ref}/mybundle ) 15 | foreach( _conf ${_confs} ) 16 | set( _dir ${_dir_${_conf}} ) 17 | set( _CONFNAME ${_conf} ) 18 | 19 | file( GLOB_RECURSE _infiles 20 | RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/mylib.in 21 | "${CMAKE_CURRENT_SOURCE_DIR}/mylib.in/*" ) 22 | foreach( _infile ${_infiles} ) 23 | configure_file( mylib.in/${_infile} ${_dir}/mylib/${_infile} @ONLY ) 24 | endforeach() 25 | endforeach() 26 | 27 | ecbuild_add_test( 28 | TARGET bundle-subdir-${_func} 29 | TYPE SCRIPT 30 | COMMAND ${_ref}/run-test.sh 31 | ) 32 | endforeach() 33 | 34 | -------------------------------------------------------------------------------- /tests/bundle_subdir/mybundle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild QUIET) 4 | 5 | include( ecbuild_bundle ) 6 | 7 | project( mybundle VERSION 0.1.0.0 LANGUAGES NONE ) 8 | 9 | ecbuild_bundle_initialize() 10 | 11 | ecbuild_requires_macro_version( 2.9.5 ) 12 | 13 | add_subdirectory( mylib ) 14 | add_subdirectory( myexe ) 15 | 16 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 17 | -------------------------------------------------------------------------------- /tests/bundle_subdir/mybundle/myexe/CMakeLists.txt.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | project( myexe VERSION 0.1.0 LANGUAGES NONE ) 4 | 5 | include( ecbuild_system NO_POLICY_SCOPE ) 6 | 7 | ecbuild_requires_macro_version( 2.9.5 ) 8 | ecbuild_declare_project() 9 | 10 | if( @_FUNC@ STREQUAL "std" ) 11 | find_package( mylib REQUIRED ) 12 | else() #( @_FUNC@ STREQUAL "ecbfind" ) 13 | ecbuild_find_package( NAME mylib REQUIRED ) 14 | endif() 15 | 16 | if( NOT mylib_CONFNAME STREQUAL "BUNDLE" ) 17 | message( FATAL_ERROR "mylib_CONFNAME == '${mylib_CONFNAME}', expected 'BUNDLE'" ) 18 | endif() 19 | 20 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 21 | -------------------------------------------------------------------------------- /tests/bundle_subdir/mylib.in/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild QUIET) 4 | 5 | project( mylib VERSION 0.1.0 LANGUAGES NONE ) 6 | 7 | include( ecbuild_system NO_POLICY_SCOPE ) 8 | 9 | ecbuild_requires_macro_version( 2.9.5 ) 10 | ecbuild_declare_project() 11 | 12 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 13 | -------------------------------------------------------------------------------- /tests/bundle_subdir/mylib.in/mylib-import.cmake.in: -------------------------------------------------------------------------------- 1 | set( mylib_CONFNAME @_CONFNAME@ ) 2 | -------------------------------------------------------------------------------- /tests/bundle_subdir/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | ECBUILD_PATH=@CMAKE_SOURCE_DIR@/bin 8 | 9 | # Add ecbuild to path 10 | export PATH=$ECBUILD_PATH:$PATH 11 | 12 | # --------------------- cleanup ------------------------ 13 | rm -rf $HERE/build 14 | rm -rf $HERE/mylib/build 15 | rm -rf $HERE/mylib/install 16 | 17 | # ------------- build the "system" package ------------- 18 | cd $HERE/mylib 19 | 20 | mkdir build 21 | cd build 22 | ecbuild --prefix=../install -- -DINSTALL_LIB_DIR=lib .. 23 | make install 24 | 25 | export mylib_DIR=$HERE/mylib/install/lib/cmake/mylib 26 | 27 | # ---------------- build the bundle -------------------- 28 | cd $HERE 29 | 30 | mkdir build 31 | cd build 32 | ecbuild -- ../mybundle 33 | -------------------------------------------------------------------------------- /tests/bundle_subproj/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( _ref ${CMAKE_CURRENT_BINARY_DIR} ) 3 | 4 | set( mybundle_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/mybundle ) 5 | configure_file( run-test.sh.in ${_ref}/run-test.sh @ONLY ) 6 | 7 | ecbuild_add_test( 8 | TARGET bundle-subproj 9 | TYPE SCRIPT 10 | COMMAND ${_ref}/run-test.sh 11 | ) 12 | -------------------------------------------------------------------------------- /tests/bundle_subproj/mybundle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | project( mybundle VERSION 0.1.0.0 LANGUAGES NONE ) 4 | 5 | add_subdirectory( ecbuild ) 6 | add_subdirectory( mylib ) 7 | 8 | find_package( mylib REQUIRED ) 9 | 10 | if( NOT mylib_found_using_find_package ) 11 | 12 | # This variable is defined within the export files that are only called during find_package() 13 | message( FATAL_ERROR "The variable mylib_found_using_find_package is not set" ) 14 | endif() 15 | 16 | message( "mylib has been found successfully within a standard CMake project" ) 17 | -------------------------------------------------------------------------------- /tests/bundle_subproj/mybundle/ecbuild: -------------------------------------------------------------------------------- 1 | ../../../ -------------------------------------------------------------------------------- /tests/bundle_subproj/mybundle/mylib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.0 REQUIRED ) 4 | 5 | project( mylib VERSION 0.1.0 LANGUAGES NONE ) 6 | 7 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 8 | -------------------------------------------------------------------------------- /tests/bundle_subproj/mybundle/mylib/mylib-import.cmake.in: -------------------------------------------------------------------------------- 1 | set( mylib_found_using_find_package 1 ) 2 | -------------------------------------------------------------------------------- /tests/bundle_subproj/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | # --------------------- cleanup ------------------------ 8 | rm -rf $HERE/build 9 | 10 | # ---------------- build the bundle -------------------- 11 | cd $HERE 12 | 13 | mkdir build 14 | cd build 15 | cmake @mybundle_SOURCE_DIR@ 16 | -------------------------------------------------------------------------------- /tests/ecbuild_add_flags/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(_dir ${CMAKE_CURRENT_BINARY_DIR}) 2 | configure_file(run-test.sh.in ${_dir}/run-test.sh @ONLY) 3 | configure_file(test_ecbuild_add_flags.cmake ${_dir}/CMakeLists.txt COPYONLY) 4 | 5 | ecbuild_add_test( 6 | TARGET test_ecbuild_add_flags 7 | TYPE SCRIPT 8 | COMMAND run-test.sh 9 | ) -------------------------------------------------------------------------------- /tests/ecbuild_add_flags/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | cd $HERE 8 | 9 | rm -rf build # cleanup 10 | mkdir build 11 | cd build 12 | 13 | cmake -DCMAKE_MODULE_PATH=@ECBUILD_MACROS_DIR@ -DECBUILD_LOG_LEVEL=DEBUG .. -------------------------------------------------------------------------------- /tests/ecbuild_add_option/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_add_option 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build_* $HERE/*.log 10 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option/test_project/cmake/Findbar.cmake: -------------------------------------------------------------------------------- 1 | set(bar_FOUND 0) 2 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option/test_project/cmake/Findfoo.cmake: -------------------------------------------------------------------------------- 1 | set(_foo_FOUND 1) 2 | set(_foo_VERSION 1.2.3 ) 3 | include( FindPackageHandleStandardArgs ) 4 | find_package_handle_standard_args( foo 5 | REQUIRED_VARS _foo_FOUND 6 | VERSION_VAR _foo_VERSION 7 | ) 8 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option_multiproject_defaults/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_add_option_multiproject_defaults 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option_multiproject_defaults/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build_* 10 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option_multiproject_defaults/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild 3.4 REQUIRED ) 4 | 5 | project( main LANGUAGES NONE VERSION 0.2 ) 6 | 7 | add_subdirectory( proja ) 8 | add_subdirectory( projb ) 9 | add_subdirectory( projc ) 10 | 11 | ecbuild_print_summary() 12 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option_multiproject_defaults/test_project/proja/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( proja LANGUAGES NONE VERSION 0.2 ) 5 | ecbuild_add_option( 6 | FEATURE FEATURE_A 7 | DEFAULT ON 8 | ) 9 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option_multiproject_defaults/test_project/projb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( projb LANGUAGES NONE VERSION 0.1 ) 5 | ecbuild_add_option( 6 | FEATURE FEATURE_A 7 | DEFAULT OFF 8 | ) 9 | -------------------------------------------------------------------------------- /tests/ecbuild_add_option_multiproject_defaults/test_project/projc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( projc LANGUAGES NONE VERSION 0.3 ) 5 | ecbuild_add_option( 6 | FEATURE FEATURE_A 7 | DEFAULT ON 8 | REQUIRED_PACKAGES nonexistent 9 | ) 10 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_find_package 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/README.md: -------------------------------------------------------------------------------- 1 | # Transitive dependencies across projects and using ecbuild_find_package 2 | 3 | This example contains 3 projects, where projectB depends on projectA, and 4 | projectC depends on projectB. Since projectB requires linking against projectA, 5 | the `projectB/projectb-import.cmake.in` file propagates the dependency (it gets 6 | included when a package calls `find_package(projectB)`). It also demonstrates 7 | PRIVATE (build requirements) and PUBLIC (usage requirements) dependency 8 | keywords. 9 | 10 | projectC searches for projectB using a FindprojectB module, which in turn uses a find_package( projectB NO_MODULE ) 11 | This demonstrates that ecbuild_find_package now prioritises Find modules. 12 | 13 | ## Usage 14 | 15 | ./build-and-run.sh 16 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/build-and-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE} 7 | 8 | # Add ecbuild to path 9 | export PATH=$SOURCE/../../bin:$PATH 10 | echo $PATH 11 | echo $SOURCE 12 | 13 | # --------------------- cleanup ------------------------ 14 | $SOURCE/clean.sh 15 | 16 | # ----------------- build projectA --------------------- 17 | 18 | mkdir -p $HERE/projectA/build && cd $HERE/projectA/build 19 | pwd 20 | ecbuild --prefix=../install -- -Wno-deprecated $SOURCE/projectA 21 | make install 22 | export projectA_ROOT=$HERE/projectA/install 23 | 24 | # ----------------- build projectB --------------------- 25 | 26 | mkdir -p $HERE/projectB/build && cd $HERE/projectB/build 27 | ecbuild --prefix=../install -- -Wno-deprecated $SOURCE/projectB 28 | make install 29 | export projectB_ROOT=$HERE/projectB/install 30 | 31 | # ----------------- build projectC --------------------- 32 | 33 | mkdir -p $HERE/projectC/build && cd $HERE/projectC/build 34 | ecbuild --prefix=../install -- -Wno-deprecated $SOURCE/projectC 35 | make install 36 | 37 | # ----------------- Run --------------------- 38 | 39 | $HERE/projectC/install/bin/main-C 40 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/projectA/build 10 | rm -rf $HERE/projectA/install 11 | rm -rf $HERE/projectB/build 12 | rm -rf $HERE/projectB/install 13 | rm -rf $HERE/projectC/build 14 | rm -rf $HERE/projectC/install 15 | 16 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectA/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( projectA VERSION 1.1.0 LANGUAGES CXX ) 5 | 6 | ecbuild_add_library( TARGET projectA_Private SOURCES libraryA_Private.cc PRIVATE_DEFINITIONS A_PRIVATE PUBLIC_DEFINITIONS A_PUBLIC ) 7 | 8 | ecbuild_add_library( TARGET projectA SOURCES libraryA.h libraryA.cc INSTALL_HEADERS LISTED PRIVATE_LIBS projectA_Private PUBLIC_DEFINITIONS A_EXPORT ) 9 | 10 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 11 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectA/libraryA.cc: -------------------------------------------------------------------------------- 1 | #include "libraryA.h" 2 | 3 | #ifdef A_PRIVATE 4 | #error A_PRIVATE should not be exported by target projectA_private 5 | #endif 6 | #ifndef A_PUBLIC 7 | #error A_PUBLIC should have been exported by target projectA_private 8 | #endif 9 | #ifndef A_EXPORT 10 | #error A_EXPORT should be defined 11 | #endif 12 | 13 | extern int libraryA_Private(); 14 | 15 | int libraryA() { 16 | return libraryA_Private(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectA/libraryA.h: -------------------------------------------------------------------------------- 1 | int libraryA(); -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectA/libraryA_Private.cc: -------------------------------------------------------------------------------- 1 | #ifndef A_PRIVATE 2 | #error A_PRIVATE should be defined 3 | #endif 4 | #ifndef A_PUBLIC 5 | #error A_PUBLIC should be defined 6 | #endif 7 | 8 | int libraryA_Private() { 9 | return 1; 10 | } -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectA/projecta-import.cmake.in: -------------------------------------------------------------------------------- 1 | 2 | if( NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY ) 3 | message( "Importing projectA, not QUIET!!!") 4 | endif() 5 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectB/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( projectB VERSION 0.1.0 LANGUAGES CXX ) 5 | 6 | ecbuild_find_package( NAME projectA REQUIRED QUIET ) 7 | 8 | ecbuild_add_library( TARGET projectB SOURCES libraryB.cc libraryB.h INSTALL_HEADERS LISTED PUBLIC_LIBS projectA ) 9 | 10 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 11 | 12 | ecbuild_debug_var( CMAKE_MODULE_PATH ) 13 | ecbuild_debug_var( CMAKE_SYSTEM_MODULE_PATH ) -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectB/libraryB.cc: -------------------------------------------------------------------------------- 1 | #ifdef A_PRIVATE 2 | #error A_PRIVATE should not be exported by target projectA_private 3 | #endif 4 | #ifdef A_PUBLIC 5 | #error A_PUBLIC should not be exported by target projectA 6 | #endif 7 | #ifndef A_EXPORT 8 | #error A_EXPORT should have been exported by target projectA 9 | #endif 10 | 11 | #include "libraryB.h" 12 | 13 | extern int libraryA(); 14 | 15 | int libraryB() { 16 | return libraryA(); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectB/libraryB.h: -------------------------------------------------------------------------------- 1 | int libraryB(); -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectB/projectb-import.cmake.in: -------------------------------------------------------------------------------- 1 | if( NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY ) 2 | message( "Importing projectB, not QUIET!!!") 3 | endif() 4 | 5 | # projectB requires projectA. 6 | 7 | # find_dependency propagates QUIET and REQUIRED keywords from current scope 8 | include( CMakeFindDependencyMacro ) 9 | find_dependency( projectA ) 10 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( projectC VERSION 0.1.0 LANGUAGES CXX ) 5 | 6 | ecbuild_find_package( NAME projectB REQUIRED ) 7 | 8 | if( NOT projectB_MODULE ) 9 | ecbuild_critical( "projectB must be found via contained cmake/FindprojectB.cmake") 10 | endif() 11 | 12 | ecbuild_add_library( TARGET projectC SOURCES libraryC.cc libraryC.h INSTALL_HEADERS LISTED PRIVATE_LIBS projectB ) 13 | 14 | ecbuild_add_executable( TARGET main-C SOURCES main.cc LIBS projectC ) 15 | 16 | ecbuild_install_project( NAME ${PROJECT_NAME} ) 17 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectC/cmake/FindprojectB.cmake: -------------------------------------------------------------------------------- 1 | set( projectB_MODULE TRUE ) 2 | 3 | find_package( projectB NO_MODULE ) 4 | 5 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectC/libraryC.cc: -------------------------------------------------------------------------------- 1 | #ifndef A_EXPORT 2 | #error A_EXPORT should be exported by projectA via projectB 3 | #endif 4 | 5 | extern int libraryB(); 6 | 7 | int libraryC() { 8 | return libraryB(); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectC/libraryC.h: -------------------------------------------------------------------------------- 1 | int libraryC(); -------------------------------------------------------------------------------- /tests/ecbuild_find_package/projectC/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libraryC.h" 3 | int main(int argc, char* argv[]) { 4 | 5 | std::cout << "libraryC = " << libraryC() << std::endl; 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /tests/ecbuild_override_compiler_flags/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(_dir ${CMAKE_CURRENT_BINARY_DIR}) 2 | configure_file(run-test.sh.in ${_dir}/run-test.sh @ONLY) 3 | configure_file(test_ecbuild_override_compiler_flags.cmake ${_dir}/CMakeLists.txt COPYONLY) 4 | configure_file(emptyfile.c ${_dir}/emptyfile.c COPYONLY) 5 | configure_file(emptyfile.cxx ${_dir}/emptyfile.cxx COPYONLY) 6 | configure_file(emptyfile.F90 ${_dir}/emptyfile.F90 COPYONLY) 7 | configure_file(compiler_flags.cmake ${_dir}/compiler_flags.cmake COPYONLY) 8 | 9 | ecbuild_add_test( 10 | TARGET test_ecbuild_override_compiler_flags 11 | TYPE SCRIPT 12 | COMMAND run-test.sh 13 | ) 14 | -------------------------------------------------------------------------------- /tests/ecbuild_override_compiler_flags/compiler_flags.cmake: -------------------------------------------------------------------------------- 1 | set( OVERRIDECOMPILERFLAGS_C_FLAGS "-g -fPIC" ) 2 | set( OVERRIDECOMPILERFLAGS_CXX_FLAGS "-g -fPIC" ) 3 | set( OVERRIDECOMPILERFLAGS_Fortran_FLAGS "-g -fortran_only_flag" ) 4 | 5 | set( OVERRIDECOMPILERFLAGS_C_FLAGS_DEBUG "-O0" ) 6 | set( OVERRIDECOMPILERFLAGS_CXX_FLAGS_DEBUG "-O0" ) 7 | 8 | set( OVERRIDECOMPILERFLAGS_C_FLAGS_BIT "-O2" ) 9 | set( OVERRIDECOMPILERFLAGS_CXX_FLAGS_BIT "-O2" ) 10 | -------------------------------------------------------------------------------- /tests/ecbuild_override_compiler_flags/emptyfile.F90: -------------------------------------------------------------------------------- 1 | ! An empty file 2 | -------------------------------------------------------------------------------- /tests/ecbuild_override_compiler_flags/emptyfile.c: -------------------------------------------------------------------------------- 1 | // An empty file 2 | -------------------------------------------------------------------------------- /tests/ecbuild_override_compiler_flags/emptyfile.cxx: -------------------------------------------------------------------------------- 1 | // An empty file 2 | -------------------------------------------------------------------------------- /tests/ecbuild_override_compiler_flags/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | cd $HERE 8 | 9 | rm -rf build # cleanup 10 | mkdir build 11 | cd build 12 | 13 | cmake -DCMAKE_MODULE_PATH=@ECBUILD_MACROS_DIR@ -DECBUILD_LOG_LEVEL=DEBUG -DCMAKE_BUILD_TYPE=BIT -DECBUILD_SOURCE_FLAGS=@CMAKE_CURRENT_SOURCE_DIR@/flags-sourceflags.json .. 14 | 15 | cd .. 16 | 17 | rm -rf build # cleanup 18 | mkdir build 19 | cd build 20 | 21 | cmake -DCMAKE_MODULE_PATH=@ECBUILD_MACROS_DIR@ -DECBUILD_LOG_LEVEL=DEBUG -DCMAKE_BUILD_TYPE=DEBUG -DECBUILD_SOURCE_FLAGS=@CMAKE_CURRENT_SOURCE_DIR@/flags-sourceflags.json .. 22 | 23 | -------------------------------------------------------------------------------- /tests/ecbuild_regex_escape/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_regex_escape 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_COMMAND} 6 | ARGS -DCMAKE_MODULE_PATH=${ECBUILD_MACROS_DIR} 7 | -P ${CMAKE_CURRENT_SOURCE_DIR}/test_ecbuild_regex_escape.cmake 8 | ) 9 | -------------------------------------------------------------------------------- /tests/ecbuild_regex_escape/test_ecbuild_regex_escape.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | include( ecbuild_regex_escape ) 5 | 6 | set(testno 1) 7 | foreach(str "bla" "1.2" "a(b)" "a[b]" "x++" "a\\0" "x*" "x?" "a|b" "$v" "^a") 8 | message("Escaping '${str}'") 9 | ecbuild_regex_escape("${str}" test${testno}) 10 | message("-> ${test${testno}}") 11 | string(REGEX REPLACE "${test${testno}}" "match" test${testno}_match "${str}") 12 | if(NOT "${test${testno}_match}" STREQUAL "match") 13 | message(FATAL_ERROR "ecbuild_regex_escape not working as expected") 14 | endif() 15 | math(EXPR testno "${testno} + 1") 16 | endforeach() 17 | -------------------------------------------------------------------------------- /tests/ecbuild_remove_fortran_flags/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_remove_fortran_flags 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_COMMAND} 6 | ARGS -DCMAKE_MODULE_PATH=${ECBUILD_MACROS_DIR} 7 | -P ${CMAKE_CURRENT_SOURCE_DIR}/test_ecbuild_remove_fortran_flags.cmake 8 | ) 9 | -------------------------------------------------------------------------------- /tests/ecbuild_shared_libs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_shared_libs 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/ecbuild_shared_libs/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build 10 | rm -f $HERE/*.log 11 | -------------------------------------------------------------------------------- /tests/ecbuild_shared_libs/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( test_shared_libs VERSION 0.1.0 LANGUAGES Fortran ) 5 | 6 | ecbuild_add_library( TARGET test_shared_libs SOURCES dummy_src.F90 ) 7 | 8 | # this should never be overriden 9 | ecbuild_add_library( TARGET lib1 TYPE SHARED SOURCES dummy_src.F90 ) 10 | 11 | ecbuild_add_library( TARGET lib2 SOURCES dummy_src.F90 ) 12 | -------------------------------------------------------------------------------- /tests/ecbuild_shared_libs/test_project/dummy_src.F90: -------------------------------------------------------------------------------- 1 | program main 2 | 3 | end program 4 | -------------------------------------------------------------------------------- /tests/find_ecbuild/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Configs to test: 3 | # - CMAKE_MODULE_PATH 4 | # - ecbuild_DIR from environment 5 | # - ecbuild_DIR from command-line definition 6 | 7 | set(_configs module direnv direnv-full dircmd) 8 | foreach(_config ${_configs}) 9 | set(_ref ${CMAKE_CURRENT_BINARY_DIR}/${_config}) 10 | 11 | if(_config STREQUAL "module") 12 | unset(_EXPORTS) 13 | set(_CMDLINE_OPTS "-DCMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake") 14 | elseif(_config STREQUAL "direnv") 15 | set(_EXPORTS "export ecbuild_DIR=${PROJECT_SOURCE_DIR}") 16 | unset(_CMDLINE_OPTS) 17 | elseif(_config STREQUAL "direnv-full") 18 | set(_EXPORTS "export ecbuild_DIR=${PROJECT_SOURCE_DIR}/lib/cmake/ecbuild") 19 | unset(_CMDLINE_OPTS) 20 | elseif(_config STREQUAL "dircmd") 21 | unset(_EXPORTS) 22 | set(_CMDLINE_OPTS "-Decbuild_DIR=${PROJECT_SOURCE_DIR}/lib/cmake/ecbuild") 23 | endif() 24 | 25 | configure_file(run-test.sh.in ${_ref}/run-test.sh @ONLY) 26 | configure_file(test-CMakeLists.txt ${_ref}/CMakeLists.txt COPYONLY) 27 | 28 | ecbuild_add_test( 29 | TARGET find-ecbuild-${_config} 30 | TYPE SCRIPT 31 | COMMAND ${_ref}/run-test.sh 32 | ) 33 | endforeach() 34 | 35 | -------------------------------------------------------------------------------- /tests/find_ecbuild/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | cd $HERE 8 | 9 | rm -rf build # cleanup 10 | mkdir build 11 | cd build 12 | 13 | @_EXPORTS@ 14 | cmake @_CMDLINE_OPTS@ .. -------------------------------------------------------------------------------- /tests/find_ecbuild/test-CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.0 REQUIRED) 4 | project(dummy VERSION 0.1 LANGUAGES NONE) 5 | 6 | if(NOT DEFINED ECBUILD_MACROS_DIR) 7 | ecbuild_critical("ecbuild has not been loaded properly") 8 | endif() 9 | 10 | if(NOT ecbuild_DIR) 11 | ecbuild_critical("ecbuild_DIR has not been defined properly") 12 | endif() 13 | -------------------------------------------------------------------------------- /tests/interface_library/.gitignore: -------------------------------------------------------------------------------- 1 | build_test_interface_library 2 | install_test_interface_library 3 | -------------------------------------------------------------------------------- /tests/interface_library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_interface_library 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/interface_library/build-and-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE} 7 | 8 | # Add ecbuild to path 9 | export PATH=$SOURCE/../../bin:$PATH 10 | echo $PATH 11 | echo $SOURCE 12 | 13 | run_test() { 14 | 15 | local tname=$1 16 | local exp_sts=$2 17 | shift 2 18 | 19 | local bdir=$HERE/build_$tname 20 | local idir=$HERE/install_$tname 21 | local logf=$HERE/$tname.log 22 | 23 | mkdir -p $bdir && cd $bdir 24 | local sts=0 25 | echo "Running test '$tname'" 26 | ecbuild --prefix=$idir -- -Wno-deprecated $* $SOURCE/test_project >$logf 2>&1 || sts=$? 27 | 28 | make install 29 | 30 | if [[ $sts -ne $exp_sts ]] ; then 31 | echo "Test '$tname': expected exit code $exp_sts, got $sts" 32 | cat $logf 33 | exit 1 34 | fi 35 | } 36 | 37 | # --------------------- cleanup ------------------------ 38 | $SOURCE/clean.sh 39 | 40 | # ---------------------- tests ------------------------- 41 | run_test test_interface_library 0 42 | -------------------------------------------------------------------------------- /tests/interface_library/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build_* $HERE/*.log 10 | -------------------------------------------------------------------------------- /tests/interface_library/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( test_interface_library VERSION 0.1.0 LANGUAGES C ) 5 | 6 | ecbuild_add_library( TARGET intfb_lib TYPE INTERFACE 7 | PUBLIC_INCLUDES 8 | $ 9 | $ENV{HOME} 10 | PUBLIC_LIBS some_lib 11 | PUBLIC_DEFINITIONS MYDEF=1 12 | ) 13 | ecbuild_install_project( NAME test_interface_library ) 14 | -------------------------------------------------------------------------------- /tests/project_import/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set( _ref ${CMAKE_CURRENT_BINARY_DIR} ) 3 | 4 | set( projectA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/projectA ) 5 | set( projectB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/projectB ) 6 | set( projectC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/projectC ) 7 | configure_file( run-test.sh.in ${_ref}/run-test.sh @ONLY ) 8 | 9 | ecbuild_add_test( 10 | TARGET project_import 11 | TYPE SCRIPT 12 | COMMAND ${_ref}/run-test.sh 13 | ) 14 | -------------------------------------------------------------------------------- /tests/project_import/projectA/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.4 REQUIRED) 4 | 5 | project(projectA VERSION 0.0 LANGUAGES C) 6 | 7 | set(projectA_FOO foo) 8 | set(projectA_BAR bar) 9 | 10 | ecbuild_add_library(TARGET libA SOURCES libA.c) 11 | 12 | ecbuild_install_project(NAME ${PROJECT_NAME}) 13 | -------------------------------------------------------------------------------- /tests/project_import/projectA/libA.c: -------------------------------------------------------------------------------- 1 | int helloA(void) { return 1; } 2 | 3 | -------------------------------------------------------------------------------- /tests/project_import/projectA/projecta-import.cmake.in: -------------------------------------------------------------------------------- 1 | set(projectA_FOO @projectA_FOO@) 2 | 3 | if(TARGET libA) 4 | message(FATAL_ERROR "libA should not be defined yet") 5 | else() 6 | message("libA not defined yet, as expected") 7 | endif() 8 | -------------------------------------------------------------------------------- /tests/project_import/projectA/projecta-post-import.cmake.in: -------------------------------------------------------------------------------- 1 | set(projectA_BAR @projectA_BAR@) 2 | 3 | if(NOT TARGET libA) 4 | message(FATAL_ERROR "libA not defined") 5 | else() 6 | message("libA defined as expected") 7 | endif() 8 | -------------------------------------------------------------------------------- /tests/project_import/projectB/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.4 REQUIRED) 4 | 5 | project(projectB VERSION 0.0 LANGUAGES C) 6 | 7 | ecbuild_add_library(TARGET libB SOURCES libB.c) 8 | 9 | ecbuild_install_project(NAME ${PROJECT_NAME}) 10 | -------------------------------------------------------------------------------- /tests/project_import/projectB/libB.c: -------------------------------------------------------------------------------- 1 | int helloB(void) { return 2; } 2 | 3 | -------------------------------------------------------------------------------- /tests/project_import/projectB/projectb-import.cmake: -------------------------------------------------------------------------------- 1 | set(projectB_FOO spam) 2 | 3 | if(TARGET libB) 4 | message(FATAL_ERROR "libB should not be defined yet") 5 | else() 6 | message("libB not defined yet, as expected") 7 | endif() 8 | -------------------------------------------------------------------------------- /tests/project_import/projectB/projectb-post-import.cmake: -------------------------------------------------------------------------------- 1 | set(projectB_BAR eggs) 2 | 3 | if(NOT TARGET libB) 4 | message(FATAL_ERROR "libB not defined") 5 | else() 6 | message("libB defined as expected") 7 | endif() 8 | -------------------------------------------------------------------------------- /tests/project_import/projectC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package(ecbuild 3.4 REQUIRED) 4 | 5 | project(projectC VERSION 0.1 LANGUAGES NONE) 6 | 7 | find_package(projectA REQUIRED) 8 | find_package(projectB REQUIRED) 9 | 10 | set(EXP_projectA_FOO foo) 11 | set(EXP_projectA_BAR bar) 12 | set(EXP_projectB_FOO spam) 13 | set(EXP_projectB_BAR eggs) 14 | 15 | foreach(var projectA_FOO projectA_BAR projectB_FOO projectB_BAR) 16 | if(NOT DEFINED ${var}) 17 | message(FATAL_ERROR "${var} is not defined") 18 | elseif(NOT ${var} STREQUAL EXP_${var}) 19 | message(FATAL_ERROR "${var}: expected ${EXP_${var}}, got ${${var}}") 20 | else() 21 | message( "${var} = ${${var}} as expected") 22 | endif() 23 | endforeach() 24 | -------------------------------------------------------------------------------- /tests/project_import/run-test.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE="$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )" 6 | 7 | export ecbuild_ROOT=@PROJECT_BINARY_DIR@ 8 | 9 | # --------------------- cleanup ------------------------ 10 | rm -rf $HERE/projectA/build 11 | rm -rf $HERE/projectA/install 12 | rm -rf $HERE/projectB/build 13 | rm -rf $HERE/projectB/install 14 | rm -rf $HERE/projectC/build 15 | rm -rf $HERE/projectC/install 16 | 17 | # ------------------ build projectA -------------------- 18 | cd $HERE 19 | mkdir -p projectA 20 | cd projectA 21 | 22 | projectA_ROOT=$PWD/install 23 | 24 | mkdir build 25 | cd build 26 | cmake -DCMAKE_INSTALL_PREFIX=$projectA_ROOT @projectA_SOURCE_DIR@ 27 | make install 28 | 29 | # ------------------ build projectB -------------------- 30 | cd $HERE 31 | mkdir -p projectB 32 | cd projectB 33 | 34 | projectB_ROOT=$PWD/install 35 | 36 | mkdir build 37 | cd build 38 | cmake -DCMAKE_INSTALL_PREFIX=$projectB_ROOT @projectB_SOURCE_DIR@ 39 | make install 40 | 41 | # ------------------ build projectC -------------------- 42 | cd $HERE 43 | mkdir -p projectC 44 | cd projectC 45 | 46 | export projectA_ROOT 47 | export projectB_ROOT 48 | 49 | mkdir build 50 | cd build 51 | cmake @projectC_SOURCE_DIR@ 52 | -------------------------------------------------------------------------------- /tests/project_options/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_project_options 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/project_options/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build_* 10 | -------------------------------------------------------------------------------- /tests/project_options/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( proja LANGUAGES NONE VERSION 0.2 ) 5 | ecbuild_add_option( 6 | FEATURE FEATUREON 7 | DEFAULT ON 8 | CONDITION DEFINED FEATUREON_CONDITION 9 | ) 10 | ecbuild_add_option( 11 | FEATURE FEATUREOFF 12 | DEFAULT OFF 13 | CONDITION DEFINED FEATUREOFF_CONDITION 14 | ) -------------------------------------------------------------------------------- /tests/project_options_cached/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_project_options_cached 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/project_options_cached/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build_* 10 | -------------------------------------------------------------------------------- /tests/project_options_cached/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( project LANGUAGES NONE VERSION 0.2 ) 5 | 6 | ecbuild_add_option( 7 | FEATURE FEATUREA 8 | DEFAULT OFF 9 | ) 10 | 11 | ecbuild_add_option( 12 | FEATURE FEATUREB 13 | DEFAULT ON 14 | ) -------------------------------------------------------------------------------- /tests/project_options_cached_multiproject/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_project_options_cached_multiproject 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/project_options_cached_multiproject/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build_* 10 | -------------------------------------------------------------------------------- /tests/project_options_cached_multiproject/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( bundle LANGUAGES NONE VERSION 0.2 ) 5 | 6 | set ( ENABLE_FEATUREB ON CACHE BOOL "" ) 7 | set ( ENABLE_FEATUREC OFF CACHE BOOL "" ) 8 | 9 | add_subdirectory( proja ) 10 | add_subdirectory( projb ) 11 | 12 | ecbuild_print_summary() -------------------------------------------------------------------------------- /tests/project_options_cached_multiproject/test_project/proja/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( proja LANGUAGES NONE VERSION 0.2 ) 5 | 6 | ecbuild_add_option( 7 | FEATURE FEATUREA 8 | DEFAULT ON 9 | ) 10 | 11 | ecbuild_add_option( 12 | FEATURE FEATUREB 13 | DEFAULT OFF 14 | ) 15 | 16 | ecbuild_add_option( 17 | FEATURE FEATUREC 18 | DEFAULT OFF 19 | ) -------------------------------------------------------------------------------- /tests/project_options_cached_multiproject/test_project/projb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( projb LANGUAGES NONE VERSION 0.1 ) 5 | 6 | ecbuild_add_option( 7 | FEATURE FEATUREA 8 | DEFAULT OFF 9 | ) 10 | 11 | ecbuild_add_option( 12 | FEATURE FEATUREB 13 | DEFAULT ON 14 | ) 15 | 16 | ecbuild_add_option( 17 | FEATURE FEATUREC 18 | DEFAULT OFF 19 | ) -------------------------------------------------------------------------------- /tests/project_summary/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_project_summary 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/project_summary/clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | 7 | # --------------------- cleanup ------------------------ 8 | echo "cleaning $HERE" 9 | rm -rf $HERE/build_* 10 | -------------------------------------------------------------------------------- /tests/project_summary/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( main LANGUAGES NONE VERSION 0.1 ) 5 | 6 | add_subdirectory( proja ) 7 | add_subdirectory( projb ) 8 | add_subdirectory( projc ) 9 | 10 | ecbuild_print_summary() -------------------------------------------------------------------------------- /tests/project_summary/test_project/proja/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( proja LANGUAGES NONE VERSION 0.2 ) 5 | ecbuild_add_option( 6 | FEATURE FEATURE_A 7 | DEFAULT ON 8 | ) 9 | -------------------------------------------------------------------------------- /tests/project_summary/test_project/projb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( projb LANGUAGES NONE VERSION 0.1 ) 5 | ecbuild_add_option( 6 | FEATURE FEATURE_A 7 | DEFAULT OFF 8 | ) 9 | 10 | ecbuild_add_option( 11 | FEATURE FEATURE_B 12 | CONDITION SOME_PACKAGE_FOUND 13 | ) 14 | -------------------------------------------------------------------------------- /tests/project_summary/test_project/projc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package( ecbuild 3.4 REQUIRED ) 3 | 4 | project( projc LANGUAGES NONE VERSION 0.3 ) 5 | ecbuild_add_option( 6 | FEATURE FEATURE_C 7 | DEFAULT ON 8 | REQUIRED_PACKAGES NONEXISTENT 9 | ) 10 | -------------------------------------------------------------------------------- /tests/test_properties/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_test_properties 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/test_properties/build-and-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE} 7 | 8 | # Add ecbuild to path 9 | export PATH=$SOURCE/../../bin:$PATH 10 | echo $PATH 11 | echo $SOURCE 12 | 13 | # Build the project 14 | ecbuild $SOURCE/test_project -B $HERE/build 15 | 16 | # Run only one specific test (which should invoke the others) 17 | (cd $HERE/build; ctest -R write_world_after_hello) # Avoid using --test-dir option in ctest 18 | 19 | # Check if the output is as expected 20 | echo -n "Hello, World!" | diff - $HERE/build/output.txt 21 | -------------------------------------------------------------------------------- /tests/test_properties/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( test_test_properties VERSION 0.1.0 LANGUAGES NONE ) 5 | 6 | ecbuild_add_test( 7 | TARGET clean_output 8 | TEST_PROPERTIES FIXTURES_SETUP clean_output 9 | COMMAND ${CMAKE_COMMAND} 10 | ARGS -E remove ${CMAKE_CURRENT_BINARY_DIR}/output.txt 11 | ) 12 | 13 | ecbuild_add_test( 14 | TARGET write_hello 15 | TEST_PROPERTIES FIXTURES_SETUP write_hello FIXTURES_REQUIRED clean_output 16 | COMMAND bash 17 | ARGS -c "echo -n 'Hello, ' >> ${CMAKE_CURRENT_BINARY_DIR}/output.txt" 18 | ) 19 | 20 | ecbuild_add_test( 21 | TARGET write_world_after_hello 22 | TEST_PROPERTIES FIXTURES_REQUIRED write_hello 23 | COMMAND bash 24 | ARGS -c "echo -n 'World!' >> ${CMAKE_CURRENT_BINARY_DIR}/output.txt" 25 | ) 26 | -------------------------------------------------------------------------------- /tests/test_requires_complex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_test_requires_complex 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/test_requires_complex/build-and-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE} 7 | 8 | # Add ecbuild to path 9 | export PATH=$SOURCE/../../bin:$PATH 10 | echo $PATH 11 | echo $SOURCE 12 | 13 | # Build the project 14 | ecbuild $SOURCE/test_project -B $HERE/build 15 | 16 | # Run only one specific test (which should invoke the dependency) 17 | (cd $HERE/build; ctest -R write_world) # Avoid using --test-dir option in ctest 18 | 19 | # Check if the output is as expected 20 | echo -n "World!" | diff - $HERE/build/world.txt 21 | 22 | # Run only one specific test (which should invoke the dependencies) 23 | (cd $HERE/build; ctest -R combine_hello_world) # Avoid using --test-dir option in ctest 24 | 25 | # Check if the output is as expected 26 | echo -n "Hello, World!" | diff - $HERE/build/helloworld.txt 27 | -------------------------------------------------------------------------------- /tests/test_requires_complex/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( test_test_requires_complex VERSION 0.1.0 LANGUAGES NONE ) 5 | 6 | ecbuild_add_test( 7 | TARGET clean_output 8 | COMMAND ${CMAKE_COMMAND} 9 | ARGS -E remove ${CMAKE_CURRENT_BINARY_DIR}/hello.txt ${CMAKE_CURRENT_BINARY_DIR}/world.txt ${CMAKE_CURRENT_BINARY_DIR}/helloworld.txt 10 | ) 11 | 12 | ecbuild_add_test( 13 | TARGET write_hello 14 | TEST_REQUIRES clean_output 15 | COMMAND bash 16 | ARGS -c "echo -n 'Hello, ' >> ${CMAKE_CURRENT_BINARY_DIR}/hello.txt" 17 | ) 18 | 19 | ecbuild_add_test( 20 | TARGET write_world 21 | TEST_REQUIRES clean_output 22 | COMMAND bash 23 | ARGS -c "echo -n 'World!' >> ${CMAKE_CURRENT_BINARY_DIR}/world.txt" 24 | ) 25 | 26 | ecbuild_add_test( 27 | TARGET combine_hello_world 28 | TEST_REQUIRES write_hello write_world 29 | COMMAND bash 30 | ARGS -c "cat ${CMAKE_CURRENT_BINARY_DIR}/hello.txt ${CMAKE_CURRENT_BINARY_DIR}/world.txt >> ${CMAKE_CURRENT_BINARY_DIR}/helloworld.txt" 31 | ) 32 | -------------------------------------------------------------------------------- /tests/test_requires_simple/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | ecbuild_add_test( 3 | TARGET test_ecbuild_test_requires_simple 4 | TYPE SCRIPT 5 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-and-run.sh 6 | ENVIRONMENT CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} 7 | ) 8 | -------------------------------------------------------------------------------- /tests/test_requires_simple/build-and-run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | HERE=${CMAKE_CURRENT_BINARY_DIR:-"$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd -P )"} 6 | SOURCE=${CMAKE_CURRENT_SOURCE_DIR:-$HERE} 7 | 8 | # Add ecbuild to path 9 | export PATH=$SOURCE/../../bin:$PATH 10 | echo $PATH 11 | echo $SOURCE 12 | 13 | # Build the project 14 | ecbuild $SOURCE/test_project -B $HERE/build 15 | 16 | # Run only one specific test (which should invoke the dependencies) 17 | (cd $HERE/build; ctest -R write_world_after_hello) # Avoid using --test-dir option in ctest 18 | 19 | # Check if the output is as expected 20 | echo -n "Hello, World!" | diff - $HERE/build/output.txt 21 | -------------------------------------------------------------------------------- /tests/test_requires_simple/test_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) 2 | 3 | find_package( ecbuild REQUIRED ) 4 | project( test_test_requires_simple VERSION 0.1.0 LANGUAGES NONE ) 5 | 6 | ecbuild_add_test( 7 | TARGET clean_output 8 | COMMAND ${CMAKE_COMMAND} 9 | ARGS -E remove ${CMAKE_CURRENT_BINARY_DIR}/output.txt 10 | ) 11 | 12 | ecbuild_add_test( 13 | TARGET write_hello 14 | TEST_REQUIRES clean_output 15 | COMMAND bash 16 | ARGS -c "echo -n 'Hello, ' >> ${CMAKE_CURRENT_BINARY_DIR}/output.txt" 17 | ) 18 | 19 | ecbuild_add_test( 20 | TARGET write_world_after_hello 21 | TEST_REQUIRES write_hello 22 | COMMAND bash 23 | ARGS -c "echo -n 'World!' >> ${CMAKE_CURRENT_BINARY_DIR}/output.txt" 24 | ) 25 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # (C) Copyright 2011- ECMWF. 2 | # 3 | # This software is licensed under the terms of the Apache Licence Version 2.0 4 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 5 | # In applying this licence, ECMWF does not waive the privileges and immunities 6 | # granted to it by virtue of its status as an intergovernmental organisation 7 | # nor does it submit to any jurisdiction. 8 | 9 | list( APPEND ecbuild_bin_files 10 | ecbuild 11 | git-meld 12 | git-mproj 13 | check_install.sh 14 | apply_license.sh 15 | license.pl ) 16 | 17 | add_custom_target( ecbuild_bin SOURCES ${ecbuild_bin_files} ) 18 | 19 | install( PROGRAMS ecbuild DESTINATION ${INSTALL_BIN_DIR} ) 20 | 21 | # install( PROGRAMS ${ecbuild_bin_files} DESTINATION ${INSTALL_BIN_DIR} ) 22 | -------------------------------------------------------------------------------- /tools/git-meld: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | meld $2 $5 4 | -------------------------------------------------------------------------------- /tools/git-mproj: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # (C) Copyright 2011- ECMWF. 4 | # 5 | # This software is licensed under the terms of the Apache Licence Version 2.0 6 | # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 7 | # In applying this licence, ECMWF does not waive the privileges and immunities 8 | # granted to it by virtue of its status as an intergovernmental organisation nor 9 | # does it submit to any jurisdiction. 10 | 11 | # 12 | # git-proj: status, branch, checkout 13 | # 14 | 15 | txtbld=$(tput bold) # bold 16 | bldblu=${txtbld}$(tput setaf 6) # bold cyan 17 | txtrst=$(tput sgr0) # reset 18 | 19 | dashless=$(basename "$0" | sed -e 's/-/ /') 20 | USAGE="$dashless [options...]" 21 | 22 | SUBDIRECTORY_OK="yes" 23 | 24 | PATH=$(git --exec-path):$PATH 25 | . git-sh-setup 26 | 27 | require_work_tree_exists 28 | 29 | # go to top 30 | 31 | cd_to_toplevel 32 | cd .. 33 | 34 | # check option for number of levels 35 | nlevels=$(git config --global --int --get mproj.levels) 36 | if [ "$nlevels" != "" ] 37 | then 38 | nlevels="-maxdepth $nlevels" 39 | fi 40 | 41 | # do it 42 | 43 | for d in $( find $PWD $nlevels -type d -iname ".git" ) 44 | do 45 | gdir=$(dirname $d) 46 | proj=$(basename $gdir) 47 | pushd $gdir > /dev/null 48 | branch=$(git symbolic-ref --short HEAD) 49 | echo -e "${bldblu}---> $proj ($branch)${txtrst}" 50 | git "$@" 51 | popd > /dev/null 52 | done 53 | 54 | 55 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = E501 3 | --------------------------------------------------------------------------------