From 06c979dfaae583cc1ac08fe2aaab72ee55ea3a6a Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@ieee.org>
Date: Wed, 22 Jan 2020 23:27:20 +0000
Subject: [PATCH] Convert all CMake paths to absolute instead of relative

It is cleaner and safer to handle the include and source paths
as absolute from the source directory instead of relative to every
path.
---
 bitmap2component/CMakeLists.txt           |   5 +-
 common/CMakeLists.txt                     | 116 +++++++++++-----------
 cvpcb/CMakeLists.txt                      |  14 +--
 eeschema/CMakeLists.txt                   |  24 ++---
 gerbview/CMakeLists.txt                   |  28 +++---
 kicad/CMakeLists.txt                      |   4 +-
 pagelayout_editor/CMakeLists.txt          |  20 ++--
 pcb_calculator/CMakeLists.txt             |  12 +--
 pcbnew/CMakeLists.txt                     |  38 +++----
 qa/common/CMakeLists.txt                  |   8 +-
 qa/common_tools/CMakeLists.txt            |   4 +-
 qa/eeschema/CMakeLists.txt                |   4 +-
 qa/gal/gal_pixel_alignment/CMakeLists.txt |  22 ++--
 qa/pcb_test_window/CMakeLists.txt         |  16 +--
 qa/pcbnew/CMakeLists.txt                  |   6 +-
 tools/CMakeLists.txt                      |   8 +-
 utils/kicad-ogltest/CMakeLists.txt        |   4 +-
 17 files changed, 168 insertions(+), 165 deletions(-)

diff --git a/bitmap2component/CMakeLists.txt b/bitmap2component/CMakeLists.txt
index 1a2acc56ce..544536935d 100644
--- a/bitmap2component/CMakeLists.txt
+++ b/bitmap2component/CMakeLists.txt
@@ -9,14 +9,15 @@ include_directories( BEFORE ${INC_BEFORE} )
 include_directories( ${INC_AFTER} )
 
 set( BITMAP2COMPONENT_SRCS
-    ../common/single_top.cpp
+    ${CMAKE_SOURCE_DIR}/common/single_top.cpp
+
     bitmap2cmp_main.cpp
     bitmap2component.cpp
     bitmap2cmp_gui_base.cpp
     bitmap2cmp_gui.cpp
     )
 
-set_source_files_properties( ../common/single_top.cpp PROPERTIES
+set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
     COMPILE_DEFINITIONS     "TOP_FRAME=FRAME_BM2CMP"
     )
 set_source_files_properties( bitmap2cmp_gui.cpp PROPERTIES
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 9ca2411b8d..4f2adcc2b7 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -15,8 +15,8 @@ include_directories(
     ${GLEW_INCLUDE_DIR}
     ${GLM_INCLUDE_DIR}
     ${CURL_INCLUDE_DIRS}
-    ../3d-viewer
-    ../pcbnew
+    ${CMAKE_SOURCE_DIR}/3d-viewer
+    ${CMAKE_SOURCE_DIR}/pcbnew
     ${INC_AFTER}
     ${OCE_INCLUDE_DIRS}
     ${OCC_INCLUDE_DIR}
@@ -416,59 +416,59 @@ set( PCB_COMMON_SRCS
     lset.cpp
     origin_viewitem.cpp
     page_info.cpp
-    ../pcbnew/pcb_base_frame.cpp
-    ../pcbnew/board_commit.cpp
-    ../pcbnew/board_connected_item.cpp
-    ../pcbnew/board_design_settings.cpp
-    ../pcbnew/board_items_to_polygon_shape_transform.cpp
-    ../pcbnew/class_board.cpp
-    ../pcbnew/class_board_item.cpp
-    ../pcbnew/class_dimension.cpp
-    ../pcbnew/class_drawsegment.cpp
-    ../pcbnew/class_edge_mod.cpp
-    ../pcbnew/class_marker_pcb.cpp
-    ../pcbnew/class_module.cpp
-    ../pcbnew/netclass.cpp
-    ../pcbnew/netinfo_item.cpp
-    ../pcbnew/netinfo_list.cpp
-    ../pcbnew/class_pad.cpp
-    ../pcbnew/class_pcb_target.cpp
-    ../pcbnew/class_pcb_text.cpp
-    ../pcbnew/board_stackup_manager/class_board_stackup.cpp
-    ../pcbnew/class_text_mod.cpp
-    ../pcbnew/class_track.cpp
-    ../pcbnew/class_zone.cpp
-    ../pcbnew/collectors.cpp
-    ../pcbnew/connectivity/connectivity_algo.cpp
-    ../pcbnew/connectivity/connectivity_items.cpp
-    ../pcbnew/connectivity/connectivity_data.cpp
-    ../pcbnew/convert_drawsegment_list_to_polygon.cpp
-    ../pcbnew/drc_item.cpp
-    ../pcbnew/eagle_plugin.cpp
-    ../pcbnew/gpcb_plugin.cpp
-    ../pcbnew/io_mgr.cpp
-    ../pcbnew/kicad_clipboard.cpp
-    ../pcbnew/netlist_reader/kicad_netlist_reader.cpp
-    ../pcbnew/kicad_plugin.cpp
-    ../pcbnew/netlist_reader/legacy_netlist_reader.cpp
-    ../pcbnew/legacy_plugin.cpp
-    ../pcbnew//netlist_reader/netlist_reader.cpp
-    ../pcbnew/pad_custom_shape_functions.cpp
-    ../pcbnew/pad_print_functions.cpp
-    ../pcbnew/pcb_display_options.cpp
-    ../pcbnew/pcb_draw_panel_gal.cpp
-    ../pcbnew/pcb_general_settings.cpp
-    ../pcbnew/netlist_reader/pcb_netlist.cpp
-    ../pcbnew/pcb_painter.cpp
-    ../pcbnew/pcb_parser.cpp
-    ../pcbnew/pcb_plot_params.cpp
-    ../pcbnew/pcb_screen.cpp
-    ../pcbnew/pcb_view.cpp
-    ../pcbnew/plugin.cpp
-    ../pcbnew/ratsnest_data.cpp
-    ../pcbnew/ratsnest_viewitem.cpp
-    ../pcbnew/sel_layer.cpp
-    ../pcbnew/zone_settings.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_base_frame.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/board_commit.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/board_connected_item.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/board_design_settings.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/board_items_to_polygon_shape_transform.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_board.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_board_item.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_dimension.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_drawsegment.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_edge_mod.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_marker_pcb.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_module.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/netclass.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/netinfo_item.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/netinfo_list.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_pad.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_pcb_target.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_pcb_text.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/board_stackup_manager/class_board_stackup.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_text_mod.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_track.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/class_zone.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/collectors.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/connectivity/connectivity_algo.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/connectivity/connectivity_items.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/connectivity/connectivity_data.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/convert_drawsegment_list_to_polygon.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/drc_item.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/eagle_plugin.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/gpcb_plugin.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/io_mgr.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/kicad_clipboard.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/kicad_netlist_reader.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/kicad_plugin.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/legacy_netlist_reader.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/legacy_plugin.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew//netlist_reader/netlist_reader.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pad_custom_shape_functions.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pad_print_functions.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_display_options.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_draw_panel_gal.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_general_settings.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/netlist_reader/pcb_netlist.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_painter.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_parser.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_plot_params.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_screen.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/pcb_view.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/plugin.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/ratsnest_data.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/ratsnest_viewitem.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/sel_layer.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/zone_settings.cpp
     widgets/net_selector.cpp
 )
 
@@ -567,13 +567,13 @@ if( false ) # future
 
     include_directories( BEFORE ${INC_BEFORE} )
     include_directories(
-        ../common
+        ${CMAKE_SOURCE_DIR}/common
         ${INC_AFTER}
         )
 
     set( SWIG_MODULE_kiway_EXTRA_DEPS
-        ../common/swig/ki_exception.i
-        ../common/swig/kicad.i
+        ${CMAKE_SOURCE_DIR}/common/swig/ki_exception.i
+        ${CMAKE_SOURCE_DIR}/common/swig/kicad.i
         )
 
     swig_add_module( kiway python
diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt
index f18796b967..f2e296ceca 100644
--- a/cvpcb/CMakeLists.txt
+++ b/cvpcb/CMakeLists.txt
@@ -8,10 +8,10 @@ add_definitions( -DCVPCB )
 include_directories( BEFORE ${INC_BEFORE} )
 include_directories(
     ./dialogs
-    ../3d-viewer
-    ../pcbnew
-    ../pcbnew/dialogs
-    ../common
+    ${CMAKE_SOURCE_DIR}/3d-viewer
+    ${CMAKE_SOURCE_DIR}/pcbnew
+    ${CMAKE_SOURCE_DIR}/pcbnew/dialogs
+    ${CMAKE_SOURCE_DIR}/common
     ${GLM_INCLUDE_DIR}
     ${INC_AFTER}
     )
@@ -27,9 +27,9 @@ set( CVPCB_DIALOGS
     )
 
 set( CVPCB_SRCS
-    ../common/base_units.cpp
-    ../pcbnew/tools/grid_helper.cpp
-    ../pcbnew/board_stackup_manager/stackup_predefined_prms.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_units.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/tools/grid_helper.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/board_stackup_manager/stackup_predefined_prms.cpp
     auto_associate.cpp
     cfg.cpp
     components_listbox.cpp
diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt
index 4b6353077b..c5f2e8965f 100644
--- a/eeschema/CMakeLists.txt
+++ b/eeschema/CMakeLists.txt
@@ -26,9 +26,9 @@ include_directories(
     ./libedit
     ./libview
     ./tools
-    ../common
-    ../common/dialogs
-    ../libs/sexpr/include
+    ${CMAKE_SOURCE_DIR}/common
+    ${CMAKE_SOURCE_DIR}/common/dialogs
+    ${CMAKE_SOURCE_DIR}/libs/sexpr/include
     ${INC_AFTER}
     )
 
@@ -238,12 +238,12 @@ set( EESCHEMA_SRCS
 
 
 set( EESCHEMA_COMMON_SRCS
-    ../common/dialogs/dialog_page_settings.cpp
-    ../common/dialogs/panel_display_options.cpp
-    ../common/base_screen.cpp
-    ../common/base_units.cpp
-    ../common/eda_text.cpp
-    ../common/page_info.cpp
+    ${CMAKE_SOURCE_DIR}/common/dialogs/dialog_page_settings.cpp
+    ${CMAKE_SOURCE_DIR}/common/dialogs/panel_display_options.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_screen.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_units.cpp
+    ${CMAKE_SOURCE_DIR}/common/eda_text.cpp
+    ${CMAKE_SOURCE_DIR}/common/page_info.cpp
     )
 
 
@@ -310,11 +310,11 @@ endif()
 
 
 add_executable( eeschema WIN32 MACOSX_BUNDLE
-    ../common/single_top.cpp
-    ../common/pgm_base.cpp
+    ${CMAKE_SOURCE_DIR}/common/single_top.cpp
+    ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
     ${EESCHEMA_RESOURCES}
     )
-set_source_files_properties( ../common/single_top.cpp PROPERTIES
+set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
     COMPILE_DEFINITIONS "TOP_FRAME=FRAME_SCH;PGM_DATA_FILE_EXT=\"sch\";BUILD_KIWAY_DLL"
     )
 target_link_libraries( eeschema
diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt
index 522e76b5b0..783548191c 100644
--- a/gerbview/CMakeLists.txt
+++ b/gerbview/CMakeLists.txt
@@ -7,10 +7,10 @@ add_definitions(-DGERBVIEW)
 
 include_directories( BEFORE ${INC_BEFORE} )
 include_directories(
-    ../pcbnew
+    ${CMAKE_SOURCE_DIR}/pcbnew
     dialogs
-    ../common
-    ../3d-viewer
+    ${CMAKE_SOURCE_DIR}/common
+    ${CMAKE_SOURCE_DIR}/3d-viewer
     ${INC_AFTER}
     )
 
@@ -67,14 +67,14 @@ set( GERBVIEW_SRCS
     )
 
 set( GERBVIEW_EXTRA_SRCS
-    ../common/base_screen.cpp
-    ../common/base_units.cpp
-    ../common/eda_text.cpp
-    ../common/widgets/layer_box_selector.cpp
-    ../common/lset.cpp
-    ../common/settings.cpp
-    ../pcbnew/layer_widget.cpp
-    ../common/page_info.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_screen.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_units.cpp
+    ${CMAKE_SOURCE_DIR}/common/eda_text.cpp
+    ${CMAKE_SOURCE_DIR}/common/widgets/layer_box_selector.cpp
+    ${CMAKE_SOURCE_DIR}/common/lset.cpp
+    ${CMAKE_SOURCE_DIR}/common/settings.cpp
+    ${CMAKE_SOURCE_DIR}/pcbnew/layer_widget.cpp
+    ${CMAKE_SOURCE_DIR}/common/page_info.cpp
 )
 
 if( MINGW )
@@ -99,11 +99,11 @@ if( APPLE )
 endif()
 
 add_executable( gerbview WIN32 MACOSX_BUNDLE
-    ../common/single_top.cpp
-    ../common/pgm_base.cpp
+    ${CMAKE_SOURCE_DIR}/common/single_top.cpp
+    ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
     ${GERBVIEW_RESOURCES}
     )
-set_source_files_properties( ../common/single_top.cpp PROPERTIES
+set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
     COMPILE_DEFINITIONS "TOP_FRAME=FRAME_GERBER;BUILD_KIWAY_DLL"
     )
 target_link_libraries( gerbview
diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt
index adf84f3bec..9cb1f558bf 100644
--- a/kicad/CMakeLists.txt
+++ b/kicad/CMakeLists.txt
@@ -7,8 +7,8 @@ add_definitions( -DKICAD )
 
 include_directories( BEFORE ${INC_BEFORE} )
 include_directories(
-    ../pcbnew
-    ../eeschema
+    ${CMAKE_SOURCE_DIR}/pcbnew
+    ${CMAKE_SOURCE_DIR}/eeschema
     ${INC_AFTER}
     )
 
diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt
index 02537af75a..5162120296 100644
--- a/pagelayout_editor/CMakeLists.txt
+++ b/pagelayout_editor/CMakeLists.txt
@@ -8,7 +8,7 @@ add_definitions(-DPL_EDITOR)
 include_directories(BEFORE ${INC_BEFORE})
 include_directories(
     dialogs
-    ../common/dialogs
+    ${CMAKE_SOURCE_DIR}/common/dialogs
     ${INC_AFTER}
     )
 
@@ -39,12 +39,12 @@ set( PL_EDITOR_SRCS
     )
 
 set( PL_EDITOR_EXTRA_SRCS
-    ../common/base_screen.cpp
-    ../common/base_units.cpp
-    ../common/eda_text.cpp
-    ../common/dialogs/dialog_page_settings.cpp
-    ../common/dialogs/panel_display_options.cpp
-    ../common/page_info.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_screen.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_units.cpp
+    ${CMAKE_SOURCE_DIR}/common/eda_text.cpp
+    ${CMAKE_SOURCE_DIR}/common/dialogs/dialog_page_settings.cpp
+    ${CMAKE_SOURCE_DIR}/common/dialogs/panel_display_options.cpp
+    ${CMAKE_SOURCE_DIR}/common/page_info.cpp
 )
 
 
@@ -72,11 +72,11 @@ endif()
 
 # a very small program launcher for pl_editor_kiface
 add_executable( pl_editor WIN32 MACOSX_BUNDLE
-    ../common/single_top.cpp
-    ../common/pgm_base.cpp
+    ${CMAKE_SOURCE_DIR}/common/single_top.cpp
+    ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
     ${PL_EDITOR_RESOURCES}
     )
-set_source_files_properties( ../common/single_top.cpp PROPERTIES
+set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
     COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PL_EDITOR;PGM_DATA_FILE_EXT=\"kicad_wks\";BUILD_KIWAY_DLL"
     )
 target_link_libraries( pl_editor
diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt
index 9d3de891ac..8b9de76dbc 100644
--- a/pcb_calculator/CMakeLists.txt
+++ b/pcb_calculator/CMakeLists.txt
@@ -5,7 +5,7 @@ include_directories(
     dialogs
     transline
     attenuators
-    ../common
+    ${CMAKE_SOURCE_DIR}/common
     ${INC_AFTER}
     )
 
@@ -56,11 +56,11 @@ if( APPLE )
 endif()
 
 add_executable( pcb_calculator WIN32 MACOSX_BUNDLE
-    ../common/single_top.cpp
-    ../common/pgm_base.cpp
+    ${CMAKE_SOURCE_DIR}/common/single_top.cpp
+    ${CMAKE_SOURCE_DIR}/common/pgm_base.cpp
     ${PCB_CALCULATOR_RESOURCES}
     )
-set_source_files_properties( ../common/single_top.cpp PROPERTIES
+set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp PROPERTIES
     COMPILE_DEFINITIONS "TOP_FRAME=FRAME_CALC;BUILD_KIWAY_DLL"
     )
 target_link_libraries( pcb_calculator
@@ -188,14 +188,14 @@ endfunction()
     md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/splitter_formula )
     md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/pi_formula )
     md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/tee_formula )
-    md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula )
+    md_doc2h( ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula )
 
 set( DOCS_LIST
         ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/pi_formula.h
         ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/tee_formula.h
         ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/bridget_tee_formula.h
         ${CMAKE_CURRENT_SOURCE_DIR}/attenuators/splitter_formula.h
-        ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula.h
+        ${CMAKE_CURRENT_SOURCE_DIR}/tracks_width_versus_current_formula.h
     )
 
 set_source_files_properties( attenuators/attenuator_classes.cpp
diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt
index 35af041488..5a1eaef61d 100644
--- a/pcbnew/CMakeLists.txt
+++ b/pcbnew/CMakeLists.txt
@@ -22,7 +22,7 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
 
     # Infrequently needed headers go at end of search paths, append to INC_AFTER
     set( INC_AFTER ${INC_AFTER} swig )
-    set( INC_AFTER ${INC_AFTER} ../common/swig )
+    set( INC_AFTER ${INC_AFTER} ${CMAKE_SOURCE_DIR}/common/swig )
 
     #message( STATUS "pcbnew INC_AFTER:${INC_AFTER}" )
 endif()
@@ -39,11 +39,11 @@ include_directories( BEFORE ${INC_BEFORE} )
 include_directories(
     ./dialogs
     ./autorouter
-    ../3d-viewer
-    ../common
-    ../common/dialogs
+    ${CMAKE_SOURCE_DIR}/3d-viewer
+    ${CMAKE_SOURCE_DIR}/common
+    ${CMAKE_SOURCE_DIR}/common/dialogs
     ./exporters
-    ../utils/idftools
+    ${CMAKE_SOURCE_DIR}/utils/idftools
     ${GLM_INCLUDE_DIR}
     ./specctra_import_export
     ${INC_AFTER}
@@ -341,9 +341,9 @@ set( PCBNEW_SRCS
 
 # extra sources from common
 set( PCBNEW_COMMON_SRCS
-    ../common/dialogs/dialog_page_settings.cpp
-    ../common/base_units.cpp
-    ../common/hotkeys_basic.cpp
+    ${CMAKE_SOURCE_DIR}/common/dialogs/dialog_page_settings.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_units.cpp
+    ${CMAKE_SOURCE_DIR}/common/hotkeys_basic.cpp
     )
 
 set( PCBNEW_SCRIPTING_DIALOGS
@@ -352,7 +352,7 @@ set( PCBNEW_SCRIPTING_DIALOGS
     )
 
 set( PCBNEW_SCRIPTING_PYTHON_HELPERS
-    ../common/swig/wx_python_helpers.cpp
+    ${CMAKE_SOURCE_DIR}/common/swig/wx_python_helpers.cpp
     swig/pcbnew_action_plugins.cpp
     swig/pcbnew_footprint_wizards.cpp
     swig/pcbnew_scripting_helpers.cpp
@@ -396,10 +396,10 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
 
     set( SWIG_FLAGS
         -I${CMAKE_CURRENT_SOURCE_DIR}
-        -I${CMAKE_CURRENT_SOURCE_DIR}/../include
-        -I${CMAKE_CURRENT_SOURCE_DIR}/../scripting
-        -I${CMAKE_CURRENT_SOURCE_DIR}/../common/swig
-        -I${CMAKE_CURRENT_SOURCE_DIR}/../libs/kimath/include
+        -I${CMAKE_SOURCE_DIR}/include
+        -I${CMAKE_SOURCE_DIR}/scripting
+        -I${CMAKE_SOURCE_DIR}/common/swig
+        -I${CMAKE_SOURCE_DIR}/libs/kimath/include
         -I${WXPYTHON_SWIG_DIR}
         )
 
@@ -460,10 +460,10 @@ if( KICAD_SCRIPTING )   # Generate pcbnew.py and pcbnew_wrap.cxx using swig
         DEPENDS swig/zone.i
         DEPENDS swig/zone_settings.i
 
-        DEPENDS ../common/swig/kicad.i
-        DEPENDS ../common/swig/wx.i
-        DEPENDS ../common/swig/ki_exception.i
-        DEPENDS ../scripting/kicadplugins.i
+        DEPENDS ${CMAKE_SOURCE_DIR}/common/swig/kicad.i
+        DEPENDS ${CMAKE_SOURCE_DIR}/common/swig/wx.i
+        DEPENDS ${CMAKE_SOURCE_DIR}/common/swig/ki_exception.i
+        DEPENDS ${CMAKE_SOURCE_DIR}/scripting/kicadplugins.i
 
         COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/docstrings
 
@@ -579,10 +579,10 @@ endif()
 
 # a very small program launcher for pcbnew_kiface
 add_executable( pcbnew WIN32 MACOSX_BUNDLE
-    ../common/single_top.cpp
+    ${CMAKE_SOURCE_DIR}/common/single_top.cpp
     ${PCBNEW_RESOURCES}
     )
-set_source_files_properties( ../common/single_top.cpp pcbnew.cpp PROPERTIES
+set_source_files_properties( ${CMAKE_SOURCE_DIR}/common/single_top.cpp pcbnew.cpp PROPERTIES
     COMPILE_DEFINITIONS "TOP_FRAME=FRAME_PCB_EDITOR;PGM_DATA_FILE_EXT=\"kicad_pcb\";BUILD_KIWAY_DLL"
     )
 target_link_libraries( pcbnew
diff --git a/qa/common/CMakeLists.txt b/qa/common/CMakeLists.txt
index 487a613cbf..1c3f4457da 100644
--- a/qa/common/CMakeLists.txt
+++ b/qa/common/CMakeLists.txt
@@ -29,12 +29,12 @@ set( common_srcs
     test_module.cpp
 
     # stuff from common due to...units?
-    ../../common/eda_text.cpp
-    ../../common/base_units.cpp
+    ${CMAKE_SOURCE_DIR}/common/eda_text.cpp
+    ${CMAKE_SOURCE_DIR}/common/base_units.cpp
 
     # stuff from common which is needed...why?
-    ../../common/colors.cpp
-    ../../common/observable.cpp
+    ${CMAKE_SOURCE_DIR}/common/colors.cpp
+    ${CMAKE_SOURCE_DIR}/common/observable.cpp
 
     wximage_test_utils.cpp
 
diff --git a/qa/common_tools/CMakeLists.txt b/qa/common_tools/CMakeLists.txt
index 60acf0d330..c592a48ab6 100644
--- a/qa/common_tools/CMakeLists.txt
+++ b/qa/common_tools/CMakeLists.txt
@@ -27,8 +27,8 @@ add_executable( qa_common_tools
     # ../../common/eda_text.cpp
 
     # stuff from common which is needed...why?
-    ../../common/colors.cpp
-    ../../common/observable.cpp
+    ${CMAKE_SOURCE_DIR}/common/colors.cpp
+    ${CMAKE_SOURCE_DIR}/common/observable.cpp
 
     # The main entry point
     main.cpp
diff --git a/qa/eeschema/CMakeLists.txt b/qa/eeschema/CMakeLists.txt
index 902bfd539b..c07205b111 100644
--- a/qa/eeschema/CMakeLists.txt
+++ b/qa/eeschema/CMakeLists.txt
@@ -29,8 +29,8 @@ add_executable( qa_eeschema
     # ../../common/single_top.cpp
 
     # stuff from common which is needed...why?
-    ../../common/colors.cpp
-    ../../common/observable.cpp
+    ${CMAKE_SOURCE_DIR}/common/colors.cpp
+    ${CMAKE_SOURCE_DIR}/common/observable.cpp
 
     # need the mock Pgm for many functions
     mocks_eeschema.cpp
diff --git a/qa/gal/gal_pixel_alignment/CMakeLists.txt b/qa/gal/gal_pixel_alignment/CMakeLists.txt
index 9553b4bde1..22c428df83 100644
--- a/qa/gal/gal_pixel_alignment/CMakeLists.txt
+++ b/qa/gal/gal_pixel_alignment/CMakeLists.txt
@@ -35,16 +35,18 @@ add_dependencies( pnsrouter pcbcommon pcad2kicadpcb ${GITHUB_PLUGIN_LIBRARIES} )
 
 add_executable(test_gal_pixel_alignment WIN32
   test_gal_pixel_alignment.cpp
-  ../../qa_utils/pcb_test_frame.cpp
-  ../../qa_utils/mocks.cpp
-  ../../../common/base_units.cpp
-  ../../../pcbnew/board_stackup_manager/stackup_predefined_prms.cpp
-  ../../../pcbnew/tools/pcb_tool_base.cpp
-  ../../../pcbnew/tools/pcb_actions.cpp
-  ../../../pcbnew/tools/pcbnew_selection.cpp
-  ../../../pcbnew/tools/selection_tool.cpp
-  ../../../pcbnew/tools/tool_event_utils.cpp
-  #../../pcbnew/tools/outline_editor.cpp
+
+  ${CMAKE_SOURCE_DIR}/qa/qa_utils/pcb_test_frame.cpp
+  ${CMAKE_SOURCE_DIR}/qa/qa_utils/mocks.cpp
+
+  ${CMAKE_SOURCE_DIR}/common/base_units.cpp
+
+  ${CMAKE_SOURCE_DIR}/pcbnew/board_stackup_manager/stackup_predefined_prms.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/pcb_tool_base.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/pcb_actions.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/pcbnew_selection.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/selection_tool.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/tool_event_utils.cpp
 )
 
 include_directories( BEFORE ${INC_BEFORE} )
diff --git a/qa/pcb_test_window/CMakeLists.txt b/qa/pcb_test_window/CMakeLists.txt
index fecdb6f960..4573a8e1c4 100644
--- a/qa/pcb_test_window/CMakeLists.txt
+++ b/qa/pcb_test_window/CMakeLists.txt
@@ -35,14 +35,14 @@ add_dependencies( pnsrouter pcbcommon pcad2kicadpcb ${GITHUB_PLUGIN_LIBRARIES} )
 
 add_executable(test_window WIN32
   test.cpp
-  ../qa_utils/pcb_test_frame.cpp
-  ../qa_utils/mocks.cpp
-  ../../common/base_units.cpp
-    ../../pcbnew/tools/pcb_tool_base.cpp
-    ../../pcbnew/tools/pcbnew_selection.cpp
-  ../../pcbnew/tools/selection_tool.cpp
-  ../../pcbnew/tools/tool_event_utils.cpp
-  #../../pcbnew/tools/outline_editor.cpp
+  ${CMAKE_SOURCE_DIR}/qa/qa_utils/pcb_test_frame.cpp
+  ${CMAKE_SOURCE_DIR}/qa/qa_utils/mocks.cpp
+
+  ${CMAKE_SOURCE_DIR}/common/base_units.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/pcb_tool_base.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/pcbnew_selection.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/selection_tool.cpp
+  ${CMAKE_SOURCE_DIR}/pcbnew/tools/tool_event_utils.cpp
 )
 
 include_directories( BEFORE ${INC_BEFORE} )
diff --git a/qa/pcbnew/CMakeLists.txt b/qa/pcbnew/CMakeLists.txt
index 7804db2475..d45aaefad6 100644
--- a/qa/pcbnew/CMakeLists.txt
+++ b/qa/pcbnew/CMakeLists.txt
@@ -28,11 +28,11 @@ add_executable( qa_pcbnew
     # ../../common/single_top.cpp
 
     # stuff from common due to...units?
-    ../../common/eda_text.cpp
+    ${CMAKE_SOURCE_DIR}/common/eda_text.cpp
 
     # stuff from common which is needed...why?
-    ../../common/colors.cpp
-    ../../common/observable.cpp
+    ${CMAKE_SOURCE_DIR}/common/colors.cpp
+    ${CMAKE_SOURCE_DIR}/common/observable.cpp
 
     # The main test entry points
     test_module.cpp
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index c83216f9f6..1026508a9c 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -15,10 +15,10 @@ add_executable( test-nm-biu-to-ascii-mm-round-tripping
 add_executable( property_tree
     EXCLUDE_FROM_ALL
     property_tree.cpp
-    ../common/richio.cpp
-    ../common/exceptions.cpp
-    ../common/dsnlexer.cpp
-    ../common/ptree.cpp
+    ${CMAKE_SOURCE_DIR}/common/richio.cpp
+    ${CMAKE_SOURCE_DIR}/common/exceptions.cpp
+    ${CMAKE_SOURCE_DIR}/common/dsnlexer.cpp
+    ${CMAKE_SOURCE_DIR}/common/ptree.cpp
     )
 target_link_libraries( property_tree
     ${wxWidgets_LIBRARIES}
diff --git a/utils/kicad-ogltest/CMakeLists.txt b/utils/kicad-ogltest/CMakeLists.txt
index 679ab54fed..c905af0016 100644
--- a/utils/kicad-ogltest/CMakeLists.txt
+++ b/utils/kicad-ogltest/CMakeLists.txt
@@ -8,8 +8,8 @@ include_directories( BEFORE
 )
 
 include_directories(
-    ../../include
-    ../../common
+    ${CMAKE_SOURCE_DIR}/include
+    ${CMAKE_SOURCE_DIR}/common
     ${INC_AFTER}
 )