orocos-toolchain / rtt

Orocos Real-Time Toolkit
http://www.orocos.org
Other
72 stars 79 forks source link

cmake: unset found and missing components list after each invocation of the RTT cmake config #220

Closed meyerj closed 5 years ago

meyerj commented 7 years ago

If the RTT cmake module is used more than once with different components and the REQUIRED argument was not given during the first invocation, a second invocation with REQUIRED might trigger false errors because of items added to MISSING_COMPONENTS earlier.

Example:

find_package(Orocos-RTT COMPONENTS non-existent-plugin)      # not available
if(OROCOS-RTT_NON-EXISTENT-PLUGIN_FOUND)
  # ...
endif()

# ...
find_package(Orocos-RTT REQUIRED COMPONENTS rtt-scripting)   # I really need scripting!

prints

-- - Detected OROCOS_TARGET environment variable. Using: gnulinux
-- Orocos-RTT found in /opt/orocos/kinetic/install_debug/lib/cmake/orocos-rtt/orocos-rtt-gnulinux-libraries.cmake
-- Found orocos-rtt  for the gnulinux target. Available transports: corba mqueue
-- - Detected OROCOS_TARGET environment variable. Using: gnulinux
-- Found orocos-rtt  for the gnulinux target. Available transports: corba mqueue
-- - Could NOT find requested orocos-rtt components: non-existent-plugin
-- - Detected OROCOS_TARGET environment variable. Using: gnulinux
CMake Error at /opt/orocos/kinetic/install_debug/lib/cmake/orocos-rtt/orocos-rtt-config.cmake:215 (message):
  Could not find the following required OROCOS-RTT plugins:
  non-existent-plugin.  You may want to append the plugins folder location to
  the RTT_COMPONENT_PATH environment variable.  E.g., if the plugin is
  located at /path/to/plugins/libfoo-plugin.so, add /path/to to
  RTT_COMPONENT_PATH
Call Stack (most recent call first):
  CMakeLists.txt:7 (find_package)

-- Configuring incomplete, errors occurred!
See also "/opt/orocos/kinetic/src/orocos_toolchain/rtt_cmake_test/CMakeFiles/CMakeOutput.log".

while with this patch the result is

-- - Detected OROCOS_TARGET environment variable. Using: gnulinux
-- Orocos-RTT found in /opt/orocos/kinetic/install_debug/lib/cmake/orocos-rtt/orocos-rtt-gnulinux-libraries.cmake
-- Found orocos-rtt  for the gnulinux target. Available transports: corba mqueue
-- - Could NOT find requested orocos-rtt components: non-existent-plugin
-- - Detected OROCOS_TARGET environment variable. Using: gnulinux
-- Found orocos-rtt  for the gnulinux target. 
-- - Found requested orocos-rtt components: rtt-scripting
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/orocos/kinetic/src/orocos_toolchain/rtt_cmake_test

Also moved initialization of OROCOS-RTT_PLUGIN_PATH to the if(NOT OROCOS-RTT_FOUND) section to not re-add the same directories over and over again.