From 171e439bd400143b15e5e4ec057155bde3cef0bc Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Fri, 14 Apr 2023 13:14:52 +0200 Subject: [PATCH] Allow builds without MPI with -DUSE_MPI=OFF --- .gitlab-ci.yml | 7 +++++++ nix/rt.nix | 6 ++++++ src/emu/CMakeLists.txt | 23 ++++++++++++++--------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7c0106b..5002cca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,6 +21,13 @@ build:rt-tests: script: - nix build -L --tarball-ttl 0 --file nix/rt.nix bsc.ovni-rt +build:no-mpi: + stage: build + tags: + - nix + script: + - nix build -L --tarball-ttl 0 --file nix/rt.nix bsc.ovni-nompi + build:old-gcc: stage: build tags: diff --git a/nix/rt.nix b/nix/rt.nix index 681c99e..d5e2780 100644 --- a/nix/rt.nix +++ b/nix/rt.nix @@ -155,6 +155,12 @@ let export NODES_HOME="${last.nodes}" ''; }); + + ovni-nompi = last.ovni.overrideAttrs (old: { + buildInputs = pkgs.lib.filter (x: x != last.mpi ) old.buildInputs; + cmakeFlags = old.cmakeFlags ++ [ "-DUSE_MPI=OFF" ]; + }); + }); in diff --git a/src/emu/CMakeLists.txt b/src/emu/CMakeLists.txt index 5b7a518..29c7762 100644 --- a/src/emu/CMakeLists.txt +++ b/src/emu/CMakeLists.txt @@ -66,14 +66,19 @@ target_link_libraries(ovnidump emu parson-static ovni-static) add_executable(ovnisort ovnisort.c) target_link_libraries(ovnisort emu parson-static ovni-static) -# Use _ROOT variables if available, commonly used by MPI -# installations -if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) +set(USE_MPI ON CACHE BOOL "Use MPI (required by ovnisync)") +if(USE_MPI) + # Use _ROOT variables if available, commonly used by MPI + # installations + if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) + endif() + find_package(MPI REQUIRED) + add_executable(ovnisync ovnisync.c) + target_link_libraries(ovnisync m MPI::MPI_C) + install(TARGETS ovnisync RUNTIME DESTINATION bin) +else() + message(STATUS "Disabling ovnisync as MPI is disabled") endif() -find_package(MPI REQUIRED) -add_executable(ovnisync ovnisync.c) -target_link_libraries(ovnisync m MPI::MPI_C) - -install(TARGETS ovniemu ovnidump ovnisync ovnisort RUNTIME DESTINATION bin) +install(TARGETS ovniemu ovnidump ovnisort RUNTIME DESTINATION bin)