summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2009-04-07 15:32:08 -0400
committerBill Hoffman <bill.hoffman@kitware.com>2009-04-07 15:32:08 -0400
commita04d74ade11a0ce1f9f60e2e333ea05d3c669fcb (patch)
treea8c1da2aeef3772505dcea53e331591d6ae547e4
parentd78e076d77c091fd53ca3a6ce591249232bb6945 (diff)
downloadcmake-a04d74ade11a0ce1f9f60e2e333ea05d3c669fcb.tar.gz
ENH: merge in changes for RC 4
-rw-r--r--CMakeLists.txt2
-rw-r--r--ChangeLog.manual5
-rw-r--r--Source/cmAddCustomCommandCommand.h13
-rw-r--r--Source/cmAddCustomTargetCommand.h10
-rw-r--r--Source/cmComputeLinkDepends.cxx34
-rw-r--r--Source/cmComputeLinkDepends.h6
-rw-r--r--Source/kwsys/SystemInformation.cxx59
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt69
-rw-r--r--Tests/ExportImport/Import/A/imp_lib1.c6
-rw-r--r--Tests/ExportImport/Import/A/imp_mod1.c (renamed from Tests/ExportImport/Import/imp_mod1.c)0
-rw-r--r--Tests/ExportImport/Import/A/imp_testExe1.c (renamed from Tests/ExportImport/Import/imp_testExe1.c)0
-rw-r--r--Tests/ExportImport/Import/CMakeLists.txt78
-rw-r--r--Tests/ExportImport/Import/imp_testTransExe1.c6
13 files changed, 173 insertions, 115 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22d20f6eed..d991e7ba48 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -354,7 +354,7 @@ ENDMACRO (CMAKE_BUILD_UTILITIES)
SET(CMake_VERSION_MAJOR 2)
SET(CMake_VERSION_MINOR 6)
SET(CMake_VERSION_PATCH 4)
-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]$")
diff --git a/ChangeLog.manual b/ChangeLog.manual
index 242db52f32..36e4abb16a 100644
--- a/ChangeLog.manual
+++ b/ChangeLog.manual
@@ -1,3 +1,8 @@
+Changes in CMake 2.6.4 RC 4
+- Better document Verbatim in custom commands
+- Fix #8843 ctest system information was not always correct on linux
+- Fix transitive linking of imported libraries
+
Changes in CMake 2.6.4 RC 3
- Documentation fix for #8815
- Fix CDash only submit with ctest_submit
diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h
index 8add9708ec..e750ebfa3c 100644
--- a/Source/cmAddCustomCommandCommand.h
+++ b/Source/cmAddCustomCommandCommand.h
@@ -123,14 +123,15 @@ public:
"options are currently ignored when APPEND is given, "
"but may be used in the future."
"\n"
- "If VERBATIM is given then all the arguments to the commands will be "
- "passed exactly as specified no matter the build tool used. "
+ "If VERBATIM is given then all arguments to the commands will be "
+ "escaped properly for the build tool so that the invoked command "
+ "receives each argument unchanged. "
"Note that one level of escapes is still used by the CMake language "
- "processor before ADD_CUSTOM_TARGET even sees the arguments. "
+ "processor before add_custom_command even sees the arguments. "
"Use of VERBATIM is recommended as it enables correct behavior. "
- "When VERBATIM is not given the behavior is platform specific. "
- "In the future VERBATIM may be enabled by default. The only reason "
- "it is an option is to preserve compatibility with older CMake code.\n"
+ "When VERBATIM is not given the behavior is platform specific because "
+ "there is no protection of tool-specific special characters."
+ "\n"
"If the output of the custom command is not actually "
"created as a file on disk it should be marked as SYMBOLIC with "
"SET_SOURCE_FILES_PROPERTIES.\n"
diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h
index c4895c02fe..71b60e657c 100644
--- a/Source/cmAddCustomTargetCommand.h
+++ b/Source/cmAddCustomTargetCommand.h
@@ -89,14 +89,14 @@ public:
"Dependencies listed with the DEPENDS argument may reference files "
"and outputs of custom commands created with add_custom_command() in "
"the same directory (CMakeLists.txt file).\n"
- "If VERBATIM is given then all the arguments to the commands will be "
- "passed exactly as specified no matter the build tool used. "
+ "If VERBATIM is given then all arguments to the commands will be "
+ "escaped properly for the build tool so that the invoked command "
+ "receives each argument unchanged. "
"Note that one level of escapes is still used by the CMake language "
"processor before add_custom_target even sees the arguments. "
"Use of VERBATIM is recommended as it enables correct behavior. "
- "When VERBATIM is not given the behavior is platform specific. "
- "In the future VERBATIM may be enabled by default. The only reason "
- "it is an option is to preserve compatibility with older CMake code."
+ "When VERBATIM is not given the behavior is platform specific because "
+ "there is no protection of tool-specific special characters."
"\n"
"The SOURCES option specifies additional source files to be included "
"in the custom target. "
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 7b768dc051..1278d8c369 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -295,7 +295,8 @@ cmComputeLinkDepends::AllocateLinkEntry(std::string const& item)
}
//----------------------------------------------------------------------------
-int cmComputeLinkDepends::AddLinkEntry(std::string const& item)
+int cmComputeLinkDepends::AddLinkEntry(int depender_index,
+ std::string const& item)
{
// Check if the item entry has already been added.
std::map<cmStdString, int>::iterator lei = this->LinkEntryIndex.find(item);
@@ -312,7 +313,7 @@ int cmComputeLinkDepends::AddLinkEntry(std::string const& item)
int index = lei->second;
LinkEntry& entry = this->EntryList[index];
entry.Item = item;
- entry.Target = this->FindTargetToLink(entry.Item.c_str());
+ entry.Target = this->FindTargetToLink(depender_index, entry.Item.c_str());
entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' &&
item.substr(0, 10) != "-framework");
@@ -409,7 +410,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
// Initialize the item entry.
LinkEntry& entry = this->EntryList[lei->second];
entry.Item = dep.Item;
- entry.Target = this->FindTargetToLink(dep.Item.c_str());
+ entry.Target = this->FindTargetToLink(dep.DependerIndex,
+ dep.Item.c_str());
// This item was added specifically because it is a dependent
// shared library. It may get special treatment
@@ -500,7 +502,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
}
else if(this->OldLinkDirMode)
{
- this->CheckWrongConfigItem(*di);
+ this->CheckWrongConfigItem(depender_index, *di);
}
// Reset the link type until another explicit type is given.
@@ -529,7 +531,7 @@ cmComputeLinkDepends::AddTargetLinkEntries(int depender_index,
}
else if(this->OldLinkDirMode)
{
- this->CheckWrongConfigItem(li->first);
+ this->CheckWrongConfigItem(depender_index, li->first);
}
}
@@ -558,7 +560,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
}
// Add a link entry for this item.
- int dependee_index = this->AddLinkEntry(item);
+ int dependee_index = this->AddLinkEntry(depender_index, item);
// The dependee must come after the depender.
if(depender_index >= 0)
@@ -664,10 +666,19 @@ std::string cmComputeLinkDepends::CleanItemName(std::string const& item)
}
//----------------------------------------------------------------------------
-cmTarget* cmComputeLinkDepends::FindTargetToLink(const char* name)
+cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index,
+ const char* name)
{
- // Look for a target.
- cmTarget* tgt = this->Makefile->FindTargetToUse(name);
+ // Look for a target in the scope of the depender.
+ cmMakefile* mf = this->Makefile;
+ if(depender_index >= 0)
+ {
+ if(cmTarget* depender = this->EntryList[depender_index].Target)
+ {
+ mf = depender->GetMakefile();
+ }
+ }
+ cmTarget* tgt = mf->FindTargetToUse(name);
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
@@ -987,7 +998,8 @@ void cmComputeLinkDepends::DisplayFinalEntries()
}
//----------------------------------------------------------------------------
-void cmComputeLinkDepends::CheckWrongConfigItem(std::string const& item)
+void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index,
+ std::string const& item)
{
if(!this->OldLinkDirMode)
{
@@ -997,7 +1009,7 @@ void cmComputeLinkDepends::CheckWrongConfigItem(std::string const& item)
// For CMake 2.4 bug-compatibility we need to consider the output
// directories of targets linked in another configuration as link
// directories.
- if(cmTarget* tgt = this->FindTargetToLink(item.c_str()))
+ if(cmTarget* tgt = this->FindTargetToLink(depender_index, item.c_str()))
{
if(!tgt->IsImported())
{
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index 47fa6489ec..fdca2b558f 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -81,14 +81,14 @@ private:
std::map<cmStdString, int>::iterator
AllocateLinkEntry(std::string const& item);
- int AddLinkEntry(std::string const& item);
+ int AddLinkEntry(int depender_index, std::string const& item);
void AddVarLinkEntries(int depender_index, const char* value);
void AddTargetLinkEntries(int depender_index,
LinkLibraryVectorType const& libs);
void AddLinkEntries(int depender_index,
std::vector<std::string> const& libs);
std::string CleanItemName(std::string const& item);
- cmTarget* FindTargetToLink(const char* name);
+ cmTarget* FindTargetToLink(int depender_index, const char* name);
// One entry for each unique item.
std::vector<LinkEntry> EntryList;
@@ -162,7 +162,7 @@ private:
// Compatibility help.
bool OldLinkDirMode;
- void CheckWrongConfigItem(std::string const& item);
+ void CheckWrongConfigItem(int depender_index, std::string const& item);
std::set<cmTarget*> OldWrongConfigItems;
};
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 2ed5161235..b597686aeb 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -2273,7 +2273,7 @@ int SystemInformationImplementation::QueryMemory()
unsigned long av=0;
unsigned long ap=0;
- char buffer[1024]; // for skipping unused lines
+ char buffer[1024]; // for reading lines
int linuxMajor = 0;
int linuxMinor = 0;
@@ -2316,34 +2316,39 @@ int SystemInformationImplementation::QueryMemory()
// new /proc/meminfo format since kernel 2.6.x
// Rigorously, this test should check from the developping version 2.5.x
// that introduced the new format...
-
- long freeMem;
- long buffersMem;
- long cachedMem;
-
- fscanf(fd,"MemTotal:%ld kB\n", &this->TotalPhysicalMemory);
- fscanf(fd,"MemFree:%ld kB\n", &freeMem);
- fscanf(fd,"Buffers:%ld kB\n", &buffersMem);
- fscanf(fd,"Cached:%ld kB\n", &cachedMem);
-
- this->TotalPhysicalMemory /= 1024;
- this->AvailablePhysicalMemory = freeMem+cachedMem+buffersMem;
- this->AvailablePhysicalMemory /= 1024;
-
- // Skip SwapCached, Active, Inactive, HighTotal, HighFree, LowTotal
- // and LowFree.
- int i=0;
- while(i<7)
+
+ enum { mMemTotal, mMemFree, mBuffers, mCached, mSwapTotal, mSwapFree };
+ const char* format[6] =
+ { "MemTotal:%lu kB", "MemFree:%lu kB", "Buffers:%lu kB",
+ "Cached:%lu kB", "SwapTotal:%lu kB", "SwapFree:%lu kB" };
+ bool have[6] = { false, false, false, false, false, false };
+ unsigned long value[6];
+ int count = 0;
+ while(fgets(buffer, sizeof(buffer), fd))
{
- fgets(buffer, sizeof(buffer), fd); // skip a line
- ++i;
+ for(int i=0; i < 6; ++i)
+ {
+ if(!have[i] && sscanf(buffer, format[i], &value[i]) == 1)
+ {
+ have[i] = true;
+ ++count;
+ }
+ }
+ }
+ if(count == 6)
+ {
+ this->TotalPhysicalMemory = value[mMemTotal] / 1024;
+ this->AvailablePhysicalMemory =
+ (value[mMemFree] + value[mBuffers] + value[mCached]) / 1024;
+ this->TotalVirtualMemory = value[mSwapTotal] / 1024;
+ this->AvailableVirtualMemory = value[mSwapFree] / 1024;
+ }
+ else
+ {
+ kwsys_ios::cout << "Problem parsing /proc/meminfo" << kwsys_ios::endl;
+ fclose(fd);
+ return 0;
}
-
- fscanf(fd,"SwapTotal:%ld kB\n", &this->TotalVirtualMemory);
- fscanf(fd,"SwapFree:%ld kB\n", &this->AvailableVirtualMemory);
-
- this->TotalVirtualMemory /= 1024;
- this->AvailableVirtualMemory /= 1024;
}
else
{
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
new file mode 100644
index 0000000000..16cff2df24
--- /dev/null
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -0,0 +1,69 @@
+# Import targets from the exported build tree.
+include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
+
+# Import targets from the exported install tree.
+include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake)
+
+# Try referencing an executable imported from the install tree.
+add_custom_command(
+ OUTPUT ${Import_BINARY_DIR}/exp_generated.c
+ COMMAND exp_testExe1 ${Import_BINARY_DIR}/exp_generated.c
+ DEPENDS exp_testExe1
+ )
+add_custom_command(
+ OUTPUT ${Import_BINARY_DIR}/exp_generated3.c
+ COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c
+ DEPENDS exp_testExe3
+ )
+
+add_executable(imp_testExe1
+ imp_testExe1.c
+ ${Import_BINARY_DIR}/exp_generated.c
+ ${Import_BINARY_DIR}/exp_generated3.c
+ )
+
+# Try linking to a library imported from the install tree.
+target_link_libraries(imp_testExe1 exp_testLib2 exp_testLib3 exp_testLib4)
+
+# Try building a plugin to an executable imported from the install tree.
+add_library(imp_mod1 MODULE imp_mod1.c)
+target_link_libraries(imp_mod1 exp_testExe2)
+
+# Try referencing an executable imported from the build tree.
+add_custom_command(
+ OUTPUT ${Import_BINARY_DIR}/bld_generated.c
+ COMMAND bld_testExe1 ${Import_BINARY_DIR}/bld_generated.c
+ DEPENDS bld_testExe1
+ )
+add_custom_command(
+ OUTPUT ${Import_BINARY_DIR}/bld_generated3.c
+ COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c
+ DEPENDS bld_testExe3
+ )
+
+add_executable(imp_testExe1b
+ imp_testExe1.c
+ ${Import_BINARY_DIR}/bld_generated.c
+ ${Import_BINARY_DIR}/bld_generated3.c
+ )
+
+# Try linking to a library imported from the build tree.
+target_link_libraries(imp_testExe1b bld_testLib2 bld_testLib3 bld_testLib4)
+
+# Try building a plugin to an executable imported from the build tree.
+add_library(imp_mod1b MODULE imp_mod1.c)
+target_link_libraries(imp_mod1b bld_testExe2)
+
+# Export/CMakeLists.txt pretends the RelWithDebInfo (as well as Debug)
+# configuration should link to debug libs.
+foreach(c DEBUG RELWITHDEBINFO)
+ set_property(TARGET imp_testExe1 PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
+ set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
+endforeach(c)
+
+# Create a library to be linked by another directory in this project
+# to test transitive linking to otherwise invisible imported targets.
+add_library(imp_lib1 STATIC imp_lib1.c)
+target_link_libraries(imp_lib1 exp_testLib2)
+add_library(imp_lib1b STATIC imp_lib1.c)
+target_link_libraries(imp_lib1b bld_testLib2)
diff --git a/Tests/ExportImport/Import/A/imp_lib1.c b/Tests/ExportImport/Import/A/imp_lib1.c
new file mode 100644
index 0000000000..d8c66e63f9
--- /dev/null
+++ b/Tests/ExportImport/Import/A/imp_lib1.c
@@ -0,0 +1,6 @@
+extern int testLib2(void);
+
+int imp_lib1(void)
+{
+ return testLib2();
+}
diff --git a/Tests/ExportImport/Import/imp_mod1.c b/Tests/ExportImport/Import/A/imp_mod1.c
index 579d949c3f..579d949c3f 100644
--- a/Tests/ExportImport/Import/imp_mod1.c
+++ b/Tests/ExportImport/Import/A/imp_mod1.c
diff --git a/Tests/ExportImport/Import/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c
index 6424d33994..6424d33994 100644
--- a/Tests/ExportImport/Import/imp_testExe1.c
+++ b/Tests/ExportImport/Import/A/imp_testExe1.c
diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt
index 27f2910285..00bf3063d0 100644
--- a/Tests/ExportImport/Import/CMakeLists.txt
+++ b/Tests/ExportImport/Import/CMakeLists.txt
@@ -6,65 +6,19 @@ if(CMAKE_ANSI_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
endif(CMAKE_ANSI_CFLAGS)
-# Import targets from the exported build tree.
-include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
-
-# Import targets from the exported install tree.
-include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake)
-
-# Try referencing an executable imported from the install tree.
-add_custom_command(
- OUTPUT ${Import_BINARY_DIR}/exp_generated.c
- COMMAND exp_testExe1 ${Import_BINARY_DIR}/exp_generated.c
- DEPENDS exp_testExe1
- )
-add_custom_command(
- OUTPUT ${Import_BINARY_DIR}/exp_generated3.c
- COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c
- DEPENDS exp_testExe3
- )
-
-add_executable(imp_testExe1
- imp_testExe1.c
- ${Import_BINARY_DIR}/exp_generated.c
- ${Import_BINARY_DIR}/exp_generated3.c
- )
-
-# Try linking to a library imported from the install tree.
-target_link_libraries(imp_testExe1 exp_testLib2 exp_testLib3 exp_testLib4)
-
-# Try building a plugin to an executable imported from the install tree.
-add_library(imp_mod1 MODULE imp_mod1.c)
-target_link_libraries(imp_mod1 exp_testExe2)
-
-# Try referencing an executable imported from the build tree.
-add_custom_command(
- OUTPUT ${Import_BINARY_DIR}/bld_generated.c
- COMMAND bld_testExe1 ${Import_BINARY_DIR}/bld_generated.c
- DEPENDS bld_testExe1
- )
-add_custom_command(
- OUTPUT ${Import_BINARY_DIR}/bld_generated3.c
- COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c
- DEPENDS bld_testExe3
- )
-
-add_executable(imp_testExe1b
- imp_testExe1.c
- ${Import_BINARY_DIR}/bld_generated.c
- ${Import_BINARY_DIR}/bld_generated3.c
- )
-
-# Try linking to a library imported from the build tree.
-target_link_libraries(imp_testExe1b bld_testLib2 bld_testLib3 bld_testLib4)
-
-# Try building a plugin to an executable imported from the build tree.
-add_library(imp_mod1b MODULE imp_mod1.c)
-target_link_libraries(imp_mod1b bld_testExe2)
-
-# Export/CMakeLists.txt pretends the RelWithDebInfo (as well as Debug)
-# configuration should link to debug libs.
-foreach(c DEBUG RELWITHDEBINFO)
- set_property(TARGET imp_testExe1 PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
- set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
-endforeach(c)
+# Import everything in a subdirectory.
+add_subdirectory(A)
+
+# Make sure the imported targets are scoped inside the subdirectory.
+if(TARGET exp_testLib2)
+ message(FATAL_ERROR "Imported target exp_testLib2 is not scoped in subdir!")
+endif()
+if(TARGET bld_testLib2)
+ message(FATAL_ERROR "Imported target bld_testLib2 is not scoped in subdir!")
+endif()
+
+# Test transitive linking to a target imported in the subdirectory.
+add_executable(imp_testTransExe1 imp_testTransExe1.c)
+target_link_libraries(imp_testTransExe1 imp_lib1)
+add_executable(imp_testTransExe1b imp_testTransExe1.c)
+target_link_libraries(imp_testTransExe1b imp_lib1b)
diff --git a/Tests/ExportImport/Import/imp_testTransExe1.c b/Tests/ExportImport/Import/imp_testTransExe1.c
new file mode 100644
index 0000000000..360a112ac3
--- /dev/null
+++ b/Tests/ExportImport/Import/imp_testTransExe1.c
@@ -0,0 +1,6 @@
+extern int imp_lib1(void);
+
+int main()
+{
+ return imp_lib1();
+}