Browse postgresql source code in clion

Answered

I want to set up postgres source code locally in CLion so that I can browse it. But clion doesn't understand include clauses. It looks like this:

I've tried pretty much everything I could find by "postgres" + "clion" search term combination, but still no luck. I bet it has something to do with includes specified in CMakeLists.txt. I tried the following options:

cmake_minimum_required(VERSION 3.6)
project(postgres)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

add_custom_target(postgres COMMAND make -C ${postgres_SOURCE_DIR})

and

cmake_minimum_required(VERSION 3.6)
project(postgres)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

include_directories (${postgres_INCLUDE_DIRS})
link_directories(${postgres_LIBRARY_DIRS})

add_custom_target(postgres COMMAND make -C ${postgres_SOURCE_DIR})

and

cmake_minimum_required(VERSION 3.6)
project(postgres)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

include_directories(SYSTEM./src)

add_custom_target(postgres COMMAND make -C ${postgres_SOURCE_DIR})

and a bunch of other options, but, yeah, still no luck.

The situation is complicated by the fact that I'm totally unfamiliar with C ecosystem, so I'm sorry if I'm being dumb.

0
3 comments

Hello!

The PostgreSQL project (https://github.com/postgres/postgres) is an Autotools project. CLion supports Autotools projects - https://www.jetbrains.com/help/clion/gnu-autotools.html. 

According to our testing, the PostgreSQL project should work, please see https://youtrack.jetbrains.com/articles/CPP-A-179994647.

So you don't need to create a fake CMakeLists.txt in order to work with the PostgreSQL project in CLion. You can open it as an Autotools project in CLion. Please close the project (`File | Close Project`), delete the .idea subfolder and the CMakeLists.txt file, on the Welcome Screen select `Open` and choose the PostgreSQL project folder (which contain the top-level Makefile, the configure file etc.).

0

I've met the same problem. Using the Makefile integration of CLion, it says:

make[2]: Leaving directory '/home/gpadmin/cbdb/src/test/isolation'
/usr/bin/make -C test/perl install
make[2]: Entering directory '/home/gpadmin/cbdb/src/test/perl'
make[2]: Nothing to be done for 'install'.
make[2]: Leaving directory '/home/gpadmin/cbdb/src/test/perl'
/usr/bin/mkdir -p '/home/gpadmin/install/cbdb/lib/postgresql/pgxs/src'
/usr/bin/install -c -m 644 Makefile.global '/home/gpadmin/install/cbdb/lib/postgresql/pgxs/src/Makefile.global'
/usr/bin/install -c -m 644 Makefile.port '/home/gpadmin/install/cbdb/lib/postgresql/pgxs/src/Makefile.port'
/usr/bin/install -c -m 644 ./Makefile.shlib '/home/gpadmin/install/cbdb/lib/postgresql/pgxs/src/Makefile.shlib'
/usr/bin/install -c -m 644 ./nls-global.mk '/home/gpadmin/install/cbdb/lib/postgresql/pgxs/src/nls-global.mk'
make[1]: Leaving directory '/home/gpadmin/cbdb/src'
/usr/bin/make -C config install
make[1]: Entering directory '/home/gpadmin/cbdb/config'
/usr/bin/mkdir -p '/home/gpadmin/install/cbdb/lib/postgresql/pgxs/config'
/usr/bin/install -c -m 755 ./install-sh '/home/gpadmin/install/cbdb/lib/postgresql/pgxs/config/install-sh'
/usr/bin/install -c -m 755 ./missing '/home/gpadmin/install/cbdb/lib/postgresql/pgxs/config/missing'
make[1]: Leaving directory '/home/gpadmin/cbdb/config'
make: Leaving directory '/home/gpadmin/cbdb'
make: *** [GNUmakefile:11: install-src-recurse] Error 2

Process finished with exit code 2
Nothing to be done for 'install'.

No rule to make target '../../src/common/libpgcommon_srv.a', needed by 'postgres'.

[Makefile:44: install-backend-recurse] Error 2

[GNUmakefile:11: install-src-recurse] Error 2

Make execution failed with exit code = 2

 

I have to run `make install` manually in the shell to firstly compile the project, then build the project in CLion to successfully import. Strangely I've configured the CLion to use the same "install" task as the menually-executed `make install`:

So I don't know why the same make procedure can be executed in shell, but not in CLion.

 

Even after I imported the project by executing `make install` first in the shell, all extensions under `contrib` folders are somehow not indexed:

You can see there's no blue boxes on the left corner of the files under `contrib` folder. It's really troublesome.

0

Ray Eldath, thanks for creating CPP-34733! Let's continue the investigation there.

0

Please sign in to leave a comment.