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:
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?

Yes. bear can solve this. Make sure to clean your Makefile and CMake projects then
bear -- make alland open the generatedcompilation_commands.jsonin CLion directly.