mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-08 14:50:10 -06:00
CMP0031: Remove support for OLD load_command command
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
CMP0031
|
||||
-------
|
||||
|
||||
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
|
||||
.. include:: REMOVED_PROLOGUE.txt
|
||||
|
||||
The :command:`load_command` command should not be called.
|
||||
|
||||
This command was added in August 2002 to allow projects to add
|
||||
@@ -10,6 +13,4 @@ the CMake process. It has been mostly superseded by the
|
||||
:command:`macro` and :command:`function` commands.
|
||||
|
||||
.. |disallowed_version| replace:: 3.0
|
||||
.. include:: DISALLOWED_COMMAND.txt
|
||||
|
||||
.. include:: DEPRECATED.txt
|
||||
.. include:: REMOVED_COMMAND.txt
|
||||
|
||||
@@ -668,8 +668,6 @@ add_library(
|
||||
cmListCommand.h
|
||||
cmLoadCacheCommand.cxx
|
||||
cmLoadCacheCommand.h
|
||||
cmLoadCommandCommand.cxx
|
||||
cmLoadCommandCommand.h
|
||||
cmMacroCommand.cxx
|
||||
cmMacroCommand.h
|
||||
cmMakeDirectoryCommand.cxx
|
||||
@@ -1381,7 +1379,5 @@ foreach(_tool IN LISTS _tools)
|
||||
install(TARGETS ${_tool} DESTINATION ${CMAKE_BIN_DIR} ${COMPONENT})
|
||||
endforeach()
|
||||
|
||||
install(FILES cmCPluginAPI.h DESTINATION ${CMAKE_DATA_DIR}/include)
|
||||
|
||||
# Unset temporary variables
|
||||
unset(_tools)
|
||||
|
||||
@@ -1,874 +0,0 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
/*
|
||||
this file contains the implementation of the C API to CMake. Generally
|
||||
these routines just manipulate arguments and then call the associated
|
||||
methods on the CMake classes. */
|
||||
|
||||
#include "cmCPluginAPI.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmValue.h"
|
||||
#include "cmVersion.h"
|
||||
|
||||
#ifdef __QNX__
|
||||
# include <malloc.h> /* for malloc/free on QNX */
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
static void CCONV* cmGetClientData(void* info)
|
||||
{
|
||||
return ((cmLoadedCommandInfo*)info)->ClientData;
|
||||
}
|
||||
|
||||
static void CCONV cmSetClientData(void* info, void* cd)
|
||||
{
|
||||
((cmLoadedCommandInfo*)info)->ClientData = cd;
|
||||
}
|
||||
|
||||
static void CCONV cmSetError(void* info, const char* err)
|
||||
{
|
||||
if (((cmLoadedCommandInfo*)info)->Error) {
|
||||
free(((cmLoadedCommandInfo*)info)->Error);
|
||||
}
|
||||
((cmLoadedCommandInfo*)info)->Error = strdup(err);
|
||||
}
|
||||
|
||||
static unsigned int CCONV cmGetCacheMajorVersion(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
cmState* state = mf->GetState();
|
||||
return state->GetCacheMajorVersion();
|
||||
}
|
||||
static unsigned int CCONV cmGetCacheMinorVersion(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
cmState* state = mf->GetState();
|
||||
return state->GetCacheMinorVersion();
|
||||
}
|
||||
|
||||
static unsigned int CCONV cmGetMajorVersion(void*)
|
||||
{
|
||||
return cmVersion::GetMajorVersion();
|
||||
}
|
||||
|
||||
static unsigned int CCONV cmGetMinorVersion(void*)
|
||||
{
|
||||
return cmVersion::GetMinorVersion();
|
||||
}
|
||||
|
||||
static void CCONV cmAddDefinition(void* arg, const char* name,
|
||||
const char* value)
|
||||
{
|
||||
if (value) {
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
mf->AddDefinition(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add a definition to this makefile and the global cmake cache. */
|
||||
static void CCONV cmAddCacheDefinition(void* arg, const char* name,
|
||||
const char* value, const char* doc,
|
||||
int type)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
std::string valueString;
|
||||
std::string docString;
|
||||
cmValue v;
|
||||
cmValue d;
|
||||
if (value != nullptr) {
|
||||
valueString = value;
|
||||
v = cmValue{ valueString };
|
||||
}
|
||||
if (doc != nullptr) {
|
||||
docString = doc;
|
||||
d = cmValue{ docString };
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case CM_CACHE_BOOL:
|
||||
mf->AddCacheDefinition(name, v, d, cmStateEnums::BOOL);
|
||||
break;
|
||||
case CM_CACHE_PATH:
|
||||
mf->AddCacheDefinition(name, v, d, cmStateEnums::PATH);
|
||||
break;
|
||||
case CM_CACHE_FILEPATH:
|
||||
mf->AddCacheDefinition(name, v, d, cmStateEnums::FILEPATH);
|
||||
break;
|
||||
case CM_CACHE_STRING:
|
||||
mf->AddCacheDefinition(name, v, d, cmStateEnums::STRING);
|
||||
break;
|
||||
case CM_CACHE_INTERNAL:
|
||||
mf->AddCacheDefinition(name, v, d, cmStateEnums::INTERNAL);
|
||||
break;
|
||||
case CM_CACHE_STATIC:
|
||||
mf->AddCacheDefinition(name, v, d, cmStateEnums::STATIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* CCONV cmGetProjectName(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
static std::string name;
|
||||
name = mf->GetStateSnapshot().GetProjectName();
|
||||
return name.c_str();
|
||||
}
|
||||
|
||||
static const char* CCONV cmGetHomeDirectory(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return mf->GetHomeDirectory().c_str();
|
||||
}
|
||||
static const char* CCONV cmGetHomeOutputDirectory(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return mf->GetHomeOutputDirectory().c_str();
|
||||
}
|
||||
static const char* CCONV cmGetStartDirectory(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return mf->GetCurrentSourceDirectory().c_str();
|
||||
}
|
||||
static const char* CCONV cmGetStartOutputDirectory(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return mf->GetCurrentBinaryDirectory().c_str();
|
||||
}
|
||||
static const char* CCONV cmGetCurrentDirectory(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return mf->GetCurrentSourceDirectory().c_str();
|
||||
}
|
||||
static const char* CCONV cmGetCurrentOutputDirectory(void* arg)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return mf->GetCurrentBinaryDirectory().c_str();
|
||||
}
|
||||
static const char* CCONV cmGetDefinition(void* arg, const char* def)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return mf->GetDefinition(def).GetCStr();
|
||||
}
|
||||
|
||||
static int CCONV cmIsOn(void* arg, const char* name)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return static_cast<int>(mf->IsOn(name));
|
||||
}
|
||||
|
||||
/** Check if a command exists. */
|
||||
static int CCONV cmCommandExists(void* arg, const char* name)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
return mf->GetState()->GetCommand(name) ? 1 : 0;
|
||||
}
|
||||
|
||||
static void CCONV cmAddDefineFlag(void* arg, const char* definition)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
mf->AddDefineFlag(definition);
|
||||
}
|
||||
|
||||
static void CCONV cmAddLinkDirectoryForTarget(void* arg, const char* tgt,
|
||||
const char* d)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
cmTarget* t = mf->FindLocalNonAliasTarget(tgt);
|
||||
if (!t) {
|
||||
cmSystemTools::Error(
|
||||
"Attempt to add link directories to non-existent target: " +
|
||||
std::string(tgt) + " for directory " + std::string(d));
|
||||
return;
|
||||
}
|
||||
t->InsertLinkDirectory(BT<std::string>(d, mf->GetBacktrace()));
|
||||
}
|
||||
|
||||
static void CCONV cmAddExecutable(void* arg, const char* exename, int numSrcs,
|
||||
const char** srcs, int win32)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
std::vector<std::string> srcs2;
|
||||
int i;
|
||||
for (i = 0; i < numSrcs; ++i) {
|
||||
srcs2.emplace_back(srcs[i]);
|
||||
}
|
||||
cmTarget* tg = mf->AddExecutable(exename, srcs2);
|
||||
if (win32) {
|
||||
tg->SetProperty("WIN32_EXECUTABLE", "ON");
|
||||
}
|
||||
}
|
||||
|
||||
static void CCONV cmAddUtilityCommand(void* arg, const char* utilityName,
|
||||
const char* command,
|
||||
const char* arguments, int all,
|
||||
int numDepends, const char** depends,
|
||||
int, const char**)
|
||||
{
|
||||
// Get the makefile instance. Perform an extra variable expansion
|
||||
// now because the API caller expects it.
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
|
||||
// Construct the command line for the command.
|
||||
cmCustomCommandLine commandLine;
|
||||
std::string expand = command;
|
||||
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
||||
if (arguments && arguments[0]) {
|
||||
// TODO: Parse arguments!
|
||||
expand = arguments;
|
||||
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
||||
}
|
||||
cmCustomCommandLines commandLines;
|
||||
commandLines.push_back(commandLine);
|
||||
|
||||
// Accumulate the list of dependencies.
|
||||
std::vector<std::string> depends2;
|
||||
for (int i = 0; i < numDepends; ++i) {
|
||||
expand = depends[i];
|
||||
depends2.push_back(mf->ExpandVariablesInString(expand));
|
||||
}
|
||||
|
||||
// Pass the call to the makefile instance.
|
||||
auto cc = cm::make_unique<cmCustomCommand>();
|
||||
cc->SetDepends(depends2);
|
||||
cc->SetCommandLines(commandLines);
|
||||
mf->AddUtilityCommand(utilityName, !all, std::move(cc));
|
||||
}
|
||||
|
||||
static void CCONV cmAddCustomCommand(void* arg, const char* source,
|
||||
const char* command, int numArgs,
|
||||
const char** args, int numDepends,
|
||||
const char** depends, int numOutputs,
|
||||
const char** outputs, const char* target)
|
||||
{
|
||||
// Get the makefile instance. Perform an extra variable expansion
|
||||
// now because the API caller expects it.
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
|
||||
// Construct the command line for the command.
|
||||
cmCustomCommandLine commandLine;
|
||||
std::string expand = command;
|
||||
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
||||
for (int i = 0; i < numArgs; ++i) {
|
||||
expand = args[i];
|
||||
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
||||
}
|
||||
cmCustomCommandLines commandLines;
|
||||
commandLines.push_back(commandLine);
|
||||
|
||||
// Accumulate the list of dependencies.
|
||||
std::vector<std::string> depends2;
|
||||
for (int i = 0; i < numDepends; ++i) {
|
||||
expand = depends[i];
|
||||
depends2.push_back(mf->ExpandVariablesInString(expand));
|
||||
}
|
||||
|
||||
// Accumulate the list of outputs.
|
||||
std::vector<std::string> outputs2;
|
||||
for (int i = 0; i < numOutputs; ++i) {
|
||||
expand = outputs[i];
|
||||
outputs2.push_back(mf->ExpandVariablesInString(expand));
|
||||
}
|
||||
|
||||
// Pass the call to the makefile instance.
|
||||
const char* no_comment = nullptr;
|
||||
mf->AddCustomCommandOldStyle(target, outputs2, depends2, source,
|
||||
commandLines, no_comment);
|
||||
}
|
||||
|
||||
static void CCONV cmAddCustomCommandToOutput(void* arg, const char* output,
|
||||
const char* command, int numArgs,
|
||||
const char** args,
|
||||
const char* main_dependency,
|
||||
int numDepends,
|
||||
const char** depends)
|
||||
{
|
||||
// Get the makefile instance. Perform an extra variable expansion
|
||||
// now because the API caller expects it.
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
|
||||
// Construct the command line for the command.
|
||||
cmCustomCommandLine commandLine;
|
||||
std::string expand = command;
|
||||
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
||||
for (int i = 0; i < numArgs; ++i) {
|
||||
expand = args[i];
|
||||
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
||||
}
|
||||
cmCustomCommandLines commandLines;
|
||||
commandLines.push_back(commandLine);
|
||||
|
||||
// Accumulate the list of dependencies.
|
||||
std::vector<std::string> depends2;
|
||||
for (int i = 0; i < numDepends; ++i) {
|
||||
expand = depends[i];
|
||||
depends2.push_back(mf->ExpandVariablesInString(expand));
|
||||
}
|
||||
|
||||
// Pass the call to the makefile instance.
|
||||
auto cc = cm::make_unique<cmCustomCommand>();
|
||||
cc->SetOutputs(output);
|
||||
cc->SetMainDependency(main_dependency);
|
||||
cc->SetDepends(depends2);
|
||||
cc->SetCommandLines(commandLines);
|
||||
mf->AddCustomCommandToOutput(std::move(cc));
|
||||
}
|
||||
|
||||
static void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
|
||||
const char* command, int numArgs,
|
||||
const char** args,
|
||||
int commandType)
|
||||
{
|
||||
// Get the makefile instance.
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
|
||||
// Construct the command line for the command. Perform an extra
|
||||
// variable expansion now because the API caller expects it.
|
||||
cmCustomCommandLine commandLine;
|
||||
std::string expand = command;
|
||||
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
||||
for (int i = 0; i < numArgs; ++i) {
|
||||
expand = args[i];
|
||||
commandLine.push_back(mf->ExpandVariablesInString(expand));
|
||||
}
|
||||
cmCustomCommandLines commandLines;
|
||||
commandLines.push_back(commandLine);
|
||||
|
||||
// Select the command type.
|
||||
cmCustomCommandType cctype = cmCustomCommandType::POST_BUILD;
|
||||
switch (commandType) {
|
||||
case CM_PRE_BUILD:
|
||||
cctype = cmCustomCommandType::PRE_BUILD;
|
||||
break;
|
||||
case CM_PRE_LINK:
|
||||
cctype = cmCustomCommandType::PRE_LINK;
|
||||
break;
|
||||
case CM_POST_BUILD:
|
||||
cctype = cmCustomCommandType::POST_BUILD;
|
||||
break;
|
||||
}
|
||||
|
||||
// Pass the call to the makefile instance.
|
||||
auto cc = cm::make_unique<cmCustomCommand>();
|
||||
cc->SetCommandLines(commandLines);
|
||||
mf->AddCustomCommandToTarget(target, cctype, std::move(cc));
|
||||
}
|
||||
|
||||
static void addLinkLibrary(cmMakefile* mf, std::string const& target,
|
||||
std::string const& lib, cmTargetLinkLibraryType llt)
|
||||
{
|
||||
cmTarget* t = mf->FindLocalNonAliasTarget(target);
|
||||
if (!t) {
|
||||
std::ostringstream e;
|
||||
e << "Attempt to add link library \"" << lib << "\" to target \"" << target
|
||||
<< "\" which is not built in this directory.";
|
||||
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
||||
return;
|
||||
}
|
||||
|
||||
cmTarget* tgt = mf->GetGlobalGenerator()->FindTarget(lib);
|
||||
if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) &&
|
||||
(tgt->GetType() != cmStateEnums::SHARED_LIBRARY) &&
|
||||
(tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
|
||||
!tgt->IsExecutableWithExports()) {
|
||||
std::ostringstream e;
|
||||
e << "Target \"" << lib << "\" of type "
|
||||
<< cmState::GetTargetTypeName(tgt->GetType())
|
||||
<< " may not be linked into another target. "
|
||||
<< "One may link only to STATIC or SHARED libraries, or "
|
||||
<< "to executables with the ENABLE_EXPORTS property set.";
|
||||
mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
|
||||
}
|
||||
|
||||
t->AddLinkLibrary(*mf, lib, llt);
|
||||
}
|
||||
|
||||
static void CCONV cmAddLinkLibraryForTarget(void* arg, const char* tgt,
|
||||
const char* value, int libtype)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
|
||||
switch (libtype) {
|
||||
case CM_LIBRARY_GENERAL:
|
||||
addLinkLibrary(mf, tgt, value, GENERAL_LibraryType);
|
||||
break;
|
||||
case CM_LIBRARY_DEBUG:
|
||||
addLinkLibrary(mf, tgt, value, DEBUG_LibraryType);
|
||||
break;
|
||||
case CM_LIBRARY_OPTIMIZED:
|
||||
addLinkLibrary(mf, tgt, value, OPTIMIZED_LibraryType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void CCONV cmAddLibrary(void* arg, const char* libname, int shared,
|
||||
int numSrcs, const char** srcs)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
std::vector<std::string> srcs2;
|
||||
int i;
|
||||
for (i = 0; i < numSrcs; ++i) {
|
||||
srcs2.emplace_back(srcs[i]);
|
||||
}
|
||||
mf->AddLibrary(
|
||||
libname,
|
||||
(shared ? cmStateEnums::SHARED_LIBRARY : cmStateEnums::STATIC_LIBRARY),
|
||||
srcs2);
|
||||
}
|
||||
|
||||
static char CCONV* cmExpandVariablesInString(void* arg, const char* source,
|
||||
int escapeQuotes, int atOnly)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
std::string barf = source;
|
||||
std::string const& result =
|
||||
mf->ExpandVariablesInString(barf, escapeQuotes != 0, atOnly != 0);
|
||||
return strdup(result.c_str());
|
||||
}
|
||||
|
||||
static int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
|
||||
const char** args)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
|
||||
std::vector<cmListFileArgument> lffArgs;
|
||||
lffArgs.reserve(numArgs);
|
||||
for (int i = 0; i < numArgs; ++i) {
|
||||
// Assume all arguments are quoted.
|
||||
lffArgs.emplace_back(args[i], cmListFileArgument::Quoted, 0);
|
||||
}
|
||||
|
||||
cmListFileFunction lff{ name, 0, 0, std::move(lffArgs) };
|
||||
cmExecutionStatus status(*mf);
|
||||
return mf->ExecuteCommand(lff, status);
|
||||
}
|
||||
|
||||
static void CCONV cmExpandSourceListArguments(void* arg, int numArgs,
|
||||
const char** args, int* resArgc,
|
||||
char*** resArgv,
|
||||
unsigned int startArgumentIndex)
|
||||
{
|
||||
(void)arg;
|
||||
(void)startArgumentIndex;
|
||||
std::vector<std::string> result;
|
||||
int i;
|
||||
for (i = 0; i < numArgs; ++i) {
|
||||
result.emplace_back(args[i]);
|
||||
}
|
||||
int resargc = static_cast<int>(result.size());
|
||||
char** resargv = nullptr;
|
||||
if (resargc) {
|
||||
resargv = (char**)malloc(resargc * sizeof(char*));
|
||||
}
|
||||
for (i = 0; i < resargc; ++i) {
|
||||
resargv[i] = strdup(result[i].c_str());
|
||||
}
|
||||
*resArgc = resargc;
|
||||
*resArgv = resargv;
|
||||
}
|
||||
|
||||
static void CCONV cmFreeArguments(int argc, char** argv)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
free(argv[i]);
|
||||
}
|
||||
free(argv);
|
||||
}
|
||||
|
||||
static int CCONV cmGetTotalArgumentSize(int argc, char** argv)
|
||||
{
|
||||
int i;
|
||||
int result = 0;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
if (argv[i]) {
|
||||
result = result + static_cast<int>(strlen(argv[i]));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Source file proxy object to support the old cmSourceFile/cmMakefile
|
||||
// API for source files.
|
||||
struct cmCPluginAPISourceFile
|
||||
{
|
||||
cmSourceFile* RealSourceFile = nullptr;
|
||||
std::string SourceName;
|
||||
std::string SourceExtension;
|
||||
std::string FullPath;
|
||||
std::vector<std::string> Depends;
|
||||
cmPropertyMap Properties;
|
||||
};
|
||||
|
||||
// Keep a map from real cmSourceFile instances stored in a makefile to
|
||||
// the CPluginAPI proxy source file.
|
||||
using cmCPluginAPISourceFileMap =
|
||||
std::map<cmSourceFile*, std::unique_ptr<cmCPluginAPISourceFile>>;
|
||||
static cmCPluginAPISourceFileMap cmCPluginAPISourceFiles;
|
||||
|
||||
static void* CCONV cmCreateSourceFile()
|
||||
{
|
||||
return new cmCPluginAPISourceFile;
|
||||
}
|
||||
|
||||
static void* CCONV cmCreateNewSourceFile(void*)
|
||||
{
|
||||
return new cmCPluginAPISourceFile;
|
||||
}
|
||||
|
||||
static void CCONV cmDestroySourceFile(void* arg)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
// Only delete if it was created by cmCreateSourceFile or
|
||||
// cmCreateNewSourceFile and is therefore not in the map.
|
||||
if (!sf->RealSourceFile) {
|
||||
delete sf;
|
||||
}
|
||||
}
|
||||
|
||||
static void CCONV* cmGetSource(void* arg, const char* name)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
if (cmSourceFile* rsf = mf->GetSource(name)) {
|
||||
// Lookup the proxy source file object for this source.
|
||||
auto i = cmCPluginAPISourceFiles.find(rsf);
|
||||
if (i == cmCPluginAPISourceFiles.end()) {
|
||||
// Create a proxy source file object for this source.
|
||||
auto sf = cm::make_unique<cmCPluginAPISourceFile>();
|
||||
sf->RealSourceFile = rsf;
|
||||
sf->FullPath = rsf->ResolveFullPath();
|
||||
sf->SourceName =
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath);
|
||||
sf->SourceExtension =
|
||||
cmSystemTools::GetFilenameLastExtension(sf->FullPath);
|
||||
|
||||
// Store the proxy in the map so it can be reused and deleted later.
|
||||
i = cmCPluginAPISourceFiles.emplace(rsf, std::move(sf)).first;
|
||||
}
|
||||
return i->second.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void* CCONV cmAddSource(void* arg, void* arg2)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
cmCPluginAPISourceFile* osf = static_cast<cmCPluginAPISourceFile*>(arg2);
|
||||
if (osf->FullPath.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Create the real cmSourceFile instance and copy over saved information.
|
||||
cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath);
|
||||
rsf->SetProperties(osf->Properties);
|
||||
// In case the properties contain the GENERATED property,
|
||||
// mark the real cmSourceFile as generated.
|
||||
if (rsf->GetIsGenerated()) {
|
||||
rsf->MarkAsGenerated();
|
||||
}
|
||||
for (std::string const& d : osf->Depends) {
|
||||
rsf->AddDepend(d);
|
||||
}
|
||||
|
||||
// Create the proxy for the real source file.
|
||||
auto sf = cm::make_unique<cmCPluginAPISourceFile>();
|
||||
sf->RealSourceFile = rsf;
|
||||
sf->FullPath = osf->FullPath;
|
||||
sf->SourceName = osf->SourceName;
|
||||
sf->SourceExtension = osf->SourceExtension;
|
||||
|
||||
// Store the proxy in the map so it can be reused and deleted later.
|
||||
auto* value = sf.get();
|
||||
cmCPluginAPISourceFiles[rsf] = std::move(sf);
|
||||
return value;
|
||||
}
|
||||
|
||||
static const char* CCONV cmSourceFileGetSourceName(void* arg)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
return sf->SourceName.c_str();
|
||||
}
|
||||
|
||||
static const char* CCONV cmSourceFileGetFullPath(void* arg)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
return sf->FullPath.c_str();
|
||||
}
|
||||
|
||||
static const char* CCONV cmSourceFileGetProperty(void* arg, const char* prop)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
if (cmSourceFile* rsf = sf->RealSourceFile) {
|
||||
return rsf->GetProperty(prop).GetCStr();
|
||||
}
|
||||
if (!strcmp(prop, "LOCATION")) {
|
||||
return sf->FullPath.c_str();
|
||||
}
|
||||
return sf->Properties.GetPropertyValue(prop).GetCStr();
|
||||
}
|
||||
|
||||
static int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
if (cmSourceFile* rsf = sf->RealSourceFile) {
|
||||
return rsf->GetPropertyAsBool(prop) ? 1 : 0;
|
||||
}
|
||||
return cmIsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0;
|
||||
}
|
||||
|
||||
static void CCONV cmSourceFileSetProperty(void* arg, const char* prop,
|
||||
const char* value)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
if (cmSourceFile* rsf = sf->RealSourceFile) {
|
||||
if (!value) {
|
||||
rsf->RemoveProperty(prop);
|
||||
} else {
|
||||
rsf->SetProperty(prop, value);
|
||||
}
|
||||
} else if (prop) {
|
||||
if (!value) {
|
||||
value = "NOTFOUND";
|
||||
}
|
||||
sf->Properties.SetProperty(prop, value);
|
||||
}
|
||||
}
|
||||
|
||||
static void CCONV cmSourceFileAddDepend(void* arg, const char* depend)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
if (cmSourceFile* rsf = sf->RealSourceFile) {
|
||||
rsf->AddDepend(depend);
|
||||
} else {
|
||||
sf->Depends.emplace_back(depend);
|
||||
}
|
||||
}
|
||||
|
||||
static void CCONV cmSourceFileSetName(void* arg, const char* name,
|
||||
const char* dir, int numSourceExtensions,
|
||||
const char** sourceExtensions,
|
||||
int numHeaderExtensions,
|
||||
const char** headerExtensions)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
if (sf->RealSourceFile) {
|
||||
// SetName is allowed only on temporary source files created by
|
||||
// the command for building and passing to AddSource.
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> sourceExts;
|
||||
std::vector<std::string> headerExts;
|
||||
int i;
|
||||
for (i = 0; i < numSourceExtensions; ++i) {
|
||||
sourceExts.emplace_back(sourceExtensions[i]);
|
||||
}
|
||||
for (i = 0; i < numHeaderExtensions; ++i) {
|
||||
headerExts.emplace_back(headerExtensions[i]);
|
||||
}
|
||||
|
||||
// Save the original name given.
|
||||
sf->SourceName = name;
|
||||
|
||||
// Convert the name to a full path in case the given name is a
|
||||
// relative path.
|
||||
std::string pathname = cmSystemTools::CollapseFullPath(name, dir);
|
||||
|
||||
// First try and see whether the listed file can be found
|
||||
// as is without extensions added on.
|
||||
std::string hname = pathname;
|
||||
if (cmSystemTools::FileExists(hname)) {
|
||||
sf->SourceName = cmSystemTools::GetFilenamePath(name);
|
||||
if (!sf->SourceName.empty()) {
|
||||
sf->SourceName += "/";
|
||||
}
|
||||
sf->SourceName += cmSystemTools::GetFilenameWithoutLastExtension(name);
|
||||
std::string::size_type pos = hname.rfind('.');
|
||||
if (pos != std::string::npos) {
|
||||
sf->SourceExtension = hname.substr(pos + 1, hname.size() - pos);
|
||||
if (cmSystemTools::FileIsFullPath(name)) {
|
||||
std::string::size_type pos2 = hname.rfind('/');
|
||||
if (pos2 != std::string::npos) {
|
||||
sf->SourceName = hname.substr(pos2 + 1, pos - pos2 - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sf->FullPath = hname;
|
||||
return;
|
||||
}
|
||||
|
||||
// Next, try the various source extensions
|
||||
for (std::string const& ext : sourceExts) {
|
||||
hname = cmStrCat(pathname, '.', ext);
|
||||
if (cmSystemTools::FileExists(hname)) {
|
||||
sf->SourceExtension = ext;
|
||||
sf->FullPath = hname;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, try the various header extensions
|
||||
for (std::string const& ext : headerExts) {
|
||||
hname = cmStrCat(pathname, '.', ext);
|
||||
if (cmSystemTools::FileExists(hname)) {
|
||||
sf->SourceExtension = ext;
|
||||
sf->FullPath = hname;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream e;
|
||||
e << "Cannot find source file \"" << pathname << "\"";
|
||||
e << "\n\nTried extensions";
|
||||
for (std::string const& ext : sourceExts) {
|
||||
e << " ." << ext;
|
||||
}
|
||||
for (std::string const& ext : headerExts) {
|
||||
e << " ." << ext;
|
||||
}
|
||||
cmSystemTools::Error(e.str());
|
||||
}
|
||||
|
||||
static void CCONV cmSourceFileSetName2(void* arg, const char* name,
|
||||
const char* dir, const char* ext,
|
||||
int headerFileOnly)
|
||||
{
|
||||
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
|
||||
if (sf->RealSourceFile) {
|
||||
// SetName is allowed only on temporary source files created by
|
||||
// the command for building and passing to AddSource.
|
||||
return;
|
||||
}
|
||||
|
||||
// Implement the old SetName method code here.
|
||||
if (headerFileOnly) {
|
||||
sf->Properties.SetProperty("HEADER_FILE_ONLY", "1");
|
||||
}
|
||||
sf->SourceName = name;
|
||||
std::string fname = sf->SourceName;
|
||||
if (cmNonempty(ext)) {
|
||||
fname += ".";
|
||||
fname += ext;
|
||||
}
|
||||
sf->FullPath = cmSystemTools::CollapseFullPath(fname, dir);
|
||||
cmSystemTools::ConvertToUnixSlashes(sf->FullPath);
|
||||
sf->SourceExtension = ext;
|
||||
}
|
||||
|
||||
static char* CCONV cmGetFilenameWithoutExtension(const char* name)
|
||||
{
|
||||
std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
|
||||
return strdup(sres.c_str());
|
||||
}
|
||||
|
||||
static char* CCONV cmGetFilenamePath(const char* name)
|
||||
{
|
||||
std::string sres = cmSystemTools::GetFilenamePath(name);
|
||||
return strdup(sres.c_str());
|
||||
}
|
||||
|
||||
static char* CCONV cmCapitalized(const char* name)
|
||||
{
|
||||
std::string sres = cmSystemTools::Capitalized(name);
|
||||
return strdup(sres.c_str());
|
||||
}
|
||||
|
||||
static void CCONV cmCopyFileIfDifferent(const char* name1, const char* name2)
|
||||
{
|
||||
cmSystemTools::CopyFileIfDifferent(name1, name2);
|
||||
}
|
||||
|
||||
static void CCONV cmRemoveFile(const char* name)
|
||||
{
|
||||
cmSystemTools::RemoveFile(name);
|
||||
}
|
||||
|
||||
static void CCONV cmDisplayStatus(void* arg, const char* message)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
mf->DisplayStatus(message, -1);
|
||||
}
|
||||
|
||||
static void CCONV cmFree(void* data)
|
||||
{
|
||||
free(data);
|
||||
}
|
||||
|
||||
static void CCONV DefineSourceFileProperty(void* arg, const char* name,
|
||||
const char* briefDocs,
|
||||
const char* longDocs, int chained)
|
||||
{
|
||||
cmMakefile* mf = static_cast<cmMakefile*>(arg);
|
||||
mf->GetState()->DefineProperty(name, cmProperty::SOURCE_FILE,
|
||||
briefDocs ? briefDocs : "",
|
||||
longDocs ? longDocs : "", chained != 0);
|
||||
}
|
||||
|
||||
} // close the extern "C" scope
|
||||
|
||||
static cmCAPI cmStaticCAPI = {
|
||||
cmGetClientData,
|
||||
cmGetTotalArgumentSize,
|
||||
cmFreeArguments,
|
||||
cmSetClientData,
|
||||
cmSetError,
|
||||
cmAddCacheDefinition,
|
||||
cmAddCustomCommand,
|
||||
cmAddDefineFlag,
|
||||
cmAddDefinition,
|
||||
cmAddExecutable,
|
||||
cmAddLibrary,
|
||||
cmAddLinkDirectoryForTarget,
|
||||
cmAddLinkLibraryForTarget,
|
||||
cmAddUtilityCommand,
|
||||
cmCommandExists,
|
||||
cmExecuteCommand,
|
||||
cmExpandSourceListArguments,
|
||||
cmExpandVariablesInString,
|
||||
cmGetCacheMajorVersion,
|
||||
cmGetCacheMinorVersion,
|
||||
cmGetCurrentDirectory,
|
||||
cmGetCurrentOutputDirectory,
|
||||
cmGetDefinition,
|
||||
cmGetHomeDirectory,
|
||||
cmGetHomeOutputDirectory,
|
||||
cmGetMajorVersion,
|
||||
cmGetMinorVersion,
|
||||
cmGetProjectName,
|
||||
cmGetStartDirectory,
|
||||
cmGetStartOutputDirectory,
|
||||
cmIsOn,
|
||||
|
||||
cmAddSource,
|
||||
cmCreateSourceFile,
|
||||
cmDestroySourceFile,
|
||||
cmGetSource,
|
||||
cmSourceFileAddDepend,
|
||||
cmSourceFileGetProperty,
|
||||
cmSourceFileGetPropertyAsBool,
|
||||
cmSourceFileGetSourceName,
|
||||
cmSourceFileGetFullPath,
|
||||
cmSourceFileSetName,
|
||||
cmSourceFileSetName2,
|
||||
cmSourceFileSetProperty,
|
||||
|
||||
cmCapitalized,
|
||||
cmCopyFileIfDifferent,
|
||||
cmGetFilenameWithoutExtension,
|
||||
cmGetFilenamePath,
|
||||
cmRemoveFile,
|
||||
cmFree,
|
||||
|
||||
cmAddCustomCommandToOutput,
|
||||
cmAddCustomCommandToTarget,
|
||||
cmDisplayStatus,
|
||||
cmCreateNewSourceFile,
|
||||
DefineSourceFileProperty,
|
||||
};
|
||||
@@ -1,236 +0,0 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
/* This header file defines the API that loadable commands can use. In many
|
||||
of these commands C++ instances of cmMakefile of cmSourceFile are passed
|
||||
in as arguments or returned. In these cases they are passed as a void *
|
||||
argument. In the function prototypes mf is used to represent a makefile
|
||||
and sf is used to represent a source file. The functions are grouped
|
||||
loosely into four groups 1) Utility 2) cmMakefile 3) cmSourceFile 4)
|
||||
cmSystemTools. Within each grouping functions are listed alphabetically */
|
||||
/*=========================================================================*/
|
||||
#ifndef cmCPluginAPI_h /* NOLINT(cmake-use-pragma-once) */
|
||||
#define cmCPluginAPI_h
|
||||
|
||||
#define CMAKE_VERSION_MAJOR 2
|
||||
#define CMAKE_VERSION_MINOR 5
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
# define CCONV __cdecl
|
||||
#else
|
||||
# define CCONV
|
||||
#endif
|
||||
/*=========================================================================
|
||||
this is the structure of function entry points that a plugin may call. This
|
||||
structure must be kept in sync with the static decaled at the bottom of
|
||||
cmCPLuginAPI.cxx
|
||||
=========================================================================*/
|
||||
/* NOLINTNEXTLINE(modernize-use-using) */
|
||||
typedef struct
|
||||
{
|
||||
/*=========================================================================
|
||||
Here we define the set of functions that a plugin may call. The first group
|
||||
of functions are utility functions that are specific to the plugin API
|
||||
=========================================================================*/
|
||||
/* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
|
||||
information is passed from the InitialPass to FinalPass for commands
|
||||
that need a FinalPass and need information from the InitialPass */
|
||||
void*(CCONV* GetClientData)(void* info);
|
||||
/* return the summed size in characters of all the arguments */
|
||||
int(CCONV* GetTotalArgumentSize)(int argc, char** argv);
|
||||
/* free all the memory associated with an argc, argv pair */
|
||||
void(CCONV* FreeArguments)(int argc, char** argv);
|
||||
/* set/Get the ClientData in the cmLoadedCommandInfo structure, this is how
|
||||
information is passed from the InitialPass to FinalPass for commands
|
||||
that need a FinalPass and need information from the InitialPass */
|
||||
void(CCONV* SetClientData)(void* info, void* cd);
|
||||
/* when an error occurs, call this function to set the error string */
|
||||
void(CCONV* SetError)(void* info, const char* err);
|
||||
|
||||
/*=========================================================================
|
||||
The following functions all directly map to methods in the cmMakefile
|
||||
class. See cmMakefile.h for descriptions of what each method does. All of
|
||||
these methods take the void * makefile pointer as their first argument.
|
||||
=========================================================================*/
|
||||
void(CCONV* AddCacheDefinition)(void* mf, const char* name,
|
||||
const char* value, const char* doc,
|
||||
int cachetype);
|
||||
void(CCONV* AddCustomCommand)(void* mf, const char* source,
|
||||
const char* command, int numArgs,
|
||||
const char** args, int numDepends,
|
||||
const char** depends, int numOutputs,
|
||||
const char** outputs, const char* target);
|
||||
void(CCONV* AddDefineFlag)(void* mf, const char* definition);
|
||||
void(CCONV* AddDefinition)(void* mf, const char* name, const char* value);
|
||||
void(CCONV* AddExecutable)(void* mf, const char* exename, int numSrcs,
|
||||
const char** srcs, int win32);
|
||||
void(CCONV* AddLibrary)(void* mf, const char* libname, int shared,
|
||||
int numSrcs, const char** srcs);
|
||||
void(CCONV* AddLinkDirectoryForTarget)(void* mf, const char* tgt,
|
||||
const char* d);
|
||||
void(CCONV* AddLinkLibraryForTarget)(void* mf, const char* tgt,
|
||||
const char* libname, int libtype);
|
||||
void(CCONV* AddUtilityCommand)(void* mf, const char* utilityName,
|
||||
const char* command, const char* arguments,
|
||||
int all, int numDepends, const char** depends,
|
||||
int numOutputs, const char** outputs);
|
||||
int(CCONV* CommandExists)(void* mf, const char* name);
|
||||
int(CCONV* ExecuteCommand)(void* mf, const char* name, int numArgs,
|
||||
const char** args);
|
||||
void(CCONV* ExpandSourceListArguments)(void* mf, int argc, const char** argv,
|
||||
int* resArgc, char*** resArgv,
|
||||
unsigned int startArgumentIndex);
|
||||
char*(CCONV* ExpandVariablesInString)(void* mf, const char* source,
|
||||
int escapeQuotes, int atOnly);
|
||||
unsigned int(CCONV* GetCacheMajorVersion)(void* mf);
|
||||
unsigned int(CCONV* GetCacheMinorVersion)(void* mf);
|
||||
const char*(CCONV* GetCurrentDirectory)(void* mf);
|
||||
const char*(CCONV* GetCurrentOutputDirectory)(void* mf);
|
||||
const char*(CCONV* GetDefinition)(void* mf, const char* def);
|
||||
const char*(CCONV* GetHomeDirectory)(void* mf);
|
||||
const char*(CCONV* GetHomeOutputDirectory)(void* mf);
|
||||
unsigned int(CCONV* GetMajorVersion)(void* mf);
|
||||
unsigned int(CCONV* GetMinorVersion)(void* mf);
|
||||
const char*(CCONV* GetProjectName)(void* mf);
|
||||
const char*(CCONV* GetStartDirectory)(void* mf);
|
||||
const char*(CCONV* GetStartOutputDirectory)(void* mf);
|
||||
int(CCONV* IsOn)(void* mf, const char* name);
|
||||
|
||||
/*=========================================================================
|
||||
The following functions are designed to operate or manipulate
|
||||
cmSourceFiles. Please see cmSourceFile.h for additional information on many
|
||||
of these methods. Some of these methods are in cmMakefile.h.
|
||||
=========================================================================*/
|
||||
void*(CCONV* AddSource)(void* mf, void* sf);
|
||||
void*(CCONV* CreateSourceFile)();
|
||||
void(CCONV* DestroySourceFile)(void* sf);
|
||||
void*(CCONV* GetSource)(void* mf, const char* sourceName);
|
||||
void(CCONV* SourceFileAddDepend)(void* sf, const char* depend);
|
||||
const char*(CCONV* SourceFileGetProperty)(void* sf, const char* prop);
|
||||
int(CCONV* SourceFileGetPropertyAsBool)(void* sf, const char* prop);
|
||||
const char*(CCONV* SourceFileGetSourceName)(void* sf);
|
||||
const char*(CCONV* SourceFileGetFullPath)(void* sf);
|
||||
void(CCONV* SourceFileSetName)(void* sf, const char* name, const char* dir,
|
||||
int numSourceExtensions,
|
||||
const char** sourceExtensions,
|
||||
int numHeaderExtensions,
|
||||
const char** headerExtensions);
|
||||
void(CCONV* SourceFileSetName2)(void* sf, const char* name, const char* dir,
|
||||
const char* ext, int headerFileOnly);
|
||||
void(CCONV* SourceFileSetProperty)(void* sf, const char* prop,
|
||||
const char* value);
|
||||
|
||||
/*=========================================================================
|
||||
The following methods are from cmSystemTools.h see that file for specific
|
||||
documentation on each method.
|
||||
=========================================================================*/
|
||||
char*(CCONV* Capitalized)(const char*);
|
||||
void(CCONV* CopyFileIfDifferent)(const char* f1, const char* f2);
|
||||
char*(CCONV* GetFilenameWithoutExtension)(const char*);
|
||||
char*(CCONV* GetFilenamePath)(const char*);
|
||||
void(CCONV* RemoveFile)(const char* f1);
|
||||
void(CCONV* Free)(void*);
|
||||
|
||||
/*=========================================================================
|
||||
The following are new functions added after 1.6
|
||||
=========================================================================*/
|
||||
void(CCONV* AddCustomCommandToOutput)(void* mf, const char* output,
|
||||
const char* command, int numArgs,
|
||||
const char** args,
|
||||
const char* main_dependency,
|
||||
int numDepends, const char** depends);
|
||||
void(CCONV* AddCustomCommandToTarget)(void* mf, const char* target,
|
||||
const char* command, int numArgs,
|
||||
const char** args, int commandType);
|
||||
|
||||
/* display status information */
|
||||
void(CCONV* DisplaySatus)(void* info, const char* message);
|
||||
|
||||
/* new functions added after 2.4 */
|
||||
void*(CCONV* CreateNewSourceFile)(void* mf);
|
||||
void(CCONV* DefineSourceFileProperty)(void* mf, const char* name,
|
||||
const char* briefDocs,
|
||||
const char* longDocs, int chained);
|
||||
|
||||
/* this is the end of the C function stub API structure */
|
||||
} cmCAPI;
|
||||
|
||||
/*=========================================================================
|
||||
CM_PLUGIN_EXPORT should be used by plugins
|
||||
=========================================================================*/
|
||||
#ifdef _WIN32
|
||||
# define CM_PLUGIN_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
# define CM_PLUGIN_EXPORT
|
||||
#endif
|
||||
|
||||
/*=========================================================================
|
||||
define the different types of cache entries, see cmCacheManager.h for more
|
||||
information
|
||||
=========================================================================*/
|
||||
#define CM_CACHE_BOOL 0
|
||||
#define CM_CACHE_PATH 1
|
||||
#define CM_CACHE_FILEPATH 2
|
||||
#define CM_CACHE_STRING 3
|
||||
#define CM_CACHE_INTERNAL 4
|
||||
#define CM_CACHE_STATIC 5
|
||||
|
||||
/*=========================================================================
|
||||
define the different types of compiles a library may be
|
||||
=========================================================================*/
|
||||
#define CM_LIBRARY_GENERAL 0
|
||||
#define CM_LIBRARY_DEBUG 1
|
||||
#define CM_LIBRARY_OPTIMIZED 2
|
||||
|
||||
/*=========================================================================
|
||||
define the different types of custom commands for a target
|
||||
=========================================================================*/
|
||||
#define CM_PRE_BUILD 0
|
||||
#define CM_PRE_LINK 1
|
||||
#define CM_POST_BUILD 2
|
||||
|
||||
/*=========================================================================
|
||||
Finally we define the key data structures and function prototypes
|
||||
=========================================================================*/
|
||||
|
||||
/* NOLINTNEXTLINE(modernize-use-using) */
|
||||
typedef const char*(CCONV* CM_DOC_FUNCTION)();
|
||||
|
||||
/* NOLINTNEXTLINE(modernize-use-using) */
|
||||
typedef int(CCONV* CM_INITIAL_PASS_FUNCTION)(void* info, void* mf, int argc,
|
||||
char*[]);
|
||||
|
||||
/* NOLINTNEXTLINE(modernize-use-using) */
|
||||
typedef void(CCONV* CM_FINAL_PASS_FUNCTION)(void* info, void* mf);
|
||||
|
||||
/* NOLINTNEXTLINE(modernize-use-using) */
|
||||
typedef void(CCONV* CM_DESTRUCTOR_FUNCTION)(void* info);
|
||||
|
||||
/* NOLINTNEXTLINE(modernize-use-using) */
|
||||
typedef struct
|
||||
{
|
||||
unsigned long reserved1; /* Reserved for future use. DO NOT USE. */
|
||||
unsigned long reserved2; /* Reserved for future use. DO NOT USE. */
|
||||
cmCAPI* CAPI;
|
||||
int m_Inherited; /* this ivar is no longer used in CMake 2.2 or later */
|
||||
CM_INITIAL_PASS_FUNCTION InitialPass;
|
||||
CM_FINAL_PASS_FUNCTION FinalPass;
|
||||
CM_DESTRUCTOR_FUNCTION Destructor;
|
||||
CM_DOC_FUNCTION GetTerseDocumentation;
|
||||
CM_DOC_FUNCTION GetFullDocumentation;
|
||||
const char* Name;
|
||||
char* Error;
|
||||
void* ClientData;
|
||||
} cmLoadedCommandInfo;
|
||||
|
||||
/* NOLINTNEXTLINE(modernize-use-using) */
|
||||
typedef void(CCONV* CM_INIT_FUNCTION)(cmLoadedCommandInfo*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -104,7 +104,6 @@
|
||||
# include "cmInstallProgramsCommand.h"
|
||||
# include "cmLinkLibrariesCommand.h"
|
||||
# include "cmLoadCacheCommand.h"
|
||||
# include "cmLoadCommandCommand.h"
|
||||
# include "cmOutputRequiredFilesCommand.h"
|
||||
# include "cmQTWrapCPPCommand.h"
|
||||
# include "cmQTWrapUICommand.h"
|
||||
@@ -307,9 +306,8 @@ void GetProjectCommands(cmState* state)
|
||||
cmPolicies::CMP0033,
|
||||
"The export_library_dependencies command should not be called; "
|
||||
"see CMP0033.");
|
||||
state->AddDisallowedCommand(
|
||||
"load_command", cmLoadCommandCommand, cmPolicies::CMP0031,
|
||||
"The load_command command should not be called; see CMP0031.");
|
||||
state->AddRemovedCommand(
|
||||
"load_command", "The load_command command has been removed; see CMP0031.");
|
||||
state->AddDisallowedCommand(
|
||||
"output_required_files", cmOutputRequiredFilesCommand, cmPolicies::CMP0032,
|
||||
"The output_required_files command should not be called; see CMP0032.");
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
|
||||
#if !defined(_WIN32) && !defined(__sun) && !defined(__OpenBSD__)
|
||||
// POSIX APIs are needed
|
||||
// NOLINTNEXTLINE(bugprone-reserved-identifier)
|
||||
# define _POSIX_C_SOURCE 200809L
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
// For isascii
|
||||
// NOLINTNEXTLINE(bugprone-reserved-identifier)
|
||||
# define _XOPEN_SOURCE 700
|
||||
#endif
|
||||
|
||||
#include "cmLoadCommandCommand.h"
|
||||
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <cm/memory>
|
||||
|
||||
#include "cmCPluginAPI.h"
|
||||
#include "cmDynamicLoader.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
// NOLINTNEXTLINE(bugprone-suspicious-include)
|
||||
#include "cmCPluginAPI.cxx"
|
||||
|
||||
#ifdef __QNX__
|
||||
# include <malloc.h> /* for malloc/free on QNX */
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning("-Wcast-function-type-strict")
|
||||
# pragma clang diagnostic ignored "-Wcast-function-type-strict"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
const char* LastName = nullptr;
|
||||
|
||||
extern "C" void TrapsForSignals(int sig);
|
||||
extern "C" void TrapsForSignals(int sig)
|
||||
{
|
||||
fprintf(stderr, "CMake loaded command %s crashed with signal: %d.\n",
|
||||
LastName, sig);
|
||||
}
|
||||
|
||||
struct SignalHandlerGuard
|
||||
{
|
||||
explicit SignalHandlerGuard(const char* name)
|
||||
{
|
||||
LastName = name ? name : "????";
|
||||
|
||||
signal(SIGSEGV, TrapsForSignals);
|
||||
#ifdef SIGBUS
|
||||
signal(SIGBUS, TrapsForSignals);
|
||||
#endif
|
||||
signal(SIGILL, TrapsForSignals);
|
||||
}
|
||||
|
||||
~SignalHandlerGuard()
|
||||
{
|
||||
signal(SIGSEGV, nullptr);
|
||||
#ifdef SIGBUS
|
||||
signal(SIGBUS, nullptr);
|
||||
#endif
|
||||
signal(SIGILL, nullptr);
|
||||
}
|
||||
|
||||
SignalHandlerGuard(SignalHandlerGuard const&) = delete;
|
||||
SignalHandlerGuard& operator=(SignalHandlerGuard const&) = delete;
|
||||
};
|
||||
|
||||
struct LoadedCommandImpl : cmLoadedCommandInfo
|
||||
{
|
||||
explicit LoadedCommandImpl(CM_INIT_FUNCTION init)
|
||||
: cmLoadedCommandInfo{ 0, 0, &cmStaticCAPI, 0,
|
||||
nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, nullptr }
|
||||
{
|
||||
init(this);
|
||||
}
|
||||
|
||||
~LoadedCommandImpl()
|
||||
{
|
||||
if (this->Destructor) {
|
||||
SignalHandlerGuard guard(this->Name);
|
||||
#if defined(__NVCOMPILER) || defined(__LCC__)
|
||||
static_cast<void>(guard); // convince compiler var is used
|
||||
#endif
|
||||
this->Destructor(this);
|
||||
}
|
||||
if (this->Error) {
|
||||
free(this->Error);
|
||||
}
|
||||
}
|
||||
|
||||
LoadedCommandImpl(LoadedCommandImpl const&) = delete;
|
||||
LoadedCommandImpl& operator=(LoadedCommandImpl const&) = delete;
|
||||
|
||||
int DoInitialPass(cmMakefile* mf, int argc, char* argv[])
|
||||
{
|
||||
SignalHandlerGuard guard(this->Name);
|
||||
#if defined(__NVCOMPILER) || defined(__LCC__)
|
||||
static_cast<void>(guard); // convince compiler var is used
|
||||
#endif
|
||||
return this->InitialPass(this, mf, argc, argv);
|
||||
}
|
||||
|
||||
void DoFinalPass(cmMakefile* mf)
|
||||
{
|
||||
SignalHandlerGuard guard(this->Name);
|
||||
#if defined(__NVCOMPILER) || defined(__LCC__)
|
||||
static_cast<void>(guard); // convince compiler var is used
|
||||
#endif
|
||||
this->FinalPass(this, mf);
|
||||
}
|
||||
};
|
||||
|
||||
// a class for loadabple commands
|
||||
class cmLoadedCommand
|
||||
{
|
||||
public:
|
||||
explicit cmLoadedCommand(CM_INIT_FUNCTION init)
|
||||
: Impl(std::make_shared<LoadedCommandImpl>(init))
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(std::vector<cmListFileArgument> const& args,
|
||||
cmExecutionStatus& status) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<LoadedCommandImpl> Impl;
|
||||
};
|
||||
|
||||
bool cmLoadedCommand::operator()(
|
||||
std::vector<cmListFileArgument> const& arguments,
|
||||
cmExecutionStatus& status) const
|
||||
{
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
|
||||
std::vector<std::string> args;
|
||||
if (!mf.ExpandArguments(arguments, args)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this->Impl->InitialPass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// clear the error string
|
||||
if (this->Impl->Error) {
|
||||
free(this->Impl->Error);
|
||||
}
|
||||
|
||||
// create argc and argv and then invoke the command
|
||||
int argc = static_cast<int>(args.size());
|
||||
char** argv = nullptr;
|
||||
if (argc) {
|
||||
argv = static_cast<char**>(malloc(argc * sizeof(char*)));
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
argv[i] = strdup(args[i].c_str());
|
||||
}
|
||||
int result = this->Impl->DoInitialPass(&mf, argc, argv);
|
||||
cmFreeArguments(argc, argv);
|
||||
|
||||
if (result) {
|
||||
if (this->Impl->FinalPass) {
|
||||
auto impl = this->Impl;
|
||||
mf.AddGeneratorAction(
|
||||
[impl](cmLocalGenerator& lg, const cmListFileBacktrace&) {
|
||||
impl->DoFinalPass(lg.GetMakefile());
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Initial Pass must have failed so set the error string */
|
||||
if (this->Impl->Error) {
|
||||
status.SetError(this->Impl->Error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// cmLoadCommandCommand
|
||||
bool cmLoadCommandCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
if (args.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Construct a variable to report what file was loaded, if any.
|
||||
// Start by removing the definition in case of failure.
|
||||
std::string reportVar = cmStrCat("CMAKE_LOADED_COMMAND_", args[0]);
|
||||
status.GetMakefile().RemoveDefinition(reportVar);
|
||||
|
||||
// the file must exist
|
||||
std::string moduleName = cmStrCat(
|
||||
status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX"),
|
||||
"cm", args[0],
|
||||
status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX"));
|
||||
|
||||
// search for the file
|
||||
std::vector<std::string> path;
|
||||
for (unsigned int j = 1; j < args.size(); j++) {
|
||||
// expand variables
|
||||
std::string exp = args[j];
|
||||
cmSystemTools::ExpandRegistryValues(exp);
|
||||
|
||||
// Glob the entry in case of wildcards.
|
||||
cmSystemTools::GlobDirs(exp, path);
|
||||
}
|
||||
|
||||
// Try to find the program.
|
||||
std::string fullPath = cmSystemTools::FindFile(moduleName, path);
|
||||
if (fullPath.empty()) {
|
||||
status.SetError(cmStrCat("Attempt to load command failed from file \"",
|
||||
moduleName, "\""));
|
||||
return false;
|
||||
}
|
||||
|
||||
// try loading the shared library / dll
|
||||
cmsys::DynamicLoader::LibraryHandle lib =
|
||||
cmDynamicLoader::OpenLibrary(fullPath.c_str());
|
||||
if (!lib) {
|
||||
std::string err =
|
||||
cmStrCat("Attempt to load the library ", fullPath, " failed.");
|
||||
const char* error = cmsys::DynamicLoader::LastError();
|
||||
if (error) {
|
||||
err += " Additional error info is:\n";
|
||||
err += error;
|
||||
}
|
||||
status.SetError(err);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Report what file was loaded for this command.
|
||||
status.GetMakefile().AddDefinition(reportVar, fullPath);
|
||||
|
||||
// find the init function
|
||||
std::string initFuncName = args[0] + "Init";
|
||||
CM_INIT_FUNCTION initFunction = reinterpret_cast<CM_INIT_FUNCTION>(
|
||||
cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
|
||||
if (!initFunction) {
|
||||
initFuncName = cmStrCat('_', args[0], "Init");
|
||||
initFunction = reinterpret_cast<CM_INIT_FUNCTION>(
|
||||
cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
|
||||
}
|
||||
// if the symbol is found call it to set the name on the
|
||||
// function blocker
|
||||
if (initFunction) {
|
||||
return status.GetMakefile().GetState()->AddScriptedCommand(
|
||||
args[0],
|
||||
BT<cmState::Command>(cmLoadedCommand(initFunction),
|
||||
status.GetMakefile().GetBacktrace()),
|
||||
status.GetMakefile());
|
||||
}
|
||||
status.SetError("Attempt to load command failed. "
|
||||
"No init function found.");
|
||||
return false;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
bool cmLoadCommandCommand(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& status);
|
||||
@@ -101,7 +101,7 @@ class cmMakefile;
|
||||
SELECT(POLICY, CMP0030, \
|
||||
"The use_mangled_mesa command should not be called.", 3, 0, 0, NEW) \
|
||||
SELECT(POLICY, CMP0031, "The load_command command should not be called.", \
|
||||
3, 0, 0, WARN) \
|
||||
3, 0, 0, NEW) \
|
||||
SELECT(POLICY, CMP0032, \
|
||||
"The output_required_files command should not be called.", 3, 0, 0, \
|
||||
WARN) \
|
||||
|
||||
@@ -468,9 +468,6 @@ if(BUILD_TESTING)
|
||||
ADD_TEST_MACRO(SetLang SetLangX)
|
||||
ADD_TEST_MACRO(EmptyProperty EmptyProperty)
|
||||
ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
|
||||
if(NOT CMake_TEST_EXTERNAL_CMAKE)
|
||||
ADD_TEST_MACRO(LoadCommand LoadedCommand)
|
||||
endif()
|
||||
ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
|
||||
ADD_TEST_MACRO(LinkLanguage LinkLanguage)
|
||||
ADD_TEST_MACRO(LinkLine LinkLine)
|
||||
@@ -1334,18 +1331,6 @@ if(BUILD_TESTING)
|
||||
set_property(TEST CMakeTestAllGenerators PROPERTY RUN_SERIAL 1)
|
||||
endif()
|
||||
|
||||
if(NOT CMake_TEST_EXTERNAL_CMAKE)
|
||||
add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig"
|
||||
"${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
|
||||
${build_generator_args}
|
||||
--build-project LoadCommand
|
||||
--test-command LoadedCommand
|
||||
)
|
||||
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
|
||||
endif()
|
||||
|
||||
add_test(complex ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/Complex"
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(CMAKE_LOADED_COMMANDS)
|
||||
|
||||
if (MUDSLIDE_TYPE MATCHES MUCHO)
|
||||
add_definitions(-DMUCHO_MUDSLIDE)
|
||||
endif ()
|
||||
|
||||
include_directories(${CMAKE_ROOT}/include ${CMAKE_ROOT}/Source)
|
||||
|
||||
add_library(cmCMAKE_TEST_COMMAND MODULE cmTestCommand.c)
|
||||
|
||||
if(WATCOM)
|
||||
target_link_libraries(cmCMAKE_TEST_COMMAND clbsdll.lib)
|
||||
endif()
|
||||
@@ -1,192 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cmCPluginAPI.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* LibraryName;
|
||||
int Argc;
|
||||
char** Argv;
|
||||
} cmVTKWrapTclData;
|
||||
|
||||
/* do almost everything in the initial pass */
|
||||
static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[])
|
||||
{
|
||||
char* file;
|
||||
char* str;
|
||||
const char* srcs;
|
||||
const char* cstr;
|
||||
char buffer[1024];
|
||||
void* source_file;
|
||||
char* args[2];
|
||||
const char* ccArgs[4];
|
||||
const char* ccDep[1];
|
||||
const char* ccOut[1];
|
||||
cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
|
||||
|
||||
cmVTKWrapTclData* cdata =
|
||||
(cmVTKWrapTclData*)malloc(sizeof(cmVTKWrapTclData));
|
||||
cdata->LibraryName = "BOO";
|
||||
cdata->Argc = argc;
|
||||
cdata->Argv = argv;
|
||||
info->CAPI->SetClientData(info, cdata);
|
||||
|
||||
/* Now check and see if the value has been stored in the cache */
|
||||
/* already, if so use that value and don't look for the program */
|
||||
if (!info->CAPI->IsOn(mf, "TEST_COMMAND_TEST1")) {
|
||||
info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
|
||||
return 1;
|
||||
}
|
||||
|
||||
info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
|
||||
cdata->LibraryName = "HOO";
|
||||
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE", "ON",
|
||||
"Test cache variable", CM_CACHE_BOOL);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE1", "",
|
||||
"Test cache variable 1", CM_CACHE_PATH);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE2", "",
|
||||
"Test cache variable 2", CM_CACHE_FILEPATH);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE3", "",
|
||||
"Test cache variable 3", CM_CACHE_STRING);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE4", "",
|
||||
"Test cache variable 4", CM_CACHE_INTERNAL);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE5", "",
|
||||
"Test cache variable 5", CM_CACHE_STATIC);
|
||||
|
||||
file = info->CAPI->ExpandVariablesInString(mf, "${CMAKE_COMMAND}", 0, 0);
|
||||
|
||||
str = info->CAPI->GetFilenameWithoutExtension(file);
|
||||
info->CAPI->DisplaySatus(mf, str);
|
||||
info->CAPI->Free(str);
|
||||
str = info->CAPI->GetFilenamePath(file);
|
||||
info->CAPI->DisplaySatus(mf, str);
|
||||
info->CAPI->Free(str);
|
||||
str = info->CAPI->Capitalized("cmake");
|
||||
info->CAPI->DisplaySatus(mf, str);
|
||||
info->CAPI->Free(str);
|
||||
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetProjectName(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetHomeDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetHomeOutputDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetStartDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetStartOutputDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentOutputDirectory(mf));
|
||||
snprintf(
|
||||
buffer, sizeof(buffer), "Cache version: %d.%d, CMake version: %d.%d",
|
||||
info->CAPI->GetCacheMajorVersion(mf), info->CAPI->GetCacheMinorVersion(mf),
|
||||
info->CAPI->GetMajorVersion(mf), info->CAPI->GetMinorVersion(mf));
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
if (info->CAPI->CommandExists(mf, "SET")) {
|
||||
info->CAPI->DisplaySatus(mf, "Command SET exists");
|
||||
}
|
||||
if (info->CAPI->CommandExists(mf, "SET_FOO_BAR")) {
|
||||
info->CAPI->SetError(mf, "Command SET_FOO_BAR should not exists");
|
||||
return 0;
|
||||
}
|
||||
info->CAPI->AddDefineFlag(mf, "-DADDED_DEFINITION");
|
||||
|
||||
source_file = info->CAPI->CreateNewSourceFile(mf);
|
||||
cstr = info->CAPI->SourceFileGetSourceName(source_file);
|
||||
snprintf(buffer, sizeof(buffer), "Should be empty (source file name): [%s]",
|
||||
cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
cstr = info->CAPI->SourceFileGetFullPath(source_file);
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Should be empty (source file full path): [%s]", cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY", "unused old prop",
|
||||
"This property is no longer used", 0);
|
||||
if (info->CAPI->SourceFileGetPropertyAsBool(source_file, "SOME_PROPERTY")) {
|
||||
info->CAPI->SetError(mf, "Property SOME_PROPERTY should not be defined");
|
||||
return 0;
|
||||
}
|
||||
info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY2", "nice prop",
|
||||
"This property is for testing.", 0);
|
||||
info->CAPI->SourceFileSetProperty(source_file, "SOME_PROPERTY2", "HERE");
|
||||
cstr = info->CAPI->SourceFileGetProperty(source_file, "ABSTRACT");
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Should be 0 (source file abstract property): [%p]", cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
|
||||
info->CAPI->DestroySourceFile(source_file);
|
||||
|
||||
srcs = argv[2];
|
||||
info->CAPI->AddExecutable(mf, "LoadedCommand", 1, &srcs, 0);
|
||||
|
||||
/* add customs commands to generate the source file */
|
||||
ccArgs[0] = "-E";
|
||||
ccArgs[1] = "copy";
|
||||
ccArgs[2] = argv[0];
|
||||
ccArgs[3] = argv[1];
|
||||
ccDep[0] = ccArgs[2];
|
||||
ccOut[0] = ccArgs[3];
|
||||
info->CAPI->AddCustomCommand(mf, "LoadedCommand.cxx.in", file, 4, ccArgs, 1,
|
||||
ccDep, 1, ccOut, "LoadedCommand");
|
||||
|
||||
ccArgs[2] = argv[1];
|
||||
ccArgs[3] = argv[2];
|
||||
ccDep[0] = ccArgs[2];
|
||||
ccOut[0] = ccArgs[3];
|
||||
info->CAPI->AddCustomCommandToOutput(mf, ccOut[0], file, 4, ccArgs, ccDep[0],
|
||||
0, 0);
|
||||
|
||||
ccArgs[1] = "echo";
|
||||
ccArgs[2] = "Build has finished";
|
||||
info->CAPI->AddCustomCommandToTarget(mf, "LoadedCommand", file, 3, ccArgs,
|
||||
CM_POST_BUILD);
|
||||
|
||||
info->CAPI->Free(file);
|
||||
|
||||
args[0] = "TEST_EXEC";
|
||||
args[1] = "TRUE";
|
||||
|
||||
/* code coverage */
|
||||
if (info->CAPI->GetTotalArgumentSize(2, args) != 13) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ccArgs[0] = "TEST_EXEC";
|
||||
ccArgs[1] = "TRUE";
|
||||
info->CAPI->ExecuteCommand(mf, "SET", 2, ccArgs);
|
||||
|
||||
/* make sure we can find the source file */
|
||||
if (!info->CAPI->GetSource(mf, argv[1])) {
|
||||
info->CAPI->SetError(mf, "Source file could not be found!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void CCONV FinalPass(void* inf, void* mf)
|
||||
{
|
||||
cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
|
||||
/* get our client data from initial pass */
|
||||
cmVTKWrapTclData* cdata = (cmVTKWrapTclData*)info->CAPI->GetClientData(info);
|
||||
if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"), "HOO") ||
|
||||
strcmp(cdata->LibraryName, "HOO")) {
|
||||
fprintf(stderr, "*** Failed LOADED COMMAND Final Pass\n");
|
||||
}
|
||||
}
|
||||
static void CCONV Destructor(void* inf)
|
||||
{
|
||||
cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
|
||||
/* get our client data from initial pass */
|
||||
cmVTKWrapTclData* cdata = (cmVTKWrapTclData*)info->CAPI->GetClientData(info);
|
||||
free(cdata);
|
||||
}
|
||||
|
||||
#ifdef MUCHO_MUDSLIDE
|
||||
void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo* info)
|
||||
{
|
||||
info->InitialPass = InitialPass;
|
||||
info->FinalPass = FinalPass;
|
||||
info->Destructor = Destructor;
|
||||
info->m_Inherited = 0;
|
||||
info->Name = "CMAKE_TEST_COMMAND";
|
||||
}
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_policy(SET CMP0031 OLD) # testing the old behavior
|
||||
project(LoadCommand)
|
||||
|
||||
# set a definition
|
||||
set (TEST_COMMAND_TEST1 1)
|
||||
|
||||
include (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
|
||||
CHECK_TYPE_SIZE(char SIZEOF_CHAR)
|
||||
CHECK_TYPE_SIZE(short SIZEOF_SHORT)
|
||||
|
||||
configure_file(${LoadCommand_SOURCE_DIR}/LoadedCommand.h.in
|
||||
${LoadCommand_BINARY_DIR}/LoadedCommand.h)
|
||||
|
||||
include_directories(${LoadCommand_BINARY_DIR})
|
||||
|
||||
# try to compile the command
|
||||
# make sure it is not already loaded
|
||||
if(COMMAND CMAKE_TEST_COMMAND)
|
||||
else()
|
||||
try_compile(COMPILE_OK
|
||||
${LoadCommand_BINARY_DIR}/CMakeCommands
|
||||
${LoadCommand_SOURCE_DIR}/CMakeCommands
|
||||
CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
|
||||
OUTPUT_VARIABLE OUTPUT )
|
||||
endif()
|
||||
|
||||
message("Output from try compile: ${OUTPUT}")
|
||||
|
||||
# if the compile was OK, try loading the command
|
||||
if (COMPILE_OK)
|
||||
load_command(CMAKE_TEST_COMMAND
|
||||
${LoadCommand_BINARY_DIR}/CMakeCommands
|
||||
${LoadCommand_BINARY_DIR}/CMakeCommands/Debug
|
||||
${LoadCommand_BINARY_DIR}/CMakeCommands/Development
|
||||
)
|
||||
# if the command loaded, execute the command
|
||||
if (COMMAND CMAKE_TEST_COMMAND)
|
||||
CMAKE_TEST_COMMAND(
|
||||
"${LoadCommand_SOURCE_DIR}/LoadedCommand.cxx.in"
|
||||
"${LoadCommand_BINARY_DIR}/LoadedCommand2.cxx.in"
|
||||
"${LoadCommand_BINARY_DIR}/LoadedCommand3.cxx"
|
||||
)
|
||||
endif ()
|
||||
else ()
|
||||
message("failed to compile CMAKE_LOADED_COMMANDS")
|
||||
endif ()
|
||||
|
||||
# TEST_DEF is set by the loaded command cmTestCommand.c
|
||||
if (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC)
|
||||
add_definitions(-DCMAKE_IS_FUN)
|
||||
endif ()
|
||||
@@ -1,32 +0,0 @@
|
||||
#include "LoadedCommand.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int testSizeOf(int s1, int s2)
|
||||
{
|
||||
return s1 - s2;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#if !defined( ADDED_DEFINITION )
|
||||
printf("Should have ADDED_DEFINITION defined\n");
|
||||
ret= 1;
|
||||
#endif
|
||||
#if !defined(CMAKE_IS_FUN)
|
||||
printf("Loaded Command was not built with CMAKE_IS_FUN: failed.\n");
|
||||
ret = 1;
|
||||
#endif
|
||||
if(testSizeOf(SIZEOF_CHAR, sizeof(char)))
|
||||
{
|
||||
printf("Size of char is broken.\n");
|
||||
ret = 1;
|
||||
}
|
||||
if(testSizeOf(SIZEOF_SHORT, sizeof(short)))
|
||||
{
|
||||
printf("Size of short is broken.\n");
|
||||
ret = 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
/* Check for size of types */
|
||||
#cmakedefine SIZEOF_CHAR ${SIZEOF_CHAR}
|
||||
#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT}
|
||||
@@ -1,17 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(CMAKE_LOADED_COMMANDS)
|
||||
|
||||
if (MUDSLIDE_TYPE MATCHES MUCHO)
|
||||
add_definitions(-DMUCHO_MUDSLIDE)
|
||||
endif ()
|
||||
|
||||
if(WATCOM)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
endif()
|
||||
include_directories(${CMAKE_ROOT}/include ${CMAKE_ROOT}/Source)
|
||||
|
||||
add_library(cmCMAKE_TEST_COMMAND MODULE cmTestCommand.c)
|
||||
|
||||
if(WATCOM)
|
||||
target_link_libraries(cmCMAKE_TEST_COMMAND clbsdll.lib)
|
||||
endif()
|
||||
@@ -1,192 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cmCPluginAPI.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* LibraryName;
|
||||
int Argc;
|
||||
char** Argv;
|
||||
} cmVTKWrapTclData;
|
||||
|
||||
/* do almost everything in the initial pass */
|
||||
static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[])
|
||||
{
|
||||
char* file;
|
||||
char* str;
|
||||
const char* srcs;
|
||||
char* cstr;
|
||||
char buffer[1024];
|
||||
void* source_file;
|
||||
char* args[2];
|
||||
const char* ccArgs[4];
|
||||
const char* ccDep[1];
|
||||
const char* ccOut[1];
|
||||
cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
|
||||
|
||||
cmVTKWrapTclData* cdata =
|
||||
(cmVTKWrapTclData*)malloc(sizeof(cmVTKWrapTclData));
|
||||
cdata->LibraryName = "BOO";
|
||||
cdata->Argc = argc;
|
||||
cdata->Argv = argv;
|
||||
info->CAPI->SetClientData(info, cdata);
|
||||
|
||||
/* Now check and see if the value has been stored in the cache */
|
||||
/* already, if so use that value and don't look for the program */
|
||||
if (!info->CAPI->IsOn(mf, "TEST_COMMAND_TEST1")) {
|
||||
info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
|
||||
return 1;
|
||||
}
|
||||
|
||||
info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
|
||||
cdata->LibraryName = "HOO";
|
||||
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE", "ON",
|
||||
"Test cache variable", CM_CACHE_BOOL);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE1", "",
|
||||
"Test cache variable 1", CM_CACHE_PATH);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE2", "",
|
||||
"Test cache variable 2", CM_CACHE_FILEPATH);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE3", "",
|
||||
"Test cache variable 3", CM_CACHE_STRING);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE4", "",
|
||||
"Test cache variable 4", CM_CACHE_INTERNAL);
|
||||
info->CAPI->AddCacheDefinition(mf, "SOME_CACHE_VARIABLE5", "",
|
||||
"Test cache variable 5", CM_CACHE_STATIC);
|
||||
|
||||
file = info->CAPI->ExpandVariablesInString(mf, "${CMAKE_COMMAND}", 0, 0);
|
||||
|
||||
str = info->CAPI->GetFilenameWithoutExtension(file);
|
||||
info->CAPI->DisplaySatus(mf, str);
|
||||
info->CAPI->Free(str);
|
||||
str = info->CAPI->GetFilenamePath(file);
|
||||
info->CAPI->DisplaySatus(mf, str);
|
||||
info->CAPI->Free(str);
|
||||
str = info->CAPI->Capitalized("cmake");
|
||||
info->CAPI->DisplaySatus(mf, str);
|
||||
info->CAPI->Free(str);
|
||||
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetProjectName(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetHomeDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetHomeOutputDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetStartDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetStartOutputDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentOutputDirectory(mf));
|
||||
snprintf(
|
||||
buffer, sizeof(buffer), "Cache version: %d.%d, CMake version: %d.%d",
|
||||
info->CAPI->GetCacheMajorVersion(mf), info->CAPI->GetCacheMinorVersion(mf),
|
||||
info->CAPI->GetMajorVersion(mf), info->CAPI->GetMinorVersion(mf));
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
if (info->CAPI->CommandExists(mf, "SET")) {
|
||||
info->CAPI->DisplaySatus(mf, "Command SET exists");
|
||||
}
|
||||
if (info->CAPI->CommandExists(mf, "SET_FOO_BAR")) {
|
||||
info->CAPI->SetError(mf, "Command SET_FOO_BAR should not exists");
|
||||
return 0;
|
||||
}
|
||||
info->CAPI->AddDefineFlag(mf, "-DADDED_DEFINITION");
|
||||
|
||||
source_file = info->CAPI->CreateNewSourceFile(mf);
|
||||
cstr = info->CAPI->SourceFileGetSourceName(source_file);
|
||||
snprintf(buffer, sizeof(buffer), "Should be empty (source file name): [%s]",
|
||||
cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
cstr = info->CAPI->SourceFileGetFullPath(source_file);
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Should be empty (source file full path): [%s]", cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY", "unused old prop",
|
||||
"This property is no longer used", 0);
|
||||
if (info->CAPI->SourceFileGetPropertyAsBool(source_file, "SOME_PROPERTY")) {
|
||||
info->CAPI->SetError(mf, "Property SOME_PROPERTY should not be defined");
|
||||
return 0;
|
||||
}
|
||||
info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY2", "nice prop",
|
||||
"This property is for testing.", 0);
|
||||
info->CAPI->SourceFileSetProperty(source_file, "SOME_PROPERTY2", "HERE");
|
||||
cstr = info->CAPI->SourceFileGetProperty(source_file, "ABSTRACT");
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Should be 0 (source file abstract property): [%p]", cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
|
||||
info->CAPI->DestroySourceFile(source_file);
|
||||
|
||||
srcs = argv[2];
|
||||
info->CAPI->AddExecutable(mf, "LoadedCommand", 1, &srcs, 0);
|
||||
|
||||
/* add customs commands to generate the source file */
|
||||
ccArgs[0] = "-E";
|
||||
ccArgs[1] = "copy";
|
||||
ccArgs[2] = argv[0];
|
||||
ccArgs[3] = argv[1];
|
||||
ccDep[0] = ccArgs[2];
|
||||
ccOut[0] = ccArgs[3];
|
||||
info->CAPI->AddCustomCommand(mf, "LoadedCommand.cxx.in", file, 4, ccArgs, 1,
|
||||
ccDep, 1, ccOut, "LoadedCommand");
|
||||
|
||||
ccArgs[2] = argv[1];
|
||||
ccArgs[3] = argv[2];
|
||||
ccDep[0] = ccArgs[2];
|
||||
ccOut[0] = ccArgs[3];
|
||||
info->CAPI->AddCustomCommandToOutput(mf, ccOut[0], file, 4, ccArgs, ccDep[0],
|
||||
0, 0);
|
||||
|
||||
ccArgs[1] = "echo";
|
||||
ccArgs[2] = "Build has finished";
|
||||
info->CAPI->AddCustomCommandToTarget(mf, "LoadedCommand", file, 3, ccArgs,
|
||||
CM_POST_BUILD);
|
||||
|
||||
info->CAPI->Free(file);
|
||||
|
||||
args[0] = "TEST_EXEC";
|
||||
args[1] = "TRUE";
|
||||
|
||||
/* code coverage */
|
||||
if (info->CAPI->GetTotalArgumentSize(2, args) != 13) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ccArgs[0] = "TEST_EXEC";
|
||||
ccArgs[1] = "TRUE";
|
||||
info->CAPI->ExecuteCommand(mf, "SET", 2, ccArgs);
|
||||
|
||||
/* make sure we can find the source file */
|
||||
if (!info->CAPI->GetSource(mf, argv[1])) {
|
||||
info->CAPI->SetError(mf, "Source file could not be found!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void CCONV FinalPass(void* inf, void* mf)
|
||||
{
|
||||
cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
|
||||
/* get our client data from initial pass */
|
||||
cmVTKWrapTclData* cdata = (cmVTKWrapTclData*)info->CAPI->GetClientData(info);
|
||||
if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"), "HOO") ||
|
||||
strcmp(cdata->LibraryName, "HOO")) {
|
||||
fprintf(stderr, "*** Failed LOADED COMMAND Final Pass\n");
|
||||
}
|
||||
}
|
||||
static void CCONV Destructor(void* inf)
|
||||
{
|
||||
cmLoadedCommandInfo* info = (cmLoadedCommandInfo*)inf;
|
||||
/* get our client data from initial pass */
|
||||
cmVTKWrapTclData* cdata = (cmVTKWrapTclData*)info->CAPI->GetClientData(info);
|
||||
free(cdata);
|
||||
}
|
||||
|
||||
#ifdef MUCHO_MUDSLIDE
|
||||
void CM_PLUGIN_EXPORT CCONV CMAKE_TEST_COMMANDInit(cmLoadedCommandInfo* info)
|
||||
{
|
||||
info->InitialPass = InitialPass;
|
||||
info->FinalPass = FinalPass;
|
||||
info->Destructor = Destructor;
|
||||
info->m_Inherited = 0;
|
||||
info->Name = "CMAKE_TEST_COMMAND";
|
||||
}
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_policy(SET CMP0031 OLD) # testing the old behavior
|
||||
project(LoadCommand)
|
||||
|
||||
# set a definition
|
||||
set (TEST_COMMAND_TEST1 1)
|
||||
|
||||
include (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
|
||||
CHECK_TYPE_SIZE(char SIZEOF_CHAR)
|
||||
CHECK_TYPE_SIZE(short SIZEOF_SHORT)
|
||||
|
||||
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||
CHECK_INCLUDE_FILE("sys/prctl.h" HAVE_SYS_PRCTL_H)
|
||||
|
||||
include (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
|
||||
CHECK_LIBRARY_EXISTS(m ceil "" HAVE_LIBM)
|
||||
|
||||
configure_file(${LoadCommand_SOURCE_DIR}/LoadedCommand.h.in
|
||||
${LoadCommand_BINARY_DIR}/LoadedCommand.h)
|
||||
|
||||
include_directories(${LoadCommand_BINARY_DIR})
|
||||
|
||||
# try to compile the command
|
||||
# make sure it is not already loaded
|
||||
if(COMMAND CMAKE_TEST_COMMAND)
|
||||
else()
|
||||
try_compile(COMPILE_OK
|
||||
${LoadCommand_BINARY_DIR}/CMakeCommands
|
||||
${LoadCommand_SOURCE_DIR}/CMakeCommands
|
||||
CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
|
||||
OUTPUT_VARIABLE OUTPUT )
|
||||
endif()
|
||||
|
||||
message("Output from try compile: ${OUTPUT}")
|
||||
|
||||
# if the compile was OK, try loading the command
|
||||
if (COMPILE_OK)
|
||||
load_command(CMAKE_TEST_COMMAND
|
||||
${LoadCommand_BINARY_DIR}/CMakeCommands
|
||||
${LoadCommand_BINARY_DIR}/CMakeCommands/Debug
|
||||
${LoadCommand_BINARY_DIR}/CMakeCommands/Development
|
||||
)
|
||||
# if the command loaded, execute the command
|
||||
if (COMMAND CMAKE_TEST_COMMAND)
|
||||
CMAKE_TEST_COMMAND(
|
||||
"${LoadCommand_SOURCE_DIR}/LoadedCommand.cxx.in"
|
||||
"${LoadCommand_BINARY_DIR}/LoadedCommand2.cxx.in"
|
||||
"${LoadCommand_BINARY_DIR}/LoadedCommand3.cxx"
|
||||
)
|
||||
endif ()
|
||||
else ()
|
||||
message("failed to compile CMAKE_LOADED_COMMANDS")
|
||||
endif ()
|
||||
|
||||
# TEST_DEF is set by the loaded command cmTestCommand.c
|
||||
if (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC)
|
||||
add_definitions(-DCMAKE_IS_FUN)
|
||||
endif ()
|
||||
@@ -1,32 +0,0 @@
|
||||
#include "LoadedCommand.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int testSizeOf(int s1, int s2)
|
||||
{
|
||||
return s1 - s2;
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#if !defined( ADDED_DEFINITION )
|
||||
printf("Should have ADDED_DEFINITION defined\n");
|
||||
ret= 1;
|
||||
#endif
|
||||
#if !defined(CMAKE_IS_FUN)
|
||||
printf("Loaded Command was not built with CMAKE_IS_FUN: failed.\n");
|
||||
ret = 1;
|
||||
#endif
|
||||
if(testSizeOf(SIZEOF_CHAR, sizeof(char)))
|
||||
{
|
||||
printf("Size of char is broken.\n");
|
||||
ret = 1;
|
||||
}
|
||||
if(testSizeOf(SIZEOF_SHORT, sizeof(short)))
|
||||
{
|
||||
printf("Size of short is broken.\n");
|
||||
ret = 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/* Check for size of types */
|
||||
#cmakedefine SIZEOF_CHAR ${SIZEOF_CHAR}
|
||||
#cmakedefine SIZEOF_SHORT ${SIZEOF_SHORT}
|
||||
|
||||
/* Check for headers */
|
||||
#cmakedefine HAVE_SYS_PRCTL_H
|
||||
|
||||
/* Check for libraries */
|
||||
#cmakedefine HAVE_LIBM
|
||||
@@ -1,4 +1,4 @@
|
||||
CMake Error at CMP0031-NEW.cmake:2 \(load_command\):
|
||||
The load_command command should not be called; see CMP0031.
|
||||
CMake Error at CMP0031-NEW.cmake:1 \(load_command\):
|
||||
The load_command command has been removed; see CMP0031.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
cmake_policy(SET CMP0031 NEW)
|
||||
load_command()
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,4 +0,0 @@
|
||||
CMake Error at CMP0031-OLD.cmake:2 \(load_command\):
|
||||
load_command Attempt to load command failed from file.*bogus_command.*
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
@@ -1,2 +0,0 @@
|
||||
cmake_policy(SET CMP0031 OLD)
|
||||
load_command(bogus_command)
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,12 +0,0 @@
|
||||
CMake Warning \(dev\) at CMP0031-WARN.cmake:1 \(load_command\):
|
||||
Policy CMP0031 is not set: The load_command command should not be called.
|
||||
Run "cmake --help-policy CMP0031" for policy details. Use the cmake_policy
|
||||
command to set the policy and suppress this warning.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||
|
||||
CMake Error at CMP0031-WARN.cmake:1 \(load_command\):
|
||||
load_command Attempt to load command failed from file.*bogus_command.*
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
@@ -1 +0,0 @@
|
||||
load_command(bogus_command)
|
||||
@@ -3,6 +3,7 @@ include(RunCMake)
|
||||
foreach(p
|
||||
CMP0029
|
||||
CMP0030
|
||||
CMP0031
|
||||
)
|
||||
run_cmake(${p}-NEW)
|
||||
endforeach()
|
||||
@@ -10,7 +11,6 @@ endforeach()
|
||||
return()
|
||||
|
||||
foreach(p
|
||||
CMP0031
|
||||
CMP0032
|
||||
CMP0033
|
||||
CMP0034
|
||||
|
||||
Reference in New Issue
Block a user