A compound having the formula: or a pharmaceutically acceptable salt thereof, wherein: A is -NHC -; B is C 3 -C 7 cycloalkyl or 3 to 8-membered heterocycloalkyl, which can be optionally substituted with R 5; X is -CH 2 -; R 1 is -N(C 1 -C 6 alkyl) 2 or R 1 and an R 3 group, together with the atoms to which they are attached, combine to form a 4 to 7-membered heterocycloalkyl, which can be optionally substituted with R 5; R 2 represents up to 3 optional substitutents, each independently selected from halo, C 1 -C 6 alkyl, -O-(C 1 -C 6 alkyl) and C 1 -C 6 haloalkyl; each occurrence of R 3 is independently selected from H, C 1 -C 6 alkyl, -OH, -O-(C 1 -C 6 alkyl), C 1 -C 6 haloalkyl, C 3 -C 7 cycloalkyl, -S-(C 1 -C 6 alkyl), -NH 2, -NH(C 1 -C 6 alkyl) and - N(C 1 -C 6 alkyl) 2, wherein both occurrences of R 3 cannot be H; R 4 is selected from H, C 1 -C 6 alkyl, C 3 -C 7 cycloalkyl, -(C 1 -C 4 alkylene)-O-(C 1 -C 6 alkyl) and C 1 -C 6 haloalkyl; R 5 represents one or more groups, each independently selected from halo, C 1 -C 6 alkyl, C 1 -C 6 haloalkyl, 3 to 8-membered monocyclic heterocycloalkyl, 6 to 10-membered bicyclic heterocycloalkyl, -O-(C 1 -C 6 alkyl), -O-(C 6 -C 10 aryl), -O-(C 1 -C 6 alkylene)-O-(C 1 -C 6 alkyl), -O-(C 1 -C 6 haloalkyl), -O-(C 1 -C 6 alkylene)-O-(C 1 -C 6 alkylene)-O-(C 1 -C 6 alkyl), -NH 2, - NH(C 1 -C 6 alkyl), -N(C 1 -C 6 alkyl) 2, -S 2 (C 1 -C 6 alkyl), -NHS 2 -(C 1 -C 6 alkyl), -S 2 NH-(C 1 -C 6 alkyl), -OC -(C 1 -C 6 haloalkyl), -(C 1 -C 6 alkylene) p -C O-(C 1 -C 6 alkyl), -(C 1 -C 6 alkylene) p -C -(C 1 -C 6 alkyl), -(C 1 -C 6 alkylene) p -C N(R 6) 2, C 1 -C 6 hydroxyalkyl, - P (OR 8) 2, and -CN; each occurrence of R 6 is independently selected from H, C 1 -C 6 alkyl, C 3 -C 7 cycloalkyl, C 1 -C 6 haloalkyl and -(C 1 -C 6 alkylene) p -R 7; each occurrence of R 7 is independently selected from H, C 1 -C 6 alkyl, -O-(C 1 -C 6 alkyl), C 3 -C 7 cycloalkyl, 5- or 6-membered monocyclic heteroaryl and 3 to 8-membered monocyclic heterocycloalkyl; each occurrence of R 8 is independently selected from H and C 1 -C 6 alkyl; and each occurrence of p is independently 0 or 1. A is -NHC -; B is C 3 -C 7 cycloalkyl or 3 to 8-membered heterocycloalkyl, which can be optionally substituted with R 5; X is -CH 2 -; R 1 is -N(C 1 -C 6 alkyl) 2 or R 1 and an R 3 group, together with the atoms to which they are attached, combine to form a 4 to 7-membered heterocycloalkyl, which can be optionally substituted with R 5; R 2 represents up to 3 optional substitutents, each independently selected from halo, C 1 -C 6 alkyl, -O-(C 1 -C 6 alkyl) and C 1 -C 6 haloalkyl; each occurrence of R 3 is independently selected from H, C 1 -C 6 alkyl, -OH, -O-(C 1 -C 6 alkyl), C 1 -C 6 haloalkyl, C 3 -C 7 cycloalkyl, -S-(C 1 -C 6 alkyl), -NH 2, -NH(C 1 -C 6 alkyl) and - N(C 1 -C 6 alkyl) 2, wherein both occurrences of R 3 cannot be H; R 4 is selected from H, C 1 -C 6 alkyl, C 3 -C 7 cycloalkyl, -(C 1 -C 4 alkylene)-O-(C 1 -C 6 alkyl) and C 1 -C 6 haloalkyl; R 5 represents one or more groups, each independently selected from halo, C 1 -C 6 alkyl, C 1 -C 6 haloalkyl, 3 to 8-membered monocyclic heterocycloalkyl, 6 to 10-membered bicyclic heterocycloalkyl, -O-(C 1 -C 6 alkyl), -O-(C 6 -C 10 aryl), -O-(C 1 -C 6 alkylene)-O-(C 1 -C 6 alkyl), -O-(C 1 -C 6 haloalkyl), -O-(C 1 -C 6 alkylene)-O-(C 1 -C 6 alkylene)-O-(C 1 -C 6 alkyl), -NH 2, - NH(C 1 -C 6 alkyl), -N(C 1 -C 6 alkyl) 2, -S 2 (C 1 -C 6 alkyl), -NHS 2 -(C 1 -C 6 alkyl), -S 2 NH-(C 1 -C 6 alkyl), -OC -(C 1 -C 6 haloalkyl), -(C 1 -C 6 alkylene) p -C O-(C 1 -C 6 alkyl), -(C 1 -C 6 alkylene) p -C -(C 1 -C 6 alkyl), -(C 1 -C 6 alkylene) p -C N(R 6) 2, C 1 -C 6 hydroxyalkyl, - P (OR 8) 2, and -CN; each occurrence of R 6 is independently selected from H, C 1 -C 6 alkyl, C 3 -C 7 cycloalkyl, C 1 -C 6 haloalkyl and -(C 1 -C 6 alkylene) p -R 7; each occurrence of R 7 is independently selected from H, C 1 -C 6 alkyl, -O-(C 1 -C 6 alkyl), C 3 -C 7 cycloalkyl, 5- or 6-membered monocyclic heteroaryl and 3 to 8-membered monocyclic heterocycloalkyl; each occurrence of R 8 is independently selected from H and C 1 -C 6 alkyl; and each occurrence of p is independently 0 or 1.