diff --git a/profile_translator_blocklist/templates/CMakeLists.txt.j2 b/profile_translator_blocklist/templates/CMakeLists.txt.j2
index c524866d7481f82d2c1f49fe908212dc21794a49..104d74212e5d52dc7f1b63d9e818c02e208ea75b 100644
--- a/profile_translator_blocklist/templates/CMakeLists.txt.j2
+++ b/profile_translator_blocklist/templates/CMakeLists.txt.j2
@@ -10,10 +10,17 @@ IF( OPENWRT_CROSSCOMPILING )
 target_link_libraries({{nfqueue_name}} jansson mnl nfnetlink nftnl nftables netfilter_queue netfilter_log)
 ENDIF()
 target_link_libraries({{nfqueue_name}} nfqueue packet_utils rule_utils)
-{% if domain_names|length > 0 %}
+{% set dns_parser_included = namespace(value=False) %}
+{% for parser in custom_parsers %}
+{% if "dns" in parser %}
+{% set dns_parser_included.value = True %}
+target_link_libraries({{nfqueue_name}} header dns dns_map)
+{% else %}
+target_link_libraries({{nfqueue_name}} header {{parser}})
+{% endif %}
+{% endfor %}
+{% if domain_names|length > 0 and not dns_parser_included.value %}
 target_link_libraries({{nfqueue_name}} header dns dns_map)
 {% endif %}
-{% set parsers = custom_parsers - set(["dns"]) if "dns" in custom_parsers else custom_parsers %}
-target_link_libraries({{nfqueue_name}} header {{parsers}})
 target_include_directories({{nfqueue_name}} PRIVATE ${INCLUDE_DIR} ${INCLUDE_PARSERS_DIR})
 install(TARGETS {{nfqueue_name}} DESTINATION ${EXECUTABLE_OUTPUT_PATH})
diff --git a/profile_translator_blocklist/translator.py b/profile_translator_blocklist/translator.py
index c69aa89cb2fefe8397dfddd5c40c23e668101da8..656d09cea211bb63bdfd3781000a23aa5d9342f0 100644
--- a/profile_translator_blocklist/translator.py
+++ b/profile_translator_blocklist/translator.py
@@ -229,11 +229,10 @@ def write_firewall(
             fw.write(main)
 
         # Create CMake file
-        custom_parsers = " ".join(global_accs["custom_parsers"])
         cmake_dict = {
             "device":  device["name"],
             "nfqueue_name": nfqueue_name,
-            "custom_parsers": custom_parsers,
+            "custom_parsers": global_accs["custom_parsers"],
             "domain_names": global_accs["domain_names"]
         }
         env.get_template("CMakeLists.txt.j2").stream(cmake_dict).dump(os.path.join(output_dir, "CMakeLists.txt"))