none
How to load linux envoironment variables before runing cmake? RRS feed

  • Question

  • Hi,

    I'm trying to code a project for Linux that already existed usin VS, so I've opened the folder where there is a CMakeLists.txt, the problem is:

    Since I use ROS, my code needs to load some environment variables before running the CMake command.

    On Linux all I have to do is run "source somepath/setup.bash" before running cmake, how can I make visual studio do the same? Or at least, how can I set those variables myself?

    Here is the output of the CMake cache trying to refresh

    1> /usr/local/bin/cmake -G "Unix Makefiles"  -DCMAKE_BUILD_TYPE="Debug" "/var/tmp/src/7f735363-f95b-3936-8d55-f6cdf7b0c706/Linux-Debug/CMakeLists.txt";
    1> CMake Error at C:\Users\twer\Documents\catkin_ws\src\CMakeLists.txt:59 (message):
    1>   find_package(catkin) failed.  catkin was neither found in the workspace nor
    1>   in the CMAKE_PREFIX_PATH.  One reason may be that no ROS setup.sh was
    1>   sourced before.
    1> 
    1> -- Configuring incomplete, errors occurred!
    1> See also "/var/tmp/build/7f735363-f95b-3936-8d55-f6cdf7b0c706/build/Linux-Debug/CMakeFiles/CMakeOutput.log".
    1> 
    1> cd /var/tmp/build/7f735363-f95b-3936-8d55-f6cdf7b0c706/build/Linux-Debug;/usr/local/bin/cmake -G "Unix Makefiles"  -DCMAKE_BUILD_TYPE="Debug" "\var\tmp\src\7f735363-f95b-3936-8d55-f6cdf7b0c706\Linux-Debug"; returned with exit code: 1
    Ps* I have successfully run the same command that visual studio try's to run directly on my Linux console through SSH.


    Using Visual studio professional 2017 on a Windows 10 machine.
    Tuesday, July 3, 2018 12:17 PM

All replies

  • Hi friend,

    Welcome to the MSDN forum.

    Refer to your description, it seems your issue is more relates to the CMake. Since our forum is to discuss the VS IDE, please redirect to this appropriate forum: https://cmake.org/developer-resources/ to seek for a more professional support, thank you for your understanding.

    If you have any other issues about the VS IDE in the future, please feel free to let us know.

    Best regards,

    Sara


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, July 4, 2018 2:28 AM