2

I'm working on Ubuntu 14.04 with ROS Indigo and I need to use Geometry Tools Wild Magic 5 for developing a package.

I have exported the path to Wild Magic folder as an environment variable by modifying .bashrc as follows:

export WM5_PATH=/home/user/catkin_ws/src/GeometricTools/WildMagic5/SDK

This is done to specify locations of header files in the CMakeLists.txt file of the package I'm coding:

include_directories(
    include
    $ENV{WM5_PATH}/Include/
)

Previously, in the same cmake file I check if the environmental variable is correctly set:

if (NOT DEFINED ENV{WM5_PATH})
    MESSAGE (FATAL_ERROR "Wild Magic Engine 5.14 missing")
endif()

Now, while building the package using catkin build the environment variable is not found (the if above is entered). But by using printenv in the terminal I can see that the environment variable WM5_PATH is actually there.

How could I solve this problem?

Dhindhimathai
  • 23
  • 1
  • 6

1 Answers1

3

I've just given your example a try and it works fine in my Ubuntu bash shell.

# export WM5_PATH=/home/user/catkin_ws/src/GeometricTools/WildMagic5/SDK
# cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: ...

So I suspect your cmake executable runs in another environment (e.g. an IDE).

To check what your CMake does see as an environment you could add the following to your CMakeLists.txt:

execute_process(
    COMMAND ${CMAKE_COMMAND} -E environment
)

Reference

Florian
  • 39,996
  • 9
  • 133
  • 149
  • Thanks for your reply. I suppose what you say is correct: while I'm building the code using `catkin build` CMake sees the catkin environment as the current one. But, unfortunately if I add the portion of code you suggested to the `CMakeLists.txt` it does not print out anything in the terminal during `catkin build`! Do you know why? – Dhindhimathai Jan 24 '18 at 08:26
  • @George CMake only runs/configures the build environment when you change/touch one of the `CMakeLists.txt` files. So no output from CMake would be normal, if you didn't change anything on the CMake side of the build. – Florian Jan 24 '18 at 08:30
  • Sorry, I'm not very expert with CMake. I have changed the `CMakeLists.txt` by adding `execute_process(COMMAND ${CMAKE_COMMAND} -E environment)` as you suggested. Would not that output the variables? – Dhindhimathai Jan 24 '18 at 08:39
  • @George Yes, so it's [`catkin`](http://catkin-tools.readthedocs.io/en/latest/verbs/catkin_build.html): "Normally, unless an error occurs, the output from each package’s build process is collected but not printed to the console." So try `catkin build --verbose` to also see messages - like CMake's output - going to `stdout`. – Florian Jan 24 '18 at 09:16