| 3055 | } |
| 3056 | |
| 3057 | void cmGlobalGenerator::ReserveGlobalTargetCodegen() |
| 3058 | { |
| 3059 | // Read the policy value at the end of the top-level CMakeLists.txt file |
| 3060 | // since it's a global policy that affects the whole project. |
| 3061 | auto& mf = this->Makefiles[0]; |
| 3062 | auto const policyStatus = mf->GetPolicyStatus(cmPolicies::CMP0171); |
| 3063 | |
| 3064 | this->AllowGlobalTargetCodegen = (policyStatus == cmPolicies::NEW); |
| 3065 | |
| 3066 | cmTarget* tgt = this->FindTarget("codegen"); |
| 3067 | if (!tgt) { |
| 3068 | return; |
| 3069 | } |
| 3070 | |
| 3071 | MessageType messageType = MessageType::AUTHOR_WARNING; |
| 3072 | std::ostringstream e; |
| 3073 | bool issueMessage = false; |
| 3074 | switch (policyStatus) { |
| 3075 | case cmPolicies::WARN: |
| 3076 | e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0171) << '\n'; |
| 3077 | issueMessage = true; |
| 3078 | CM_FALLTHROUGH; |
| 3079 | case cmPolicies::OLD: |
| 3080 | break; |
| 3081 | case cmPolicies::NEW: |
| 3082 | issueMessage = true; |
| 3083 | messageType = MessageType::FATAL_ERROR; |
| 3084 | break; |
| 3085 | } |
| 3086 | if (issueMessage) { |
| 3087 | e << "The target name \"codegen\" is reserved."; |
| 3088 | this->GetCMakeInstance()->IssueMessage(messageType, e.str(), |
| 3089 | tgt->GetBacktrace()); |
| 3090 | if (messageType == MessageType::FATAL_ERROR) { |
| 3091 | cmSystemTools::SetFatalErrorOccurred(); |
| 3092 | return; |
| 3093 | } |
| 3094 | } |
| 3095 | } |
| 3096 | |
| 3097 | bool cmGlobalGenerator::CheckCMP0171() const |
| 3098 | { |
no test coverage detected