Commit f99fa86c authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: 2.6.2 RC 4 merge into main tree

parent c7055ac8
......@@ -354,7 +354,7 @@ ENDMACRO (CMAKE_BUILD_UTILITIES)
SET(CMake_VERSION_MAJOR 2)
SET(CMake_VERSION_MINOR 6)
SET(CMake_VERSION_PATCH 2)
SET(CMake_VERSION_RC 3)
SET(CMake_VERSION_RC 4)
# CVS versions are odd, if this is an odd minor version
# then set the CMake_VERSION_DATE variable
IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
......
Changes in CMake 2.6.2 RC 4
- Fix bug #7359 make llvm-gcc work, by explicitely excluding
"llvm-" from _CMAKE_TOOLCHAIN_PREFIX
- Fix bug 7046: OS X Framework support: extensionless headers were
being ignored when specified as public headers
- Fix documentation in CheckCCompilerFlag.cmake
- Add better version support to find_package command
- Fix Xcode debug not working
- Add VERSION compare to if command
- Make FindThreads sete THREADS_FOUND
- Deb cpack generator sets Installed-Size for the package
- Do not add an empty /D"" at the end of VS 6 .dsp compile lines
- Recognize /MAP in VS 7 and greater
- Add new policy CMP0009 - GLOB_RECURSE should not follow symlinks by default
Changes in CMake 2.6.2 RC 3
- Fix bug, and remove extra closing > in visual fortran projects.
- Fix bug in ctest -C where it was sometimes ignored.
......
......@@ -88,20 +88,6 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH)
ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION)
# If we have a gcc cross compiler, they have usually some prefix, like
# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc .
# The other tools of the toolchain usually have the same prefix
# NAME_WE cannot be used since then this test will fail for names lile
# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be
# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME)
IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$")
STRING(REGEX REPLACE "^(.+-)g?cc(\\.exe)?$" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$")
ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
# Build a small source file to identify the compiler.
IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
SET(CMAKE_C_COMPILER_ID_RUN 1)
......@@ -141,6 +127,33 @@ IF(NOT CMAKE_C_COMPILER_ID_RUN)
ENDIF("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
ENDIF(NOT CMAKE_C_COMPILER_ID_RUN)
# If we have a gcc cross compiler, they have usually some prefix, like
# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc .
# The other tools of the toolchain usually have the same prefix
# NAME_WE cannot be used since then this test will fail for names lile
# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be
# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
IF (CMAKE_CROSSCOMPILING
AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU"
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME)
IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$")
SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$")
# if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils
# but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.)
IF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$")
SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
ENDIF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$")
ENDIF (CMAKE_CROSSCOMPILING
AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU"
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
INCLUDE(CMakeFindBinUtils)
# configure variables set in this file for fast reload later on
......
......@@ -88,19 +88,6 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION)
# if we have a g++ cross compiler, they have usually some prefix, like
# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++
# the other tools of the toolchain usually have the same prefix
# NAME_WE cannot be used since then this test will fail for names lile
# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be
# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME)
IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$")
STRING(REGEX REPLACE "^(.+-)[gc]\\+\\+(\\.exe)?$" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$")
ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
# This block was used before the compiler was identified by building a
# source file. Unless g++ crashes when building a small C++
# executable this should no longer be needed.
......@@ -151,6 +138,30 @@ IF(NOT CMAKE_CXX_COMPILER_ID_RUN)
ENDIF("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW")
ENDIF(NOT CMAKE_CXX_COMPILER_ID_RUN)
# if we have a g++ cross compiler, they have usually some prefix, like
# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++
# the other tools of the toolchain usually have the same prefix
# NAME_WE cannot be used since then this test will fail for names lile
# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be
# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
IF (CMAKE_CROSSCOMPILING
AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME)
IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$")
SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$")
# if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils
# but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.)
IF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$")
SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
ENDIF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$")
ENDIF (CMAKE_CROSSCOMPILING
AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
INCLUDE(CMakeFindBinUtils)
# configure all variables set in this file
......
......@@ -3,6 +3,10 @@
#
# FLAG - the compiler flag
# VARIABLE - variable to store the result
#
# This actually calls the check_c_source_compiles macro.
# See help for CheckCSourceCompiles for a listing of variables
# that can modify the build.
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
......
......@@ -8,6 +8,7 @@
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckLibraryExists)
SET(Threads_FOUND FALSE)
# Do we have sproc?
IF(CMAKE_SYSTEM MATCHES IRIX)
......@@ -30,11 +31,13 @@ ELSE(CMAKE_HAVE_SPROC_H)
IF(CMAKE_HAVE_PTHREADS_CREATE)
SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
SET(Threads_FOUND TRUE)
ENDIF(CMAKE_HAVE_PTHREADS_CREATE)
# Ok, how about -lpthread
CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
IF(CMAKE_HAVE_PTHREAD_CREATE)
SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
SET(Threads_FOUND TRUE)
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
ENDIF(CMAKE_HAVE_PTHREAD_CREATE)
IF(CMAKE_SYSTEM MATCHES "SunOS.*")
......@@ -43,6 +46,7 @@ ELSE(CMAKE_HAVE_SPROC_H)
IF(CMAKE_HAVE_THR_CREATE)
SET(CMAKE_THREAD_LIBS_INIT "-lthread")
SET(CMAKE_HAVE_THREADS_LIBRARY 1)
SET(Threads_FOUND TRUE)
ENDIF(CMAKE_HAVE_THR_CREATE)
ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*")
ENDIF(NOT THREADS_HAVE_PTHREAD_ARG)
......@@ -58,6 +62,7 @@ ELSE(CMAKE_HAVE_SPROC_H)
COMPILE_OUTPUT_VARIABLE OUTPUT)
IF(THREADS_HAVE_PTHREAD_ARG)
IF(THREADS_PTHREAD_ARG MATCHES "^2$")
SET(Threads_FOUND TRUE)
MESSAGE(STATUS "Check if compiler accepts -pthread - yes")
ELSE(THREADS_PTHREAD_ARG MATCHES "^2$")
MESSAGE(STATUS "Check if compiler accepts -pthread - no")
......@@ -73,6 +78,7 @@ ELSE(CMAKE_HAVE_SPROC_H)
ENDIF(THREADS_HAVE_PTHREAD_ARG)
ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
IF(THREADS_HAVE_PTHREAD_ARG)
SET(Threads_FOUND TRUE)
SET(CMAKE_THREAD_LIBS_INIT "-pthread")
ENDIF(THREADS_HAVE_PTHREAD_ARG)
ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY)
......@@ -81,10 +87,12 @@ ENDIF(CMAKE_HAVE_SPROC_H)
IF(CMAKE_THREAD_LIBS_INIT)
SET(CMAKE_USE_PTHREADS_INIT 1)
SET(Threads_FOUND TRUE)
ENDIF(CMAKE_THREAD_LIBS_INIT)
IF(CMAKE_SYSTEM MATCHES "Windows")
SET(CMAKE_USE_WIN32_THREADS_INIT 1)
SET(Threads_FOUND TRUE)
ENDIF(CMAKE_SYSTEM MATCHES "Windows")
IF(CMAKE_USE_PTHREADS_INIT)
......@@ -101,6 +109,7 @@ IF(CMAKE_USE_PTHREADS_INIT)
IF(CMAKE_HAVE_HP_CMA)
SET(CMAKE_THREAD_LIBS_INIT "-lcma")
SET(CMAKE_HP_PTHREADS_INIT 1)
SET(Threads_FOUND TRUE)
ENDIF(CMAKE_HAVE_HP_CMA)
SET(CMAKE_USE_PTHREADS_INIT 1)
ENDIF(CMAKE_SYSTEM MATCHES "HP-UX-*")
......@@ -112,8 +121,11 @@ IF(CMAKE_USE_PTHREADS_INIT)
IF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
SET(CMAKE_USE_PTHREADS_INIT 1)
SET(Threads_FOUND TRUE)
SET(CMAKE_THREAD_LIBS_INIT )
SET(CMAKE_USE_WIN32_THREADS_INIT 0)
ENDIF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
ENDIF(CMAKE_USE_PTHREADS_INIT)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND)
......@@ -67,20 +67,25 @@ line.
A FindXXX.cmake module will typically be loaded by the command
FIND_PACKAGE(XXX [major[.minor[.patch]]] [EXACT]
FIND_PACKAGE(XXX [major[.minor[.patch[.tweak]]]] [EXACT]
[QUIET] [REQUIRED [components...]])
If any version numbers are given to the command it will set the
variable XXX_FIND_VERSION to contain the whole version. The variables
XXX_FIND_VERSION_MAJOR, XXX_FIND_VERSION_MINOR, and
XXX_FIND_VERSION_PATCH will be set to contain the corresponding
portions of the version number. The variable XXX_FIND_VERSION_EXACT
will indicate whether an exact version is requested.
following variables before loading the module:
XXX_FIND_VERSION = full requested version string
XXX_FIND_VERSION_MAJOR = major version if requested, else 0
XXX_FIND_VERSION_MINOR = minor version if requested, else 0
XXX_FIND_VERSION_PATCH = patch version if requested, else 0
XXX_FIND_VERSION_TWEAK = tweak version if requested, else 0
XXX_FIND_VERSION_COUNT = number of version components, 0 to 4
XXX_FIND_VERSION_EXACT = true if EXACT option was given
If the find module supports versioning it should locate a version of
the package that is compatible with the version requested. If a
compatible version of the package cannot be found the module should
not report success. The version of the package found should be stored
in the version variables named above.
in "XXX_VERSION..." version variables docmented by the module.
If the QUIET option is given to the command it will set the variable
XXX_FIND_QUIETLY to true before loading the FindXXX.cmake module. If
......
......@@ -116,6 +116,17 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
{
out << "Suggests: " << debian_pkg_sug << "\n";
}
unsigned long totalSize = 0;
{
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
dirName += '/';
for (std::vector<std::string>::const_iterator fileIt = files.begin();
fileIt != files.end(); ++ fileIt )
{
totalSize += cmSystemTools::FileLength(fileIt->c_str());
}
}
out << "Installed-Size: " << totalSize << "\n";
out << "Maintainer: " << maintainer << "\n";
out << "Description: " << desc << "\n";
out << std::endl;
......
......@@ -668,18 +668,39 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
i++;
cmsys::Glob g;
g.SetRecurse(recurse);
bool explicitFollowSymlinks = false;
cmPolicies::PolicyStatus status =
this->Makefile->GetPolicyStatus(cmPolicies::CMP0009);
if(recurse)
{
switch(status)
{
case cmPolicies::NEW:
g.RecurseThroughSymlinksOff();
break;
case cmPolicies::OLD:
case cmPolicies::WARN:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
g.RecurseThroughSymlinksOn();
break;
}
}
std::string output = "";
bool first = true;
for ( ; i != args.end(); ++i )
{
if ( *i == "RECURSE_SYMLINKS_OFF" )
if ( recurse && (*i == "FOLLOW_SYMLINKS") )
{
g.RecurseThroughSymlinksOff();
explicitFollowSymlinks = true;
g.RecurseThroughSymlinksOn();
++i;
if ( i == args.end() )
{
this->SetError(
"GLOB requires a glob expression after RECURSE_SYMLINKS_OFF");
"GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS");
return false;
}
}
......@@ -732,6 +753,37 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
first = false;
}
}
if(recurse && !explicitFollowSymlinks)
{
switch (status)
{
case cmPolicies::NEW:
// Correct behavior, yay!
break;
case cmPolicies::OLD:
// Probably not really the expected behavior, but the author explicitly
// asked for the old behavior... no warning.
case cmPolicies::WARN:
// Possibly unexpected old behavior *and* we actually traversed
// symlinks without being explicitly asked to: warn the author.
if(g.GetFollowedSymlinkCount() != 0)
{
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
this->Makefile->GetPolicies()->
GetPolicyWarning(cmPolicies::CMP0009));
}
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
this->SetError("policy CMP0009 error");
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
this->Makefile->GetPolicies()->
GetRequiredPolicyError(cmPolicies::CMP0009));
return false;
}
}
this->Makefile->AddDefinition(variable.c_str(), output.c_str());
return true;
}
......
......@@ -77,7 +77,7 @@ public:
" [NO_HEX_CONVERSION])\n"
" file(GLOB variable [RELATIVE path] [globbing expressions]...)\n"
" file(GLOB_RECURSE variable [RELATIVE path] \n"
" [RECURSE_SYMLINKS_OFF] [globbing expressions]...)\n"
" [FOLLOW_SYMLINKS] [globbing expressions]...)\n"
" file(REMOVE [file1 ...])\n"
" file(REMOVE_RECURSE [file1 ...])\n"
" file(MAKE_DIRECTORY [directory1 directory2 ...])\n"
......@@ -124,11 +124,11 @@ public:
" *.cxx - match all files with extension cxx\n"
" *.vt? - match all files with extension vta,...,vtz\n"
" f[3-5].txt - match files f3.txt, f4.txt, f5.txt\n"
"GLOB_RECURSE will generate similar list as the regular GLOB, except "
"GLOB_RECURSE will generate a list similar to the regular GLOB, except "
"it will traverse all the subdirectories of the matched directory and "
"match the files. Subdirectories that are symlinks are traversed by "
"default to match the behavior of older CMake releases. Use "
"RECURSE_SYMLINKS_OFF to prevent recursion through symlinks.\n"
"match the files. Subdirectories that are symlinks are only traversed "
"if FOLLOW_SYMLINKS is given or cmake policy CMP0009 is not set to NEW. "
"See cmake --help-policy CMP0009 for more information.\n"
"Examples of recursive globbing include:\n"
" /dir/*.py - match all python files in /dir and subdirectories\n"
"MAKE_DIRECTORY will create the given directories, also if their parent "
......
......@@ -67,14 +67,16 @@ cmFindPackageCommand::cmFindPackageCommand()
this->VersionMajor = 0;
this->VersionMinor = 0;
this->VersionPatch = 0;
this->VersionTweak = 0;
this->VersionCount = 0;
this->VersionExact = false;
this->VersionFoundMajor = 0;
this->VersionFoundMinor = 0;
this->VersionFoundPatch = 0;
this->VersionFoundTweak = 0;
this->VersionFoundCount = 0;
this->CommandDocumentation =
" find_package(<package> [major[.minor[.patch]]] [EXACT] [QUIET]\n"
" find_package(<package> [version] [EXACT] [QUIET]\n"
" [[REQUIRED|COMPONENTS] [components...]])\n"
"Finds and loads settings from an external project. "
"<package>_FOUND will be set to indicate whether the package was found. "
......@@ -86,8 +88,8 @@ cmFindPackageCommand::cmFindPackageCommand()
"A package-specific list of components may be listed after the "
"REQUIRED option or after the COMPONENTS option if no REQUIRED "
"option is given. "
"The \"[major[.minor[.patch]]]\" version argument specifies a desired "
"version with which the package found should be compatible. "
"The [version] argument requests a version with which the package found "
"should be compatible (format is major[.minor[.patch[.tweak]]]). "
"The EXACT option requests that the version be matched exactly. "
"Version support is currently provided only on a package-by-package "
"basis (details below).\n"
......@@ -109,7 +111,7 @@ cmFindPackageCommand::cmFindPackageCommand()
"check the module documentation. "
"If no module is found the command proceeds to Config mode.\n"
"The complete Config mode command signature is:\n"
" find_package(<package> [major[.minor[.patch]]] [EXACT] [QUIET]\n"
" find_package(<package> [version] [EXACT] [QUIET]\n"
" [[REQUIRED|COMPONENTS] [components...]] [NO_MODULE]\n"
" [NAMES name1 [name2 ...]]\n"
" [CONFIGS config1 [config2 ...]]\n"
......@@ -153,9 +155,9 @@ cmFindPackageCommand::cmFindPackageCommand()
"a configuration file a fatal error is always generated because user "
"intervention is required."
"\n"
"When the \"[major[.minor[.patch]]]\" version argument is specified "
"Config mode will only find a version of the package that claims "
"compatibility with the requested version. "
"When the [version] argument is given Config mode will only find a "
"version of the package that claims compatibility with the requested "
"version (format is major[.minor[.patch[.tweak]]]). "
"If the EXACT option is given only a version of the package claiming "
"an exact match of the requested version may be found. "
"CMake does not establish any convention for the meaning of version "
......@@ -173,22 +175,26 @@ cmFindPackageCommand::cmFindPackageCommand()
"variables have been defined:\n"
" PACKAGE_FIND_NAME = the <package> name\n"
" PACKAGE_FIND_VERSION = full requested version string\n"
" PACKAGE_FIND_VERSION_MAJOR = requested major version, if any\n"
" PACKAGE_FIND_VERSION_MINOR = requested minor version, if any\n"
" PACKAGE_FIND_VERSION_PATCH = requested patch version, if any\n"
" PACKAGE_FIND_VERSION_MAJOR = major version if requested, else 0\n"
" PACKAGE_FIND_VERSION_MINOR = minor version if requested, else 0\n"
" PACKAGE_FIND_VERSION_PATCH = patch version if requested, else 0\n"
" PACKAGE_FIND_VERSION_TWEAK = tweak version if requested, else 0\n"
" PACKAGE_FIND_VERSION_COUNT = number of version components, 0 to 4\n"
"The version file checks whether it satisfies the requested version "
"and sets these variables:\n"
" PACKAGE_VERSION = package version (major[.minor[.patch]])\n"
" PACKAGE_VERSION = full provided version string\n"
" PACKAGE_VERSION_EXACT = true if version is exact match\n"
" PACKAGE_VERSION_COMPATIBLE = true if version is compatible\n"
"These variables are checked by the find_package command to determine "
"whether the configuration file provides an acceptable version. "
"They are not available after the find_package call returns. "
"If the version is acceptable the following variables are set:\n"
" <package>_VERSION = package version (major[.minor[.patch]])\n"
" <package>_VERSION_MAJOR = major from major[.minor[.patch]], if any\n"
" <package>_VERSION_MINOR = minor from major[.minor[.patch]], if any\n"
" <package>_VERSION_PATCH = patch from major[.minor[.patch]], if any\n"
" <package>_VERSION = full provided version string\n"
" <package>_VERSION_MAJOR = major version if provided, else 0\n"
" <package>_VERSION_MINOR = minor version if provided, else 0\n"
" <package>_VERSION_PATCH = patch version if provided, else 0\n"
" <package>_VERSION_TWEAK = tweak version if provided, else 0\n"
" <package>_VERSION_COUNT = number of version components, 0 to 4\n"
"and the corresponding package configuration file is loaded. "
"When multiple package configuration files are available whose version "
"files claim compatibility with the version requested it is unspecified "
......@@ -411,7 +417,7 @@ bool cmFindPackageCommand
{
// Set a variable telling the find script this component
// is required.
std::string req_var = Name + "_FIND_REQUIRED_" + args[i];
std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i];
this->Makefile->AddDefinition(req_var.c_str(), "1");
// Append to the list of required components.
......@@ -469,10 +475,13 @@ bool cmFindPackageCommand
unsigned int parsed_major;
unsigned int parsed_minor;
unsigned int parsed_patch;
this->VersionCount = sscanf(this->Version.c_str(), "%u.%u.%u",
&parsed_major, &parsed_minor, &parsed_patch);
unsigned int parsed_tweak;
this->VersionCount = sscanf(this->Version.c_str(), "%u.%u.%u.%u",
&parsed_major, &parsed_minor,
&parsed_patch, &parsed_tweak);
switch(this->VersionCount)
{
case 4: this->VersionTweak = parsed_tweak; // no break!
case 3: this->VersionPatch = parsed_patch; // no break!
case 2: this->VersionMinor = parsed_minor; // no break!
case 1: this->VersionMajor = parsed_major; // no break!
......@@ -480,9 +489,7 @@ bool cmFindPackageCommand
}
}
// Store the list of components.
std::string components_var = Name + "_FIND_COMPONENTS";
this->Makefile->AddDefinition(components_var.c_str(), components.c_str());
this->SetModuleVariables(components);
// See if there is a Find<package>.cmake module.
if(!this->NoModule)
......@@ -533,6 +540,60 @@ bool cmFindPackageCommand
return result;
}
//----------------------------------------------------------------------------
void cmFindPackageCommand::SetModuleVariables(const std::string& components)
{
// Store the list of components.
std::string components_var = this->Name + "_FIND_COMPONENTS";
this->Makefile->AddDefinition(components_var.c_str(), components.c_str());
if(this->Quiet)
{
// Tell the module that is about to be read that it should find
// quietly.
std::string quietly = this->Name;
quietly += "_FIND_QUIETLY";
this->Makefile->AddDefinition(quietly.c_str(), "1");
}
if(this->Required)
{
// Tell the module that is about to be read that it should report
// a fatal error if the package is not found.
std::string req = this->Name;
req += "_FIND_REQUIRED";
this->Makefile->AddDefinition(req.c_str(), "1");
}
if(!this->Version.empty())
{
// Tell the module that is about to be read what version of the
// package has been requested.
std::string ver = this->Name;
ver += "_FIND_VERSION";
this->Makefile->AddDefinition(ver.c_str(), this->Version.c_str());
char buf[64];
sprintf(buf, "%u", this->VersionMajor);
this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
sprintf(buf, "%u", this->VersionMinor);
this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
sprintf(buf, "%u", this->VersionPatch);
this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
sprintf(buf, "%u", this->VersionTweak);
this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf);
sprintf(buf, "%u", this->VersionCount);
this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf);
// Tell the module whether an exact version has been requested.
std::string exact = this->Name;
exact += "_FIND_VERSION_EXACT";
this->Makefile->AddDefinition(exact.c_str(),
this->VersionExact? "1":"0");
}
}
//----------------------------------------------------------------------------
bool cmFindPackageCommand::FindModule(bool& found)
{
......@@ -542,59 +603,6 @@ bool cmFindPackageCommand::FindModule(bool& found)
std::string mfile = this->Makefile->GetModulesFile(module.c_str());
if ( mfile.size() )
{
if(this->Quiet)
{
// Tell the module that is about to be read that it should find
// quietly.
std::string quietly = this->Name;
quietly += "_FIND_QUIETLY";
this->Makefile->AddDefinition(quietly.c_str(), "1");
}
if(this->Required)
{
// Tell the module that is about to be read that it should report
// a fatal error if the package is not found.
std::string req = this->Name;
req += "_FIND_REQUIRED";
this->Makefile->AddDefinition(req.c_str(), "1");
}
if(!this->Version.empty())
{
// Tell the module that is about to be read what version of the
// package has been requested.
std::string ver = this->Name;
ver += "_FIND_VERSION";
this->Makefile->AddDefinition(ver.c_str(), this->Version.c_str());
char buf[64];
switch(this->VersionCount)
{
case 3:
{
sprintf(buf, "%u", this->VersionPatch);
this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
} // no break
case 2:
{
sprintf(buf, "%u", this->VersionMinor);
this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
} // no break
case 1:
{
sprintf(buf, "%u", this->VersionMajor);
this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
} // no break
default: break;
}
// Tell the module whether an exact version has been requested.