diff --git a/NPLib/CMakeLists.txt b/NPLib/CMakeLists.txt
index 38d17a052c2f77322e1a3b127bcc4ecf6b49321c..abf40c026f82693a0c048da91c2dfac2868f46a4 100644
--- a/NPLib/CMakeLists.txt
+++ b/NPLib/CMakeLists.txt
@@ -15,7 +15,8 @@ set(CMAKE_BUILD_TYPE Release)
 
 set(DETLIST ${ETLIST})
 
-if("${DETLIST}" MATCHES "")
+string(COMPARE EQUAL "${DETLIST}" "" rdet)
+if(rdet)
     message("Building all detectors")
   else()
     message("Building the following detectors ${DETLIST}") 
diff --git a/NPLib/NPLibConfig.cmake.in b/NPLib/NPLibConfig.cmake.in
index f2e9b44f39353a89adb8edda37efbdc92ef3059b..4d54a720ad1e9721757de7379fe5bbf3a599d337 100644
--- a/NPLib/NPLibConfig.cmake.in
+++ b/NPLib/NPLibConfig.cmake.in
@@ -6,9 +6,10 @@
  
 # Compute paths
 get_filename_component(NPLib_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+set(NPLib_USE_FILE "@CMAKE_BINARY_DIR@/NPLibConfig.cmake")
 set(NPLib_INCLUDE_DIRS "@CMAKE_INCLUDE_OUTPUT_DIRECTORY@")
+set(NPLib_DETECTOR_LIST "@DETLIST@")
 include_directories("${NPLib_INCLUDE_DIRS}")
-set(NPLib_USE_FILE "@CMAKE_BINARY_DIR@/NPLibConfig.cmake")
 
 set(NPLib_LIBRARIES "-L@CMAKE_BINARY_DIR@/lib -lNPCore -lNPPhysics -lNPInteractionCoordinates -lNPInitialConditions")
 
diff --git a/NPSimulation/CMakeLists.txt b/NPSimulation/CMakeLists.txt
index 19d2c83244fc03fb58c6eda9b52687b0ab135483..e867dc2d7a26441c8cdd41278b71bddc043e2725 100644
--- a/NPSimulation/CMakeLists.txt
+++ b/NPSimulation/CMakeLists.txt
@@ -21,7 +21,8 @@ configure_file(Core/NPSimulationVersion.hh.in Core/NPSimulationVersion.hh @ONLY)
 
 set(DETLIST ${NPLib_DETECTOR_LIST})
 
-if("${DETLIST}" MATCHES "")
+string(COMPARE EQUAL "${DETLIST}" "" rdet)
+if(rdet)
     message("Building all detectors")
   else()
     message("Building the following detectors ${DETLIST}")