diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -369,13 +369,25 @@
 	primitives/block.cpp
 	protocol.cpp
 	scheduler.cpp
+	warnings.cpp
+)
+
+target_link_libraries(common util secp256k1)
+
+# script library
+add_library(script
+	script/bitcoinconsensus.cpp
+	script/bitfield.cpp
+	script/interpreter.cpp
 	script/ismine.cpp
+	script/script.cpp
+	script/script_error.cpp
+	script/sigencoding.cpp
 	script/sign.cpp
 	script/standard.cpp
-	warnings.cpp
 )
 
-target_link_libraries(common util secp256k1)
+target_link_libraries(script common)
 
 # libbitcoinconsensus
 add_library(bitcoinconsensus
@@ -383,17 +395,11 @@
 	hash.cpp
 	primitives/transaction.cpp
 	pubkey.cpp
-	script/bitcoinconsensus.cpp
-	script/bitfield.cpp
-	script/interpreter.cpp
-	script/script.cpp
-	script/script_error.cpp
-	script/sigencoding.cpp
 	uint256.cpp
 	util/strencodings.cpp
 )
 
-target_link_libraries(bitcoinconsensus common)
+target_link_libraries(bitcoinconsensus script)
 
 # Bitcoin server facilities
 add_library(server
diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt
--- a/src/wallet/CMakeLists.txt
+++ b/src/wallet/CMakeLists.txt
@@ -25,6 +25,6 @@
 	walletutil.cpp
 )
 
-target_link_libraries(wallet common univalue Event ${BDBXX_LIBRARY})
+target_link_libraries(wallet script univalue Event ${BDBXX_LIBRARY})
 
 target_include_directories(wallet PUBLIC ${BDBXX_INCLUDE_DIR})