CLion and add_library(target INTERFACE)

Viewed 2213

I have a header-only library project. In my CMakeLists.txt I use INTERFACE library type

I wanted to import this project into CLion, but when I open any of the header files the IDE complains that this file does not belong to any project target

So is there a way to develop a header-only project in CLion?

Test project layout is pretty simple:

% tree foo
foo
├── CMakeLists.txt
└── foo.hpp

And CMakeLists content is

cmake_minimum_required(VERSION 3.8)
project(foo)

add_library(foo INTERFACE)
target_include_directories(foo INTERFACE ${PROJECT_SOURCE_DIR})
target_sources(foo INTERFACE ${PROJECT_SOURCE_DIR}/foo.hpp)

CLion 2017.2 + CMake 3.8

1 Answers
Related