diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 70c0f73f1..f4c00645e 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -324,14 +324,10 @@ void cmFindCommon::AddUserPath(std::string const& p, // it. cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32; cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64; - if(const char* psize = - this->Makefile->GetDefinition("CMAKE_SIZEOF_VOID_P")) + if(this->Makefile->PlatformIs64Bit()) { - if(atoi(psize) == 8) - { - view = cmSystemTools::KeyWOW64_64; - other_view = cmSystemTools::KeyWOW64_32; - } + view = cmSystemTools::KeyWOW64_64; + other_view = cmSystemTools::KeyWOW64_32; } // Expand using the view of the target application. diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index e7beb84de..165dbc2cc 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -329,15 +329,11 @@ bool cmFindPackageCommand this->DebugMode = this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE"); // Lookup whether lib64 paths should be used. - if(const char* sizeof_dptr = - this->Makefile->GetDefinition("CMAKE_SIZEOF_VOID_P")) + if(this->Makefile->PlatformIs64Bit() && + this->Makefile->GetCMakeInstance() + ->GetPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS")) { - if(atoi(sizeof_dptr) == 8 && - this->Makefile->GetCMakeInstance() - ->GetPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS")) - { - this->UseLib64Paths = true; - } + this->UseLib64Paths = true; } // Find the current root path mode. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e49ec3d98..7aa1202bc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2050,6 +2050,15 @@ bool cmMakefile::IsSet(const char* name) const return true; } +bool cmMakefile::PlatformIs64Bit() const +{ + if(const char* sizeof_dptr = this->GetDefinition("CMAKE_SIZEOF_VOID_P")) + { + return atoi(sizeof_dptr) == 8; + } + return false; +} + bool cmMakefile::CanIWriteThisFile(const char* fileName) { if ( !this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES") ) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index ea9eb17c0..485d9e24d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -588,6 +588,9 @@ public: bool IsOn(const char* name) const; bool IsSet(const char* name) const; + /** Return whether the target platform is 64-bit. */ + bool PlatformIs64Bit() const; + /** * Get a list of preprocessor define flags. */