Reputation: 2184
I'm having a lot of trouble trying to do something seemingly trivial. I'd like to install a few libraries to use in my project in a docker container (think of it as any other VM) but use the IDE from within the host to actually develop against it.
The direct dependencies somewhat work in that case, but their common counterparts like boost, etc are missing the headers in the IDE, so even though the program compiles, I get a bunch of errors and missing headers in the IDE.
Here is an example CMake file to use nghttp2 as a dependency in the project:
cmake_minimum_required(VERSION 3.2)
project(deptest)
set(CMAKE_CXX_STANDARD 11)
################ hidapi
set(NGHTTP2_ROOT ${CMAKE_BINARY_DIR}/vendor/nghttp2)
set(NGHTTP2_LIB_DIR ${NGHTTP2_ROOT}/bin/lib)
set(NGHTTP2_INCLUDE_DIR ${NGHTTP2_ROOT}/bin/include)
include(ExternalProject)
ExternalProject_Add(nghttp2_dep
PREFIX ${NGHTTP2_ROOT}
GIT_REPOSITORY "https://github.com/nghttp2/nghttp2.git"
GIT_TAG "0641d314a62fc2f9ede5cbb487895236da4ae4f4"
UPDATE_COMMAND ""
PATCH_COMMAND ""
BINARY_DIR ${NGHTTP2_ROOT}/src/nghttp2
SOURCE_DIR ${NGHTTP2_ROOT}/src/nghttp2
INSTALL_DIR ${NGHTTP2_ROOT}/bin
CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> --enable-asio-lib
BUILD_COMMAND make
BUILD_BYPRODUCTS ${HIDAPI_LIB_DIR}/libnghttp2.a)
# hidapi requires an initial execution of "./bootstrap" to run autoreconf
ExternalProject_Add_Step(nghttp2_dep
bootstrap
COMMAND autoreconf -i && automake && autoconf
DEPENDEES download
DEPENDERS configure
WORKING_DIRECTORY ${NGHTTP2_ROOT}/src/nghttp2)
add_library(nghttp2 STATIC IMPORTED)
set_target_properties(nghttp2 PROPERTIES IMPORTED_LOCATION ${HIDAPI_LIB_DIR}/libnghttp2.a)
add_dependencies(nghttp2 nghttp2_external)
################ test app
include_directories(build/vendor/nghttp2/bin/include)
#include_directories("build/vendor/std")
add_executable(deptest src/main.cpp)
target_link_libraries(deptest nghttp2)
target_link_libraries(deptest ${Boost_LIBRARIES})
Any recommendations on how to achieve that? Since the dependencies are Linux only, I cant build and run everything on the mac directly, so I only want to use it as an IDE source but do all the compilation on the VM box, the only issues seems to be how to get CMake to understand where the headers are on the Mac. Also I'm using the latest CLion release.
Upvotes: 6
Views: 2047
Reputation: 396
Update from 02/2025
This is now under File > Invalidate Caches and tick "Clear remote hosts caches", then click "Invalidate and Restart"
Thanks to @emmanuelmess
Original Answer:
Reload your CMake project and then do the following:
Tools -> Resync with Remote Hosts
Afterwards wait some seconds and don't be unpatient - the headers will be found after CLion completed indexing the new files, which may take some time in larger projects.
Since everything worked fine after the inital creation of the project, it seems the resync has to be done manually from time to time because CLion is becoming async for some reason.
Upvotes: 11