aliases
Opened this issue · 0 comments
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