catkin
catkin copied to clipboard
Catkin cannot handle when the CMake language is set to none
Setting the CMake Language to none (which makes sense if this is a catkin package that is solely providing resources, meshes, configurations, etc.) causes CMake to fail.
The smallest CMakeLists.txt that will cause the issue:
cmake_minimum_required(VERSION 3.0.2)
project(hello_test LANGUAGES NONE)
find_package(catkin REQUIRED)
catkin_package()
This will result in two different errors, one regarding FindThreads and GTest:
CMake Error at /usr/share/cmake-3.10/Modules/FindThreads.cmake:54 (message):
FindThreads only works if either C or CXX language is enabled
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindGTest.cmake:204 (find_package)
/opt/ros/melodic/share/catkin/cmake/test/gtest.cmake:304 (find_package)
/opt/ros/melodic/share/catkin/cmake/all.cmake:164 (include)
/opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:20 (include)
CMakeLists.txt:6 (find_package)
and another regarding RT (if built with CATKIN_ENABLE_TESTING=False
):
CMake Error at /opt/ros/melodic/share/catkin/cmake/assert.cmake:17 (message):
Assertion failed: check for file existence, but filename
(RT_LIBRARY-NOTFOUND) unset. Message: RT Library
Call Stack (most recent call first):
/opt/ros/melodic/share/catkin/cmake/tools/rt.cmake:42 (assert_file_exists)
/opt/ros/melodic/share/catkin/cmake/all.cmake:164 (include)
/opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:20 (include)
CMakeLists.txt:4 (find_package)
The main issue is that catkin tries to find a lot of C++ libraries when it doesn't need to (and when CMake can't).
The easy fix is to just make the project's languages CXX
, but to "proper" (and probably too much effort) fix is to not include all of the C++ specific libraries that are necessary.
It should be possible to wrap the specific logic which assumes that either C or C++ is an enabled language in a conditional checking the global CMake variable ENABLED_LANGUAGES
. A pull request to support this would be appreciated.