Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aliases #17

Open
Yaraslaut opened this issue Dec 19, 2023 · 0 comments
Open

aliases #17

Yaraslaut opened this issue Dec 19, 2023 · 0 comments

Comments

@Yaraslaut
Copy link
Member

Yaraslaut commented Dec 19, 2023

Very often when trying to compile different projects i need to set some cmake flags that are specific to this project.
fish in that regard is quite good at path sensitive command completion but issue when i have different configuration for the same project, one of the solution that provided by cmake itself is user defined presets they are good if you are working with one project for long time but not very convenient when you just started development.
what would be nice is to have possibility to create aliases for the commands for given directory, something like :

cmake --build build --target clean && cmake --build build >> clean-build
will create alias for this directory (or global one) that will execute this command when typing
clean-build

While this can be archived by creating custom functions that will depend on directory and I use it at the moment with fish, issue that I have is that i want to have one configuration for different machines and then i need to distinguish in this function directories and host machines that i am using, so creation of such alliases directly from the shell can make it much easier.
as an example of this function for kokkos that i have in my fish function

    case "kokkos"
         if test $name = "bahamankolibri.lin.tuni.fi"
            set EXTRA -DKokkos_ARCH_TURING75=ON
         end
	 $EXTRA
         switch $argv
         case "cuda"
              $executable -S . -B build -G Ninja \
              -D CMAKE_CXX_COMPILER=$CXX \
              -D CMAKE_C_COMPILER=$CC \
              -D CMAKE_BUILD_TYPE=Debug \
              -D Kokkos_ENABLE_SERIAL=ON \
              -D Kokkos_ENABLE_OPENMP=OFF \
              -D Kokkos_ENABLE_CUDA=ON \
              -D Kokkos_ENABLE_TESTS=ON \
              $EXTRA
         case "serial"
              $executable -S . -B build -G Ninja \
              -D CMAKE_CXX_COMPILER=$CXX \
              -D CMAKE_C_COMPILER=$CC \
              -D CMAKE_BUILD_TYPE=Debug \
              -D Kokkos_ENABLE_SERIAL=ON \
              -D Kokkos_ENABLE_OPENMP=ON \
              -D Kokkos_ENABLE_CUDA=OFF \
              -D Kokkos_ENABLE_TESTS=ON \
              $EXTRA
        case '*'
              $executable -S . -B build -G Ninja \
              -D CMAKE_CXX_COMPILER=$CXX \
              -D CMAKE_C_COMPILER=$CC \
              -D CMAKE_BUILD_TYPE=Debug \
              -D Kokkos_ENABLE_SERIAL=ON \
              -D Kokkos_ENABLE_OPENMP=ON \
              -D Kokkos_ENABLE_CUDA=ON \
              -D Kokkos_ENABLE_TESTS=ON \
              $EXTRA
        end

Where CXX and CC variables depend on host machine.

Another example is long cmake command for some projects, for example
cmake -S . -B build -G Ninja -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_C_COMPILER=clang -DLLVM_DIR=/home/yaraslau/.local/lib/cmake/llvm -D LLVM_EXTERNAL_LIT=/home/yaraslau/repo/llvm-project/build/bin/llvm-lit -DCUDAQ_BUILD_TESTS=ON -DCUDA Q_ENABLE_PYTHON=ON -D CMAKE_INSTALL_PREFIX=/home/yaraslau/.local -D CUDAQ_SKIP_MPI=ON -D CUDAQ_BUILD_TESTS=ON
or
cmake -S llvm -B build -G Ninja -DLLVM_TARGETS_TO_BUILD="X86;NVPTX" -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb;mlir;llvm" -D CMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_LINK_JOBS=2 -D LLVM_ENABLE_RUNTIMES=all -DCMAKE_INSTALL_PR EFIX=/home/yaraslau/.local -DLLVM_INSTALL_UTILS=ON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant