4

I have an Android project that has an NDK component, configured to be built with CMake. And depending on where the project dir is located on a drive, I may get a "Command line too long." error when CMake is trying to build this project. It's because CMake assembles huge command lines listing all the .cpp files in a project.

I read that CMake has a mechanism called "response files" to work around this, but I can't find a way to enable them in an NDK project. A little advice, please?

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335

1 Answers1

4

You can specify response file in CMakeLists.txt, or in build.gradle, add

android { defaultConfig { ...
  externalNativeBuild {
      cmake {
          arguments 
              "-DCMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS=1",
              "-DCMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS=1" ,
              "-DCMAKE_C_RESPONSE_FILE_LINK_FLAG=@",
              "-DCMAKE_CXX_RESPONSE_FILE_LINK_FLAG=@",
              "-DCMAKE_NINJA_FORCE_RESPONSE_FILE=1"
      }
  }
}}
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307