How to import a mixture of CMake and Makefile project to CLion?

38 Views Asked by At

We have a PostgreSQL-based project which adds several new C++ plugins under ./contrib folder. PostgreSQL is built in Makefile, in order to build those newly-added C++ plugins, we just add a task

# in contrib/storage_am/Makefile
build-storage-am:
    mkdir -p build && cd build && cmake .. ${CMAKE_FLAGS} -DBUILD_GTEST=ON -DCMAKE_PREFIX_PATH=${prefix} -DCMAKE_INSTALL_PATH=${prefix} && make

# in main Makefile:
all:
    ...
    $(MAKE) -C contrib/storage_am

and when importing this project to CLion, it read it as a Makefile project and starts dry-run the task all. From the Build panel I can see it properly read the Makefile file and executed these tasks using CMake to build these plugins:

CLion Build Syncing

but all code files using CMake are still unindexed. Is there any way to import these "CMake called by Makefile" project into CLion? would Compilation Database and bear be helpful?

1

There are 1 best solutions below

0
Ray Eldath On

Yes. bear can solve this. Make sure to clean your Makefile and CMake projects then bear -- make all and open the generated compilation_commands.json in CLion directly.