Improve backward compatibility, so that all backward compatibility stuff is in two modules; fix invoking of try_compile; add checking for header files and sizes of types
This commit is contained in:
parent
cabe849c03
commit
b5de000f26
22
Modules/CMakeBackwardCompatibilityC.cmake
Normal file
22
Modules/CMakeBackwardCompatibilityC.cmake
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Nothing here yet
|
||||||
|
|
||||||
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckSizeOf.cmake)
|
||||||
|
CHECK_TYPE_SIZE(int CMAKE_SIZEOF_INT)
|
||||||
|
CHECK_TYPE_SIZE(long CMAKE_SIZEOF_LONG)
|
||||||
|
CHECK_TYPE_SIZE("void*" CMAKE_SIZEOF_VOID_P)
|
||||||
|
CHECK_TYPE_SIZE(char CMAKE_SIZEOF_CHAR)
|
||||||
|
CHECK_TYPE_SIZE(short CMAKE_SIZEOF_SHORT)
|
||||||
|
CHECK_TYPE_SIZE(float CMAKE_SIZEOF_FLOAT)
|
||||||
|
CHECK_TYPE_SIZE(double CMAKE_SIZEOF_DOUBLE)
|
||||||
|
|
||||||
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
|
||||||
|
CHECK_FUNCTION_EXISTS(gethostbyname CMAKE_HAVE_GETHOSTBYNAME)
|
||||||
|
CHECK_FUNCTION_EXISTS(connect CMAKE_HAVE_CONNECT)
|
||||||
|
CHECK_FUNCTION_EXISTS(remove CMAKE_HAVE_REMOVE)
|
||||||
|
CHECK_FUNCTION_EXISTS(shmat CMAKE_HAVE_SHMAT)
|
||||||
|
|
||||||
|
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
|
||||||
|
CHECK_INCLUDE_FILE("limits.h" CMAKE_HAVE_LIMITS_H)
|
||||||
|
CHECK_INCLUDE_FILE("unistd.h" CMAKE_HAVE_UNISTD_H)
|
||||||
|
CHECK_INCLUDE_FILE("sys/prctl.h" CMAKE_HAVE_SYS_PRCTL_H)
|
||||||
|
CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
|
2
Modules/CMakeBackwardCompatibilityCXX.cmake
Normal file
2
Modules/CMakeBackwardCompatibilityCXX.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#
|
||||||
|
INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIStreamHeaders.cmake)
|
@ -54,14 +54,29 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
|
|||||||
putenv(envCC);
|
putenv(envCC);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
std::string cmd = root;
|
if (!m_CMakeInstance->GetIsInTryCompile())
|
||||||
cmd += "/Templates/cconfigure";
|
{
|
||||||
cmSystemTools::RunCommand(cmd.c_str(), output,
|
std::string cmd = root;
|
||||||
cmSystemTools::ConvertToOutputPath(mf->GetHomeOutputDirectory()).c_str());
|
cmd += "/Templates/cconfigure";
|
||||||
|
cmSystemTools::RunCommand(cmd.c_str(), output,
|
||||||
|
cmSystemTools::ConvertToOutputPath(
|
||||||
|
mf->GetHomeOutputDirectory()).c_str());
|
||||||
|
}
|
||||||
std::string fpath = mf->GetHomeOutputDirectory();
|
std::string fpath = mf->GetHomeOutputDirectory();
|
||||||
fpath += "/CCMakeSystemConfig.cmake";
|
fpath += "/CCMakeSystemConfig.cmake";
|
||||||
mf->ReadListFile(0,fpath.c_str());
|
mf->ReadListFile(0,fpath.c_str());
|
||||||
this->SetLanguageEnabled("C");
|
this->SetLanguageEnabled("C");
|
||||||
|
if (!m_CMakeInstance->GetIsInTryCompile())
|
||||||
|
{
|
||||||
|
// for old versions of CMake ListFiles
|
||||||
|
const char* versionValue
|
||||||
|
= mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
|
||||||
|
if (!versionValue || atof(versionValue) <= 1.4)
|
||||||
|
{
|
||||||
|
std::string fpath = root + "/Modules/CMakeBackwardCompatibilityC.cmake";
|
||||||
|
mf->ReadListFile(NULL,fpath.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if CXX
|
// if CXX
|
||||||
if(!this->GetLanguageEnabled("CXX") && strcmp(lang, "CXX") == 0)
|
if(!this->GetLanguageEnabled("CXX") && strcmp(lang, "CXX") == 0)
|
||||||
@ -85,26 +100,31 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
std::string cmd = root;
|
std::string cmd = root;
|
||||||
cmd += "/Templates/cxxconfigure";
|
if (!m_CMakeInstance->GetIsInTryCompile())
|
||||||
cmSystemTools::RunCommand(cmd.c_str(), output,
|
{
|
||||||
cmSystemTools::ConvertToOutputPath(mf->GetHomeOutputDirectory()).c_str());
|
cmd += "/Templates/cxxconfigure";
|
||||||
|
cmSystemTools::RunCommand(cmd.c_str(), output,
|
||||||
|
cmSystemTools::ConvertToOutputPath(
|
||||||
|
mf->GetHomeOutputDirectory()).c_str());
|
||||||
|
}
|
||||||
std::string fpath = mf->GetHomeOutputDirectory();
|
std::string fpath = mf->GetHomeOutputDirectory();
|
||||||
fpath += "/CXXCMakeSystemConfig.cmake";
|
fpath += "/CXXCMakeSystemConfig.cmake";
|
||||||
mf->ReadListFile(0,fpath.c_str());
|
mf->ReadListFile(0,fpath.c_str());
|
||||||
this->SetLanguageEnabled("CXX");
|
this->SetLanguageEnabled("CXX");
|
||||||
|
|
||||||
// for old versions of CMake ListFiles
|
|
||||||
if (!m_CMakeInstance->GetIsInTryCompile())
|
if (!m_CMakeInstance->GetIsInTryCompile())
|
||||||
{
|
{
|
||||||
|
// for old versions of CMake ListFiles
|
||||||
const char* versionValue
|
const char* versionValue
|
||||||
= mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
|
= mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
|
||||||
if (!versionValue || atof(versionValue) <= 1.4)
|
if (!versionValue || atof(versionValue) <= 1.4)
|
||||||
{
|
{
|
||||||
fpath = root + "/Modules/TestForANSIStreamHeaders.cmake";
|
fpath = root + "/Modules/CMakeBackwardCompatibilityCXX.cmake";
|
||||||
mf->ReadListFile(NULL,fpath.c_str());
|
mf->ReadListFile(NULL,fpath.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are from the top, always define this
|
// if we are from the top, always define this
|
||||||
mf->AddDefinition("RUN_CONFIGURE", true);
|
mf->AddDefinition("RUN_CONFIGURE", true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user