1

I have a project which is build using cmake. I am trying to write a shell script for automating the build. But the trouble is, when run from the script the cmake is giving the following error

"include could not find load file:
            cmake/comp.cmake "

I tried to run the cmake from the terminal and its working fine. How can i get to run cmake from the shell script??

EDIT: cmake/comp.cmake is a file inside the project folder. which is actually an module i am loading in the cmakelists.txt

EDIT: the script

#!/bin/bash

num=$(grep -c "PATH=$PATH:/opt/robocomp/bin" ~/.bashrc)
if [ $num -eq 0 ]; then
    echo "export PATH=$PATH:/opt/robocomp/bin" >> ~/.bashrc;
    echo "added /opt/robocomp/bin to PATH ";
fi

source ~/.bashrc
cd ~/robocomp
cmake .
make
sudo make install

if [ $? -eq 0 ]; then 
    echo "/opt/robocomp/lib/" >> /etc/ld.so.conf
    sudo ldconfig
fi
Nithin
  • 5,470
  • 37
  • 44

1 Answers1

0

You could try to add the path of directory which contains comp.cmake to CMAKE_MODULE_PATH. Add this line to your CMakeLists.txt:

list( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" )

and then include your module:

include( comp )

As side note: it is usually better use out-of-source builds.

nils
  • 2,424
  • 1
  • 17
  • 31