0

I found an adjacent question regarding pqxx with CLion.

cmake_minimum_required(VERSION 3.15)
project(pqxx_test)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
    message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
    file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.15/conan.cmake"
            "${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_run(
        REQUIRES
            libpqxx/7.0.1@bincrafters/stable
            boost/1.71.0@conan/stable
        OPTIONS    *:shared=False
                   *:fPIC=False
        BUILD      missing
        GENERATORS cmake_find_package
                   cmake)


include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
add_executable(pqxx_test main.cpp)
target_link_libraries(pqxx_test CONAN_PKG::libpqxx CONAN_PKG::boost Threads::Threads)

The CLion reports on #include <pqxx/pqxx> that it is not found and hence any of the variables declared with classes from pqxx namespace show in red.

Is there a way to have the CLion index the headers?

P.S. The toolchain is set up for remote builds.

Karlson
  • 2,958
  • 1
  • 21
  • 48
  • If you have an include in <>, you need to have it in header search path to process it right. Just add the PQXX include folder by `include_directories` CMake command. – uta Mar 19 '20 at 10:27
  • @uta Yes ordinarily that would be the case. Except in a different project I am using catch added via conan package and catch headers `catch.hpp` to be exact is indexed without the explicitly specifying `include_directories`. – Karlson Mar 19 '20 at 14:14

1 Answers1

0

In actuality the issue is that when dealing with remote development if you have conan generated files in the cmake-build-debug directory you would need at least once manually resync with remote as described in this blog by calling Tools -> Resync with Remote Hosts

This way CLion will Reindex the conan generated headers for you.

Karlson
  • 2,958
  • 1
  • 21
  • 48