title: CLion doesn't resolve headers from external library
body: <p>Some time ago I started a big header library in C++1x using XCode. The current layout of the library is () something like (partial output from <code>ls -R sponf</code>)</p>
  <pre><code>sponf/sponf:
  ancestors        sponf.h                sponf_utilities.h
  categories       sponf_children.h       utilities
  children         sponf_macros.h           
  
  sponf/sponf/ancestors:
  function.h       meter.h        set.h                    simulation.h
  
  sponf/sponf/categories:
  free_space.h     prng.h         random_distribution.h    series.h
  
  sponf/sponf/children:
  distributions    histogram.h    random                   simulations
  meters           numeric        series                   spaces
  
  sponf/sponf/children/distributions:
  arcsine_der.h    exponential.h
  box_muller.h     uniform.h
  
  sponf/sponf/children/meters:
  accumulator.h    timer.h
  
  #... other subdirs of 'children' ...
  
  sponf/sponf/utilities:
  common_math.h    limits.h       string_const.h
  
  #... other directories ...
  </code></pre>
  <p>I wanted to port this project to CLion, which seems a really good IDE (based on the similar AndroidStudio IDE) but I'm getting some troubles.</p>
  <h2>Small test program</h2>
  <p>I tried this small program as a test:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sponf/sponf.h&gt;
  
  using namespace std;
  
  int main() {
      using space = sponf::spaces::euclidean_free_space&lt;double, 3&gt;;
      sponf::simulations::random_walk&lt;space&gt; rw;
  
      rw.step(1);
  
      std::cout &lt;&lt; rw.position.value &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  <p>The program compiles and runs fine. However, CLion does not recognize the <code>spaces</code> namespace (declared in one of the children files), nor the <code>simulations</code> namespace; they are both marked red and I cannot inspect their content, nor navigate to their definitions by <kbd>⌘</kbd>-clicking, etc. etc...</p>
  <h2>Relevant parts of the library</h2>
  <p>Looking in <code>&quot;sponf.h&quot;</code> we find</p>
  <pre><code>#ifndef sponf_h
  #define sponf_h
  
  /* The classes below are exported */
  #pragma GCC visibility push(default)
  
  // include some of the standard library files
  // ...
  
  #include &lt;Eigen/Eigen&gt;
  
  #include &quot;sponf_macros.h&quot;
  
  #include &quot;sponf_utilities.h&quot;
  #include &quot;sponf_children.h&quot;
  
  #pragma GCC visibility pop
  
  #endif
  </code></pre>
  <p>while in <code>&quot;sponf_children.h&quot;</code> (which is located at the top level, next to <code>&quot;sponf.h&quot;</code>) we find</p>
  <pre><code>#ifndef sponf_locp_sponf_children_h
  #define sponf_locp_sponf_children_h
  
  namespace sponf {
  
  // include some of the children
  // ...
  
  #include &quot;children/spaces/euclidean_free_space.h&quot;
  #include &quot;children/simulations/random_walk.h&quot;
  
  // include remaining children
  // ...
  
  }
  
  #endif
  </code></pre>
  <p>Each &quot;child&quot; header will then include its corresponding &quot;ancestor&quot; or &quot;category&quot; header (which defines the superclass of the &quot;child&quot; itself).</p>
  <h2>The reaction of CLion</h2>
  <p>Despite the autocompletition prediction, which easily finds all the subdirectories and the headers, all the include directives in this last file get marked red and <kbd>⌘</kbd>-clicking on any of them leads to a popup message</p>
  <blockquote>
  <p>Cannot find declaration to go to</p>
  </blockquote>
  <p>while the right ribbon of the editor signal many errors like</p>
  <blockquote>
  <p>',' or ) expected</p>
  <p>) expected</p>
  <p>Declarator expected</p>
  <p>Expecting type</p>
  <p>Missing ;</p>
  <p>Unexpected symbol</p>
  </blockquote>
  <p>which are not the same for each include statement (each generates from 2 to all of these errors).</p>
  <p>On the other hand, CLion is perfectly able to find all <code>Eigen</code> headers, which have pretty much the same structure!</p>
  <p>I have put both libs in <code>/opt/local/include</code> and changed <code>CMakeLists.txt</code> accordingly</p>
  <pre><code>cmake_minimum_required(VERSION 2.8.4)
  project(sponf)
  
  set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} -std=gnu++11&quot;)
  
  include_directories(/opt/local/include/sponf /opt/local/include/eigen3)
  
  set(SOURCE_FILES main.cpp)
  add_executable(sponf ${SOURCE_FILES})
  </code></pre>
  <p>Why can't CLion properly parse the project structure? XCode, after having included <code>/opt/local/include/sponf</code> and <code>/opt/local/include/eigen3</code> in the <code>HEADER_SEARCH_PATHS</code> env. variable of the project, is able to find any header while compiling the same exact program.</p>
  <p>Is there anything else I need to know? Am I doing it wrong or is it that CLion isn't that mature yet and this is just a sorry bug? This is my first approach to the CLion and the CMake toolchain, so any kind of information about it will be greatly appreciated!</p>
  <p>Sorry for the very long question, I didn't manage to shrink it further... Thanks in advance guys, see you soon!</p>