The scope of compulsory jurisdiction at the ICJ is by unilateral declaration of each nation. You can see the declarations of states that have assented to compulsory jurisdiction of the ICJ here: https://www.icj-cij.org/en/declarations
Each declaration specifies the scope of compulsory jurisdiction that the state is assenting to.
For example, Romania has said it does not accept compulsory jurisdiction for "any dispute regarding to the protection of the environment."
I believe all the states that have conditioned their acceptance of compulsory jurisdiction on the opposing state having accepted the same obligation. E.g. Sweden
accepts as compulsory ipso facto and without special agreement, in relation to any other State accepting the same obligation, the jurisdiction of the International Court of Justice, ...