Linking JNI and put some ifs in the top level CMakeLists.txt