diff options
24 files changed, 976 insertions, 446 deletions
diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake new file mode 100644 index 0000000..9da7d30 --- /dev/null +++ b/Modules/CMakeASM_NASMInformation.cmake @@ -0,0 +1,46 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# support for the nasm assembler + +set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS nasm asm) + +if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) + if(WIN32) + if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) + SET(CMAKE_ASM_NASM_OBJECT_FORMAT win64) + else() + SET(CMAKE_ASM_NASM_OBJECT_FORMAT win32) + endif() + elseif(APPLE) + if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) + SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) + else() + SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho) + endif() + else() + if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) + SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) + else() + SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf) + endif() + endif() +endif() + +set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>") + +# Load the generic ASMInformation file: +set(ASM_DIALECT "_NASM") +include(CMakeASMInformation) +set(ASM_DIALECT) diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 06dd6b8..8353be4 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -65,6 +65,7 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_GNU "--version") SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "GNU assembler") + INCLUDE(CMakeDetermineCompilerId) CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT}) IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) diff --git a/Modules/CMakeDetermineASM_NASMCompiler.cmake b/Modules/CMakeDetermineASM_NASMCompiler.cmake new file mode 100644 index 0000000..d184c0a --- /dev/null +++ b/Modules/CMakeDetermineASM_NASMCompiler.cmake @@ -0,0 +1,27 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Find the nasm assembler. yasm (http://www.tortall.net/projects/yasm/) is nasm compatible + +SET(CMAKE_ASM_NASM_COMPILER_INIT nasm yasm) + +IF(NOT CMAKE_ASM_NASM_COMPILER) + FIND_PROGRAM(CMAKE_ASM_NASM_COMPILER nasm + "$ENV{ProgramFiles}/NASM") +ENDIF(NOT CMAKE_ASM_NASM_COMPILER) + +# Load the generic DetermineASM compiler file with the DIALECT set properly: +SET(ASM_DIALECT "_NASM") +INCLUDE(CMakeDetermineASMCompiler) +SET(ASM_DIALECT) diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index e20348a..1c63cca 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -83,7 +83,7 @@ #endif /* For windows compilers MSVC and Intel we can determine - the architecture of the compiler being used. This is becase + the architecture of the compiler being used. This is because the compilers do not have flags that can change the architecture, but rather depend on which compiler is being used */ diff --git a/Modules/CMakeTestASM-ATTCompiler.cmake b/Modules/CMakeTestASM-ATTCompiler.cmake index 3b7a74f..581ad0c 100644 --- a/Modules/CMakeTestASM-ATTCompiler.cmake +++ b/Modules/CMakeTestASM-ATTCompiler.cmake @@ -13,10 +13,10 @@ # License text for the above reference.) # This file is used by EnableLanguage in cmGlobalGenerator to -# determine that that selected ASM-ATT compiler can actually compile -# and link the most basic of programs. If not, a fatal error -# is set and cmake stops processing commands and will not generate -# any makefiles or projects. +# determine that the selected ASM-ATT "compiler" works. +# For assembler this can only check whether the compiler has been found, +# because otherwise there would have to be a separate assembler source file +# for each assembler on every architecture. SET(ASM_DIALECT "-ATT") INCLUDE(CMakeTestASMCompiler) diff --git a/Modules/CMakeTestASMCompiler.cmake b/Modules/CMakeTestASMCompiler.cmake index 54def81..56cf332 100644 --- a/Modules/CMakeTestASMCompiler.cmake +++ b/Modules/CMakeTestASMCompiler.cmake @@ -13,10 +13,11 @@ # License text for the above reference.) # This file is used by EnableLanguage in cmGlobalGenerator to -# determine that that selected ASM compiler can actually compile -# and link the most basic of programs. If not, a fatal error -# is set and cmake stops processing commands and will not generate -# any makefiles or projects. +# determine that the selected ASM compiler works. +# For assembler this can only check whether the compiler has been found, +# because otherwise there would have to be a separate assembler source file +# for each assembler on every architecture. + IF(CMAKE_ASM${ASM_DIALECT}_COMPILER) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS 1 CACHE INTERNAL "") ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER) diff --git a/Modules/CMakeTestASM_MASMCompiler.cmake b/Modules/CMakeTestASM_MASMCompiler.cmake index 84ca98f..8369b94 100644 --- a/Modules/CMakeTestASM_MASMCompiler.cmake +++ b/Modules/CMakeTestASM_MASMCompiler.cmake @@ -13,10 +13,10 @@ # License text for the above reference.) # This file is used by EnableLanguage in cmGlobalGenerator to -# determine that the selected ASM_MASM "compiler" (should be masm or masm64) -# can actually "compile" and link the most basic of programs. If not, a -# fatal error is set and cmake stops processing commands and will not generate -# any makefiles or projects. +# determine that the selected ASM_MASM "compiler" (should be masm or masm64) +# works. For assembler this can only check whether the compiler has been found, +# because otherwise there would have to be a separate assembler source file +# for each assembler on every architecture. SET(ASM_DIALECT "_MASM") INCLUDE(CMakeTestASMCompiler) diff --git a/Modules/CMakeTestASM_NASMCompiler.cmake b/Modules/CMakeTestASM_NASMCompiler.cmake new file mode 100644 index 0000000..a5e2bea --- /dev/null +++ b/Modules/CMakeTestASM_NASMCompiler.cmake @@ -0,0 +1,23 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This file is used by EnableLanguage in cmGlobalGenerator to +# determine that the selected ASM_NASM "compiler" works. +# For assembler this can only check whether the compiler has been found, +# because otherwise there would have to be a separate assembler source file +# for each assembler on every architecture. + +SET(ASM_DIALECT "_NASM") +INCLUDE(CMakeTestASMCompiler) +SET(ASM_DIALECT) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index e2d78802..ab909f4 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -331,7 +331,7 @@ ELSE(CPACK_RPM_COMPRESSION_TYPE) ENDIF(CPACK_RPM_COMPRESSION_TYPE) if(CPACK_PACKAGE_RELOCATABLE) - set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) + set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) endif(CPACK_PACKAGE_RELOCATABLE) if(CPACK_RPM_PACKAGE_RELOCATABLE) if(CPACK_RPM_PACKAGE_DEBUG) @@ -453,6 +453,17 @@ SET(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") #STRING(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") + +# Are we packaging components ? +IF(CPACK_RPM_PACKAGE_COMPONENT) + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "/${CPACK_RPM_PACKAGE_COMPONENT}") + SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_RPM_PACKAGE_COMPONENT}") +ELSE(CPACK_RPM_PACKAGE_COMPONENT) + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "") + SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") +ENDIF(CPACK_RPM_PACKAGE_COMPONENT) # Use files tree to construct files command (spec file) # We should not forget to include symlinks (thus -o -type l) # We must remove the './' due to the local search and escape the @@ -460,10 +471,10 @@ SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") # Then we must authorize any man pages extension (adding * at the end) # because rpmbuild may automatically compress those files EXECUTE_PROCESS(COMMAND find -type f -o -type l - COMMAND sed {s:.*/man.*/.*:&*:} - COMMAND sed {s/\\.\\\(.*\\\)/\"\\1\"/} - WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" - OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) + COMMAND sed {s:.*/man.*/.*:&*:} + COMMAND sed {s/\\.\\\(.*\\\)/\"\\1\"/} + WORKING_DIRECTORY "${WDIR}" + OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) if (CPACK_ABSOLUTE_DESTINATION_FILES) IF(CPACK_RPM_PACKAGE_DEBUG) @@ -494,7 +505,7 @@ if (CPACK_ABSOLUTE_DESTINATION_FILES) endif(CPACK_ABSOLUTE_DESTINATION_FILES) # The name of the final spec file to be used by rpmbuild -SET(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec") +SET(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec") # Print out some debug information if we were asked for that IF(CPACK_RPM_PACKAGE_DEBUG) @@ -517,7 +528,7 @@ ENDIF(CPACK_RPM_PACKAGE_DEBUG) IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in "# -*- rpm-spec -*- -BuildRoot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@ +BuildRoot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@ Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ Name: \@CPACK_RPM_PACKAGE_NAME\@ Version: \@CPACK_RPM_PACKAGE_VERSION\@ @@ -608,15 +619,15 @@ IF(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE EXECUTE_PROCESS( COMMAND "${RPMBUILD_EXECUTABLE}" -bb - --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" + --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" "${CPACK_RPM_BINARY_SPECFILE}" - WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" - ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err" - OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out") + WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" + ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err" + OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: You may consult rpmbuild logs in: ") - MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err") - MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out") + MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err") + MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") ENDIF(CPACK_RPM_PACKAGE_DEBUG) ELSE(RPMBUILD_EXECUTABLE) IF(ALIEN_EXECUTABLE) diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index 50c8527..ea0abb7 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -31,7 +31,7 @@ macro(_FIND_BULLET_LIBRARY _var) find_library(${_var} NAMES ${ARGN} - PATHS + HINTS ${BULLET_ROOT} ${BULLET_ROOT}/out/release8/libs ${BULLET_ROOT}/out/debug8/libs @@ -50,9 +50,10 @@ macro(_BULLET_APPEND_LIBRARIES _list _release) endmacro() find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h - PATHS + HINTS ${BULLET_ROOT}/include ${BULLET_ROOT}/src + PATH_SUFFIXES bullet ) # Find the libraries diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index df07d25..6a609a0 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -71,12 +71,12 @@ MACRO (QT4_GET_MOC_FLAGS _moc_flags) GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES) FOREACH(_current ${_inc_DIRS}) - IF("${_current}" MATCHES ".framework/?$") - STRING(REGEX REPLACE "/[^/]+.framework" "" framework_path "${_current}") + IF("${_current}" MATCHES "\\.framework/?$") + STRING(REGEX REPLACE "/[^/]+\\.framework" "" framework_path "${_current}") SET(${_moc_flags} ${${_moc_flags}} "-F${framework_path}") - ELSE("${_current}" MATCHES ".framework/?$") + ELSE("${_current}" MATCHES "\\.framework/?$") SET(${_moc_flags} ${${_moc_flags}} "-I${_current}") - ENDIF("${_current}" MATCHES ".framework/?$") + ENDIF("${_current}" MATCHES "\\.framework/?$") ENDFOREACH(_current ${_inc_DIRS}) GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 71284b2..718e52e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -183,6 +183,8 @@ SET(SRCS cmGlobalUnixMakefileGenerator3.cxx cmGlobalUnixMakefileGenerator3.h cmGraphAdjacencyList.h + cmGraphVizWriter.cxx + cmGraphVizWriter.h cmInstallGenerator.h cmInstallGenerator.cxx cmInstallExportGenerator.cxx @@ -332,7 +334,7 @@ ENDIF (WIN32) # create a library used by the command line and the GUI ADD_LIBRARY(CMakeLib ${SRCS}) -TARGET_LINK_LIBRARIES(CMakeLib cmsys +TARGET_LINK_LIBRARIES(CMakeLib cmsys ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} ${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES} ${CMAKE_CURL_LIBRARIES} ) @@ -432,7 +434,7 @@ IF(CYGWIN) CPack/cmCPackCygwinSourceGenerator.cxx ) ENDIF(CYGWIN) - + IF(UNIX) SET(CPACK_SRCS ${CPACK_SRCS} CPack/cmCPackDebGenerator.cxx diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index c86434e..424c1a0 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -105,12 +105,12 @@ if (!archive) \ } //---------------------------------------------------------------------- -int cmCPackArchiveGenerator::PackageComponents(bool ignoreComponentGroup) +int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) { packageFileNames.clear(); // The default behavior is to have one package by component group // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. - if (!ignoreComponentGroup) + if (!ignoreGroup) { std::map<std::string, cmCPackComponentGroup>::iterator compGIt; for (compGIt=this->ComponentGroups.begin(); @@ -170,7 +170,7 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreComponentGroup) } //---------------------------------------------------------------------- -int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponentInOne) +int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponent) { // reset the package file names packageFileNames.clear(); @@ -185,7 +185,7 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponentInOne) DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive); // The ALL GROUP in ONE package case - if (! allComponentInOne) { + if (! allComponent) { // iterate over the component groups std::map<std::string, cmCPackComponentGroup>::iterator compGIt; for (compGIt=this->ComponentGroups.begin(); @@ -226,63 +226,8 @@ int cmCPackArchiveGenerator::PackageFiles() cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl); - // The default behavior is to create 1 package by component group - // unless the user asked to put all COMPONENTS in a single package - bool allGroupInOne = (NULL != - (this->GetOption( - "CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE"))); - bool allComponentInOne = (NULL != - (this->GetOption( - "CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))); - bool ignoreComponentGroup = ( NULL != - (this->GetOption( - "CPACK_COMPONENTS_IGNORE_GROUPS"))); + PrepareGroupingKind(); - std::string groupingType; - - // Second way to specify grouping - if (NULL != this->GetOption("CPACK_COMPONENTS_GROUPING")) { - groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING"); - } - - if (groupingType.length()>0) - { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" - << this->Name << "]" - << " requested component grouping = "<< groupingType <<std::endl); - if (groupingType == "ALL_GROUP_IN_ONE") - { - allGroupInOne = true; - } - else if (groupingType == "ALL_COMPONENT_IN_ONE") - { - allComponentInOne = true; - } - else if (groupingType == "IGNORE") - { - ignoreComponentGroup = true; - } - else - { - cmCPackLogger(cmCPackLog::LOG_WARNING, "[" - << this->Name << "]" - << " requested component grouping type <"<< groupingType - << "> UNKNOWN not in (ALL_GROUP_IN_ONE," - "ALL_COMPONENT_IN_ONE,IGNORE)" <<std::endl); - } - } - - // Some components were defined but NO group - // force ignoreGroups - if (this->ComponentGroups.empty() && (!this->Components.empty()) - && (!ignoreComponentGroup)) { - cmCPackLogger(cmCPackLog::LOG_WARNING, "[" - << this->Name << "]" - << " Some Components defined but NO component group:" - << " Ignoring component group." - << std::endl); - ignoreComponentGroup = true; - } // CASE 1 : COMPONENT ALL-IN-ONE package // If ALL GROUPS or ALL COMPONENTS in ONE package has been requested // then the package file is unique and should be open here. diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 6e173bd..dc17257 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -60,12 +60,12 @@ protected: * install is used. This will create one * archive for each component group. */ - int PackageComponents(bool ignoreComponentGroup); + int PackageComponents(bool ignoreGroup); /** * Special case of component install where all * components will be put in a single installer. */ - int PackageComponentsAllInOne(bool allComponentInOne); + int PackageComponentsAllInOne(bool allComponent); virtual const char* GetOutputExtension() = 0; cmArchiveWrite::Compress Compress; cmArchiveWrite::Type Archive; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index c39aea4..92e5b6a 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -35,6 +35,9 @@ cmCPackGenerator::cmCPackGenerator() this->GeneratorVerbose = false; this->MakefileMap = 0; this->Logger = 0; + this->allGroupInOne = false; + this->allComponentInOne = false; + this->ignoreComponentGroup = false; } //---------------------------------------------------------------------- @@ -220,7 +223,7 @@ int cmCPackGenerator::InstallProject() // If the CPackConfig file sets CPACK_INSTALLED_DIRECTORIES // then glob it and copy it to CPACK_TEMPORARY_DIRECTORY - // This is used in Source packageing + // This is used in Source packaging if ( !this->InstallProjectViaInstalledDirectories( setDestDir, tempInstallDirectory) ) { @@ -691,7 +694,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // // If DESTDIR has been 'internally set ON' this means that // the underlying CPack specific generator did ask for that - // In this case we may overrode CPACK_INSTALL_PREFIX with + // In this case we may override CPACK_INSTALL_PREFIX with // CPACK_PACKAGING_INSTALL_PREFIX // I know this is tricky and awkward but it's the price for // CPACK_SET_DESTDIR backward compatibility. @@ -727,7 +730,20 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( { dir = tempInstallDirectory + "/" + dir; } - + /* + * We must re-set DESTDIR for each component + * We must not add the CPACK_INSTALL_PREFIX part because + * it will be added using the override of CMAKE_INSTALL_PREFIX + * The main reason for this awkward trick is that + * are using DESTDIR for 2 different reasons: + * - Because it was asked by the CPack Generator or the user + * using CPACK_SET_DESTDIR + * - Because it was already used for component install + * in order to put things in subdirs... + */ + cmSystemTools::PutEnv( + (std::string("DESTDIR=")+tempInstallDirectory).c_str() + ); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '" << dir << "'" << std::endl); @@ -1196,6 +1212,70 @@ int cmCPackGenerator::CleanTemporaryDirectory() } //---------------------------------------------------------------------- +int cmCPackGenerator::PrepareGroupingKind() +{ + // The default behavior is to create 1 package by component group + // unless the user asked to put all COMPONENTS in a single package + allGroupInOne = (NULL != + (this->GetOption( + "CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE"))); + allComponentInOne = (NULL != + (this->GetOption( + "CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))); + ignoreComponentGroup = (NULL != + (this->GetOption( + "CPACK_COMPONENTS_IGNORE_GROUPS"))); + + std::string groupingType; + + // Second way to specify grouping + if (NULL != this->GetOption("CPACK_COMPONENTS_GROUPING")) { + groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING"); + } + + if (groupingType.length()>0) + { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" + << this->Name << "]" + << " requested component grouping = "<< groupingType <<std::endl); + if (groupingType == "ALL_GROUP_IN_ONE") + { + allGroupInOne = true; + } + else if (groupingType == "ALL_COMPONENT_IN_ONE") + { + allComponentInOne = true; + } + else if (groupingType == "IGNORE") + { + ignoreComponentGroup = true; + } + else + { + cmCPackLogger(cmCPackLog::LOG_WARNING, "[" + << this->Name << "]" + << " requested component grouping type <"<< groupingType + << "> UNKNOWN not in (ALL_GROUP_IN_ONE," + "ALL_COMPONENT_IN_ONE,IGNORE)" <<std::endl); + } + } + + // Some components were defined but NO group + // force ignoreGroups + if (this->ComponentGroups.empty() && (!this->Components.empty()) + && (!ignoreComponentGroup)) { + cmCPackLogger(cmCPackLog::LOG_WARNING, "[" + << this->Name << "]" + << " Some Components defined but NO component group:" + << " Ignoring component group." + << std::endl); + ignoreComponentGroup = true; + } + + return 1; +} + +//---------------------------------------------------------------------- bool cmCPackGenerator::SupportsComponentInstallation() const { return false; diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 74b780d..c450763 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -120,6 +120,17 @@ protected: virtual const char* GetOutputPostfix() { return 0; } /** + * Prepare requested grouping kind from CPACK_xxx vars + * CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE + * CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE + * CPACK_COMPONENTS_IGNORE_GROUPS + * or + * CPACK_COMPONENTS_GROUPING + * @return 1 on success 0 on failure. + */ + virtual int PrepareGroupingKind(); + + /** * Package the list of files and/or components which * has been prepared by the beginning of DoPackage. * @pre @ref toplevel has been filled-in @@ -200,6 +211,20 @@ protected: */ std::map<std::string, cmCPackComponent> Components; std::map<std::string, cmCPackComponentGroup> ComponentGroups; + /** + * If true All component groups will be put in a single package. + */ + bool allGroupInOne; + /** + * If true All component will be put in a single package. + */ + bool allComponentInOne; + /** + * If true component grouping will be ignored. + * You will still get 1 package for each component unless + * allComponentInOne is true. + */ + bool ignoreComponentGroup; cmCPackLog* Logger; private: diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 0641418..34e93d3 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -37,13 +37,84 @@ int cmCPackRPMGenerator::InitializeInternal() //---------------------------------------------------------------------- int cmCPackRPMGenerator::PackageFiles() { - this->ReadListFile("CPackRPM.cmake"); + int retval = 1; + /* Digest Component grouping specification */ + retval = PrepareGroupingKind(); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " + << toplevel << std::endl); + + /* Are we in the component packaging case */ + if (SupportsComponentInstallation() & (!this->ComponentGroups.empty())) + { + /* Reset package file name list it will be populated during the + * component packaging run*/ + packageFileNames.clear(); + std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); + /* One Package per component CASE */ + /* Iterate over components */ + std::map<std::string, cmCPackComponent>::iterator compIt; + for (compIt=this->Components.begin(); + compIt!=this->Components.end(); ++compIt ) + { + std::string localToplevel(initialTopLevel); + std::string packageFileName( + cmSystemTools::GetParentDirectory(toplevel.c_str()) + ); + std::string outputFileName( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME") + ) + +"-"+compIt->first + this->GetOutputExtension()); + + localToplevel += "/"+ compIt->first; + /* replace the TEMP DIRECTORY with the component one */ + this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str()); + packageFileName += "/"+ outputFileName; + /* replace proposed CPACK_OUTPUT_FILE_NAME */ + this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str()); + /* replace the TEMPORARY package file name */ + this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", + packageFileName.c_str()); + + this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",compIt->first.c_str()); + if (!this->ReadListFile("CPackRPM.cmake")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackRPM.cmake" << std::endl); + retval = 0; + } + + // add the generated package to package file names list + packageFileNames.push_back(packageFileName); + } + } + /* This is the non component case */ + else + { + if (!this->ReadListFile("CPackRPM.cmake")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackRPM.cmake" << std::endl); + retval = 0; + } + } + if (!this->IsSet("RPMBUILD_EXECUTABLE")) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find rpmbuild" << std::endl); - return 0; + retval = 0; } - return 1; + return retval; } +bool cmCPackRPMGenerator::SupportsComponentInstallation() const + { + if (IsSet("CPACK_RPM_COMPONENT_INSTALL")) + { + return true; + } + else + { + return false; + } + } diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index 570e45f..57d5cca 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -39,6 +39,7 @@ protected: virtual int InitializeInternal(); virtual int PackageFiles(); virtual const char* GetOutputExtension() { return ".rpm"; } + virtual bool SupportsComponentInstallation() const; }; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 1cabed2..d53200c 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -923,7 +923,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddLinkPrefix(const char* p) { - if(p) + if(p && *p) { this->LinkPrefixes.insert(p); } diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx new file mode 100644 index 0000000..bdb33bc --- /dev/null +++ b/Source/cmGraphVizWriter.cxx @@ -0,0 +1,435 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGraphVizWriter.h" +#include "cmMakefile.h" +#include "cmLocalGenerator.h" +#include "cmGlobalGenerator.h" +#include "cmGeneratedFileStream.h" + +#include <memory> + + + +static const char* getShapeForTarget(const cmTarget* target) +{ + if (!target) + { + return "ellipse"; + } + + switch ( target->GetType() ) + { + case cmTarget::EXECUTABLE: + return "house"; + case cmTarget::STATIC_LIBRARY: + return "diamond"; + case cmTarget::SHARED_LIBRARY: + return "polygon"; + case cmTarget::MODULE_LIBRARY: + return "octagon"; + default: + break; + } + + return "box"; +} + + +cmGraphVizWriter::cmGraphVizWriter(const std::vector<cmLocalGenerator*>& + localGenerators) +:GraphType("digraph") +,GraphName("GG") +,GraphHeader("node [\n fontsize = \"12\"\n];") +,GraphNodePrefix("node") +,GenerateForExecutables(true) +,GenerateForStaticLibs(true) +,GenerateForSharedLibs(true) +,GenerateForModuleLibs(true) +,LocalGenerators(localGenerators) +,HaveTargetsAndLibs(false) +{ +} + + +void cmGraphVizWriter::ReadSettings(const char* settingsFileName, + const char* fallbackSettingsFileName) +{ + cmake cm; + cmGlobalGenerator ggi; + ggi.SetCMakeInstance(&cm); + std::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator()); + cmMakefile *mf = lg->GetMakefile(); + + const char* inFileName = settingsFileName; + + if ( !cmSystemTools::FileExists(inFileName) ) + { + inFileName = fallbackSettingsFileName; + if ( !cmSystemTools::FileExists(inFileName) ) + { + return; + } + } + + if ( !mf->ReadListFile(0, inFileName) ) + { + cmSystemTools::Error("Problem opening GraphViz options file: ", + inFileName); + return; + } + + std::cout << "Reading GraphViz options file: " << inFileName << std::endl; + +#define __set_if_set(var, cmakeDefinition) \ + { \ + const char* value = mf->GetDefinition(cmakeDefinition); \ + if ( value ) \ + { \ + var = value; \ + } \ + } + + __set_if_set(this->GraphType, "GRAPHVIZ_GRAPH_TYPE"); + __set_if_set(this->GraphName, "GRAPHVIZ_GRAPH_NAME"); + __set_if_set(this->GraphHeader, "GRAPHVIZ_GRAPH_HEADER"); + __set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX"); + +#define __set_bool_if_set(var, cmakeDefinition) \ + { \ + const char* value = mf->GetDefinition(cmakeDefinition); \ + if ( value ) \ + { \ + var = mf->IsOn(cmakeDefinition); \ + } \ + } + + __set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES"); + __set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS"); + __set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS"); + __set_bool_if_set(this->GenerateForModuleLibs , "GRAPHVIZ_MODULE_LIBS"); + + cmStdString tmpRegexString; + __set_if_set(tmpRegexString, "GRAPHVIZ_TARGET_IGNORE_REGEX"); + if (tmpRegexString.size() > 0) + { + if (!this->TargetIgnoreRegex.compile(tmpRegexString.c_str())) + { + std::cerr << "Could not compile bad regex \"" << tmpRegexString << "\"" + << std::endl; + } + } + + this->TargetsToIgnore.clear(); + const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS"); + if ( ignoreTargets ) + { + std::vector<std::string> ignoreTargetsVector; + cmSystemTools::ExpandListArgument(ignoreTargets,ignoreTargetsVector); + for(std::vector<std::string>::iterator itvIt = ignoreTargetsVector.begin(); + itvIt != ignoreTargetsVector.end(); + ++ itvIt ) + { + this->TargetsToIgnore.insert(itvIt->c_str()); + } + } + +} + + +void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) +{ + this->CollectTargetsAndLibs(); + + for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt = + this->TargetPtrs.begin(); + ptrIt != this->TargetPtrs.end(); + ++ptrIt) + { + if (ptrIt->second == NULL) + { + continue; + } + + if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) + { + continue; + } + + std::set<std::string> insertedConnections; + std::set<std::string> insertedNodes; + + std::string currentFilename = fileName; + currentFilename += "."; + currentFilename += ptrIt->first; + cmGeneratedFileStream str(currentFilename.c_str()); + if ( !str ) + { + return; + } + + std::cout << "Writing " << currentFilename << "..." << std::endl; + this->WriteHeader(str); + + this->WriteConnections(ptrIt->first.c_str(), + insertedNodes, insertedConnections, str); + this->WriteFooter(str); + } + +} + + +void cmGraphVizWriter::WriteGlobalFile(const char* fileName) +{ + this->CollectTargetsAndLibs(); + + cmGeneratedFileStream str(fileName); + if ( !str ) + { + return; + } + this->WriteHeader(str); + + std::cout << "Writing " << fileName << "..." << std::endl; + + std::set<std::string> insertedConnections; + std::set<std::string> insertedNodes; + + for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt = + this->TargetPtrs.begin(); + ptrIt != this->TargetPtrs.end(); + ++ptrIt) + { + if (ptrIt->second == NULL) + { + continue; + } + + if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) + { + continue; + } + + this->WriteConnections(ptrIt->first.c_str(), + insertedNodes, insertedConnections, str); + } + this->WriteFooter(str); +} + + +void cmGraphVizWriter::WriteHeader(cmGeneratedFileStream& str) const +{ + str << this->GraphType << " " << this->GraphName << " {" << std::endl; + str << this->GraphHeader << std::endl; +} + + +void cmGraphVizWriter::WriteFooter(cmGeneratedFileStream& str) const +{ + str << "}" << std::endl; +} + + +void cmGraphVizWriter::WriteConnections(const char* targetName, + std::set<std::string>& insertedNodes, + std::set<std::string>& insertedConnections, + cmGeneratedFileStream& str) const +{ + std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt = + this->TargetPtrs.find(targetName); + + if (targetPtrIt == this->TargetPtrs.end()) // not found at all + { + return; + } + + this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str); + + if (targetPtrIt->second == NULL) // it's an external library + { + return; + } + + + std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; + + const cmTarget::LinkLibraryVectorType* ll = + &(targetPtrIt->second->GetOriginalLinkLibraries()); + + for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); + llit != ll->end(); + ++ llit ) + { + const char* libName = llit->first.c_str(); + std::map<cmStdString, cmStdString>::const_iterator libNameIt = + this->TargetNamesNodes.find(libName); + + std::string connectionName = myNodeName; + connectionName += "-"; + connectionName += libNameIt->second; + if (insertedConnections.find(connectionName) == insertedConnections.end()) + { + insertedConnections.insert(connectionName); + this->WriteNode(libName, this->TargetPtrs.find(libName)->second, + insertedNodes, str); + + str << " \"" << myNodeName.c_str() << "\" -> \"" + << libNameIt->second.c_str() << "\""; + str << " // " << targetName << " -> " << libName << std::endl; + this->WriteConnections(libName, insertedNodes, insertedConnections, str); + } + } + +} + + +void cmGraphVizWriter::WriteNode(const char* targetName, + const cmTarget* target, + std::set<std::string>& insertedNodes, + cmGeneratedFileStream& str) const +{ + if (insertedNodes.find(targetName) == insertedNodes.end()) + { + insertedNodes.insert(targetName); + std::map<cmStdString, cmStdString>::const_iterator nameIt = + this->TargetNamesNodes.find(targetName); + + str << " \"" << nameIt->second.c_str() << "\" [ label=\"" + << targetName << "\" shape=\"" << getShapeForTarget(target) + << "\"];" << std::endl; + } +} + + +void cmGraphVizWriter::CollectTargetsAndLibs() +{ + if (this->HaveTargetsAndLibs == false) + { + this->HaveTargetsAndLibs = true; + int cnt = this->CollectAllTargets(); + this->CollectAllExternalLibs(cnt); + } +} + + +int cmGraphVizWriter::CollectAllTargets() +{ + int cnt = 0; + // First pass get the list of all cmake targets + for (std::vector<cmLocalGenerator*>::const_iterator lit = + this->LocalGenerators.begin(); + lit != this->LocalGenerators.end(); + ++ lit ) + { + const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); + for ( cmTargets::const_iterator tit = targets->begin(); + tit != targets->end(); + ++ tit ) + { + const char* realTargetName = tit->first.c_str(); + if(this->IgnoreThisTarget(realTargetName)) + { + // Skip ignored targets + continue; + } + //std::cout << "Found target: " << tit->first.c_str() << std::endl; + cmOStringStream ostr; + ostr << this->GraphNodePrefix << cnt++; + this->TargetNamesNodes[realTargetName] = ostr.str(); + this->TargetPtrs[realTargetName] = &tit->second; + } + } + + return cnt; +} + + +int cmGraphVizWriter::CollectAllExternalLibs(int cnt) +{ + // Ok, now find all the stuff we link to that is not in cmake + for (std::vector<cmLocalGenerator*>::const_iterator lit = + this->LocalGenerators.begin(); + lit != this->LocalGenerators.end(); + ++ lit ) + { + const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); + for ( cmTargets::const_iterator tit = targets->begin(); + tit != targets->end(); + ++ tit ) + { + const char* realTargetName = tit->first.c_str(); + if (this->IgnoreThisTarget(realTargetName)) + { + // Skip ignored targets + continue; + } + const cmTarget::LinkLibraryVectorType* ll = + &(tit->second.GetOriginalLinkLibraries()); + for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); + llit != ll->end(); + ++ llit ) + { + const char* libName = llit->first.c_str(); + if (this->IgnoreThisTarget(libName)) + { + // Skip ignored targets + continue; + } + + std::map<cmStdString, const cmTarget*>::const_iterator tarIt = + this->TargetPtrs.find(libName); + if ( tarIt == this->TargetPtrs.end() ) + { + cmOStringStream ostr; + ostr << this->GraphNodePrefix << cnt++; + this->TargetNamesNodes[libName] = ostr.str(); + this->TargetPtrs[libName] = NULL; + //str << " \"" << ostr.c_str() << "\" [ label=\"" << libName + //<< "\" shape=\"ellipse\"];" << std::endl; + } + } + } + } + return cnt; +} + + +bool cmGraphVizWriter::IgnoreThisTarget(const char* name) +{ + if (this->TargetIgnoreRegex.is_valid()) + { + if (this->TargetIgnoreRegex.find(name)) + { + return true; + } + } + return (this->TargetsToIgnore.find(name) != this->TargetsToIgnore.end()); +} + + +bool cmGraphVizWriter::GenerateForTargetType(cmTarget::TargetType targetType) + const +{ + switch (targetType) + { + case cmTarget::EXECUTABLE: + return this->GenerateForExecutables; + case cmTarget::STATIC_LIBRARY: + return this->GenerateForStaticLibs; + case cmTarget::SHARED_LIBRARY: + return this->GenerateForSharedLibs; + case cmTarget::MODULE_LIBRARY: + return this->GenerateForModuleLibs; + default: + break; + } + return false; +} diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h new file mode 100644 index 0000000..105eb96 --- /dev/null +++ b/Source/cmGraphVizWriter.h @@ -0,0 +1,84 @@ +#ifndef CMGRAPHVIZWRITER_H +#define CMGRAPHVIZWRITER_H +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmStandardIncludes.h" +#include "cmLocalGenerator.h" +#include "cmGeneratedFileStream.h" +#include "cmTarget.h" +#include <cmsys/RegularExpression.hxx> + + +/** This class implements writing files for graphviz (dot) for graphs + * representing the dependencies between the targets in the project. */ +class cmGraphVizWriter +{ +public: + + cmGraphVizWriter(const std::vector<cmLocalGenerator*>& localGenerators); + + void ReadSettings(const char* settingsFileName, + const char* fallbackSettingsFileName); + + void WritePerTargetFiles(const char* fileName); + + void WriteGlobalFile(const char* fileName); + +protected: + + void CollectTargetsAndLibs(); + + int CollectAllTargets(); + + int CollectAllExternalLibs(int cnt); + + void WriteHeader(cmGeneratedFileStream& str) const; + + void WriteConnections(const char* targetName, + std::set<std::string>& insertedNodes, + std::set<std::string>& insertedConnections, + cmGeneratedFileStream& str) const; + + void WriteNode(const char* targetName, const cmTarget* target, + std::set<std::string>& insertedNodes, + cmGeneratedFileStream& str) const; + + void WriteFooter(cmGeneratedFileStream& str) const; + + bool IgnoreThisTarget(const char* name); + + bool GenerateForTargetType(cmTarget::TargetType targetType) const; + + cmStdString GraphType; + cmStdString GraphName; + cmStdString GraphHeader; + cmStdString GraphNodePrefix; + + bool GenerateForExecutables; + bool GenerateForStaticLibs; + bool GenerateForSharedLibs; + bool GenerateForModuleLibs; + + cmsys::RegularExpression TargetIgnoreRegex; + + std::set<cmStdString> TargetsToIgnore; + + const std::vector<cmLocalGenerator*>& LocalGenerators; + + std::map<cmStdString, const cmTarget*> TargetPtrs; + // maps from the actual target names to node names in dot: + std::map<cmStdString, cmStdString> TargetNamesNodes; + + bool HaveTargetsAndLibs; +}; + +#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2ebd165..aec8e06 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -26,6 +26,7 @@ #include "cmDocumentationFormatterText.h" #if defined(CMAKE_BUILD_WITH_CMAKE) +# include "cmGraphVizWriter.h" # include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback. # include "cmVariableWatch.h" # include <cmsys/Terminal.h> @@ -169,7 +170,7 @@ cmake::cmake() this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; this->ScriptMode = false; - + #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; this->VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN", @@ -382,7 +383,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) this->DoSuppressDevWarnings = true; } else if(arg.find("-Wdev",0) == 0) - { + { this->SuppressDevWarnings = false; this->DoSuppressDevWarnings = true; } @@ -406,7 +407,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) cmsys::Glob::PatternToRegex(entryPattern.c_str(), true, true).c_str()); //go through all cache entries and collect the vars which will be removed std::vector<std::string> entriesToDelete; - cmCacheManager::CacheIterator it = + cmCacheManager::CacheIterator it = this->CacheManager->GetCacheIterator(); for ( it.Begin(); !it.IsAtEnd(); it.Next() ) { @@ -422,8 +423,8 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } // now remove them from the cache - for(std::vector<std::string>::const_iterator currentEntry = - entriesToDelete.begin(); + for(std::vector<std::string>::const_iterator currentEntry = + entriesToDelete.begin(); currentEntry != entriesToDelete.end(); ++currentEntry) { @@ -791,7 +792,7 @@ int cmake::AddCMakePaths() cMakeSelf += "/cmake"; std::cerr << cMakeSelf.c_str() << "\n"; } -#endif +#endif if(!cmSystemTools::FileExists(cMakeSelf.c_str())) { cmSystemTools::Error("CMake executable cannot be found at ", @@ -802,12 +803,12 @@ int cmake::AddCMakePaths() this->CacheManager->AddCacheEntry ("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake executable.", cmCacheManager::INTERNAL); - // if the edit command is not yet in the cache, + // if the edit command is not yet in the cache, // or if CMakeEditCommand has been set on this object, // then set the CMAKE_EDIT_COMMAND in the cache // This will mean that the last gui to edit the cache // will be the one that make edit_cache uses. - if(!this->GetCacheDefinition("CMAKE_EDIT_COMMAND") + if(!this->GetCacheDefinition("CMAKE_EDIT_COMMAND") || !this->CMakeEditCommand.empty()) { // Find and save the command to edit the cache @@ -815,8 +816,8 @@ int cmake::AddCMakePaths() if(!this->CMakeEditCommand.empty()) { editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) - + std::string("/") - + this->CMakeEditCommand + + std::string("/") + + this->CMakeEditCommand + cmSystemTools::GetFilenameExtension(cMakeSelf); } if( !cmSystemTools::FileExists(editCacheCommand.c_str())) @@ -936,7 +937,7 @@ void CMakeCommandUsage(const char* program) errorStream << "cmake bootstrap\n"; #endif - // If you add new commands, change here, + // If you add new commands, change here, // and in cmakemain.cxx in the options table errorStream << "Usage: " << program << " -E [command] [arguments ...]\n" @@ -1091,7 +1092,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) return 0; } #endif - + else if (args[1] == "make_directory" && args.size() == 3) { if(!cmSystemTools::MakeDirectory(args[2].c_str())) @@ -1342,7 +1343,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) } return 0; } - + // Command to create a symbolic link. Fails on platforms not // supporting them. else if (args[1] == "create_symlink" && args.size() == 4) @@ -1410,7 +1411,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) // Use the make system's VERBOSE environment variable to enable // verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE // (which is set by the Eclipse and KDevelop generators). - bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) + bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0)); // Create a cmake object instance to process dependencies. @@ -1635,14 +1636,14 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) return 1; } -void cmake::AddExtraGenerator(const char* name, +void cmake::AddExtraGenerator(const char* name, CreateExtraGeneratorFunctionType newFunction) { cmExternalMakefileProjectGenerator* extraGenerator = newFunction(); const std::vector<std::string>& supportedGlobalGenerators = extraGenerator->GetSupportedGlobalGenerators(); - for(std::vector<std::string>::const_iterator + for(std::vector<std::string>::const_iterator it = supportedGlobalGenerators.begin(); it != supportedGlobalGenerators.end(); ++it ) @@ -1670,11 +1671,11 @@ void cmake::AddDefaultExtraGenerators() #endif #ifdef CMAKE_USE_KDEVELOP - this->AddExtraGenerator(cmGlobalKdevelopGenerator::GetActualName(), + this->AddExtraGenerator(cmGlobalKdevelopGenerator::GetActualName(), &cmGlobalKdevelopGenerator::New); - // for kdevelop also add the generator with just the name of the + // for kdevelop also add the generator with just the name of the // extra generator, since it was this way since cmake 2.2 - this->ExtraGenerators[cmGlobalKdevelopGenerator::GetActualName()] + this->ExtraGenerators[cmGlobalKdevelopGenerator::GetActualName()] = &cmGlobalKdevelopGenerator::New; #endif @@ -1690,7 +1691,7 @@ void cmake::GetRegisteredGenerators(std::vector<std::string>& names) { names.push_back(i->first); } - for(RegisteredExtraGeneratorsMap::const_iterator + for(RegisteredExtraGeneratorsMap::const_iterator i = this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i) { @@ -1828,7 +1829,7 @@ int cmake::DoPreConfigureChecks() // do a sanity check on some values if(this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY")) { - std::string cacheStart = + std::string cacheStart = this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"); cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); @@ -1872,13 +1873,13 @@ int cmake::HandleDeleteCacheVariables(const char* var) cmCacheManager::CacheIterator ci = this->CacheManager->NewIterator(); std::vector<SaveCacheEntry> saved; cmOStringStream warning; - warning + warning << "You have changed variables that require your cache to be deleted.\n" << "Configure will be re-run and you may have to reset some variables.\n" << "The following variables have changed:\n"; for(std::vector<std::string>::iterator i = argsSplit.begin(); i != argsSplit.end(); ++i) - { + { SaveCacheEntry save; save.key = *i; warning << *i << "= "; @@ -1892,7 +1893,7 @@ int cmake::HandleDeleteCacheVariables(const char* var) } saved.push_back(save); } - + // remove the cache this->CacheManager->DeleteCache(this->GetStartOutputDirectory()); // load the empty cache @@ -1964,7 +1965,7 @@ int cmake::ActualConfigure() if ( !res ) { this->CacheManager->AddCacheEntry - ("CMAKE_HOME_DIRECTORY", + ("CMAKE_HOME_DIRECTORY", this->GetHomeDirectory(), "Start directory with the top level CMakeLists.txt file for this " "project", @@ -1974,9 +1975,9 @@ int cmake::ActualConfigure() // no generator specified on the command line if(!this->GlobalGenerator) { - const char* genName = + const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); - const char* extraGenName = + const char* extraGenName = this->CacheManager->GetCacheValue("CMAKE_EXTRA_GENERATOR"); if(genName) { @@ -1998,7 +1999,7 @@ int cmake::ActualConfigure() this->SetGlobalGenerator(new cmGlobalBorlandMakefileGenerator); #elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) std::string installedCompiler; - // Try to find the newest VS installed on the computer and + // Try to find the newest VS installed on the computer and // use that as a default if -G is not specified std::string vsregBase = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\"; @@ -2062,11 +2063,11 @@ int cmake::ActualConfigure() } if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR")) { - this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", + this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", this->GlobalGenerator->GetName(), "Name of generator.", cmCacheManager::INTERNAL); - this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR", + this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR", this->GlobalGenerator->GetExtraGeneratorName(), "Name of external makefile project generator.", cmCacheManager::INTERNAL); @@ -2205,7 +2206,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) // set the cmake command this->CMakeCommand = args[0]; - + if ( !this->ScriptMode ) { // load the cache @@ -2330,7 +2331,7 @@ void cmake::AddCacheEntry(const char* key, const char* value, const char* helpString, int type) { - this->CacheManager->AddCacheEntry(key, value, + this->CacheManager->AddCacheEntry(key, value, helpString, cmCacheManager::CacheEntryType(type)); } @@ -2445,8 +2446,8 @@ void cmake::UpdateProgress(const char *msg, float prog) } } -void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v, - bool withCurrentCommands, +void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v, + bool withCurrentCommands, bool withCompatCommands) const { for(RegisteredCommandsMap::const_iterator j = this->Commands.begin(); @@ -2457,7 +2458,7 @@ void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v, { continue; } - + cmDocumentationEntry e((*j).second->GetName(), (*j).second->GetTerseDocumentation(), (*j).second->GetFullDocumentation()); @@ -2493,7 +2494,7 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) delete generator; v.push_back(e); } - for(RegisteredExtraGeneratorsMap::const_iterator + for(RegisteredExtraGeneratorsMap::const_iterator i = this->ExtraGenerators.begin(); i != this->ExtraGenerators.end(); ++i) { cmDocumentationEntry e; @@ -2508,7 +2509,7 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: - const char* tablepath = + const char* tablepath = this->CacheManager->GetCacheValue("CMAKE_PATH_TRANSLATION_FILE"); if(tablepath) @@ -2540,7 +2541,7 @@ int cmake::CheckBuildSystem() // the make system's VERBOSE environment variable to enable verbose // output. This can be skipped by setting CMAKE_NO_VERBOSE (which is set // by the Eclipse and KDevelop generators). - bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) + bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0)); // This method will check the integrity of the build system if the @@ -2549,7 +2550,7 @@ int cmake::CheckBuildSystem() // If no file is provided for the check, we have to rerun. if(this->CheckBuildSystemArgument.size() == 0) - { + { if(verbose) { cmOStringStream msg; @@ -2565,7 +2566,7 @@ int cmake::CheckBuildSystem() if(verbose) { cmOStringStream msg; - msg << "Re-run cmake missing file: " + msg << "Re-run cmake missing file: " << this->CheckBuildSystemArgument.c_str() << "\n"; cmSystemTools::Stdout(msg.str().c_str()); } @@ -2585,7 +2586,7 @@ int cmake::CheckBuildSystem() if(verbose) { cmOStringStream msg; - msg << "Re-run cmake error reading : " + msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument.c_str() << "\n"; cmSystemTools::Stdout(msg.str().c_str()); } @@ -2835,253 +2836,27 @@ const char* cmake::GetCPackCommand() return this->CPackCommand.c_str(); } + void cmake::GenerateGraphViz(const char* fileName) const { - cmGeneratedFileStream str(fileName); - if ( !str ) - { - return; - } - cmake cm; - cmGlobalGenerator ggi; - ggi.SetCMakeInstance(&cm); - std::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator()); - cmMakefile *mf = lg->GetMakefile(); - - std::string infile = this->GetHomeOutputDirectory(); - infile += "/CMakeGraphVizOptions.cmake"; - if ( !cmSystemTools::FileExists(infile.c_str()) ) - { - infile = this->GetHomeDirectory(); - infile += "/CMakeGraphVizOptions.cmake"; - if ( !cmSystemTools::FileExists(infile.c_str()) ) - { - infile = ""; - } - } - - if ( !infile.empty() ) - { - if ( !mf->ReadListFile(0, infile.c_str()) ) - { - cmSystemTools::Error("Problem opening GraphViz options file: ", - infile.c_str()); - return; - } - std::cout << "Read GraphViz options file: " << infile.c_str() - << std::endl; - } - -#define __set_if_not_set(var, value, cmakeDefinition) \ - const char* var = mf->GetDefinition(cmakeDefinition); \ - if ( !var ) \ - { \ - var = value; \ - } - __set_if_not_set(graphType, "digraph", "GRAPHVIZ_GRAPH_TYPE"); - __set_if_not_set(graphName, "GG", "GRAPHVIZ_GRAPH_NAME"); - __set_if_not_set(graphHeader, "node [\n fontsize = \"12\"\n];", - "GRAPHVIZ_GRAPH_HEADER"); - __set_if_not_set(graphNodePrefix, "node", "GRAPHVIZ_NODE_PREFIX"); - const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS"); - std::set<cmStdString> ignoreTargetsSet; - if ( ignoreTargets ) - { - std::vector<std::string> ignoreTargetsVector; - cmSystemTools::ExpandListArgument(ignoreTargets,ignoreTargetsVector); - std::vector<std::string>::iterator itvIt; - for ( itvIt = ignoreTargetsVector.begin(); - itvIt != ignoreTargetsVector.end(); - ++ itvIt ) - { - ignoreTargetsSet.insert(itvIt->c_str()); - } - } - - str << graphType << " " << graphName << " {" << std::endl; - str << graphHeader << std::endl; - - const cmGlobalGenerator* gg = this->GetGlobalGenerator(); - const std::vector<cmLocalGenerator*>& localGenerators = - gg->GetLocalGenerators(); - std::vector<cmLocalGenerator*>::const_iterator lit; - // for target deps - // 1 - cmake target - // 2 - external target - // 0 - no deps - std::map<cmStdString, int> targetDeps; - std::map<cmStdString, const cmTarget*> targetPtrs; - std::map<cmStdString, cmStdString> targetNamesNodes; - int cnt = 0; - // First pass get the list of all cmake targets - for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit ) - { - const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); - cmTargets::const_iterator tit; - for ( tit = targets->begin(); tit != targets->end(); ++ tit ) - { - const char* realTargetName = tit->first.c_str(); - if ( ignoreTargetsSet.find(realTargetName) != ignoreTargetsSet.end() ) - { - // Skip ignored targets - continue; - } - //std::cout << "Found target: " << tit->first.c_str() << std::endl; - cmOStringStream ostr; - ostr << graphNodePrefix << cnt++; - targetNamesNodes[realTargetName] = ostr.str(); - targetPtrs[realTargetName] = &tit->second; - } - } - // Ok, now find all the stuff we link to that is not in cmake - for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit ) - { - const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); - cmTargets::const_iterator tit; - for ( tit = targets->begin(); tit != targets->end(); ++ tit ) - { - const cmTarget::LinkLibraryVectorType* ll - = &(tit->second.GetOriginalLinkLibraries()); - cmTarget::LinkLibraryVectorType::const_iterator llit; - const char* realTargetName = tit->first.c_str(); - if ( ignoreTargetsSet.find(realTargetName) != ignoreTargetsSet.end() ) - { - // Skip ignored targets - continue; - } - if ( ll->size() > 0 ) - { - targetDeps[realTargetName] = 1; - } - for ( llit = ll->begin(); llit != ll->end(); ++ llit ) - { - const char* libName = llit->first.c_str(); - std::map<cmStdString, cmStdString>::const_iterator tarIt - = targetNamesNodes.find(libName); - if ( ignoreTargetsSet.find(libName) != ignoreTargetsSet.end() ) - { - // Skip ignored targets - continue; - } - if ( tarIt == targetNamesNodes.end() ) - { - cmOStringStream ostr; - ostr << graphNodePrefix << cnt++; - targetDeps[libName] = 2; - targetNamesNodes[libName] = ostr.str(); - //str << " \"" << ostr.c_str() << "\" [ label=\"" << libName - //<< "\" shape=\"ellipse\"];" << std::endl; - } - else - { - std::map<cmStdString, int>::const_iterator depIt - = targetDeps.find(libName); - if ( depIt == targetDeps.end() ) - { - targetDeps[libName] = 1; - } - } - } - } - } +#ifdef CMAKE_BUILD_WITH_CMAKE + std::auto_ptr<cmGraphVizWriter> gvWriter( + new cmGraphVizWriter(this->GetGlobalGenerator()->GetLocalGenerators())); - // Write out nodes - std::map<cmStdString, int>::const_iterator depIt; - for ( depIt = targetDeps.begin(); depIt != targetDeps.end(); ++ depIt ) - { - const char* newTargetName = depIt->first.c_str(); - std::map<cmStdString, cmStdString>::const_iterator tarIt - = targetNamesNodes.find(newTargetName); - if ( tarIt == targetNamesNodes.end() ) - { - // We should not be here. - std::cout << __LINE__ << " Cannot find library: " << newTargetName - << " even though it was added in the previous pass" << std::endl; - abort(); - } + std::string settingsFile = this->GetHomeOutputDirectory(); + settingsFile += "/CMakeGraphVizOptions.cmake"; + std::string fallbackSettingsFile = this->GetHomeDirectory(); + fallbackSettingsFile += "/CMakeGraphVizOptions.cmake"; - str << " \"" << tarIt->second.c_str() << "\" [ label=\"" - << newTargetName << "\" shape=\""; - if ( depIt->second == 1 ) - { - std::map<cmStdString, const cmTarget*>::const_iterator tarTypeIt = - targetPtrs.find(newTargetName); - if ( tarTypeIt == targetPtrs.end() ) - { - // We should not be here. - std::cout << __LINE__ << " Cannot find library: " << newTargetName - << " even though it was added in the previous pass" << std::endl; - abort(); - } - const cmTarget* tg = tarTypeIt->second; - switch ( tg->GetType() ) - { - case cmTarget::EXECUTABLE: - str << "house"; - break; - case cmTarget::STATIC_LIBRARY: - str << "diamond"; - break; - case cmTarget::SHARED_LIBRARY: - str << "polygon"; - break; - case cmTarget::MODULE_LIBRARY: - str << "octagon"; - break; - default: - str << "box"; - } - } - else - { - str << "ellipse"; - } - str << "\"];" << std::endl; - } + gvWriter->ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str()); - // Now generate the connectivity - for ( lit = localGenerators.begin(); lit != localGenerators.end(); ++ lit ) - { - const cmTargets* targets = &((*lit)->GetMakefile()->GetTargets()); - cmTargets::const_iterator tit; - for ( tit = targets->begin(); tit != targets->end(); ++ tit ) - { - std::map<cmStdString, int>::iterator dependIt - = targetDeps.find(tit->first.c_str()); - if ( dependIt == targetDeps.end() ) - { - continue; - } - std::map<cmStdString, cmStdString>::iterator cmakeTarIt - = targetNamesNodes.find(tit->first.c_str()); - const cmTarget::LinkLibraryVectorType* ll - = &(tit->second.GetOriginalLinkLibraries()); - cmTarget::LinkLibraryVectorType::const_iterator llit; - for ( llit = ll->begin(); llit != ll->end(); ++ llit ) - { - const char* libName = llit->first.c_str(); - std::map<cmStdString, cmStdString>::const_iterator tarIt - = targetNamesNodes.find(libName); - if ( tarIt == targetNamesNodes.end() ) - { - // We should not be here. - std::cout << __LINE__ << " Cannot find library: " << libName - << " even though it was added in the previous pass" << std::endl; - abort(); - } - str << " \"" << cmakeTarIt->second.c_str() << "\" -> \"" - << tarIt->second.c_str() << "\"" << std::endl; - } - } - } + gvWriter->WritePerTargetFiles(fileName); + gvWriter->WriteGlobalFile(fileName); - // TODO: Use dotted or something for external libraries - //str << " \"node0\":f4 -> \"node12\"[color=\"#0000ff\" style=dotted]" - //<< std::endl; - // - str << "}" << std::endl; +#endif } + //---------------------------------------------------------------------------- int cmake::SymlinkLibrary(std::vector<std::string>& args) { @@ -3336,7 +3111,7 @@ int cmake::ExecuteLinkScript(std::vector<std::string>& args) void cmake::DefineProperties(cmake *cm) { cm->DefineProperty - ("REPORT_UNDEFINED_PROPERTIES", cmProperty::GLOBAL, + ("REPORT_UNDEFINED_PROPERTIES", cmProperty::GLOBAL, "If set, report any undefined properties to this file.", "If this property is set to a filename then when CMake runs " "it will report any properties or variables that were accessed " @@ -3344,7 +3119,7 @@ void cmake::DefineProperties(cmake *cm) ); cm->DefineProperty - ("TARGET_SUPPORTS_SHARED_LIBS", cmProperty::GLOBAL, + ("TARGET_SUPPORTS_SHARED_LIBS", cmProperty::GLOBAL, "Does the target platform support shared libraries.", "TARGET_SUPPORTS_SHARED_LIBS is a boolean specifying whether the target " "platform supports shared libraries. Basically all current general " @@ -3381,7 +3156,7 @@ void cmake::DefineProperties(cmake *cm) "this list.This property is used by the macros in FeatureSummary.cmake."); cm->DefineProperty ("DISABLED_FEATURES", cmProperty::GLOBAL, - "List of features which are disabled during the CMake run.", + "List of features which are disabled during the CMake run.", "List of features which are disabled during the CMake run. Be default " "it contains the names of all packages which were not found. This is " "determined using the <NAME>_FOUND variables. Packages which are " @@ -3531,13 +3306,13 @@ void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope, bool chained, const char *docSection) { this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription, - FullDescription, + FullDescription, docSection, chained); } cmPropertyDefinition *cmake -::GetPropertyDefinition(const char *name, +::GetPropertyDefinition(const char *name, cmProperty::ScopeType scope) { if (this->IsPropertyDefined(name,scope)) @@ -3547,7 +3322,7 @@ cmPropertyDefinition *cmake return 0; } -void cmake::RecordPropertyAccess(const char *name, +void cmake::RecordPropertyAccess(const char *name, cmProperty::ScopeType scope) { this->AccessedProperties.insert @@ -3619,13 +3394,13 @@ void cmake::ReportUndefinedPropertyAccesses(const char *filename) { if (!this->IsPropertyDefined(ap->first.c_str(),ap->second) && aliasedProperties.find(std::pair<cmStdString,cmProperty::ScopeType> - (ap->first,ap->second)) == + (ap->first,ap->second)) == aliasedProperties.end()) { const char *scopeStr = ""; switch (ap->second) { - case cmProperty::TARGET: + case cmProperty::TARGET: scopeStr = "TARGET"; break; case cmProperty::SOURCE_FILE: @@ -3727,7 +3502,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) } else if ( propname == "COMMANDS" ) { - cmake::RegisteredCommandsMap::iterator cmds + cmake::RegisteredCommandsMap::iterator cmds = this->GetCommands()->begin(); for (unsigned int cc=0 ; cmds != this->GetCommands()->end(); ++ cmds ) { @@ -3835,14 +3610,14 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // we have to find the module directory, so we can copy the files this->AddCMakePaths(); - std::string modulesPath = + std::string modulesPath = this->CacheManager->GetCacheValue("CMAKE_ROOT"); modulesPath += "/Modules"; std::string inFile = modulesPath; inFile += "/SystemInformation.cmake"; std::string outFile = destPath; outFile += "/CMakeLists.txt"; - + // Copy file if(!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) { @@ -3850,7 +3625,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) << "\" to \"" << outFile.c_str() << "\".\n"; return 1; } - + // do we write to a file or to stdout? if (resultFile.size() == 0) { @@ -3876,7 +3651,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // change back to the original directory cmSystemTools::ChangeDirectory(cwd.c_str()); - + // echo results to stdout if needed if (writeToStdout) { @@ -3897,7 +3672,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) fclose(fin); } } - + // clean up the directory cmSystemTools::RemoveADirectory(destPath.c_str()); return 0; @@ -4016,7 +3791,7 @@ int cmake::VisualStudioLink(std::vector<std::string>& args, int type) for(std::vector<std::string>::iterator i = args.begin(); i != args.end(); ++i) { - // check for nmake temporary files + // check for nmake temporary files if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 ) { std::ifstream fin(i->substr(1).c_str()); @@ -4069,7 +3844,7 @@ int cmake::VisualStudioLink(std::vector<std::string>& args, int type) type, hasManifest, verbose); } -int cmake::ParseVisualStudioLinkCommand(std::vector<std::string>& args, +int cmake::ParseVisualStudioLinkCommand(std::vector<std::string>& args, std::vector<cmStdString>& command, std::string& targetName) { @@ -4120,7 +3895,7 @@ bool cmake::RunCommand(const char* comment, &retCode, 0, false); // always print the output of the command, unless // it is the dumb rc command banner, but if the command - // returned an error code then print the output anyway as + // returned an error code then print the output anyway as // the banner may be mixed with some other important information. if(output.find("Resource Compiler Version") == output.npos || retCode !=0) @@ -4141,12 +3916,12 @@ bool cmake::RunCommand(const char* comment, return retCode == 0; } -int cmake::VisualStudioLinkIncremental(std::vector<std::string>& args, +int cmake::VisualStudioLinkIncremental(std::vector<std::string>& args, int type, bool verbose) { // This follows the steps listed here: // http://blogs.msdn.com/zakramer/archive/2006/05/22/603558.aspx - + // 1. Compiler compiles the application and generates the *.obj files. // 2. An empty manifest file is generated if this is a clean build and if // not the previous one is reused. @@ -4158,10 +3933,10 @@ int cmake::VisualStudioLinkIncremental(std::vector<std::string>& args, // on. // 5. The manifest tool (mt.exe) is then used to generate the final // manifest. - + // If the final manifest is changed, then 6 and 7 are run, if not // they are skipped, and it is done. - + // 6. The resource compiler is invoked one more time. // 7. Finally, the Linker does another incremental link, but since the // only thing that has changed is the *.res file that contains the @@ -4220,7 +3995,7 @@ int cmake::VisualStudioLinkIncremental(std::vector<std::string>& args, outputOpt += resourceFile; rcCommand.push_back(outputOpt); rcCommand.push_back(resourceInputFile); - // Run rc command to create resource + // Run rc command to create resource if(!cmake::RunCommand("RC Pass 1", rcCommand, verbose)) { return -1; @@ -4230,7 +4005,7 @@ int cmake::VisualStudioLinkIncremental(std::vector<std::string>& args, { return -1; } - // create mt command + // create mt command std::string outArg("/out:"); outArg+= manifestFile; mtCommand.push_back("/nologo"); @@ -4281,7 +4056,7 @@ int cmake::VisualStudioLinkNonIncremental(std::vector<std::string>& args, { return -1; } - // Run the link command as given + // Run the link command as given linkCommand.push_back("/MANIFEST"); if(!cmake::RunCommand("LINK", linkCommand, verbose)) { @@ -4472,7 +4247,7 @@ int cmake::Build(const std::string& dir, makeProgram = it.GetValue(); return gen->Build(0, dir.c_str(), projName.c_str(), target.c_str(), - &output, + &output, makeProgram.c_str(), config.c_str(), clean, false, 0, true, 0, nativeOptions); diff --git a/Source/cmake.h b/Source/cmake.h index 8312795..435d38b 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -21,14 +21,14 @@ // command line arguments. // 3) Load the cache by calling LoadCache (duh) // 4) if you are using command line arguments with -D or -C flags then -// call SetCacheArgs (or if for some other reason you want to modify the +// call SetCacheArgs (or if for some other reason you want to modify the // cache, do it now. // 5) Finally call Configure // 6) Let the user change values and go back to step 5 // 7) call Generate // // If your GUI allows the user to change the start & home directories then -// you must at a minimum redo steps 2 through 7. +// you must at a minimum redo steps 2 through 7. // @@ -50,6 +50,8 @@ class cmExternalMakefileProjectGenerator; class cmDocumentationSection; class cmPolicies; class cmListFileBacktrace; +class cmTarget; +class cmGeneratedFileStream; class cmake { @@ -73,14 +75,14 @@ class cmake static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";}; static const char *GetCMakeFilesDirectoryPostSlash() { return "CMakeFiles/";}; - + //@{ /** * Set/Get the home directory (or output directory) in the project. The * home directory is the top directory of the project. It is where * cmake was run. Remember that CMake processes * CMakeLists files by recursing up the tree starting at the StartDirectory - * and going up until it reaches the HomeDirectory. + * and going up until it reaches the HomeDirectory. */ void SetHomeDirectory(const char* dir); const char* GetHomeDirectory() const @@ -100,9 +102,9 @@ class cmake * is the directory of the CMakeLists.txt file that started the current * round of processing. Remember that CMake processes CMakeLists files by * recursing up the tree starting at the StartDirectory and going up until - * it reaches the HomeDirectory. + * it reaches the HomeDirectory. */ - void SetStartDirectory(const char* dir) + void SetStartDirectory(const char* dir) { this->cmStartDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); @@ -158,7 +160,7 @@ class cmake ///! Return the global generator assigned to this instance of cmake cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; } ///! Return the global generator assigned to this instance of cmake, const - const cmGlobalGenerator* GetGlobalGenerator() const + const cmGlobalGenerator* GetGlobalGenerator() const { return this->GlobalGenerator; } ///! Return the global generator assigned to this instance of cmake @@ -169,25 +171,25 @@ class cmake ///! get the cmCachemManager used by this invocation of cmake cmCacheManager *GetCacheManager() { return this->CacheManager; } - + ///! set the cmake command this instance of cmake should use void SetCMakeCommand(const char* cmd) { this->CMakeCommand = cmd; } - + /** * Given a variable name, return its value (as a string). */ const char* GetCacheDefinition(const char*) const; ///! Add an entry into the cache - void AddCacheEntry(const char* key, const char* value, - const char* helpString, + void AddCacheEntry(const char* key, const char* value, + const char* helpString, int type); - /** + /** * Execute commands during the build process. Supports options such * as echo, remove file etc. */ static int ExecuteCMakeCommand(std::vector<std::string>&); - /** + /** * Get the system information and write it to the file specified */ int GetSystemInformation(std::vector<std::string>&); @@ -210,16 +212,16 @@ class cmake /** Check if a command exists. */ bool CommandExists(const char* name) const; - + ///! Parse command line arguments void SetArgs(const std::vector<std::string>&); ///! Is this cmake running as a result of a TRY_COMPILE command bool GetIsInTryCompile() { return this->InTryCompile; } - + ///! Is this cmake running as a result of a TRY_COMPILE command void SetIsInTryCompile(bool i) { this->InTryCompile = i; } - + ///! Parse command line arguments that might set cache values bool SetCacheArgs(const std::vector<std::string>&); @@ -227,9 +229,9 @@ class cmake (const char*msg, float progress, void *); /** * Set the function used by GUI's to receive progress updates - * Function gets passed: message as a const char*, a progress + * Function gets passed: message as a const char*, a progress * amount ranging from 0 to 1.0 and client data. The progress - * number provided may be negative in cases where a message is + * number provided may be negative in cases where a message is * to be displayed without any progress percentage. */ void SetProgressCallback(ProgressCallbackType f, void* clientData=0); @@ -244,14 +246,14 @@ class cmake cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } /** Get the documentation entries for the supported commands. - * If withCurrentCommands is true, the documentation for the + * If withCurrentCommands is true, the documentation for the * recommended set of commands is included. * If withCompatCommands is true, the documentation for discouraged * (compatibility) commands is included. * You probably don't want to set both to false. */ - void GetCommandDocumentation(std::vector<cmDocumentationEntry>& entries, - bool withCurrentCommands = true, + void GetCommandDocumentation(std::vector<cmDocumentationEntry>& entries, + bool withCurrentCommands = true, bool withCompatCommands = true) const; void GetPropertiesDocumentation(std::map<std::string, cmDocumentationSection *>&); @@ -278,7 +280,7 @@ class cmake */ void SetScriptMode(bool mode) { this->ScriptMode = mode; } bool GetScriptMode() { return this->ScriptMode; } - + ///! Debug the try compile stuff by not delelting the files bool GetDebugTryCompile(){return this->DebugTryCompile;} void DebugTryCompileOn(){this->DebugTryCompile = true;} @@ -310,7 +312,7 @@ class cmake void DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, - bool chain = false, + bool chain = false, const char *variableGroup = 0); // get property definition @@ -338,7 +340,7 @@ class cmake } void SetSuppressDevWarnings(bool v) { - this->SuppressDevWarnings = v; + this->SuppressDevWarnings = v; this->DoSuppressDevWarnings = true; } @@ -357,10 +359,10 @@ protected: cmPropertyMap Properties; std::set<std::pair<cmStdString,cmProperty::ScopeType> > AccessedProperties; - std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> + std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions; - typedef + typedef cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)(); typedef std::map<cmStdString, CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap; @@ -374,15 +376,15 @@ protected: void AddDefaultCommands(); void AddDefaultGenerators(); void AddDefaultExtraGenerators(); - void AddExtraGenerator(const char* name, + void AddExtraGenerator(const char* name, CreateExtraGeneratorFunctionType newFunction); - cmPolicies *Policies; + cmPolicies *Policies; cmGlobalGenerator *GlobalGenerator; cmCacheManager *CacheManager; - std::string cmHomeDirectory; + std::string cmHomeDirectory; std::string HomeOutputDirectory; - std::string cmStartDirectory; + std::string cmStartDirectory; std::string StartOutputDirectory; bool SuppressDevWarnings; bool DoSuppressDevWarnings; @@ -393,7 +395,7 @@ protected: ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. /// If it is set, truncate it to 50kb void TruncateOutputLog(const char* fname); - + /** * Method called to check build system integrity at build time. * Returns 1 if CMake should rerun and 0 otherwise. @@ -416,24 +418,24 @@ protected: static int ExecuteLinkScript(std::vector<std::string>& args); static int VisualStudioLink(std::vector<std::string>& args, int type); static int VisualStudioLinkIncremental(std::vector<std::string>& args, - int type, + int type, bool verbose); static int VisualStudioLinkNonIncremental(std::vector<std::string>& args, int type, bool hasManifest, bool verbose); - static int ParseVisualStudioLinkCommand(std::vector<std::string>& args, - std::vector<cmStdString>& command, + static int ParseVisualStudioLinkCommand(std::vector<std::string>& args, + std::vector<cmStdString>& command, std::string& targetName); static bool RunCommand(const char* comment, std::vector<cmStdString>& command, bool verbose, int* retCodeOut = 0); cmVariableWatch* VariableWatch; - + ///! Find the full path to one of the cmake programs like ctest, cpack, etc. std::string FindCMakeProgram(const char* name) const; -private: +private: cmake(const cmake&); // Not implemented. void operator=(const cmake&); // Not implemented. ProgressCallbackType ProgressCallback; @@ -458,7 +460,7 @@ private: cmFileTimeComparison* FileComparison; std::string GraphVizFile; std::vector<std::string> DebugConfigs; - + void UpdateConversionPathTable(); }; diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index f14c43c..92aa88f 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2010) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 18) +SET(KWSYS_DATE_STAMP_DAY 23) |