| 78 | } |
| 79 | |
| 80 | QStringList CMakeJob::commandLine() const |
| 81 | { |
| 82 | QStringList args; |
| 83 | args << CMake::currentCMakeExecutable( m_project ).toLocalFile(); |
| 84 | |
| 85 | args << QStringLiteral("-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"); |
| 86 | |
| 87 | QString installDir = CMake::currentInstallDir( m_project ).toLocalFile(); |
| 88 | if( !installDir.isEmpty() ) |
| 89 | { |
| 90 | args << QStringLiteral("-DCMAKE_INSTALL_PREFIX=%1").arg(installDir); |
| 91 | } |
| 92 | QString buildType = CMake::currentBuildType( m_project ); |
| 93 | if( !buildType.isEmpty() ) |
| 94 | { |
| 95 | args << QStringLiteral("-DCMAKE_BUILD_TYPE=%1").arg(buildType); |
| 96 | } |
| 97 | QVariantMap cacheArgs = property("extraCMakeCacheValues").toMap(); |
| 98 | for( auto it = cacheArgs.constBegin(), itEnd = cacheArgs.constEnd(); it!=itEnd; ++it) { |
| 99 | args << QStringLiteral("-D%1=%2").arg(it.key(), it.value().toString()); |
| 100 | } |
| 101 | |
| 102 | auto rt = ICore::self()->runtimeController()->currentRuntime(); |
| 103 | //if we are creating a new build directory, we'll want to specify the generator |
| 104 | QDir builddir(rt->pathInRuntime(CMake::currentBuildDir( m_project )).toLocalFile()); |
| 105 | if(!builddir.exists() || !builddir.exists(QStringLiteral("CMakeCache.txt"))) { |
| 106 | CMakeBuilderSettings::self()->load(); |
| 107 | args << QStringLiteral("-G") << CMake::defaultGenerator(); |
| 108 | } |
| 109 | QString cmakeargs = CMake::currentExtraArguments( m_project ); |
| 110 | if( !cmakeargs.isEmpty() ) { |
| 111 | KShell::Errors err; |
| 112 | QStringList tmp = KShell::splitArgs( cmakeargs, KShell::TildeExpand | KShell::AbortOnMeta, &err ); |
| 113 | if( err == KShell::NoError ) { |
| 114 | args += tmp; |
| 115 | } else { |
| 116 | qCWarning(KDEV_CMAKEBUILDER) << "Ignoring cmake Extra arguments"; |
| 117 | if( err == KShell::BadQuoting ) { |
| 118 | qCWarning(KDEV_CMAKEBUILDER) << "CMake arguments badly quoted:" << cmakeargs; |
| 119 | } else { |
| 120 | qCWarning(KDEV_CMAKEBUILDER) << "CMake arguments had meta character:" << cmakeargs; |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | args << rt->pathInRuntime(CMake::projectRoot( m_project )).toLocalFile(); |
| 125 | |
| 126 | return args; |
| 127 | } |
| 128 | |
| 129 | QString CMakeJob::environmentProfile() const |
| 130 | { |
nothing calls this directly
no test coverage detected