summaryrefslogtreecommitdiffstats
path: root/Source/cmTryCompileCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmTryCompileCommand.cxx')
-rw-r--r--Source/cmTryCompileCommand.cxx27
1 files changed, 26 insertions, 1 deletions
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index 7514a23..971dccb 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -6,6 +6,10 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
+#include "cmState.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmValue.h"
#include "cmake.h"
bool cmTryCompileCommand(std::vector<std::string> const& args,
@@ -24,8 +28,29 @@ bool cmTryCompileCommand(std::vector<std::string> const& args,
return false;
}
+ cmStateEnums::TargetType targetType = cmStateEnums::EXECUTABLE;
+ cmValue tt = mf.GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE");
+ if (cmNonempty(tt)) {
+ if (*tt == cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE)) {
+ targetType = cmStateEnums::EXECUTABLE;
+ } else if (*tt ==
+ cmState::GetTargetTypeName(cmStateEnums::STATIC_LIBRARY)) {
+ targetType = cmStateEnums::STATIC_LIBRARY;
+ } else {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Invalid value '", *tt,
+ "' for CMAKE_TRY_COMPILE_TARGET_TYPE. Only '",
+ cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE),
+ "' and '",
+ cmState::GetTargetTypeName(cmStateEnums::STATIC_LIBRARY),
+ "' are allowed."));
+ return false;
+ }
+ }
+
cmCoreTryCompile tc(&mf);
- tc.TryCompileCode(args, false);
+ tc.TryCompileCode(args, targetType);
// if They specified clean then we clean up what we can
if (tc.SrcFileSignature) {