← Back to team overview

kicad-developers team mailing list archive

[PATCH v2 1/1] Fix build order for generated headers and sources

 

This changes make_lexer() so that it no longer generates a custom target
but instead attaches the generated files to an existing one (so the first
argument now is the name of an existing library or executable, and it needs
to come after the add_library/add_executable call).

The generated source is no longer listed in the project sources, as it is
added by the function. The files are generated in the build tree rather
than the source tree, and the directory is added to the include path for
the respective project as well as exported to projects linking against it.

Generated files in subdirectories are somewhat supported, but need to be
referenced with the same name as they were generated (i.e. including the
subdirectory name).
---
 CMakeModules/Functions.cmake              | 27 ++++--------
 CMakeModules/TokenList2DsnLexer.cmake     |  2 +-
 common/CMakeLists.txt                     | 73 +++++++++----------------------
 common/page_layout/page_layout_reader.cpp |  2 +-
 common/page_layout/ws_data_model_io.cpp   |  2 +-
 eeschema/CMakeLists.txt                   | 52 ++++++++++------------
 eeschema/dialogs/dialog_bom.cpp           |  2 +-
 new/CMakeLists.txt                        | 26 +++++------
 pcb_calculator/CMakeLists.txt             | 14 ++----
 pcbnew/CMakeLists.txt                     | 33 ++++++--------
 pcbnew/specctra_import_export/specctra.h  |  2 +-
 qa/eeschema/CMakeLists.txt                |  5 +--
 12 files changed, 89 insertions(+), 151 deletions(-)

diff --git a/CMakeModules/Functions.cmake b/CMakeModules/Functions.cmake
index b926cc0dd..6e7879d70 100644
--- a/CMakeModules/Functions.cmake
+++ b/CMakeModules/Functions.cmake
@@ -33,35 +33,24 @@
 function( make_lexer outputTarget inputFile outHeaderFile outCppFile enum )
 
     add_custom_command(
-        OUTPUT  ${outHeaderFile}
-                ${outCppFile}
+        OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/${outHeaderFile}
+                ${CMAKE_CURRENT_BINARY_DIR}/${outCppFile}
         COMMAND ${CMAKE_COMMAND}
             -Denum=${enum}
-            -DinputFile=${inputFile}
-            -DoutHeaderFile=${outHeaderFile}
-            -DoutCppFile=${outCppFile}
+            -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/${inputFile}
+            -DoutHeaderFile=${CMAKE_CURRENT_BINARY_DIR}/${outHeaderFile}
+            -DoutCppFile=${CMAKE_CURRENT_BINARY_DIR}/${outCppFile}
             -P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
         COMMENT "TokenList2DsnLexer.cmake creating:
            ${outHeaderFile} and
            ${outCppFile} from
            ${inputFile}"
-        DEPENDS ${inputFile}
-        )
-
-    add_custom_target( ${outputTarget}
-        DEPENDS ${outHeaderFile} ${outCppFile}
+        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${inputFile}
                 ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
         )
-    set_property( GLOBAL PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${outHeaderFile} ${outCppFile} )
-
-    # extra_args, if any, are treated as source files (typically headers) which
-    # are known to depend on the generated outHeader.
-    foreach( extra_arg ${ARGN} )
-        set_source_files_properties( ${extra_arg}
-            PROPERTIES OBJECT_DEPENDS ${outHeaderFile}
-            )
-    endforeach()
 
+    target_sources( ${outputTarget} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${outCppFile} )
+    target_include_directories( ${outputTarget} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} )
 endfunction()
 
 
diff --git a/CMakeModules/TokenList2DsnLexer.cmake b/CMakeModules/TokenList2DsnLexer.cmake
index 589ac0c49..8c325e047 100644
--- a/CMakeModules/TokenList2DsnLexer.cmake
+++ b/CMakeModules/TokenList2DsnLexer.cmake
@@ -150,7 +150,7 @@ set( sourceFileHeader
  * your DSN lexer.
  */
 
-#include <${result}_lexer.h>
+#include <${outHeaderFile}>
 
 using namespace ${enum};
 
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 2f675467d..10fb73af4 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -220,7 +220,6 @@ set( COMMON_PAGE_LAYOUT_SRCS
     page_layout/ws_draw_item.cpp
     page_layout/ws_proxy_undo_item.cpp
     page_layout/ws_proxy_view_item.cpp
-    page_layout/page_layout_reader_keywords.cpp
     page_layout/page_layout_reader.cpp
     )
 
@@ -312,14 +311,12 @@ set( COMMON_SRCS
     languages_menu.cpp
     lib_id.cpp
     lib_table_base.cpp
-    lib_table_keywords.cpp
     lib_tree_model.cpp
     lib_tree_model_adapter.cpp
     lockfile.cpp
     marker_base.cpp
     md5_hash.cpp
     msgpanel.cpp
-    netlist_keywords.cpp
     observable.cpp
     prependpath.cpp
     printout.cpp
@@ -427,8 +424,6 @@ set( PCB_COMMON_SRCS
     lset.cpp
     origin_viewitem.cpp
     page_info.cpp
-    pcb_keywords.cpp
-    pcb_plot_params_keywords.cpp
     ../pcbnew/pcb_base_frame.cpp
     ../pcbnew/board_commit.cpp
     ../pcbnew/board_connected_item.cpp
@@ -502,78 +497,50 @@ target_link_libraries( pcbcommon PUBLIC
 
 # auto-generate netlist_lexer.h and netlist_keywords.cpp
 make_lexer(
-    netlist_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
-    ${PROJECT_SOURCE_DIR}/include/netlist_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp
+    common
+    netlist.keywords
+    netlist_lexer.h
+    netlist_keywords.cpp
     NL_T
-
-    # Pass header file with dependency on *_lexer.h as extra_arg
-    ${CMAKE_PROJECT_SOURCE_DIR}/pcbnew/netlist_reader.h
     )
 
-add_dependencies( common netlist_lexer_source_files )
-add_dependencies( pcbcommon netlist_lexer_source_files )
-
 # auto-generate pcb_plot_params_lexer.h and pcb_plot_params_keywords.cpp
 make_lexer(
-    pcb_plot_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_plot_params.keywords
-    ${PROJECT_SOURCE_DIR}/include/pcb_plot_params_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_plot_params_keywords.cpp
+    pcbcommon
+    pcb_plot_params.keywords
+    pcb_plot_params_lexer.h
+    pcb_plot_params_keywords.cpp
     PCBPLOTPARAMS_T
-
-    # Pass header file with dependencies on *_lexer.h as extra_arg
-    ${PROJECT_SOURCE_DIR}/pcbnew/pcb_plot_params.h
     )
 
-add_dependencies( pcbcommon pcb_plot_lexer_source_files )
-
 # auto-generate pcbnew_sexpr.h and pcbnew_sexpr.cpp
 make_lexer(
-    pcb_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/pcb.keywords
-    ${PROJECT_SOURCE_DIR}/include/pcb_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_keywords.cpp
+    pcbcommon
+    pcb.keywords
+    pcb_lexer.h
+    pcb_keywords.cpp
     PCB_KEYS_T
-
-    # Pass header file with dependency on *_lexer.h as extra_arg
-    ${PROJECT_SOURCE_DIR}/pcbnew/pcb_parser.h
     )
 
-add_dependencies( pcbcommon pcb_lexer_source_files )
-
 # auto-generate s-expression library table code.
 make_lexer(
-    lib_table_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/lib_table.keywords
-    ${PROJECT_SOURCE_DIR}/include/lib_table_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/lib_table_keywords.cpp
+    common
+    lib_table.keywords
+    lib_table_lexer.h
+    lib_table_keywords.cpp
     LIB_TABLE_T
-
-    # These files consume *_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table.cpp
-    ${CMAKE_CURRENT_SOURCE_DIR}/lib_table_base.cpp
-    ${PROJECT_SOURCE_DIR}/pcbnew/dialogs/panel_fp_lib_table.cpp
-    ${PROJECT_SOURCE_DIR}/eeschema/symbol_lib_table.cpp
-    ${PROJECT_SOURCE_DIR}/eeschema/dialogs/panel_sym_lib_table.cpp
     )
 
-add_dependencies( common lib_table_lexer_source_files )
-add_dependencies( pcbcommon lib_table_lexer_source_files )
-
 # auto-generate page layout reader s-expression page_layout_reader_lexer.h
 # and title_block_reader_keywords.cpp.
 make_lexer(
-    page_layout_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/page_layout/page_layout_reader.keywords
-    ${PROJECT_SOURCE_DIR}/include/page_layout_reader_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/page_layout/page_layout_reader_keywords.cpp
+    common
+    page_layout/page_layout_reader.keywords
+    page_layout/page_layout_reader_lexer.h
+    page_layout/page_layout_reader_keywords.cpp
     TB_READER_T
     )
 
-add_dependencies( common page_layout_lexer_source_files )
-
 # This one gets made only when testing.
 # to build it, first enable #define STAND_ALONE at top of dsnlexer.cpp
 add_executable( dsntest EXCLUDE_FROM_ALL dsnlexer.cpp )
diff --git a/common/page_layout/page_layout_reader.cpp b/common/page_layout/page_layout_reader.cpp
index 46880983b..74b3980ea 100644
--- a/common/page_layout/page_layout_reader.cpp
+++ b/common/page_layout/page_layout_reader.cpp
@@ -34,7 +34,7 @@
 #include <ws_painter.h>
 #include <ws_draw_item.h>
 #include <ws_data_model.h>
-#include <page_layout_reader_lexer.h>
+#include <page_layout/page_layout_reader_lexer.h>
 
 #include <wx/file.h>
 #include <wx/mstream.h>
diff --git a/common/page_layout/ws_data_model_io.cpp b/common/page_layout/ws_data_model_io.cpp
index 40ee677f2..79c529668 100644
--- a/common/page_layout/ws_data_model_io.cpp
+++ b/common/page_layout/ws_data_model_io.cpp
@@ -36,7 +36,7 @@
 #include <ws_draw_item.h>
 #include <ws_data_model.h>
 #include <math/vector2d.h>
-#include <page_layout_reader_lexer.h>
+#include <page_layout/page_layout_reader_lexer.h>
 #include <macros.h>
 #include <convert_to_biu.h>
 
diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt
index 051b1ae19..a592e4a5c 100644
--- a/eeschema/CMakeLists.txt
+++ b/eeschema/CMakeLists.txt
@@ -36,7 +36,6 @@ set( EESCHEMA_DLGS
     dialogs/dialog_annotate_base.cpp
     dialogs/dialog_bom.cpp
     dialogs/dialog_bom_base.cpp
-    dialogs/dialog_bom_cfg_keywords.cpp
     dialogs/dialog_bus_manager.cpp
     dialogs/dialog_fields_editor_global.cpp
     dialogs/dialog_fields_editor_global_base.cpp
@@ -136,7 +135,6 @@ set( EESCHEMA_SRCS
     bus-wire-junction.cpp
     class_libentry.cpp
     class_library.cpp
-    cmp_library_keywords.cpp
     cmp_library_lexer.cpp
     component_references_lister.cpp
     connection_graph.cpp
@@ -206,7 +204,6 @@ set( EESCHEMA_SRCS
     symbol_tree_model_adapter.cpp
     symbol_tree_synchronizing_adapter.cpp
     template_fieldnames.cpp
-    template_fieldnames_keywords.cpp
     toolbars_sch_editor.cpp
     toolbars_viewlib.cpp
     transform.cpp
@@ -335,15 +332,24 @@ add_library( eeschema_kiface_objects OBJECT
 
 # CMake <3.9 can't link anything to object libraries,
 # but we only need include directories, as we will link the kiface MODULE
-target_include_directories( eeschema_kiface_objects PRIVATE
-   $<TARGET_PROPERTY:common,INCLUDE_DIRECTORIES>
+target_include_directories( eeschema_kiface_objects PUBLIC
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    $<TARGET_PROPERTY:common,INTERFACE_INCLUDE_DIRECTORIES>
 )
 
+# Since we're not using target_link_libraries, we need to explicitly
+# declare the dependency
+add_dependencies( eeschema_kiface_objects common )
+
 add_library( eeschema_kiface MODULE
     eeschema.cpp
     $<TARGET_OBJECTS:eeschema_kiface_objects>
     )
 
+target_include_directories( eeschema_kiface PUBLIC
+    $<TARGET_PROPERTY:eeschema_kiface_objects,INTERFACE_INCLUDE_DIRECTORIES>
+)
+
 target_link_libraries( eeschema_kiface
     common
     ${wxWidgets_LIBRARIES}
@@ -442,39 +448,27 @@ endif()
 # auto-generate cmp_library_lexer.h and cmp_library_keywords.cpp for the component
 # library format.
 make_lexer(
-    cmp_library_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library.keywords
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/cmp_library_keywords.cpp
+    eeschema_kiface_objects
+    cmp_library.keywords
+    cmp_library_lexer.h
+    cmp_library_keywords.cpp
     TLIB_T
     )
 
-add_dependencies( eeschema_kiface cmp_library_lexer_source_files )
-
 make_lexer(
-    field_template_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames.keywords
-    ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_keywords.cpp
+    eeschema_kiface_objects
+    template_fieldnames.keywords
+    template_fieldnames_lexer.h
+    template_fieldnames_keywords.cpp
     TFIELD_T
-
-    # Pass header file with dependency on *_lexer.h as extra_arg
-    template_fieldnames.h
     )
 
-add_dependencies( eeschema_kiface field_template_lexer_source_files )
-
 make_lexer(
-    dialog_bom_cfg_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_cfg.keywords
-    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_cfg_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_bom_cfg_keywords.cpp
+    eeschema_kiface_objects
+    dialogs/dialog_bom_cfg.keywords
+    dialogs/dialog_bom_cfg_lexer.h
+    dialogs/dialog_bom_cfg_keywords.cpp
     T_BOMCFG_T
-
-    # Pass header file with dependency on *_lexer.h as extra_arg
-    dialogs/dialog_bom_cfg.h
     )
 
-add_dependencies( eeschema_kiface dialog_bom_cfg_lexer_source_files )
-
 add_subdirectory( plugins )
diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp
index 6a6fc2dff..119015173 100644
--- a/eeschema/dialogs/dialog_bom.cpp
+++ b/eeschema/dialogs/dialog_bom.cpp
@@ -44,7 +44,7 @@
 #include <bom_plugins.h>
 #include <make_unique.h>
 
-#include <dialog_bom_cfg_lexer.h>
+#include <dialogs/dialog_bom_cfg_lexer.h>
 
 static constexpr wxChar BOM_TRACE[] = wxT( "BOM_GENERATORS" );
 
diff --git a/new/CMakeLists.txt b/new/CMakeLists.txt
index 11a686b9a..6e45eee01 100644
--- a/new/CMakeLists.txt
+++ b/new/CMakeLists.txt
@@ -110,7 +110,19 @@ endif( false )
 #=====</on standby for possible C++ unit testing>===============================
 
 
+add_library( sweet SHARED
+    sch_lib_table.cpp
+    sch_lib.cpp
+    sch_lpid.cpp
+    sch_dir_lib_source.cpp
+    sch_part.cpp
+    sch_sweet_parser.cpp
+    ${PROJECT_SOURCE_DIR}/common/richio.cpp
+    ${PROJECT_SOURCE_DIR}/common/dsnlexer.cpp
+    )
+
 make_lexer(
+    sweet
     ${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table.keywords
     ${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table_lexer.h
     ${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table_keywords.cpp
@@ -118,25 +130,13 @@ make_lexer(
     )
 
 make_lexer(
+    sweet
     ${CMAKE_CURRENT_SOURCE_DIR}/sweet.keywords
     ${CMAKE_CURRENT_SOURCE_DIR}/sweet_lexer.h
     ${CMAKE_CURRENT_SOURCE_DIR}/sweet_keywords.cpp
     PR
     )
 
-
-add_library( sweet SHARED
-    sch_lib_table.cpp
-    sch_lib_table_keywords.cpp
-    sch_lib.cpp
-    sch_lpid.cpp
-    sch_dir_lib_source.cpp
-    sch_part.cpp
-    sch_sweet_parser.cpp
-    sweet_keywords.cpp
-    ${PROJECT_SOURCE_DIR}/common/richio.cpp
-    ${PROJECT_SOURCE_DIR}/common/dsnlexer.cpp
-    )
 target_link_libraries( sweet ${wxWidgets_LIBRARIES} )
 
 # talk to import_export.h
diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt
index df3c651e7..aad4cf5a1 100644
--- a/pcb_calculator/CMakeLists.txt
+++ b/pcb_calculator/CMakeLists.txt
@@ -23,7 +23,6 @@ set( PCB_CALCULATOR_SRCS
     via.cpp
     transline_ident.cpp
     UnitSelector.cpp
-    pcb_calculator_datafile_keywords.cpp
     transline/transline.cpp
     transline/c_microstrip.cpp
     transline/microstrip.cpp
@@ -151,14 +150,11 @@ endif()
 # auto-generate pcb_calculator_datafile.h and pcb_calculator_datafile_keywords.cpp
 # for the storage data file format.
 make_lexer(
-    pcb_calculator_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile.keywords
-    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile_keywords.cpp
+    pcb_calculator_kiface
+    pcb_calculator_datafile.keywords
+    pcb_calculator_datafile_lexer.h
+    pcb_calculator_datafile_keywords.cpp
     PCBCALC_DATA_T
-
-    # Pass header file with dependency on *_lexer.h as extra_arg
-    datafile_read_write.h
    )
 
 #
@@ -191,5 +187,3 @@ set( DOCS_LIST
 set_source_files_properties( attenuators/attenuator_classes.cpp
     PROPERTIES OBJECT_DEPENDS "${DOCS_LIST}"
     )
-
-add_dependencies( pcb_calculator_kiface pcb_calculator_lexer_source_files )
diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt
index 533135e59..ffe526f24 100644
--- a/pcbnew/CMakeLists.txt
+++ b/pcbnew/CMakeLists.txt
@@ -283,7 +283,6 @@ set( PCBNEW_CLASS_SRCS
     specctra_import_export/specctra.cpp
     specctra_import_export/specctra_export.cpp
     specctra_import_export/specctra_import.cpp
-    specctra_import_export/specctra_keywords.cpp
     text_mod_grid_table.cpp
     toolbars_footprint_editor.cpp
     toolbars_footprint_viewer.cpp
@@ -349,19 +348,6 @@ set( PCBNEW_SCRIPTING_PYTHON_HELPERS
     swig/python_scripting.cpp
     )
 
-
-# auto-generate specctra_lexer.h and specctra_keywords.cpp
-make_lexer(
-    specctra_lexer_source_files
-    ${CMAKE_CURRENT_SOURCE_DIR}/specctra_import_export/specctra.keywords
-    ${CMAKE_CURRENT_SOURCE_DIR}/specctra_import_export/specctra_lexer.h
-    ${CMAKE_CURRENT_SOURCE_DIR}/specctra_import_export/specctra_keywords.cpp
-    DSN
-
-    # Pass header file with dependency on *_lexer.h as extra_arg
-    specctra_import_export/specctra.h
-    )
-
 if( COMPILER_SUPPORTS_WSHADOW )
     # .cpp files are compiled with extra ${WSHADOW_FLAGS}, but not .cxx files
     set_source_files_properties(
@@ -608,12 +594,25 @@ add_library( pcbnew_kiface_objects OBJECT
     ${PCBNEW_SCRIPTING_SRCS}
     )
 
+# auto-generate specctra_lexer.h and specctra_keywords.cpp
+make_lexer(
+    pcbnew_kiface_objects
+    specctra_import_export/specctra.keywords
+    specctra_import_export/specctra_lexer.h
+    specctra_import_export/specctra_keywords.cpp
+    DSN
+    )
+
 # CMake <3.9 can't link anything to object libraries,
 # but we only need include directories, as we will link the kiface MODULE
 target_include_directories( pcbnew_kiface_objects PRIVATE
-   $<TARGET_PROPERTY:common,INCLUDE_DIRECTORIES>
+   $<TARGET_PROPERTY:common,INTERFACE_INCLUDE_DIRECTORIES>
 )
 
+# Since we're not using target_link_libraries, we need to explicitly
+# declare the dependency
+add_dependencies( pcbnew_kiface_objects common )
+
 add_library( pcbnew_kiface MODULE $<TARGET_OBJECTS:pcbnew_kiface_objects> )
 
 set_target_properties( pcbnew_kiface PROPERTIES
@@ -674,10 +673,6 @@ endif()
 # if building pcbnew, then also build pcbnew_kiface if out of date.
 add_dependencies( pcbnew pcbnew_kiface )
 
-# add dependency to specctra_lexer_source_files, to force
-# generation of autogenerated file
-add_dependencies( pcbnew_kiface_objects specctra_lexer_source_files )
-
 # these 2 binaries are a matched set, keep them together:
 if( APPLE )
     include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake )
diff --git a/pcbnew/specctra_import_export/specctra.h b/pcbnew/specctra_import_export/specctra.h
index 624286318..31be70fcf 100644
--- a/pcbnew/specctra_import_export/specctra.h
+++ b/pcbnew/specctra_import_export/specctra.h
@@ -33,7 +33,7 @@
 #include <boost/ptr_container/ptr_set.hpp>
 
 #include <fctsys.h>
-#include "specctra_lexer.h"
+#include <specctra_import_export/specctra_lexer.h>
 #include <pcbnew.h>
 
 #include <memory>
diff --git a/qa/eeschema/CMakeLists.txt b/qa/eeschema/CMakeLists.txt
index 727be8cf6..65009ca4b 100644
--- a/qa/eeschema/CMakeLists.txt
+++ b/qa/eeschema/CMakeLists.txt
@@ -68,8 +68,7 @@ target_link_libraries( qa_eeschema
 target_include_directories( qa_eeschema PUBLIC
     # Paths for eeschema lib usage (should really be in eeschema/common
     # target_include_directories and made PUBLIC)
-    ${CMAKE_SOURCE_DIR}/eeschema
-    ${INC_AFTER}
+    $<TARGET_PROPERTY:eeschema_kiface_objects,INCLUDE_DIRECTORIES>
 )
 
 # Eeschema tests, so pretend to be eeschema (for units, etc)
@@ -82,4 +81,4 @@ set_source_files_properties( eeschema_test_utils.cpp PROPERTIES
     COMPILE_DEFINITIONS "QA_EESCHEMA_DATA_LOCATION=(\"${CMAKE_CURRENT_SOURCE_DIR}/data\")"
 )
 
-kicad_add_boost_test( qa_eeschema eeschema )
\ No newline at end of file
+kicad_add_boost_test( qa_eeschema eeschema )

Follow ups

References