summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-07-27 12:59:59 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-07-27 12:59:59 (GMT)
commitd6a0c330bc2087eb5007d4b6b056e573220dc590 (patch)
tree1413695a25b3348b79d3541c22029fb7b80bc3a3
parente2aeecc29440b906fad3d8964b169b62cdfef188 (diff)
downloadCMake-d6a0c330bc2087eb5007d4b6b056e573220dc590.zip
CMake-d6a0c330bc2087eb5007d4b6b056e573220dc590.tar.gz
CMake-d6a0c330bc2087eb5007d4b6b056e573220dc590.tar.bz2
ENH: deb generator can now generate deb packages
-remove the unscriptable commands also from the cpack cmake -use CPACK_PACKAGE_CONTACT in CMakeCPack.cmake, it's used in the nsis and the deb generator -make set_properties() scriptable -use a non-const char array for adding the python modules Alex
-rw-r--r--CMakeCPack.cmake3
-rw-r--r--Modules/CPackDeb.cmake50
-rw-r--r--Modules/FindPythonLibs.cmake2
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx40
-rw-r--r--Source/CPack/cpack.cxx1
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx20
-rw-r--r--Source/cmSetPropertiesCommand.h7
-rw-r--r--Source/cmake.cxx23
-rw-r--r--Source/cmake.h1
9 files changed, 104 insertions, 43 deletions
diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake
index 23739a9..f676349 100644
--- a/CMakeCPack.cmake
+++ b/CMakeCPack.cmake
@@ -31,6 +31,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
+ SET(CPACK_PACKAGE_CONTACT "cmake@cmake.org")
IF(WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
@@ -40,7 +41,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} a cross-platform, open-source build system")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.cmake.org")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.kitware.com")
- SET(CPACK_NSIS_CONTACT "cmake@cmake.org")
+ SET(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
SET(CPACK_NSIS_MODIFY_PATH ON)
ELSE(WIN32 AND NOT UNIX)
SET(CPACK_STRIP_FILES "bin/ccmake;bin/cmake;bin/cpack;bin/ctest")
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index e4c123b..4b782c8 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -8,3 +8,53 @@ ENDIF(NOT UNIX)
FIND_PROGRAM(AR_EXECUTABLE ar)
+IF(NOT AR_EXECUTABLE)
+ # Is there a *NIX out there without ar ?
+ MESSAGE(FATAL_ERROR "debian package require a ar executable")
+ENDIF(NOT AR_EXECUTABLE)
+
+# Let's define the control file found in debian package:
+
+# Package:
+# debian policy enforce lower case for package name
+IF(NOT DEBIAN_PACKAGE_NAME)
+ STRING(TOLOWER ${CPACK_PACKAGE_NAME} DEBIAN_PACKAGE_NAME)
+ENDIF(NOT DEBIAN_PACKAGE_NAME)
+
+# Version:
+IF(NOT DEBIAN_PACKAGE_VERSION)
+ IF(NOT CPACK_PACKAGE_VERSION)
+ MESSAGE(FATAL_ERROR "debian package require a package version")
+ ENDIF(NOT CPACK_PACKAGE_VERSION)
+ SET(DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
+ENDIF(NOT DEBIAN_PACKAGE_VERSION)
+
+# Architecture:
+IF(NOT DEBIAN_PACKAGE_ARCHITECTURE)
+# There is no such thing as i686 architecture on debian, you should use i386 instead
+# $ dpkg --print-architecture
+ SET(DEBIAN_PACKAGE_ARCHITECTURE i386)
+ENDIF(NOT DEBIAN_PACAKGE_ARCHITECTURE)
+
+# Depends:
+IF(NOT DEBIAN_PACKAGE_DEPENDS)
+ SET(DEBIAN_PACKAGE_DEPENDS
+ "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12)"
+ )
+ENDIF(NOT DEBIAN_PACKAGE_DEPENDS)
+
+# Maintainer:
+IF(NOT DEBIAN_PACKAGE_MAINTAINER)
+ IF(NOT CPACK_PACKAGE_CONTACT)
+ MESSAGE(FATAL_ERROR "debian package require a maintainer for a package")
+ ENDIF(NOT CPACK_PACKAGE_CONTACT)
+ SET(DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
+ENDIF(NOT DEBIAN_PACKAGE_MAINTAINER)
+
+# Description:
+IF(NOT DEBIAN_PACKAGE_DESCRIPTION)
+ IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+ MESSAGE(FATAL_ERROR "debian package require a summary for a package")
+ ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+ SET(DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
+ENDIF(NOT DEBIAN_PACKAGE_DESCRIPTION)
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 029d0fd..5e7da5a 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -127,7 +127,7 @@ MACRO(PYTHON_WRITE_MODULES_HEADER _filename)
ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
- FILE(APPEND ${_filename} "int CMakeLoadPythonModule_${_currentModule}(void) \n{\n return PyImport_AppendInittab(\"${_currentModule}\", init${_currentModule});\n}\n\n")
+ FILE(APPEND ${_filename} "int CMakeLoadPythonModule_${_currentModule}(void) \n{\n char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n")
ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FILE(APPEND ${_filename} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n")
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index c4c4750..a9078f8 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -52,39 +52,36 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
out << std::endl; // required for valid debian package
}
- // debian policy enforce lower case for package name
- // IF(NOT DEBIAN_PACKAGE_NAME)
- // STRING(TOLOWER
- // ${CPACK_PACKAGE_NAME}
- // DEBIAN_PACKAGE_NAME
- // )
-
// control file
std::string ctlfilename;
ctlfilename = toplevel;
ctlfilename += "/control";
+
+ // debian policy enforce lower case for package name
+ std::string debian_pkg_name = cmsys::SystemTools::LowerCase( this->GetOption("DEBIAN_PACKAGE_NAME") );
+ const char* debian_pkg_version = this->GetOption("DEBIAN_PACKAGE_VERSION");
+ const char* debian_pkg_arch = this->GetOption("DEBIAN_PACKAGE_ARCHITECTURE");
+ const char* debian_pkg_dep = this->GetOption("DEBIAN_PACKAGE_DEPENDS");
+ const char* maintainer = this->GetOption("DEBIAN_PACKAGE_MAINTAINER");
+ const char* desc = this->GetOption("DEBIAN_PACKAGE_DESCRIPTION");
+
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(ctlfilename.c_str());
- out << "Package: ${DEBIAN_PACKAGE_NAME}\n";
- out << "Version: ${CPACK_PACKAGE_VERSION}\n";
+ out << "Package: " << debian_pkg_name << "\n";
+ out << "Version: " << debian_pkg_version << "\n";
out << "Section: devel\n";
out << "Priority: optional\n";
- out << "Architecture: ${DEBIAN_ARCHITECTURE}\n";
- out << "Depends: ${DEBIAN_PACKAGE_DEPENDS}\n";
- out << "Maintainer: ${CPACK_NSIS_CONTACT}\n";
- out << "Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n";
- out << "${DEBIAN_PACKAGE_NAME} was packaged by UseDebian and CMake.\n";
+ out << "Architecture: " << debian_pkg_arch << "\n";
+ out << "Depends: " << debian_pkg_dep << " \n";
+ out << "Maintainer: " << maintainer << "\n";
+ out << "Description: " << desc << "\n";
+ out << " " << debian_pkg_name << " was packaged by CMake.\n";
out << std::endl;
}
- std::string output;
- std::string cmd;
-// cmd = this->GetOption("CPACK_DEB_COMMAND");
-// cmsys::SystemTools::ReplaceString(cmd, "<ARCHIVE>", outFileName);
-// cmsys::SystemTools::ReplaceString(cmd, "<FILELIST>", "deb.filelist");
-
- cmd = cmakeExecutable;
+ std::string cmd = cmakeExecutable;
cmd += " -E tar cfz data.tar.gz ./usr";
+ std::string output;
int retVal = -1;
int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0);
@@ -151,6 +148,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName,
cmd += "\" debian-binary control.tar.gz data.tar.gz";
res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0);
+
return 1;
}
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index a737d8b..8428315 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -218,6 +218,7 @@ int main (int argc, char *argv[])
"Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
cmake cminst;
+ cminst.RemoveUnscriptableCommands();
cmGlobalGenerator cmgg;
cmgg.SetCMakeInstance(&cminst);
cmLocalGenerator* cmlg = cmgg.CreateLocalGenerator();
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index db44531..64cf92d 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -303,25 +303,7 @@ void cmCTestScriptHandler::CreateCMake()
// remove all cmake commands which are not scriptable, since they can't be
// used in ctest scripts
- std::vector<std::string> unscriptableCommands;
- cmake::RegisteredCommandsMap* commands = this->CMake->GetCommands();
- for (cmake::RegisteredCommandsMap::const_iterator pos = commands->begin();
- pos != commands->end();
- ++pos)
- {
- if (!pos->second->IsScriptable())
- {
- unscriptableCommands.push_back(pos->first);
- }
- }
-
- for(std::vector<std::string>::const_iterator it=unscriptableCommands.begin();
- it != unscriptableCommands.end();
- ++it)
- {
-// fprintf(stderr, "Removing %s\n", it->c_str());
- this->CMake->RemoveCommand(it->c_str());
- }
+ this->CMake->RemoveUnscriptableCommands();
// add any ctest specific commands, probably should have common superclass
// for ctest commands to clean this up. If a couple more commands are
diff --git a/Source/cmSetPropertiesCommand.h b/Source/cmSetPropertiesCommand.h
index 51c52b1..79c9394 100644
--- a/Source/cmSetPropertiesCommand.h
+++ b/Source/cmSetPropertiesCommand.h
@@ -60,7 +60,12 @@ public:
"or TEST test_name."
;
}
-
+
+ /**
+ * This determines if the command is invoked when in script mode.
+ */
+ virtual bool IsScriptable() { return true; }
+
cmTypeMacro(cmSetPropertiesCommand, cmCommand);
};
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index c8d5fde..ea1e8b7 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -290,6 +290,29 @@ void cmake::AddCommand(cmCommand* wg)
this->Commands.insert( RegisteredCommandsMap::value_type(name, wg));
}
+
+void cmake::RemoveUnscriptableCommands()
+{
+ std::vector<std::string> unscriptableCommands;
+ cmake::RegisteredCommandsMap* commands = this->GetCommands();
+ for (cmake::RegisteredCommandsMap::const_iterator pos = commands->begin();
+ pos != commands->end();
+ ++pos)
+ {
+ if (!pos->second->IsScriptable())
+ {
+ unscriptableCommands.push_back(pos->first);
+ }
+ }
+
+ for(std::vector<std::string>::const_iterator it=unscriptableCommands.begin();
+ it != unscriptableCommands.end();
+ ++it)
+ {
+ this->RemoveCommand(it->c_str());
+ }
+}
+
// Parse the args
bool cmake::SetCacheArgs(const std::vector<std::string>& args)
{
diff --git a/Source/cmake.h b/Source/cmake.h
index a089e95..c0b3cd0 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -197,6 +197,7 @@ class cmake
void AddCommand(cmCommand* );
void RenameCommand(const char* oldName, const char* newName);
void RemoveCommand(const char* name);
+ void RemoveUnscriptableCommands();
/**
* Get a command by its name