diff --git a/CMakeLists.txt b/CMakeLists.txt
index 50b9df3dd0d0ccba5a2c9c9a5a5cb706d1e7e066..3f60b3418a732d2e113c46f6a34c82f016572d88 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,7 +64,6 @@ set(PAIRS_TARGET "pairs")
 
 # PAIRS dependencies 
 set(PAIRS_LINK_LIBRARIES)
-set(PAIRS_LINK_DIRS ${CMAKE_CURRENT_BINARY_DIR})
 set(PAIRS_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
 
 # The target can either be an executable or a static library
@@ -72,7 +71,9 @@ if(USER_SOURCE_FILES)
     add_executable(${PAIRS_TARGET} ${RUNTIME_COMMON_FILES})
 else()
     add_library(${PAIRS_TARGET} STATIC ${RUNTIME_COMMON_FILES})
-    list(APPEND PAIRS_LINK_LIBRARIES ${PAIRS_TARGET})
+
+    # TODO: Get the location with $<TARGET_FILE> generator expression (at build time)
+    list(APPEND PAIRS_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/lib${PAIRS_TARGET}.a")
 endif()
 
 # Include P4IRS 'runtime' dir
@@ -119,12 +120,18 @@ if(USE_WALBERLA)
     waLBerla_import()
 
     # Recent issue from the waLBerla side: warnings about empty CUDA_ARCHITECTURES for walberla_gpu 
-    set(PAIRS_WALBERLA_DEPENDENCIES walberla::blockforest walberla::core)
-    target_link_libraries(${PAIRS_TARGET} PUBLIC ${PAIRS_WALBERLA_DEPENDENCIES})
+    target_link_libraries(${PAIRS_TARGET} PUBLIC 
+        walberla::blockforest 
+        walberla::domain_decomposition 
+        walberla::core 
+        stdc++fs
+    )
 
-    ## TODO: PAIRS_LINK_DIRS and PAIRS_LINK_LIBRARIES for walberla modules *AND* their dependencies
-    ## This implemention only works if the consumer of the library is itself a walberla app (made within the build system of walberla)
-    list(APPEND PAIRS_LINK_LIBRARIES ${PAIRS_WALBERLA_DEPENDENCIES})
+    # TODO: Get the location with $<TARGET_FILE> generator expression (at build time)
+    list(APPEND PAIRS_LINK_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/external/walberla/src/blockforest/libwalberla_blockforest.a)
+    list(APPEND PAIRS_LINK_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/external/walberla/src/domain_decomposition/libwalberla_domain_decomposition.a)
+    list(APPEND PAIRS_LINK_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/external/walberla/src/core/libwalberla_core.a)
+    list(APPEND PAIRS_LINK_LIBRARIES stdc++fs)
 endif()
 
 #================================================================================
diff --git a/cmake/pairs-config.cmake.in b/cmake/pairs-config.cmake.in
index fdf10effa045063348fbe03d60608d6db3892cc2..db70813fdec6792fea813a3967a821015730425b 100644
--- a/cmake/pairs-config.cmake.in
+++ b/cmake/pairs-config.cmake.in
@@ -2,5 +2,4 @@ set ( pairs_SOURCE_DIR @pairs_SOURCE_DIR@ )
 set ( pairs_BINARY_DIR @pairs_BINARY_DIR@ )
 
 set ( PAIRS_LINK_LIBRARIES @PAIRS_LINK_LIBRARIES@ )
-set ( PAIRS_LINK_DIRS @PAIRS_LINK_DIRS@ )
 set ( PAIRS_INCLUDE_DIRS @PAIRS_INCLUDE_DIRS@ )
diff --git a/src/pairs/code_gen/cgen.py b/src/pairs/code_gen/cgen.py
index 272e1a95de8376f53267160361eb10c808e8db05..78c395871525672fa4d213ae885422deb63885dd 100644
--- a/src/pairs/code_gen/cgen.py
+++ b/src/pairs/code_gen/cgen.py
@@ -147,6 +147,9 @@ class CGen:
             self.print("#define PAIRS_TARGET_OPENMP")
             self.print("#include <omp.h>")
 
+        if self.sim._use_walberla:
+            self.print("#define USE_WALBERLA")
+            
         self.print("#include <limits.h>")
         self.print("#include <math.h>")
         self.print("#include <stdbool.h>")
diff --git a/src/pairs/sim/simulation.py b/src/pairs/sim/simulation.py
index 0e1164afb29e257fd5e6a44dd70cef3254e7eeaa..3550a7aa4fa80efde963bd8a73e805a9c69b434d 100644
--- a/src/pairs/sim/simulation.py
+++ b/src/pairs/sim/simulation.py
@@ -93,6 +93,7 @@ class Simulation:
         # Domain partitioning
         self._dom_part = None
         self._partitioner = None
+        self._use_walberla = False
         self._comm = None
 
         # Contact history
@@ -122,6 +123,7 @@ class Simulation:
 
         elif partitioner == DomainPartitioners.BlockForest:
             self._dom_part = BlockForest(self)
+            self._use_walberla = True
 
         else:
             raise Exception("Invalid domain partitioner.")