Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem lies in the scoping rules of CMake. each <code>add_subdirectory</code> call creates its own scope. Variables declared in such a subdirectory aren't automatically populated up to the parent scope.</p> <p>So the problem is that while <code>RESOURCE_ADDED</code> contains a valid path in the scope of icons/CMakeLists.txt, it doesn't in the root CMakeLists.txt and hence it is an empty variable by the time you use it in src/CMakeLists.txt.</p> <p>To raise the variable up a scope, in icons/CMakeLists.txt you can do:</p> <pre class="lang-none prettyprint-override"><code>qt5_add_resources(RESOURCE_ADDED ${RESOURCE}) set(RESOURCE_ADDED ${RESOURCE_ADDED} PARENT_SCOPE) </code></pre> <p>There's another slight problem now though!</p> <p>While this will contain a valid value in src/CMakeLists.txt, it points to a file which doesn't yet exist. The <code>qt5_add_resources</code> function must apply the <a href="http://www.cmake.org/cmake/help/v2.8.11/cmake.html#prop_sf%3aGENERATED" rel="nofollow" title="CMake v2.8.11 documentation for &quot;GENERATED&quot; source file property"><code>GENERATED</code></a> source file property to the variable. This property is not carried forward to the variable set in the parent scope.</p> <p>Since <code>add_executable</code> expects files to exist by default, you'll need to reapply the <code>GENERATED</code> property to the variable in the parent scope. You can do this e.g. in the src/CMakeLists.txt like this:</p> <pre class="lang-none prettyprint-override"><code>set_source_files_properties(${RESOURCE_ADDED} PROPERTIES GENERATED ON) add_executable(fluchOmat ... ${RESOURCE_ADDED}) </code></pre> <p>I'm not sure if the <code>qt5_add_resources</code> adds any other properties - if so, you'd maybe also have to reapply these.</p> <p>I'd guess the easiest way to avoid this would be to not use <code>add_subdirectory(icons)</code>, and instead just move all the Qt-related CMake code to src/CMakeLists.txt:</p> <pre class="lang-none prettyprint-override"><code>set(RESOURCE ${CMAKE_SOURCE_DIR}/icons/icons.qrc) qt5_add_resources(RESOURCE_ADDED ${RESOURCE}) add_executable(fluchOmat ... ${RESOURCE_ADDED}) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload