Search code examples
c++linuxcmakeclion

Why does CLion's integrated CMake fail to find installed packages?


I have a C++ project described by a CMakeLists.txt file from which CMake successfully generates a MAKE file if I call CMake from the terminal. (This is on Ubuntu.)

The project has dependencies on Boost and Eigen which are both installed on my system. I can see the Boost includes in /usr/include/boost, Boost binaries in /usr/lib/x86_64-linux-gnu, and the Boost .cmake files in /usr/lib/x86_64-linux-gnu/cmake/. I see the Eigen headers in /usr/include/eigen3 and Eigen3Config.cmake in /usr/lib/cmake/eigen3.

My CMakeLists.txt file calls find_package in config mode as below:

find_package(Eigen3 CONFIG REQUIRED)
if (${Eigen3_FOUND})
   Message(STATUS "eigen found...")
endif (${Eigen3_FOUND})

find_package(Boost 1.7 CONFIG REQUIRED QUIET)
if (${Boost_FOUND})
    Message(STATUS "boost found...")
endif (${Boost_FOUND})

The above works as expected from the command line but when I attempt to open the project from CLion 2020.2.3 i get the following error

CMake Error at CMakeLists.txt:4 (find_package): Could not find a package configuration file provided by "Eigen3" with any of the following names:

Eigen3Config.cmake
eigen3-config.cmake

Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set "Eigen3_DIR" to a directory containing one of the above files. If "Eigen3" provides a separate development package or SDK, be sure it has been installed.

If I change the order of the find_package calls CMake fails to find boost similarly.


Solution

  • Actually this behavior seems to have been a result of installing CLion as a flatpak package. I uninstalled and reinstalled as normal binaries and the problem goes away. (new to Linux here...)

    This is the same issue as described here: Jetbrains YouTrack. The take away seems to be do not install JetBrains products via Flatpak.