diff options
804 files changed, 11309 insertions, 7592 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 761ad20..b0793d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,9 @@ if(CMAKE_BOOTSTRAP) unset(CMAKE_BOOTSTRAP CACHE) endif() -set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin) +endif() if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") # Disallow architecture-specific try_run. It may not run on the host. @@ -34,6 +36,13 @@ if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") endmacro() endif() +# option to set the internal encoding of CMake to UTF-8 +option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally (experimental)." OFF) +mark_as_advanced(CMAKE_ENCODING_UTF8) +if(CMAKE_ENCODING_UTF8) + set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) +endif() + #----------------------------------------------------------------------- # a macro to deal with system libraries, implemented as a macro # simply to improve readability of the main script @@ -102,9 +111,11 @@ endmacro() -set(CMAKE_BUILD_ON_VISUAL_STUDIO 0) -if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW ) - set(CMAKE_BUILD_ON_VISUAL_STUDIO 1) +if(NOT CMake_TEST_EXTERNAL_CMAKE) + set(CMAKE_BUILD_ON_VISUAL_STUDIO 0) + if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW ) + set(CMAKE_BUILD_ON_VISUAL_STUDIO 1) + endif() endif() @@ -114,29 +125,6 @@ endif() #----------------------------------------------------------------------- macro(CMAKE_SETUP_TESTING) if(BUILD_TESTING) - set(CMAKE_TEST_GENERATOR "" CACHE STRING - "Generator used when running tests") - set(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH - "Generator used when running tests") - if(NOT CMAKE_TEST_GENERATOR) - set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}") - set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}") - else() - set(CMAKE_TEST_DIFFERENT_GENERATOR TRUE) - set(CMAKE_TEST_GENERATOR_TOOLSET "") - endif() - - # Are we testing with the MSVC compiler? - set(CMAKE_TEST_MSVC 0) - if(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR) - set(CMAKE_TEST_MSVC 1) - else() - if("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR - "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio") - set(CMAKE_TEST_MSVC 1) - endif() - endif() - set(CMAKE_TEST_SYSTEM_LIBRARIES 0) foreach(util CURL EXPAT XMLRPC ZLIB) if(CMAKE_USE_SYSTEM_${util}) @@ -149,9 +137,19 @@ macro(CMAKE_SETUP_TESTING) # the ctest from this cmake is used for testing # and not the ctest from the cmake building and testing # cmake. - set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest") - set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake") - set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack") + if(CMake_TEST_EXTERNAL_CMAKE) + set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest") + set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake") + set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack") + foreach(exe cmake ctest cpack) + add_executable(${exe} IMPORTED) + set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe}) + endforeach() + else() + set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest") + set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake") + set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack") + endif() endif() # configure some files for testing @@ -164,8 +162,6 @@ macro(CMAKE_SETUP_TESTING) ${CMake_BINARY_DIR}/Modules/.NoDartCoverage) configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY) - configure_file(${CMake_SOURCE_DIR}/CTestCustom.ctest.in - ${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY) if(BUILD_TESTING AND DART_ROOT) configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY) @@ -387,18 +383,20 @@ macro (CMAKE_BUILD_UTILITIES) endmacro () #----------------------------------------------------------------------- -if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") - execute_process(COMMAND ${CMAKE_CXX_COMPILER} - ${CMAKE_CXX_COMPILER_ARG1} -dumpversion - OUTPUT_VARIABLE _GXX_VERSION - ) - string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" - _GXX_VERSION_SHORT ${_GXX_VERSION}) - if(_GXX_VERSION_SHORT EQUAL 33) - message(FATAL_ERROR - "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n" - "Please use GXX 4.2 or greater to build CMake on OpenBSD\n" - "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}") +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") + execute_process(COMMAND ${CMAKE_CXX_COMPILER} + ${CMAKE_CXX_COMPILER_ARG1} -dumpversion + OUTPUT_VARIABLE _GXX_VERSION + ) + string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" + _GXX_VERSION_SHORT ${_GXX_VERSION}) + if(_GXX_VERSION_SHORT EQUAL 33) + message(FATAL_ERROR + "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n" + "Please use GXX 4.2 or greater to build CMake on OpenBSD\n" + "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}") + endif() endif() endif() @@ -417,30 +415,32 @@ include (${CMAKE_ROOT}/Modules/Dart.cmake) set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake") -# where to write the resulting executables and libraries -set(BUILD_SHARED_LIBS OFF) -set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.") -set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL - "Where to put the libraries for CMake") +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # where to write the resulting executables and libraries + set(BUILD_SHARED_LIBS OFF) + set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.") + set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL + "Where to put the libraries for CMake") -# The CMake executables usually do not need any rpath to run in the build or -# install tree. -set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") + # The CMake executables usually do not need any rpath to run in the build or + # install tree. + set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") -# Load install destinations. -include(Source/CMakeInstallDestinations.cmake) + # Load install destinations. + include(Source/CMakeInstallDestinations.cmake) -if(BUILD_TESTING) - include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake) -endif() + if(BUILD_TESTING) + include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake) + endif() -# include special compile flags for some compilers -include(CompileFlags.cmake) + # include special compile flags for some compilers + include(CompileFlags.cmake) -# no clue why we are testing for this here -include(CheckSymbolExists) -CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV) -CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE) + # no clue why we are testing for this here + include(CheckSymbolExists) + CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV) + CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE) +endif() # CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests. # @@ -459,69 +459,72 @@ if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x") set(CMAKE_TESTS_CDASH_SERVER "http://www.cdash.org/CDash") endif() -# build the utilities (a macro defined in this file) -CMAKE_BUILD_UTILITIES() - -# On NetBSD ncurses is required, since curses doesn't have the wsyncup() -# function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib, -# which isn't in the default linker search path. So without RPATH ccmake -# doesn't run and the build doesn't succeed since ccmake is executed for -# generating the documentation. -if(BUILD_CursesDialog) - get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH) - set(CURSES_NEED_RPATH FALSE) - if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64") - set(CURSES_NEED_RPATH TRUE) - endif() -endif() +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # build the utilities (a macro defined in this file) + CMAKE_BUILD_UTILITIES() -if(BUILD_QtDialog) - if(APPLE) - set(CMAKE_BUNDLE_VERSION - "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") - set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") - # make sure CMAKE_INSTALL_PREFIX ends in / - string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN) - math(EXPR LEN "${LEN} -1" ) - string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH) - if(NOT "${ENDCH}" STREQUAL "/") - set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") + # On NetBSD ncurses is required, since curses doesn't have the wsyncup() + # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib, + # which isn't in the default linker search path. So without RPATH ccmake + # doesn't run and the build doesn't succeed since ccmake is executed for + # generating the documentation. + if(BUILD_CursesDialog) + get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH) + set(CURSES_NEED_RPATH FALSE) + if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64") + set(CURSES_NEED_RPATH TRUE) endif() - set(CMAKE_INSTALL_PREFIX - "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") endif() - set(QT_NEED_RPATH FALSE) - if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64") - set(QT_NEED_RPATH TRUE) + if(BUILD_QtDialog) + if(APPLE) + set(CMAKE_BUNDLE_VERSION + "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") + set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") + # make sure CMAKE_INSTALL_PREFIX ends in / + string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN) + math(EXPR LEN "${LEN} -1" ) + string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH) + if(NOT "${ENDCH}" STREQUAL "/") + set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") + endif() + set(CMAKE_INSTALL_PREFIX + "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") + endif() + + set(QT_NEED_RPATH FALSE) + if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64") + set(QT_NEED_RPATH TRUE) + endif() endif() -endif() -# The same might be true on other systems for other libraries. -# Then only enable RPATH if we have are building at least with cmake 2.4, -# since this one has much better RPATH features than cmake 2.2. -# The executables are then built with the RPATH for the libraries outside -# the build tree, which is both the build and the install RPATH. -if (UNIX) - if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB - OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH) - set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.") - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - endif() -endif () + # The same might be true on other systems for other libraries. + # Then only enable RPATH if we have are building at least with cmake 2.4, + # since this one has much better RPATH features than cmake 2.2. + # The executables are then built with the RPATH for the libraries outside + # the build tree, which is both the build and the install RPATH. + if (UNIX) + if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB + OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH) + set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.") + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + endif() + endif () -# add the uninstall support -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - @ONLY) -add_custom_target(uninstall - "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") + # add the uninstall support + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + @ONLY) + add_custom_target(uninstall + "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") -include (CMakeCPack.cmake) + include (CMakeCPack.cmake) + +endif() # setup some Testing support (a macro defined in this file) CMAKE_SETUP_TESTING() @@ -530,62 +533,69 @@ configure_file( "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf" COPYONLY) -if(NOT CMake_VERSION_IS_RELEASE) - if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND - NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) - set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts - -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security - -Wmissing-format-attribute -fno-common -Wundef - ) - set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W - -Wshadow -Wpointer-arith -Wformat-security -Wundef - ) - - foreach(FLAG_LANG C CXX) - foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) - if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") - set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") - endif() +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(NOT CMake_VERSION_IS_RELEASE) + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND + NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) + set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts + -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security + -Wmissing-format-attribute -fno-common -Wundef + ) + set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W + -Wshadow -Wpointer-arith -Wformat-security -Wundef + ) + + foreach(FLAG_LANG C CXX) + foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) + if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") + set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") + endif() + endforeach() endforeach() - endforeach() - unset(C_FLAGS_LIST) - unset(CXX_FLAGS_LIST) + unset(C_FLAGS_LIST) + unset(CXX_FLAGS_LIST) + endif() endif() + + # build the remaining subdirectories + add_subdirectory(Source) + add_subdirectory(Utilities) endif() -# build the remaining subdirectories -add_subdirectory(Source) -add_subdirectory(Utilities) add_subdirectory(Tests) -if(BUILD_TESTING) - CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") -endif() -CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat") -if(TARGET documentation) - CMAKE_SET_TARGET_FOLDER(documentation "Documentation") +if(NOT CMake_TEST_EXTERNAL_CMAKE) + if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") + endif() + CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat") + if(TARGET documentation) + CMAKE_SET_TARGET_FOLDER(documentation "Documentation") + endif() endif() # add a test add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" - --system-information -G "${CMAKE_TEST_GENERATOR}" ) - -# Install license file as it requires. -install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}) - -# Install script directories. -install( - DIRECTORY Help Modules Templates - DESTINATION ${CMAKE_DATA_DIR} - FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE - PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE - ) - -# Install auxiliary files integrating with other tools. -add_subdirectory(Auxiliary) + --system-information -G "${CMAKE_GENERATOR}" ) + +if(NOT CMake_TEST_EXTERNAL_CMAKE) + # Install license file as it requires. + install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}) + + # Install script directories. + install( + DIRECTORY Help Modules Templates + DESTINATION ${CMAKE_DATA_DIR} + FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + ) + + # Install auxiliary files integrating with other tools. + add_subdirectory(Auxiliary) +endif() diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 92eacd8..819f9ba 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -18,8 +18,3 @@ set(CTEST_DROP_LOCATION "/CDash/submit.php?project=CMake") set(CTEST_DROP_SITE_CDASH TRUE) set(CTEST_CDASH_VERSION "1.6") set(CTEST_CDASH_QUERY_VERSION TRUE) - -# use old trigger stuff so that cmake 2.4 and below will not -# get errors on trigger -set (TRIGGER_SITE - "http://public.kitware.com/cgi-bin/Submit-CMake-TestingResults.cgi") diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index eb0b2f6..6010b64 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -39,6 +39,8 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "Warning: public.*BZ2_bz.*in module.*bzlib.*clashes with prior module.*bzlib.*" "Warning: public.*_archive.*clashes with prior module.*" "Warning: LINN32: Last line.*is less.*" + "Warning: Olimit was exceeded on function.*" + "Warning: To override Olimit for all functions in file.*" "warning.*directory name.*CMake-Xcode.*/bin/.*does not exist.*" "stl_deque.h:1051" "(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)" @@ -52,6 +54,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "ld: warning: directory not found for option .-(F|L)" "warning.*This version of Mac OS X is unsupported" "clang.*: warning: argument unused during compilation: .-g" + "note: in expansion of macro" # diagnostic context note # Ignore clang's summary warning, assuming prior text has matched some # other warning expression: diff --git a/CTestCustom.ctest.in b/CTestCustom.ctest.in deleted file mode 100644 index 6127843..0000000 --- a/CTestCustom.ctest.in +++ /dev/null @@ -1,3 +0,0 @@ -# This file is provided for compatibility with CMake 2.2 and lower. -# Just include the custom file by its new name. -INCLUDE("CTestCustom.cmake") diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index b0c5446..028ca5a 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -156,3 +156,7 @@ target is built before any target using this custom command. Additionally, if the target is an executable or library a file-level dependency is created to cause the custom command to re-run whenever the target is recompiled. + +Arguments to ``DEPENDS`` may use "generator expressions" with the syntax +``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for +available expressions. diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index 376b56c..d025d63 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -55,7 +55,7 @@ used in a comparison with the iterator returned by ``end()``: .. code-block:: c++ - const std::set<cmStdString>& someSet = getSet(); + const std::set<std::string>& someSet = getSet(); if (someSet.find("needle") == someSet.end()) // Wrong { // ... @@ -66,8 +66,8 @@ The return value of ``find()`` must be assigned to an intermediate .. code-block:: c++ - const std::set<cmStdString>& someSet; - const std::set<cmStdString>::const_iterator i = someSet.find("needle"); + const std::set<std::string>& someSet; + const std::set<std::string>::const_iterator i = someSet.find("needle"); if (i != propSet.end()) // Ok { // ... @@ -110,7 +110,7 @@ conversion is not allowed: .. code-block:: c++ - std::set<cmStdString> theSet; + std::set<const char*> theSet; std::vector<std::string> theVector; theVector.insert(theVector.end(), theSet.begin(), theSet.end()); // Wrong @@ -118,9 +118,9 @@ A loop must be used instead: .. code-block:: c++ - std::set<cmStdString> theSet; + std::set<const char*> theSet; std::vector<std::string> theVector; - for(std::set<cmStdString>::iterator li = theSet.begin(); + for(std::set<const char*>::iterator li = theSet.begin(); li != theSet.end(); ++li) { theVector.push_back(*li); diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 7a06be6..2bbe622 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -138,6 +138,7 @@ All Modules /module/FindMPEG /module/FindMPI /module/FindOpenAL + /module/FindOpenCL /module/FindOpenGL /module/FindOpenMP /module/FindOpenSceneGraph diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index d315fcb..6ea5839 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -100,6 +100,10 @@ Properties on Targets /prop_tgt/COMPILE_DEFINITIONS /prop_tgt/COMPILE_FLAGS /prop_tgt/COMPILE_OPTIONS + /prop_tgt/COMPILE_PDB_NAME + /prop_tgt/COMPILE_PDB_NAME_CONFIG + /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY + /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX /prop_tgt/DEBUG_POSTFIX diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst index e4c3246..cad4951 100644 --- a/Help/manual/cmake-qt.7.rst +++ b/Help/manual/cmake-qt.7.rst @@ -173,7 +173,7 @@ The Qt 4 and 5 :prop_tgt:`IMPORTED` targets for the QtGui libraries specify that the qtmain.lib static library shipped with Qt will be linked by all dependent executables which have the :prop_tgt:`WIN32_EXECUTABLE` enabled. -Do disable this behavior, enable the ``Qt5_NO_LINK_QTMAIN`` target property for +To disable this behavior, enable the ``Qt5_NO_LINK_QTMAIN`` target property for Qt 5 based targets or ``QT4_NO_LINK_QTMAIN`` target property for Qt 4 based targets. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index d9d7a0c..8b4ce26 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -200,6 +200,8 @@ Variables that Control the Build /variable/CMAKE_AUTOUIC /variable/CMAKE_AUTOUIC_OPTIONS /variable/CMAKE_BUILD_WITH_INSTALL_RPATH + /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY + /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_CONFIG_POSTFIX /variable/CMAKE_DEBUG_POSTFIX /variable/CMAKE_EXE_LINKER_FLAGS_CONFIG diff --git a/Help/module/FindOpenCL.rst b/Help/module/FindOpenCL.rst new file mode 100644 index 0000000..e87e289 --- /dev/null +++ b/Help/module/FindOpenCL.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindOpenCL.cmake diff --git a/Help/prop_tgt/COMPILE_PDB_NAME.rst b/Help/prop_tgt/COMPILE_PDB_NAME.rst new file mode 100644 index 0000000..24a9f62 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NAME.rst @@ -0,0 +1,11 @@ +COMPILE_PDB_NAME +---------------- + +Output name for the MS debug symbol ``.pdb`` file generated by the +compiler while building source files. + +This property specifies the base name for the debug symbols file. +If not set, the default is unspecified. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst new file mode 100644 index 0000000..e4077f5 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst @@ -0,0 +1,10 @@ +COMPILE_PDB_NAME_<CONFIG> +------------------------- + +Per-configuration output name for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This is the configuration-specific version of :prop_tgt:`COMPILE_PDB_NAME`. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME_<CONFIG>` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_NOTE.txt b/Help/prop_tgt/COMPILE_PDB_NOTE.txt new file mode 100644 index 0000000..5941d72 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_NOTE.txt @@ -0,0 +1,8 @@ +.. note:: + The compiler-generated program database files are specified by the + ``/Fd`` compiler flag and are not the same as linker-generated + program database files specified by the ``/pdb`` linker flag. + Use the |PDB_XXX| property to specify the latter. + + This property is not implemented by the :generator:`Visual Studio 6` + generator. diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst new file mode 100644 index 0000000..34f49be --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst @@ -0,0 +1,13 @@ +COMPILE_PDB_OUTPUT_DIRECTORY +---------------------------- + +Output directory for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This property specifies the directory into which the MS debug symbols +will be placed by the compiler. This property is initialized by the +value of the :variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY` variable +if it is set when a target is created. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst new file mode 100644 index 0000000..52ef013 --- /dev/null +++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -0,0 +1,16 @@ +COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG> +------------------------------------- + +Per-configuration output directory for the MS debug symbol ``.pdb`` file +generated by the compiler while building source files. + +This is a per-configuration version of +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`, +but multi-configuration generators (VS, Xcode) do NOT append a +per-configuration subdirectory to the specified directory. This +property is initialized by the value of the +:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable +if it is set when a target is created. + +.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY_<CONFIG>` +.. include:: COMPILE_PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NAME.rst b/Help/prop_tgt/PDB_NAME.rst index e8fc3be..479dec3 100644 --- a/Help/prop_tgt/PDB_NAME.rst +++ b/Help/prop_tgt/PDB_NAME.rst @@ -7,7 +7,5 @@ linker for an executable or shared library target. This property specifies the base name for the debug symbols file. If not set, the logical target name is used by default. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME` .. include:: PDB_NOTE.txt - -This property is not implemented by the :generator:`Visual Studio 6` -generator. diff --git a/Help/prop_tgt/PDB_NAME_CONFIG.rst b/Help/prop_tgt/PDB_NAME_CONFIG.rst index c846b57..cb3121c 100644 --- a/Help/prop_tgt/PDB_NAME_CONFIG.rst +++ b/Help/prop_tgt/PDB_NAME_CONFIG.rst @@ -6,5 +6,5 @@ generated by the linker for an executable or shared library target. This is the configuration-specific version of :prop_tgt:`PDB_NAME`. -This property is not implemented by the :generator:`Visual Studio 6` -generator. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME_<CONFIG>` +.. include:: PDB_NOTE.txt diff --git a/Help/prop_tgt/PDB_NOTE.txt b/Help/prop_tgt/PDB_NOTE.txt index e55aba2..f90ea81 100644 --- a/Help/prop_tgt/PDB_NOTE.txt +++ b/Help/prop_tgt/PDB_NOTE.txt @@ -3,6 +3,10 @@ is invoked to produce them so they have no linker-generated ``.pdb`` file containing debug symbols. - The compiler-generated program database files specified by the MSVC - ``/Fd`` flag are not the same as linker-generated program database - files and so are not influenced by this property. + The linker-generated program database files are specified by the + ``/pdb`` linker flag and are not the same as compiler-generated + program database files specified by the ``/Fd`` compiler flag. + Use the |COMPILE_PDB_XXX| property to specify the latter. + + This property is not implemented by the :generator:`Visual Studio 6` + generator. diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst index 9a863a1..730cf57 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst @@ -9,7 +9,5 @@ will be placed by the linker. This property is initialized by the value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is set when a target is created. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` .. include:: PDB_NOTE.txt - -This property is not implemented by the :generator:`Visual Studio 6` -generator. diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst index caec2de..6037fa0 100644 --- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst +++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -11,5 +11,5 @@ property is initialized by the value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable if it is set when a target is created. -This property is not implemented by the :generator:`Visual Studio 6` -generator. +.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>` +.. include:: PDB_NOTE.txt diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst new file mode 100644 index 0000000..e4cc01e --- /dev/null +++ b/Help/release/dev/0-sample-topic.rst @@ -0,0 +1,7 @@ +0-sample-topic +-------------- + +* This is a sample release note for the change in a topic. + Developers should add similar notes for each topic branch + making a noteworthy change. Each document should be named + and titled to match the topic name to avoid merge conflicts. diff --git a/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst b/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst new file mode 100644 index 0000000..5384671 --- /dev/null +++ b/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst @@ -0,0 +1,6 @@ +ExternalProject-BUILD_ALWAYS +---------------------------- + +* The :module:`ExternalProject` module ``ExternalProject_Add`` command + learned a new ``BUILD_ALWAYS`` option to cause the external project + build step to run every time the host project is built. diff --git a/Help/release/dev/ExternalProject-no-download-progress.rst b/Help/release/dev/ExternalProject-no-download-progress.rst new file mode 100644 index 0000000..41db55d --- /dev/null +++ b/Help/release/dev/ExternalProject-no-download-progress.rst @@ -0,0 +1,6 @@ +ExternalProject-no-download-progress +------------------------------------ + +* The :module:`ExternalProject` module ``ExternalProject_Add`` command + learned a new ``DOWNLOAD_NO_PROGRESS`` option to disable progress + output while downloading the source tarball. diff --git a/Help/release/dev/FeatureSummary_combine_WHAT_values.rst b/Help/release/dev/FeatureSummary_combine_WHAT_values.rst new file mode 100644 index 0000000..174ef15 --- /dev/null +++ b/Help/release/dev/FeatureSummary_combine_WHAT_values.rst @@ -0,0 +1,6 @@ +FeatureSummary_combine_WHAT_values +---------------------------------- + +* The :module:`FeatureSummary` module ``feature_summary`` API + learned to accept multiple values for the ``WHAT`` option and + combine them appropriately. diff --git a/Help/release/dev/FindGTest-AUTO-SOURCES.rst b/Help/release/dev/FindGTest-AUTO-SOURCES.rst new file mode 100644 index 0000000..17b2a1b --- /dev/null +++ b/Help/release/dev/FindGTest-AUTO-SOURCES.rst @@ -0,0 +1,7 @@ +FindGTest-AUTO-SOURCES +---------------------- + +* The :module:`FindGTest` module ``gtest_add_tests`` macro learned + a new ``AUTO`` option to automatically read the :prop_tgt:`SOURCES` + target property of the test executable and scan the source files + for tests to be added. diff --git a/Help/release/dev/FindHg-WC_INFO.rst b/Help/release/dev/FindHg-WC_INFO.rst new file mode 100644 index 0000000..0caf2b3 --- /dev/null +++ b/Help/release/dev/FindHg-WC_INFO.rst @@ -0,0 +1,5 @@ +FindHg-WC_INFO +-------------- + +* The :module:`FindHg` module gained a new ``Hg_WC_INFO`` macro to + help run ``hg`` to extract information about a Mercurial work copy. diff --git a/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst b/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst new file mode 100644 index 0000000..c0f6471 --- /dev/null +++ b/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst @@ -0,0 +1,5 @@ +FindPkgConfig-PKG_CONFIG +------------------------ + +* The :module:`FindPkgConfig` module learned to use the ``PKG_CONFIG`` + environment variable value as the ``pkg-config`` executable, if set. diff --git a/Help/release/dev/add-FindOpenCL.rst b/Help/release/dev/add-FindOpenCL.rst new file mode 100644 index 0000000..e1e30d1 --- /dev/null +++ b/Help/release/dev/add-FindOpenCL.rst @@ -0,0 +1,4 @@ +add-FindOpenCL +-------------- + +* The :module:`FindOpenCL` module was introduced. diff --git a/Help/release/dev/add_custom_command-DEPENDS-genex.rst b/Help/release/dev/add_custom_command-DEPENDS-genex.rst new file mode 100644 index 0000000..1e528e6 --- /dev/null +++ b/Help/release/dev/add_custom_command-DEPENDS-genex.rst @@ -0,0 +1,5 @@ +add_custom_command-DEPENDS-genex +-------------------------------- + +* The :command:`add_custom_command` command learned to interpret + :manual:`cmake-generator-expressions(7)` in arguments to ``DEPENDS``. diff --git a/Help/release/dev/cpack-deb-compression-types.rst b/Help/release/dev/cpack-deb-compression-types.rst new file mode 100644 index 0000000..a33e333 --- /dev/null +++ b/Help/release/dev/cpack-deb-compression-types.rst @@ -0,0 +1,6 @@ +cpack-deb-compression-types +--------------------------- + +* The :module:`CPackDeb` module learned a new + :variable:`CPACK_DEBIAN_COMPRESSION_TYPE` variable to set the + tarball compression type. diff --git a/Help/release/dev/ctest-coverage-extra.rst b/Help/release/dev/ctest-coverage-extra.rst new file mode 100644 index 0000000..85d023b --- /dev/null +++ b/Help/release/dev/ctest-coverage-extra.rst @@ -0,0 +1,5 @@ +ctest-coverage-extra +-------------------- + +* The :command:`ctest_coverage` command learned to read variable + ``CTEST_COVERAGE_EXTRA_FLAGS`` to set ``CoverageExtraFlags``. diff --git a/Help/release/dev/ctest-intel-coverage.rst b/Help/release/dev/ctest-intel-coverage.rst new file mode 100644 index 0000000..11455a5 --- /dev/null +++ b/Help/release/dev/ctest-intel-coverage.rst @@ -0,0 +1,5 @@ +ctest-intel-coverage +-------------------- + +* The :command:`ctest_coverage` command learned to support + Intel coverage files with the ``codecov`` tool. diff --git a/Help/release/dev/custom-ninja-deptypes.rst b/Help/release/dev/custom-ninja-deptypes.rst new file mode 100644 index 0000000..7750da8 --- /dev/null +++ b/Help/release/dev/custom-ninja-deptypes.rst @@ -0,0 +1,5 @@ +custom-ninja-deptypes +--------------------- + +* Add a `CMAKE_NINJA_DEPTYPE_<LANG>` variable so that compilers may set the + deptype for use in Ninja other than those CMake itself knows about. diff --git a/Help/release/dev/faster-parsers.rst b/Help/release/dev/faster-parsers.rst new file mode 100644 index 0000000..c2a8bfb --- /dev/null +++ b/Help/release/dev/faster-parsers.rst @@ -0,0 +1,6 @@ +faster-parsers +-------------- + +* The :manual:`cmake-language(7)` internal implementation of generator + expression and list expansion parsers have been optimized and shows + non-trivial speedup on large projects. diff --git a/Help/release/dev/link-libraries-response-files.rst b/Help/release/dev/link-libraries-response-files.rst new file mode 100644 index 0000000..cecf7f6 --- /dev/null +++ b/Help/release/dev/link-libraries-response-files.rst @@ -0,0 +1,5 @@ +link-libraries-response-files +----------------------------- + +* The Makefile generators learned to use response files with GNU tools + on Windows to pass library directories and names to the linker. diff --git a/Help/release/dev/msvc-compiler-pdb-files.rst b/Help/release/dev/msvc-compiler-pdb-files.rst new file mode 100644 index 0000000..d06d202 --- /dev/null +++ b/Help/release/dev/msvc-compiler-pdb-files.rst @@ -0,0 +1,10 @@ +msvc-compiler-pdb-files +----------------------- + +* New :prop_tgt:`COMPILE_PDB_NAME` and + :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` target properties + were introduced to specify the MSVC compiler program database + file location (``cl /Fd``). This complements the existing + :prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY` + target properties that specify the linker program database + file location (``link /pdb``). diff --git a/Help/release/index.rst b/Help/release/index.rst index 752c568..15ce065 100644 --- a/Help/release/index.rst +++ b/Help/release/index.rst @@ -5,6 +5,8 @@ CMake Release Notes This file should include the adjacent "dev.txt" file in development versions but not in release versions. +.. include:: dev.txt + Releases ======== diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst new file mode 100644 index 0000000..ea33c7d --- /dev/null +++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst @@ -0,0 +1,8 @@ +CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY +---------------------------------- + +Output directory for MS debug symbol ``.pdb`` files +generated by the compiler while building source files. + +This variable is used to initialize the +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` property on all the targets. diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst new file mode 100644 index 0000000..fdeb9ab --- /dev/null +++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst @@ -0,0 +1,11 @@ +CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG> +------------------------------------------- + +Per-configuration output directory for MS debug symbol ``.pdb`` files +generated by the compiler while building source files. + +This is a per-configuration version of +:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY`. +This variable is used to initialize the +:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>` +property on all the targets. diff --git a/Help/variable/CMAKE_HOST_SYSTEM.rst b/Help/variable/CMAKE_HOST_SYSTEM.rst index 4366ee3..c2a8f1a 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM.rst @@ -1,7 +1,10 @@ CMAKE_HOST_SYSTEM ----------------- -Name of system cmake is being run on. +Composit Name of OS CMake is being run on. -The same as CMAKE_SYSTEM but for the host system instead of the target -system when cross compiling. +This variable is the composite of :variable:`CMAKE_HOST_SYSTEM_NAME` and +:variable:`CMAKE_HOST_SYSTEM_VERSION`, e.g. +``${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_VERSION}``. If +:variable:`CMAKE_HOST_SYSTEM_VERSION` is not set, then this variable is +the same as :variable:`CMAKE_HOST_SYSTEM_NAME`. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst index 718208a..a221de9 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst @@ -3,5 +3,6 @@ CMAKE_HOST_SYSTEM_NAME Name of the OS CMake is running on. -The same as CMAKE_SYSTEM_NAME but for the host system instead of the -target system when cross compiling. +On systems that have the uname command, this variable is set to the +output of uname -s. ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X +are the values found on the big three operating systems. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst index 2700b66..790565a 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst @@ -3,5 +3,6 @@ CMAKE_HOST_SYSTEM_PROCESSOR The name of the CPU CMake is running on. -The same as CMAKE_SYSTEM_PROCESSOR but for the host system instead of -the target system when cross compiling. +On systems that support uname, this variable is set to the output of +uname -p, on windows it is set to the value of the environment variable +``PROCESSOR_ARCHITECTURE``. diff --git a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst index a8451e8..e7e0052 100644 --- a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst @@ -1,7 +1,8 @@ CMAKE_HOST_SYSTEM_VERSION ------------------------- -OS version CMake is running on. +The OS version CMake is running on. -The same as CMAKE_SYSTEM_VERSION but for the host system instead of -the target system when cross compiling. +A numeric version string for the system. On systems that support +uname, this variable is set to the output of uname -r. On other +systems this is set to major-minor version numbers. diff --git a/Help/variable/CMAKE_SYSTEM.rst b/Help/variable/CMAKE_SYSTEM.rst index 283d0be..23f5980 100644 --- a/Help/variable/CMAKE_SYSTEM.rst +++ b/Help/variable/CMAKE_SYSTEM.rst @@ -1,9 +1,10 @@ CMAKE_SYSTEM ------------ -Name of system cmake is compiling for. +Composit Name of OS CMake is compiling for. -This variable is the composite of CMAKE_SYSTEM_NAME and -CMAKE_SYSTEM_VERSION, like this -${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}. If CMAKE_SYSTEM_VERSION -is not set, then CMAKE_SYSTEM is the same as CMAKE_SYSTEM_NAME. +This variable is the composite of :variable:`CMAKE_SYSTEM_NAME` and +:variable:`CMAKE_SYSTEM_VERSION`, e.g. +``${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}``. If +:variable:`CMAKE_SYSTEM_VERSION` is not set, then this variable is +the same as :variable:`CMAKE_SYSTEM_NAME`. diff --git a/Help/variable/CMAKE_SYSTEM_NAME.rst b/Help/variable/CMAKE_SYSTEM_NAME.rst index 9871dd9..189dc18 100644 --- a/Help/variable/CMAKE_SYSTEM_NAME.rst +++ b/Help/variable/CMAKE_SYSTEM_NAME.rst @@ -3,7 +3,6 @@ CMAKE_SYSTEM_NAME Name of the OS CMake is building for. -This is the name of the operating system on which CMake is targeting. -On systems that have the uname command, this variable is set to the -output of uname -s. Linux, Windows, and Darwin for Mac OS X are the -values found on the big three operating systems. +This is the name of the OS on which CMake is targeting. This variable +is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the +host system instead of the target system when cross compiling. diff --git a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst index 1655ada..8ad89f1 100644 --- a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst +++ b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst @@ -3,6 +3,6 @@ CMAKE_SYSTEM_PROCESSOR The name of the CPU CMake is building for. -On systems that support uname, this variable is set to the output of -uname -p, on windows it is set to the value of the environment -variable PROCESSOR_ARCHITECTURE +This variable is the same as :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` if +you build for the host system instead of the target system when +cross compiling. diff --git a/Help/variable/CMAKE_SYSTEM_VERSION.rst b/Help/variable/CMAKE_SYSTEM_VERSION.rst index 61bb40e..33510bb 100644 --- a/Help/variable/CMAKE_SYSTEM_VERSION.rst +++ b/Help/variable/CMAKE_SYSTEM_VERSION.rst @@ -1,8 +1,8 @@ CMAKE_SYSTEM_VERSION -------------------- -OS version CMake is building for. +The OS version CMake is building for. -A numeric version string for the system, on systems that support -uname, this variable is set to the output of uname -r. On other -systems this is set to major-minor version numbers. +This variable is the same as :variable:`CMAKE_HOST_SYSTEM_VERSION` if +you build for the host system instead of the target system when +cross compiling. diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 804cce2..694f8b8 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -26,7 +26,7 @@ if(CMAKE_COMPILER_IS_MINGW) set(MINGW 1) endif() set(CMAKE_C_COMPILER_ID_RUN 1) -set(CMAKE_C_SOURCE_FILE_EXTENSIONS c) +set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) set(CMAKE_C_LINKER_PREFERENCE 10) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 561ccf2..16e19cd 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -68,10 +68,19 @@ # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) #elif defined(__WATCOMC__) -# define COMPILER_ID "Watcom" - /* __WATCOMC__ = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) -# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) +# if __WATCOMC__ < 1200 +# define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRP */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# else +# define COMPILER_ID "OpenWatcom" + /* __WATCOMC__ = VVRP + 1100 */ +# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) +# endif +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif #elif defined(__SUNPRO_C) # define COMPILER_ID "SunPro" diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 35aa6c4..c75611a 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -27,7 +27,7 @@ if(CMAKE_COMPILER_IS_MINGW) endif() set(CMAKE_CXX_COMPILER_ID_RUN 1) set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) -set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP) +set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP) set(CMAKE_CXX_LINKER_PREFERENCE 30) set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 6c602d4..d81df77 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -73,10 +73,19 @@ # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) #elif defined(__WATCOMC__) -# define COMPILER_ID "Watcom" - /* __WATCOMC__ = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) -# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) +# if __WATCOMC__ < 1200 +# define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRP */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# else +# define COMPILER_ID "OpenWatcom" + /* __WATCOMC__ = VVRP + 1100 */ +# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) +# endif +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif #elif defined(__SUNPRO_CC) # define COMPILER_ID "SunPro" diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake index 38a6d35..fa025a8 100644 --- a/Modules/CMakeCommonLanguageInclude.cmake +++ b/Modules/CMakeCommonLanguageInclude.cmake @@ -16,9 +16,11 @@ # cache values that can be initialized in the platform-compiler.cmake file # it may be included by more than one language. -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" - CACHE STRING "Flags used by the linker.") - +if(NOT "x$ENV{LDFLAGS}" STREQUAL "x") + set (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") + set (CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") + set (CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}") +endif() if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) # default build type is none @@ -82,12 +84,17 @@ if(NOT CMAKE_NOT_USING_CONFIG_FLAGS) ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING "Flags used by the linker during Release with Debug Info builds.") endif() + +# executable linker flags +set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT}" + CACHE STRING "Flags used by the linker.") + # shared linker flags -set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" +set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT}" CACHE STRING "Flags used by the linker during the creation of dll's.") # module linker flags -set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" +set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT}" CACHE STRING "Flags used by the linker during the creation of modules.") # static linker flags @@ -124,4 +131,3 @@ CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL CMAKE_STATIC_LINKER_FLAGS_RELEASE CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ) - diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 1e41fec..bc26c07 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -74,6 +74,23 @@ #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) # define PLATFORM_ID "Xenix" +#elif defined(__WATCOMC__) +# if defined(__LINUX__) +# define PLATFORM_ID "Linux" + +# elif defined(__DOS__) +# define PLATFORM_ID "DOS" + +# elif defined(__OS2__) +# define PLATFORM_ID "OS2" + +# elif defined(__WINDOWS__) +# define PLATFORM_ID "Windows3x" + +# else /* unknown platform */ +# define PLATFORM_ID "" +# endif + #else /* unknown platform */ # define PLATFORM_ID "" @@ -107,6 +124,17 @@ # define ARCHITECTURE_ID "" # endif +#elif defined(__WATCOMC__) +# if defined(_M_I86) +# define ARCHITECTURE_ID "I86" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + #else # define ARCHITECTURE_ID "" #endif diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake index 39f0023..bf4ec0e 100644 --- a/Modules/CMakePushCheckState.cmake +++ b/Modules/CMakePushCheckState.cmake @@ -53,6 +53,7 @@ macro(CMAKE_RESET_CHECK_STATE) set(CMAKE_REQUIRED_DEFINITIONS) set(CMAKE_REQUIRED_LIBRARIES) set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_QUIET) endmacro() @@ -68,6 +69,7 @@ macro(CMAKE_PUSH_CHECK_STATE) set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) + set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) if (ARGC GREATER 0 AND ARGV0 STREQUAL "RESET") cmake_reset_check_state() @@ -84,6 +86,7 @@ macro(CMAKE_POP_CHECK_STATE) set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") endif() diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index c79ef06..b210bbb 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -67,7 +67,12 @@ # * Mandatory : YES # * Default : 'devel' # -# The debian package section +# .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE +# +# * Mandatory : YES +# * Default : 'gzip' +# +# Possible values are: lzma, xz, bzip2 and gzip. # # .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY # @@ -390,6 +395,12 @@ if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY) set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") endif() +# Compression: (recommended) +if(NOT CPACK_DEBIAN_COMPRESSION_TYPE) + set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip") +endif() + + # Recommends: # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 39183c6..0a47e19 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -216,9 +216,24 @@ # allow other CMake projects to find your package with # the :command:`find_package` command. # +# .. variable:: CPACK_WIX_PROPERTY_<PROPERTY> +# +# This variable can be used to provide a value for +# the Windows Installer property ``<PROPERTY>`` +# +# The follwing list contains some example properties that can be used to +# customize information under +# "Programs and Features" (also known as "Add or Remove Programs") +# +# * ARPCOMMENTS - Comments +# * ARPHELPLINK - Help and support information URL +# * ARPURLINFOABOUT - General information URL +# * URLUPDATEINFO - Update information URL +# * ARPHELPTELEPHONE - Help and support telephone number +# * ARPSIZE - Size (in kilobytes) of the application #============================================================================= -# Copyright 2013 Kitware, Inc. +# Copyright 2014 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake index c2f6915..8721d55 100644 --- a/Modules/CheckCSourceCompiles.cmake +++ b/Modules/CheckCSourceCompiles.cmake @@ -21,6 +21,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2005-2009 Kitware, Inc. @@ -67,7 +68,9 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c @@ -85,13 +88,17 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n") else() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n" diff --git a/Modules/CheckCSourceRuns.cmake b/Modules/CheckCSourceRuns.cmake index 2e68454..a4fa57e 100644 --- a/Modules/CheckCSourceRuns.cmake +++ b/Modules/CheckCSourceRuns.cmake @@ -21,6 +21,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -56,7 +57,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c @@ -73,7 +76,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) # if the return value was 0 then it worked if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" @@ -86,7 +91,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR) set(${VAR} "" CACHE INTERNAL "Test ${VAR}") endif() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n" "${OUTPUT}\n" diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake index c7ef5ec..6ce64a1 100644 --- a/Modules/CheckCXXSourceCompiles.cmake +++ b/Modules/CheckCXXSourceCompiles.cmake @@ -21,6 +21,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2005-2009 Kitware, Inc. @@ -68,7 +69,9 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx @@ -86,13 +89,17 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n") else() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake index 4e3ff6c..c655863 100644 --- a/Modules/CheckCXXSourceRuns.cmake +++ b/Modules/CheckCXXSourceRuns.cmake @@ -21,6 +21,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -56,7 +57,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx @@ -74,7 +77,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) # if the return value was 0 then it worked if("${${VAR}_EXITCODE}" EQUAL 0) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" @@ -87,7 +92,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR) set(${VAR} "" CACHE INTERNAL "Test ${VAR}") endif() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" "${OUTPUT}\n" diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake index aa62fbf..084fbb4 100644 --- a/Modules/CheckCXXSymbolExists.cmake +++ b/Modules/CheckCXXSymbolExists.cmake @@ -27,6 +27,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2003-2011 Kitware, Inc. diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index e232bd7..bfd1836 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -20,6 +20,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2011 Kitware, Inc. @@ -40,7 +41,9 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) if("${VARIABLE}" MATCHES "^${VARIABLE}$") set(MACRO_CHECK_FUNCTION_DEFINITIONS "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Looking for ${FUNCTION}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION}") + endif() if(CMAKE_REQUIRED_LIBRARIES) set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) @@ -63,12 +66,16 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") - message(STATUS "Looking for ${FUNCTION} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} - found") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the function ${FUNCTION} exists passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for ${FUNCTION} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the function ${FUNCTION} exists failed with the following output:\n" diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index 9dc1648..ea73267 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -24,6 +24,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -49,7 +50,9 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c) - message(STATUS "Looking for ${INCLUDE}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${INCLUDE}") + endif() if(${ARGC} EQUAL 3) set(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGV2}") @@ -69,14 +72,18 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) endif() if(${VARIABLE}) - message(STATUS "Looking for ${INCLUDE} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${INCLUDE} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the include file ${INCLUDE} " "exists passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for ${INCLUDE} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${INCLUDE} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the include file ${INCLUDE} " diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index fa36a3f..39abeff 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -28,6 +28,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -53,7 +54,9 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) - message(STATUS "Looking for C++ include ${INCLUDE}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for C++ include ${INCLUDE}") + endif() if(${ARGC} EQUAL 3) set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}") @@ -73,14 +76,18 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) endif() if(${VARIABLE}) - message(STATUS "Looking for C++ include ${INCLUDE} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for C++ include ${INCLUDE} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the include file ${INCLUDE} " "exists passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for C++ include ${INCLUDE} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for C++ include ${INCLUDE} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the include file ${INCLUDE} " diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 182067f..6aa0f2b 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -23,6 +23,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2003-2012 Kitware, Inc. @@ -66,7 +67,9 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) set(_description "include file ${_INCLUDE}") endif() - message(STATUS "Looking for ${_description}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${_description}") + endif() try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c @@ -76,14 +79,18 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) - message(STATUS "Looking for ${_description} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${_description} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if files ${INCLUDE} " "exist passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for ${_description} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${_description} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have includes ${INCLUDE}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if files ${INCLUDE} " diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index f5c563c..2b41379 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -23,6 +23,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -43,7 +44,9 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) if("${VARIABLE}" MATCHES "^${VARIABLE}$") set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}") + endif() set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY}) if(CMAKE_REQUIRED_LIBRARIES) set(CHECK_LIBRARY_EXISTS_LIBRARIES @@ -60,14 +63,18 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " "passed with the following output:\n" "${OUTPUT}\n\n") else() - message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake index 25ea7f4..fe00074 100644 --- a/Modules/CheckPrototypeDefinition.cmake +++ b/Modules/CheckPrototypeDefinition.cmake @@ -33,6 +33,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2005-2009 Kitware, Inc. @@ -97,12 +98,16 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB if (${_VARIABLE}) set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") - message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n" "${OUTPUT}\n\n") else () - message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + endif() set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n" diff --git a/Modules/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake index a864e82..880a688 100644 --- a/Modules/CheckStructHasMember.cmake +++ b/Modules/CheckStructHasMember.cmake @@ -28,6 +28,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages # # # diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index e1ca412..bf2e797 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -28,6 +28,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2003-2011 Kitware, Inc. @@ -74,7 +75,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" "${SOURCEFILE}" @ONLY) - message(STATUS "Looking for ${SYMBOL}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${SYMBOL}") + endif() try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} "${SOURCEFILE}" @@ -85,7 +88,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) "${CMAKE_SYMBOL_EXISTS_INCLUDES}" OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) - message(STATUS "Looking for ${SYMBOL} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${SYMBOL} - found") + endif() set(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the ${SYMBOL} " @@ -93,7 +98,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) "${OUTPUT}\nFile ${SOURCEFILE}:\n" "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") else() - message(STATUS "Looking for ${SYMBOL} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${SYMBOL} - not found") + endif() set(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the ${SYMBOL} " diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index ec28d8b..d4651b9 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -59,6 +59,7 @@ # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_INCLUDES = list of include directories # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages # CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include #============================================================================= @@ -75,6 +76,7 @@ # License text for the above reference.) include(CheckIncludeFile) +include(CheckIncludeFileCXX) cmake_policy(PUSH) cmake_minimum_required(VERSION 2.6 FATAL_ERROR) @@ -84,7 +86,9 @@ get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) #----------------------------------------------------------------------------- # Helper function. DO NOT CALL DIRECTLY. function(__check_type_size_impl type var map builtin language) - message(STATUS "Check size of ${type}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Check size of ${type}") + endif() # Include header files. set(headers) @@ -168,13 +172,17 @@ function(__check_type_size_impl type var map builtin language) message(SEND_ERROR "CHECK_TYPE_SIZE found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !") endif() - message(STATUS "Check size of ${type} - done") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Check size of ${type} - done") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining size of ${type} passed with the following output:\n${output}\n\n") set(${var} "${${var}}" CACHE INTERNAL "CHECK_TYPE_SIZE: sizeof(${type})") else() # The check failed to compile. - message(STATUS "Check size of ${type} - failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Check size of ${type} - failed") + endif() file(READ ${src} content) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${content}\n\n") @@ -218,9 +226,15 @@ macro(CHECK_TYPE_SIZE TYPE VARIABLE) set(_builtin 0) else() set(_builtin 1) - check_include_file(sys/types.h HAVE_SYS_TYPES_H) - check_include_file(stdint.h HAVE_STDINT_H) - check_include_file(stddef.h HAVE_STDDEF_H) + if("${_language}" STREQUAL "C") + check_include_file(sys/types.h HAVE_SYS_TYPES_H) + check_include_file(stdint.h HAVE_STDINT_H) + check_include_file(stddef.h HAVE_STDDEF_H) + elseif("${_language}" STREQUAL "CXX") + check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H) + check_include_file_cxx(stdint.h HAVE_STDINT_H) + check_include_file_cxx(stddef.h HAVE_STDDEF_H) + endif() endif() unset(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY) unset(_CHECK_TYPE_SIZE_LANGUAGE) diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index 4861ff0..3a7ef13 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -27,6 +27,7 @@ # CMAKE_REQUIRED_FLAGS = string of compile command line flags # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) # CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -47,7 +48,9 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) if("${VARIABLE}" MATCHES "^${VARIABLE}$") set(MACRO_CHECK_VARIABLE_DEFINITIONS "-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}") - message(STATUS "Looking for ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${VAR}") + endif() if(CMAKE_REQUIRED_LIBRARIES) set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) @@ -63,13 +66,17 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}") - message(STATUS "Looking for ${VAR} - found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${VAR} - found") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the variable ${VAR} exists passed with the following output:\n" "${OUTPUT}\n\n") else() set(${VARIABLE} "" CACHE INTERNAL "Have variable ${VAR}") - message(STATUS "Looking for ${VAR} - not found") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Looking for ${VAR} - not found") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the variable ${VAR} exists failed with the following output:\n" "${OUTPUT}\n\n") diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 0df51a8..e490e69 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -20,6 +20,7 @@ # [DOWNLOAD_NAME fname] # File name to store (if not end of URL) # [DOWNLOAD_DIR dir] # Directory to store downloaded files # [DOWNLOAD_COMMAND cmd...] # Command to download source tree +# [DOWNLOAD_NO_PROGRESS 1] # Disable download progress reports # [CVS_REPOSITORY cvsroot] # CVSROOT of CVS repository # [CVS_MODULE mod] # Module to checkout from CVS repo # [CVS_TAG tag] # Tag to checkout from CVS repo @@ -54,6 +55,7 @@ # [BINARY_DIR dir] # Specify build dir location # [BUILD_COMMAND cmd...] # Command to drive the native build # [BUILD_IN_SOURCE 1] # Use source dir for build dir +# [BUILD_ALWAYS 1] # No stamp file, build step always runs # #--Install step--------------- # [INSTALL_DIR dir] # Installation prefix # [INSTALL_COMMAND cmd...] # Command to drive install after build @@ -452,6 +454,7 @@ execute_process( WORKING_DIRECTORY \"${work_dir}\" RESULT_VARIABLE error_code OUTPUT_VARIABLE head_sha + OUTPUT_STRIP_TRAILING_WHITESPACE ) if(error_code) message(FATAL_ERROR \"Failed to get the hash for HEAD\") @@ -470,6 +473,17 @@ else() set(is_remote_ref 0) endif() +# Tag is in the form <remote>/<tag> (i.e. origin/master) we must strip +# the remote from the tag. +if(\"\${show_ref_output}\" MATCHES \"refs/remotes/${git_tag}\") + string(REGEX MATCH \"^([^/]+)/(.+)$\" _unused \"${git_tag}\") + set(git_remote \"\${CMAKE_MATCH_1}\") + set(git_tag \"\${CMAKE_MATCH_2}\") +else() + set(git_remote \"origin\") + set(git_tag \"${git_tag}\") +endif() + # This will fail if the tag does not exist (it probably has not been fetched # yet). execute_process( @@ -477,6 +491,7 @@ execute_process( WORKING_DIRECTORY \"${work_dir}\" RESULT_VARIABLE error_code OUTPUT_VARIABLE tag_sha + OUTPUT_STRIP_TRAILING_WHITESPACE ) # Is the hash checkout out that we want? @@ -490,13 +505,94 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\" message(FATAL_ERROR \"Failed to fetch repository '${git_repository}'\") endif() - execute_process( - COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag} - WORKING_DIRECTORY \"${work_dir}\" - RESULT_VARIABLE error_code - ) - if(error_code) - message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\") + if(is_remote_ref) + # Check if stash is needed + execute_process( + COMMAND \"${git_EXECUTABLE}\" status --porcelain + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + OUTPUT_VARIABLE repo_status + ) + if(error_code) + message(FATAL_ERROR \"Failed to get the status\") + endif() + string(LENGTH \"\${repo_status}\" need_stash) + + # If not in clean state, stash changes in order to be able to be able to + # perform git pull --rebase + if(need_stash) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash save --all --quiet + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to stash changes\") + endif() + endif() + + # Pull changes from the remote branch + execute_process( + COMMAND \"${git_EXECUTABLE}\" rebase \${git_remote}/\${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + # Rebase failed: Restore previous state. + execute_process( + COMMAND \"${git_EXECUTABLE}\" rebase --abort + WORKING_DIRECTORY \"${work_dir}\" + ) + if(need_stash) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet + WORKING_DIRECTORY \"${work_dir}\" + ) + endif() + message(FATAL_ERROR \"\\nFailed to rebase in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\") + endif() + + if(need_stash) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + # Stash pop --index failed: Try again dropping the index + execute_process( + COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash pop --quiet + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + # Stash pop failed: Restore previous state. + execute_process( + COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet \${head_sha} + WORKING_DIRECTORY \"${work_dir}\" + ) + execute_process( + COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet + WORKING_DIRECTORY \"${work_dir}\" + ) + message(FATAL_ERROR \"\\nFailed to unstash changes in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\") + endif() + endif() + endif() + else() + execute_process( + COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\") + endif() endif() execute_process( @@ -514,7 +610,7 @@ endif() endfunction(_ep_write_gitupdate_script) -function(_ep_write_downloadfile_script script_filename remote local timeout hash tls_verify tls_cainfo) +function(_ep_write_downloadfile_script script_filename remote local timeout no_progress hash tls_verify tls_cainfo) if(timeout) set(timeout_args TIMEOUT ${timeout}) set(timeout_msg "${timeout} seconds") @@ -523,6 +619,12 @@ function(_ep_write_downloadfile_script script_filename remote local timeout hash set(timeout_msg "none") endif() + if(no_progress) + set(show_progress "") + else() + set(show_progress "SHOW_PROGRESS") + endif() + if("${hash}" MATCHES "${_ep_hash_regex}") set(hash_args EXPECTED_HASH ${CMAKE_MATCH_1}=${CMAKE_MATCH_2}) else() @@ -562,7 +664,7 @@ ${tls_cainfo} file(DOWNLOAD \"${remote}\" \"${local}\" - SHOW_PROGRESS + ${show_progress} ${hash_args} ${timeout_args} STATUS status @@ -1442,10 +1544,11 @@ function(_ep_add_download_command name) string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) + get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) set(download_script "${stamp_dir}/download-${name}.cmake") - _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}") set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) set(retries 3) @@ -1716,10 +1819,18 @@ function(_ep_add_build_command name) set(log "") endif() + get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS) + if(build_always) + set(always 1) + else() + set(always 0) + endif() + ExternalProject_Add_Step(${name} build COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES configure + ALWAYS ${always} ${log} ) endfunction() diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index c0e63d5..a72954c 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -71,6 +71,13 @@ # RUNTIME_PACKAGES_FOUND: only those packages which have been found which have the type RUNTIME # RUNTIME_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type RUNTIME # +# With the exception of the ``ALL`` value, these values can be combined +# in order to customize the output. For example: +# +# :: +# +# feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES) +# # # # If a FILENAME is given, the information is printed into this file. If @@ -417,8 +424,8 @@ endfunction() function(FEATURE_SUMMARY) # CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) - set(oneValueArgs FILENAME VAR DESCRIPTION WHAT) - set(multiValueArgs ) # none + set(oneValueArgs FILENAME VAR DESCRIPTION) + set(multiValueArgs WHAT) CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) @@ -451,23 +458,42 @@ function(FEATURE_SUMMARY) set(requiredPackagesNotFound TRUE) endif() - elseif("${_FS_WHAT}" STREQUAL "ALL") - - set(allWhatParts "ENABLED_FEATURES" - "RUNTIME_PACKAGES_FOUND" - "OPTIONAL_PACKAGES_FOUND" - "RECOMMENDED_PACKAGES_FOUND" - "REQUIRED_PACKAGES_FOUND" + else() + if("${_FS_WHAT}" STREQUAL "ALL") + + set(allWhatParts "ENABLED_FEATURES" + "RUNTIME_PACKAGES_FOUND" + "OPTIONAL_PACKAGES_FOUND" + "RECOMMENDED_PACKAGES_FOUND" + "REQUIRED_PACKAGES_FOUND" + + "DISABLED_FEATURES" + "RUNTIME_PACKAGES_NOT_FOUND" + "OPTIONAL_PACKAGES_NOT_FOUND" + "RECOMMENDED_PACKAGES_NOT_FOUND" + "REQUIRED_PACKAGES_NOT_FOUND" + ) - "DISABLED_FEATURES" - "RUNTIME_PACKAGES_NOT_FOUND" - "OPTIONAL_PACKAGES_NOT_FOUND" - "RECOMMENDED_PACKAGES_NOT_FOUND" - "REQUIRED_PACKAGES_NOT_FOUND" - ) + else() + set(allWhatParts) + foreach(part ${_FS_WHAT}) + list(FIND validWhatParts "${part}" indexInList) + if(NOT "${indexInList}" STREQUAL "-1") + list(APPEND allWhatParts "${part}") + else() + if("${part}" STREQUAL "ALL") + message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ALL, which cannot be combined with other values.") + else() + message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ${part}, which is not a valid value.") + endif() + endif() + endforeach() + endif() set(title_ENABLED_FEATURES "The following features have been enabled:") set(title_DISABLED_FEATURES "The following features have been disabled:") + set(title_PACKAGES_FOUND "The following packages have been found:") + set(title_PACKAGES_NOT_FOUND "The following packages have not been found:") set(title_OPTIONAL_PACKAGES_FOUND "The following OPTIONAL packages have been found:") set(title_OPTIONAL_PACKAGES_NOT_FOUND "The following OPTIONAL packages have not been found:") set(title_RECOMMENDED_PACKAGES_FOUND "The following RECOMMENDED packages have been found:") @@ -488,8 +514,6 @@ function(FEATURE_SUMMARY) endif() endif() endforeach() - else() - message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() is set to ${_FS_WHAT}, which is not a valid value.") endif() if(_FS_FILENAME) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 3b658ef..1cf9124 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -52,6 +52,9 @@ include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) +cmake_push_check_state() +set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) @@ -687,4 +690,5 @@ else() endif() endif() +cmake_pop_check_state() set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 3883877..b479332 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -57,7 +57,11 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 if (BZIP2_FOUND) include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY}) CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX) + cmake_pop_check_state() endif () mark_as_advanced(BZIP2_INCLUDE_DIR) diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake index 83789cc..5620661 100644 --- a/Modules/FindBacktrace.cmake +++ b/Modules/FindBacktrace.cmake @@ -62,6 +62,7 @@ if (NOT DEFINED Backtrace_LIBRARY) # First, check if we already have backtrace(), e.g., in libc cmake_push_check_state(RESET) set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_QUIET ${Backtrace_FIND_QUIETLY}) check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND) cmake_pop_check_state() endif() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index a57e12c..d4026af 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -954,7 +954,8 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # Compute component-specific hints. set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "") - if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python") + if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR + ${COMPONENT} STREQUAL "graph_parallel") foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES}) if(IS_ABSOLUTE "${lib}") get_filename_component(libdir "${lib}" PATH) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 7bc8d49..94f82f6 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -987,7 +987,7 @@ function(CUDA_COMPUTE_BUILD_PATH path build_path) endif() endif() - # This recipie is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the # CMake source. # Remove leading / diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index 4b55d6a..61353ca 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -36,9 +36,13 @@ find_library(CUPS_LIBRARIES NAMES cups ) if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${Cups_FIND_QUIETLY}) # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint) CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE) + cmake_pop_check_state() endif () if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h") diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index 971edb7..fa420c1 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -67,6 +67,9 @@ endif() # default search paths. if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${Curses_FIND_QUIETLY}) CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}" wsyncup "" CURSES_CURSES_HAS_WSYNCUP) @@ -77,6 +80,7 @@ if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) set(CURSES_USE_NCURSES TRUE) endif() endif() + cmake_pop_check_state() endif() diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 6f03c86..f0f9fe1 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -62,7 +62,7 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h ENV GTKMM_BASEPATH [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] - PATH_SUFFIXES include/freetype2 include + PATH_SUFFIXES include/freetype2 include freetype2 ) find_path(FREETYPE_INCLUDE_DIR_freetype2 @@ -79,7 +79,7 @@ find_path(FREETYPE_INCLUDE_DIR_freetype2 ENV GTKMM_BASEPATH [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] - PATH_SUFFIXES include/freetype2 include + PATH_SUFFIXES include/freetype2 include freetype2 ) find_library(FREETYPE_LIBRARY diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 117ded7..7bbb8cf 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -66,6 +66,7 @@ if(GIF_INCLUDE_DIR) include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) include(${CMAKE_CURRENT_LIST_DIR}/CheckStructHasMember.cmake) CMAKE_PUSH_CHECK_STATE() + set(CMAKE_REQUIRED_QUIET ${GIF_FIND_QUIETLY}) set(GIF_VERSION 3) set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}") CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData ) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index c00a750..aa3c235 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -79,7 +79,7 @@ # extra_args = Pass a list of extra arguments to be passed to # executable enclosed in quotes (or "" for none) # ARGN = A list of source files to search for tests & test -# fixtures. +# fixtures. Or AUTO to find them from executable target. # # # @@ -88,7 +88,7 @@ # Example: # set(FooTestArgs --foo 1 --bar 2) # add_executable(FooTest FooUnitTest.cc) -# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" FooUnitTest.cc) +# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO) #============================================================================= # Copyright 2009 Kitware, Inc. @@ -111,6 +111,10 @@ function(GTEST_ADD_TESTS executable extra_args) if(NOT ARGN) message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS") endif() + if(ARGN STREQUAL "AUTO") + # obtain sources used for building that executable + get_property(ARGN TARGET ${executable} PROPERTY SOURCES) + endif() foreach(source ${ARGN}) file(READ "${source}" contents) string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents}) diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake index a1fb33f..c418afd 100644 --- a/Modules/FindHg.cmake +++ b/Modules/FindHg.cmake @@ -2,7 +2,7 @@ # FindHg # ------ # -# +# Extract information from a mercurial working copy. # # The module defines the following variables: # @@ -12,6 +12,20 @@ # HG_FOUND - true if the command line client was found # HG_VERSION_STRING - the version of mercurial found # +# If the command line client executable is found the following macro is defined: +# +# :: +# +# HG_WC_INFO(<dir> <var-prefix>) +# +# Hg_WC_INFO extracts information of a mercurial working copy +# at a given location. This macro defines the following variables: +# +# :: +# +# <var-prefix>_WC_CHANGESET - current changeset +# <var-prefix>_WC_REVISION - current revision +# # Example usage: # # :: @@ -19,11 +33,15 @@ # find_package(Hg) # if(HG_FOUND) # message("hg found: ${HG_EXECUTABLE}") +# HG_WC_INFO(${PROJECT_SOURCE_DIR} Project) +# message("Current revision is ${Project_WC_REVISION}") +# message("Current changeset is ${Project_WC_CHANGESET}") # endif() #============================================================================= # Copyright 2010-2012 Kitware, Inc. # Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> +# Copyright 2014 Matthaeus G. Chajdas # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -37,6 +55,8 @@ find_program(HG_EXECUTABLE NAMES hg + PATHS + [HKEY_LOCAL_MACHINE\\Software\\TortoiseHG] PATH_SUFFIXES Mercurial DOC "hg command line client" ) @@ -51,6 +71,21 @@ if(HG_EXECUTABLE) set(HG_VERSION_STRING "${CMAKE_MATCH_1}") endif() unset(hg_version) + + macro(HG_WC_INFO dir prefix) + execute_process(COMMAND ${HG_EXECUTABLE} id -i -n + WORKING_DIRECTORY ${dir} + RESULT_VARIABLE hg_id_result + ERROR_VARIABLE hg_id_error + OUTPUT_VARIABLE ${prefix}_WC_DATA + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT ${hg_id_result} EQUAL 0) + message(SEND_ERROR "Command \"${HG_EXECUTBALE} id -n\" in directory ${dir} failed with output:\n${hg_id_error}") + endif() + + string(REGEX REPLACE "([0-9a-f]+)\\+? [0-9]+\\+?" "\\1" ${prefix}_WC_CHANGESET ${${prefix}_WC_DATA}) + string(REGEX REPLACE "[0-9a-f]+\\+? ([0-9]+)\\+?" "\\1" ${prefix}_WC_REVISION ${${prefix}_WC_DATA}) + endmacro(HG_WC_INFO) endif() # Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 69da4cd..33f4f0c 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -54,6 +54,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) else () include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake) endif () +include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + +cmake_push_check_state() +set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) set(LAPACK_FOUND FALSE) set(LAPACK95_FOUND FALSE) @@ -347,4 +351,5 @@ else() endif() endif() +cmake_pop_check_state() set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake index be01594..742b851 100644 --- a/Modules/FindLibLZMA.cmake +++ b/Modules/FindLibLZMA.cmake @@ -55,9 +55,12 @@ endif() # Avoid using old codebase if (LIBLZMA_LIBRARY) include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) + set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY}) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER) CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET) + set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) endif () include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake new file mode 100644 index 0000000..b5eed9a --- /dev/null +++ b/Modules/FindOpenCL.cmake @@ -0,0 +1,135 @@ +#.rst: +# FindOpenCL +# ---------- +# +# Try to find OpenCL +# +# Once done this will define:: +# +# OpenCL_FOUND - True if OpenCL was found +# OpenCL_INCLUDE_DIRS - include directories for OpenCL +# OpenCL_LIBRARIES - link against this library to use OpenCL +# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2) +# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation +# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation +# +# The module will also define two cache variables:: +# +# OpenCL_INCLUDE_DIR - the OpenCL include directory +# OpenCL_LIBRARY - the path to the OpenCL library +# + +#============================================================================= +# Copyright 2014 Matthaeus G. Chajdas +# +# 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.) + +function(_FIND_OPENCL_VERSION) + include(CheckSymbolExists) + include(CMakePushCheckState) + set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY}) + + CMAKE_PUSH_CHECK_STATE() + foreach(VERSION "2_0" "1_2" "1_1" "1_0") + set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}") + + if(APPLE) + CHECK_SYMBOL_EXISTS( + CL_VERSION_${VERSION} + "${OpenCL_INCLUDE_DIR}/OpenCL/cl.h" + OPENCL_VERSION_${VERSION}) + else() + CHECK_SYMBOL_EXISTS( + CL_VERSION_${VERSION} + "${OpenCL_INCLUDE_DIR}/CL/cl.h" + OPENCL_VERSION_${VERSION}) + endif() + + if(OPENCL_VERSION_${VERSION}) + string(REPLACE "_" "." VERSION "${VERSION}") + set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE) + string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}") + list(GET version_components 0 major_version) + list(GET version_components 1 minor_version) + set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE) + set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE) + break() + endif() + endforeach() + CMAKE_POP_CHECK_STATE() +endfunction() + +find_path(OpenCL_INCLUDE_DIR + NAMES + CL/cl.h OpenCL/cl.h + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + NVSDKCOMPUTE_ROOT + CUDA_PATH + ATISTREAMSDKROOT + PATH_SUFFIXES + OpenCL/common/inc + "AMD APP/include") + +_FIND_OPENCL_VERSION() + +if(WIN32) + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + find_library(OpenCL_LIBRARY + NAMES OpenCL + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + CUDA_PATH + NVSDKCOMPUTE_ROOT + ATISTREAMSDKROOT + PATH_SUFFIXES + "AMD APP/lib/x86" + lib/x86 + lib/Win32 + OpenCL/common/lib/Win32) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + find_library(OpenCL_LIBRARY + NAMES OpenCL + PATHS ENV + "PROGRAMFILES(X86)" + AMDAPPSDKROOT + INTELOCLSDKROOT + CUDA_PATH + NVSDKCOMPUTE_ROOT + ATISTREAMSDKROOT + PATH_SUFFIXES + "AMD APP/lib/x86_64" + lib/x86_64 + lib/x64 + OpenCL/common/lib/x64) + endif() +else() + find_library(OpenCL_LIBRARY + NAMES OpenCL) +endif() + +set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) +set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args( + OpenCL + FOUND_VAR OpenCL_FOUND + REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR + VERSION_VAR OpenCL_VERSION_STRING) + +mark_as_advanced( + OpenCL_INCLUDE_DIR + OpenCL_LIBRARY) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index fead4a6..30972ae 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -39,6 +39,8 @@ # License text for the above reference.) set(_OPENMP_REQUIRED_VARS) +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${OpenMP_FIND_QUIETLY}) function(_OPENMP_FLAG_CANDIDATES LANG) set(OpenMP_FLAG_CANDIDATES @@ -116,7 +118,9 @@ if(CMAKE_C_COMPILER_LOADED) set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${FLAG}") unset(OpenMP_FLAG_DETECTED CACHE) - message(STATUS "Try OpenMP C flag = [${FLAG}]") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Try OpenMP C flag = [${FLAG}]") + endif() check_c_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED) set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") if(OpenMP_FLAG_DETECTED) @@ -150,7 +154,9 @@ if(CMAKE_CXX_COMPILER_LOADED) set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${FLAG}") unset(OpenMP_FLAG_DETECTED CACHE) - message(STATUS "Try OpenMP CXX flag = [${FLAG}]") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Try OpenMP CXX flag = [${FLAG}]") + endif() check_cxx_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED) set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}") if(OpenMP_FLAG_DETECTED) @@ -167,6 +173,8 @@ if(CMAKE_CXX_COMPILER_LOADED) unset(OpenMP_CXX_TEST_SOURCE) endif() +set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) + if(_OPENMP_REQUIRED_VARS) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index e6fdefe..8327143 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -2,140 +2,20 @@ # FindPkgConfig # ------------- # -# a pkg-config module for CMake +# A `pkg-config` module for CMake. # +# Finds the ``pkg-config`` executable and add the +# :command:`pkg_check_modules` and :command:`pkg_search_module` +# commands. # -# -# Usage: -# -# :: -# -# pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*) -# checks for all the given modules -# -# -# -# :: -# -# pkg_search_module(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*) -# checks for given modules and uses the first working one -# -# -# -# When the 'REQUIRED' argument was set, macros will fail with an error -# when module(s) could not be found -# -# When the 'QUIET' argument is set, no status messages will be printed. -# -# It sets the following variables: -# -# :: -# -# PKG_CONFIG_FOUND ... if pkg-config executable was found -# PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program -# PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found -# (since CMake 2.8.8) -# -# -# -# For the following variables two sets of values exist; first one is the -# common one and has the given PREFIX. The second set contains flags -# which are given out when pkgconfig was called with the '--static' -# option. -# -# :: -# -# <XPREFIX>_FOUND ... set to 1 if module(s) exist -# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') -# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') -# <XPREFIX>_LDFLAGS ... all required linker flags -# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags -# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') -# <XPREFIX>_CFLAGS ... all required cflags -# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags -# -# -# -# :: -# -# <XPREFIX> = <PREFIX> for common case -# <XPREFIX> = <PREFIX>_STATIC for static linking -# -# -# -# There are some special variables whose prefix depends on the count of -# given modules. When there is only one module, <PREFIX> stays -# unchanged. When there are multiple modules, the prefix will be -# changed to <PREFIX>_<MODNAME>: -# -# :: -# -# <XPREFIX>_VERSION ... version of the module -# <XPREFIX>_PREFIX ... prefix-directory of the module -# <XPREFIX>_INCLUDEDIR ... include-dir of the module -# <XPREFIX>_LIBDIR ... lib-dir of the module -# -# -# -# :: -# -# <XPREFIX> = <PREFIX> when |MODULES| == 1, else -# <XPREFIX> = <PREFIX>_<MODNAME> -# -# -# -# A <MODULE> parameter can have the following formats: -# -# :: -# -# {MODNAME} ... matches any version -# {MODNAME}>={VERSION} ... at least version <VERSION> is required -# {MODNAME}={VERSION} ... exactly version <VERSION> is required -# {MODNAME}<={VERSION} ... modules must not be newer than <VERSION> -# -# -# -# Examples -# -# :: -# -# pkg_check_modules (GLIB2 glib-2.0) -# -# -# -# :: -# -# pkg_check_modules (GLIB2 glib-2.0>=2.10) -# requires at least version 2.10 of glib2 and defines e.g. -# GLIB2_VERSION=2.10.3 -# -# -# -# :: -# -# pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0) -# requires both glib2 and gtk2, and defines e.g. -# FOO_glib-2.0_VERSION=2.10.3 -# FOO_gtk+-2.0_VERSION=2.8.20 -# -# -# -# :: -# -# pkg_check_modules (XRENDER REQUIRED xrender) -# defines e.g.: -# XRENDER_LIBRARIES=Xrender;X11 -# XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp -# -# -# -# :: -# -# pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) +# In order to find the ``pkg-config`` executable, it uses the +# :variable:`PKG_CONFIG_EXECUTABLE` variable or the ``PKG_CONFIG`` +# environment variable first. #============================================================================= -# Copyright 2006-2009 Kitware, Inc. -# Copyright 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> +# Copyright 2006-2014 Kitware, Inc. +# Copyright 2014 Christoph Grüninger <foss@grueninger.de> +# Copyright 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -150,6 +30,10 @@ ### Common stuff #### set(PKG_CONFIG_VERSION 1) +# find pkg-config, use PKG_CONFIG if set +if((NOT PKG_CONFIG_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG}" STREQUAL "")) + set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}" CACHE FILEPATH "pkg-config executable") +endif() find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable") mark_as_advanced(PKG_CONFIG_EXECUTABLE) @@ -215,9 +99,20 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro() # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req _is_silent) +macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path) set(${_is_req} 0) set(${_is_silent} 0) + set(${_no_cmake_path} 0) + set(${_no_cmake_environment_path} 0) + if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH) + if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH) + set(${_no_cmake_path} 1) + set(${_no_cmake_environment_path} 1) + endif() + elseif(${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_LESS 3.1) + set(${_no_cmake_path} 1) + set(${_no_cmake_environment_path} 1) + endif() foreach(_pkg ${ARGN}) if (_pkg STREQUAL "REQUIRED") @@ -226,15 +121,48 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent) if (_pkg STREQUAL "QUIET") set(${_is_silent} 1) endif () + if (_pkg STREQUAL "NO_CMAKE_PATH") + set(${_no_cmake_path} 1) + endif() + if (_pkg STREQUAL "NO_CMAKE_ENVIRONMENT_PATH") + set(${_no_cmake_environment_path} 1) + endif() endforeach() set(${_result} ${ARGN}) list(REMOVE_ITEM ${_result} "REQUIRED") list(REMOVE_ITEM ${_result} "QUIET") + list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH") + list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH") endmacro() +# Add the content of a variable or an environment variable to a list of +# paths +# Usage: +# - _pkgconfig_add_extra_path(_extra_paths VAR) +# - _pkgconfig_add_extra_path(_extra_paths ENV VAR) +function(_pkgconfig_add_extra_path _extra_paths_var _var) + set(_is_env 0) + if(_var STREQUAL "ENV") + set(_var ${ARGV2}) + set(_is_env 1) + endif() + if(NOT _is_env) + if(NOT "${${_var}}" STREQUAL "") + list(APPEND ${_extra_paths_var} ${CMAKE_PREFIX_PATH}) + endif() + else() + if(NOT "$ENV{${_var}}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{${_var}}" _path) + list(APPEND ${_extra_paths_var} ${_path}) + unset(_path) + endif() + endif() + set(${_extra_paths_var} ${${_extra_paths_var}} PARENT_SCOPE) +endfunction() + ### -macro(_pkg_check_modules_internal _is_required _is_silent _prefix) +macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) _pkgconfig_unset(${_prefix}_PREFIX) @@ -273,6 +201,77 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) set(_pkg_check_modules_packages) set(_pkg_check_modules_failed) + set(_extra_paths) + + if(NOT _no_cmake_path) + _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH) + _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH) + _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH) + endif() + + if(NOT _no_cmake_environment_path) + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH) + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH) + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH) + endif() + + if(NOT "${_extra_paths}" STREQUAL "") + # Save the PKG_CONFIG_PATH environment variable, and add paths + # from the CMAKE_PREFIX_PATH variables + set(_pkgconfig_path_old $ENV{PKG_CONFIG_PATH}) + set(_pkgconfig_path ${_pkgconfig_path_old}) + if(NOT "${_pkgconfig_path}" STREQUAL "") + file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path) + endif() + + # Create a list of the possible pkgconfig subfolder (depending on + # the system + set(_lib_dirs) + if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE) + list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + list(APPEND _lib_dirs "lib64/pkgconfig") + endif() + endif() + endif() + list(APPEND _lib_dirs "lib/pkgconfig") + + # Check if directories exist and eventually append them to the + # pkgconfig path list + foreach(_prefix_dir ${_extra_paths}) + foreach(_lib_dir ${_lib_dirs}) + if(EXISTS "${_prefix_dir}/${_lib_dir}") + list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}") + list(REMOVE_DUPLICATES _pkgconfig_path) + endif() + endforeach() + endforeach() + + # Prepare and set the environment variable + if(NOT "${_pkgconfig_path}" STREQUAL "") + # remove empty values from the list + list(REMOVE_ITEM _pkgconfig_path "") + file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) + if(UNIX) + string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") + string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") + endif() + set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path}) + endif() + + # Unset variables + unset(_lib_dirs) + unset(_pkgconfig_path) + endif() + # iterate through module list and check whether they exist and match the required version foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list}) set(_pkg_check_modules_exist_query) @@ -338,7 +337,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) if(_pkg_check_modules_failed) # fail when requested if (${_is_required}) - message(SEND_ERROR "A required package was not found") + message(FATAL_ERROR "A required package was not found") endif () else() # when we are here, we checked whether requested modules @@ -376,6 +375,14 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) endif() + + if(NOT "${_extra_paths}" STREQUAL "") + # Restore the environment variable + set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path}) + endif() + + unset(_extra_paths) + unset(_pkgconfig_path_old) else() if (${_is_required}) message(SEND_ERROR "pkg-config tool not found") @@ -387,23 +394,138 @@ endmacro() ### User visible macros start here ### -### +#[========================================[.rst: +.. command:: pkg_check_modules + + Checks for all the given modules. :: + + pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] + [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] + <MODULE> [<MODULE>]*) + + + When the ``REQUIRED`` argument was set, macros will fail with an error + when module(s) could not be found. + + When the ``QUIET`` argument is set, no status messages will be printed. + + By default, if :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or + later, or if :variable:`PKG_CONFIG_USE_CMAKE_PREFIX_PATH` is set, the + :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_FRAMEWORK_PATH`, and + :variable:`CMAKE_APPBUNDLE_PATH` cache and environment variables will + be added to ``pkg-config`` search path. + The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments + disable this behavior for the cache variables and the environment + variables, respectively. + + It sets the following variables: :: + + PKG_CONFIG_FOUND ... if pkg-config executable was found + PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program + PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found + (since CMake 2.8.8) + + For the following variables two sets of values exist; first one is the + common one and has the given PREFIX. The second set contains flags + which are given out when ``pkg-config`` was called with the ``--static`` + option. :: + + <XPREFIX>_FOUND ... set to 1 if module(s) exist + <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l') + <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L') + <XPREFIX>_LDFLAGS ... all required linker flags + <XPREFIX>_LDFLAGS_OTHER ... all other linker flags + <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I') + <XPREFIX>_CFLAGS ... all required cflags + <XPREFIX>_CFLAGS_OTHER ... the other compiler flags + + :: + + <XPREFIX> = <PREFIX> for common case + <XPREFIX> = <PREFIX>_STATIC for static linking + + There are some special variables whose prefix depends on the count of + given modules. When there is only one module, <PREFIX> stays + unchanged. When there are multiple modules, the prefix will be + changed to <PREFIX>_<MODNAME>: :: + + <XPREFIX>_VERSION ... version of the module + <XPREFIX>_PREFIX ... prefix-directory of the module + <XPREFIX>_INCLUDEDIR ... include-dir of the module + <XPREFIX>_LIBDIR ... lib-dir of the module + + :: + + <XPREFIX> = <PREFIX> when |MODULES| == 1, else + <XPREFIX> = <PREFIX>_<MODNAME> + + A <MODULE> parameter can have the following formats: :: + + {MODNAME} ... matches any version + {MODNAME}>={VERSION} ... at least version <VERSION> is required + {MODNAME}={VERSION} ... exactly version <VERSION> is required + {MODNAME}<={VERSION} ... modules must not be newer than <VERSION> + + Examples + + .. code-block:: cmake + + pkg_check_modules (GLIB2 glib-2.0) + + .. code-block:: cmake + + pkg_check_modules (GLIB2 glib-2.0>=2.10) + + Requires at least version 2.10 of glib2 and defines e.g. + ``GLIB2_VERSION=2.10.3`` + + .. code-block:: cmake + + pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0) + + Requires both glib2 and gtk2, and defines e.g. + ``FOO_glib-2.0_VERSION=2.10.3`` and ``FOO_gtk+-2.0_VERSION=2.8.20`` + + .. code-block:: cmake + + pkg_check_modules (XRENDER REQUIRED xrender) + + Defines e.g.: + ``XRENDER_LIBRARIES=Xrender;X11`` and + ``XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp`` +#]========================================] macro(pkg_check_modules _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) - _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) - _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" "${_prefix}" ${_pkg_modules}) + _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) endif() endmacro() -### + +#[========================================[.rst: +.. command:: pkg_search_module + + Same as :command:`pkg_check_modules`, but instead it checks for given + modules and uses the first working one. :: + + pkg_search_module(<PREFIX> [REQUIRED] [QUIET] + [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] + <MODULE> [<MODULE>]*) + + Examples + + .. code-block:: cmake + + pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) +#]========================================] macro(pkg_search_module _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) if (NOT ${_pkg_is_silent}) message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") @@ -412,7 +534,7 @@ macro(pkg_search_module _prefix _module0) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) if(NOT _pkg_modules_found) - _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}") + _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" "${_pkg_alt}") endif() if (${_prefix}_FOUND) @@ -430,6 +552,26 @@ macro(pkg_search_module _prefix _module0) endif() endmacro() + +#[========================================[.rst: +.. variable:: PKG_CONFIG_EXECUTABLE + + Path to the pkg-config executable. + + +.. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH + + Whether :command:`pkg_check_modules` and :command:`pkg_search_module` + should add the paths in :variable:`CMAKE_PREFIX_PATH`, + :variable:`CMAKE_FRAMEWORK_PATH`, and :variable:`CMAKE_APPBUNDLE_PATH` + cache and environment variables to ``pkg-config`` search path. + + If this variable is not set, this behavior is enabled by default if + :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or later, disabled + otherwise. +#]========================================] + + ### Local Variables: ### mode: cmake ### End: diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index e23a58b..c41f3a7 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -27,6 +27,10 @@ # of version numbers that should be taken into account when searching # for Python. You need to set this variable before calling # find_package(PythonInterp). +# +# If also calling find_package(PythonLibs), call find_package(PythonInterp) +# first to get the currently active Python version by default with a consistent +# version of PYTHON_LIBRARIES. #============================================================================= # Copyright 2005-2010 Kitware, Inc. @@ -71,18 +75,23 @@ if(PythonInterp_FIND_VERSION) else() set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) endif() - -list(APPEND _Python_NAMES python) - -# Search for the current active python version first find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES}) # Set up the versions we know about, in the order we will search. Always add # the user supplied additional versions to the front. -set(_Python_VERSIONS - ${Python_ADDITIONAL_VERSIONS} - ${_PYTHON_FIND_OTHER_VERSIONS} - ) +set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS}) +# If FindPythonInterp has already found the major and minor version, +# insert that version next to get consistent versions of the interpreter and +# library. +if(DEFINED PYTHONLIBS_VERSION_STRING) + string(REPLACE "." ";" _PYTHONLIBS_VERSION "${PYTHONLIBS_VERSION_STRING}") + list(GET _PYTHONLIBS_VERSION 0 _PYTHONLIBS_VERSION_MAJOR) + list(GET _PYTHONLIBS_VERSION 1 _PYTHONLIBS_VERSION_MINOR) + list(APPEND _Python_VERSIONS ${_PYTHONLIBS_VERSION_MAJOR}.${_PYTHONLIBS_VERSION_MINOR}) +endif() +# Search for the current active python version first +list(APPEND _Python_VERSIONS ";") +list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS}) unset(_PYTHON_FIND_OTHER_VERSIONS) unset(_PYTHON1_VERSIONS) @@ -91,7 +100,7 @@ unset(_PYTHON3_VERSIONS) # Search for newest python version if python executable isn't found if(NOT PYTHON_EXECUTABLE) - foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS) set(_Python_NAMES python${_CURRENT_VERSION}) if(WIN32) list(APPEND _Python_NAMES python) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 1dbc967..cc875ad 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -31,6 +31,10 @@ # # PYTHON_LIBRARY - path to the python library # PYTHON_INCLUDE_DIR - path to where Python.h is found +# +# If also calling find_package(PythonInterp), call find_package(PythonInterp) +# first to get the currently active Python version by default with a consistent +# version of PYTHON_LIBRARIES. #============================================================================= # Copyright 2001-2009 Kitware, Inc. @@ -80,10 +84,14 @@ endif() # Set up the versions we know about, in the order we will search. Always add # the user supplied additional versions to the front. -set(_Python_VERSIONS - ${Python_ADDITIONAL_VERSIONS} - ${_PYTHON_FIND_OTHER_VERSIONS} - ) +# If FindPythonInterp has already found the major and minor version, +# insert that version between the user supplied versions and the stock +# version list. +set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS}) +if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR) + list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +endif() +list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS}) unset(_PYTHON_FIND_OTHER_VERSIONS) unset(_PYTHON1_VERSIONS) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index d0515c6..e44d1d9 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -335,6 +335,7 @@ endif() include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSymbolExists.cmake) include(${CMAKE_CURRENT_LIST_DIR}/MacroAddFileDependencies.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) set(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) @@ -613,9 +614,13 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) set(QT_QTCORE_FOUND 1) else() - message(WARNING "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as \"${QT_LIBRARY_DIR_TMP}\" " - "but QtCore could not be found there. " - "Qt is NOT installed correctly for the target build environment.") + if(NOT Qt4_FIND_QUIETLY) + message(WARNING + "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as " + "\"${QT_LIBRARY_DIR_TMP}\" " + "but QtCore could not be found there. " + "Qt is NOT installed correctly for the target build environment.") + endif() set(Qt4_FOUND FALSE) if(Qt4_FIND_REQUIRED) message( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") @@ -747,11 +752,10 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) # Find out what window system we're using # ############################################# - # Save required variable - set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) - set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) + cmake_push_check_state() # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}") + set(CMAKE_REQUIRED_QUIET ${Qt4_FIND_QUIETLY}) # Check for Window system symbols (note: only one should end up being set) CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) CHECK_CXX_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) @@ -771,9 +775,7 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) endif () endif () - # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + cmake_pop_check_state() # ############################################# diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake index e5173e3..fc2c043 100644 --- a/Modules/FindSDL_image.cmake +++ b/Modules/FindSDL_image.cmake @@ -54,7 +54,9 @@ find_path(SDL_IMAGE_INCLUDE_DIR SDL_image.h HINTS ENV SDLIMAGEDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake index 8f2f066..176fee6 100644 --- a/Modules/FindSDL_mixer.cmake +++ b/Modules/FindSDL_mixer.cmake @@ -54,7 +54,9 @@ find_path(SDL_MIXER_INCLUDE_DIR SDL_mixer.h HINTS ENV SDLMIXERDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake index e5c2cdb..ef23573 100644 --- a/Modules/FindSDL_net.cmake +++ b/Modules/FindSDL_net.cmake @@ -54,7 +54,9 @@ find_path(SDL_NET_INCLUDE_DIR SDL_net.h HINTS ENV SDLNETDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index 3a6ab7b..8b22ff7 100644 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -98,7 +98,9 @@ find_path(SDL_SOUND_INCLUDE_DIR SDL_sound.h HINTS ENV SDLSOUNDDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) find_library(SDL_SOUND_LIBRARY diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake index 3f58ac1..4b527fa 100644 --- a/Modules/FindSDL_ttf.cmake +++ b/Modules/FindSDL_ttf.cmake @@ -54,7 +54,9 @@ find_path(SDL_TTF_INCLUDE_DIR SDL_ttf.h HINTS ENV SDLTTFDIR ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include + PATH_SUFFIXES SDL + # path suffixes to search inside ENV{SDLDIR} + include/SDL include/SDL12 include/SDL11 include ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index ec671bf..6d1c65d 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -37,6 +37,8 @@ include (CheckIncludeFiles) include (CheckLibraryExists) include (CheckSymbolExists) set(Threads_FOUND FALSE) +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY}) # Do we have sproc? if(CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD) @@ -63,32 +65,31 @@ else() set(CMAKE_THREAD_LIBS_INIT "") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) - endif() + else() - if(NOT CMAKE_HAVE_THREADS_LIBRARY) # Do we have -lpthreads CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) if(CMAKE_HAVE_PTHREADS_CREATE) set(CMAKE_THREAD_LIBS_INIT "-lpthreads") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) - endif() - - # Ok, how about -lpthread - CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) - if(CMAKE_HAVE_PTHREAD_CREATE) - set(CMAKE_THREAD_LIBS_INIT "-lpthread") - set(CMAKE_HAVE_THREADS_LIBRARY 1) - set(Threads_FOUND TRUE) - endif() + else() - if(CMAKE_SYSTEM MATCHES "SunOS.*") - # On sun also check for -lthread - CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) - if(CMAKE_HAVE_THR_CREATE) - set(CMAKE_THREAD_LIBS_INIT "-lthread") + # Ok, how about -lpthread + CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) + if(CMAKE_HAVE_PTHREAD_CREATE) + set(CMAKE_THREAD_LIBS_INIT "-lpthread") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) + + elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS") + # On sun also check for -lthread + CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) + if(CMAKE_HAVE_THR_CREATE) + set(CMAKE_THREAD_LIBS_INIT "-lthread") + set(CMAKE_HAVE_THREADS_LIBRARY 1) + set(Threads_FOUND TRUE) + endif() endif() endif() endif() @@ -96,7 +97,7 @@ else() if(NOT CMAKE_HAVE_THREADS_LIBRARY) # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread - if("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG") + if("x${THREADS_HAVE_PTHREAD_ARG}" STREQUAL "x") message(STATUS "Check if compiler accepts -pthread") try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG ${CMAKE_BINARY_DIR} @@ -174,5 +175,6 @@ if(CMAKE_USE_PTHREADS_INIT) endif() endif() +set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 67cecc2..3a31cf0 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -73,6 +73,8 @@ if (UNIX) # found in tcl on the mac set(CMAKE_FIND_FRAMEWORK_SAVE ${CMAKE_FIND_FRAMEWORK}) set(CMAKE_FIND_FRAMEWORK NEVER) + set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) + set(CMAKE_REQUIRED_QUIET ${X11_FIND_QUIETLY}) set(X11_INC_SEARCH_PATH /usr/pkg/xorg/include /usr/X11R6/include @@ -507,6 +509,7 @@ if (UNIX) X11_XSync_INCLUDE_PATH ) set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE}) + set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) endif () # X11_FIND_REQUIRED_<component> could be checked too diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 013a028..4b551e6 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -366,18 +366,18 @@ endif() if(WATCOM) get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH ) - if(WATCOM17) - set( __install__libs ${CompilerPath}/clbr17.dll - ${CompilerPath}/mt7r17.dll ${CompilerPath}/plbr17.dll ) - endif() - if(WATCOM18) - set( __install__libs ${CompilerPath}/clbr18.dll - ${CompilerPath}/mt7r18.dll ${CompilerPath}/plbr18.dll ) - endif() - if(WATCOM19) - set( __install__libs ${CompilerPath}/clbr19.dll - ${CompilerPath}/mt7r19.dll ${CompilerPath}/plbr19.dll ) + if(CMAKE_C_COMPILER_VERSION) + set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + else() + set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) endif() + string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}") + list(GET _watcom_version_list 0 _watcom_major) + list(GET _watcom_version_list 1 _watcom_minor) + set( __install__libs + ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll + ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll + ${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll ) foreach(lib ${__install__libs} ) diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake new file mode 100644 index 0000000..a4c122d --- /dev/null +++ b/Modules/Platform/Android.cmake @@ -0,0 +1,5 @@ +include(Platform/Linux) +set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "") +# RPath is useless on Android, because we can't determine the installation +# location ahead of time. +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake index 825f851..dfc2664 100644 --- a/Modules/Platform/Haiku.cmake +++ b/Modules/Platform/Haiku.cmake @@ -21,18 +21,26 @@ set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") # "/boot/system/develop/lib/<subdir>/", which we assume to be the secondary # architecture specific subdirectory and extract the name of the architecture # accordingly. -set(__HAIKU_COMPILER ${CMAKE_C_COMPILER}) -if(NOT __HAIKU_COMPILER) +# First of all, find a C or C++ compiler we can run. The "arg1" is necessary +# here for compilers such as "distcc gcc-x86" or "ccache gcc-x86" +# TODO See CMakeDetermineCompilerId.cmake for some more things we may want to do. +if(CMAKE_C_COMPILER) + set(__HAIKU_COMPILER ${CMAKE_C_COMPILER}) + string (STRIP "${CMAKE_C_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS) +else() set(__HAIKU_COMPILER ${CMAKE_CXX_COMPILER}) + string (STRIP "${CMAKE_CXX_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS) endif() + execute_process( - COMMAND ${__HAIKU_COMPILER} -print-search-dirs + COMMAND ${__HAIKU_COMPILER} ${__HAIKU_COMPILER_FLAGS} -print-search-dirs OUTPUT_VARIABLE _HAIKU_SEARCH_DIRS + RESULT_VARIABLE _HAIKU_SEARCH_DIRS_FOUND OUTPUT_STRIP_TRAILING_WHITESPACE) -string(REGEX MATCH ".*\nlibraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/(:[^\n]*)?\n.*" _dummy "\n${_HAIKU_SEARCH_DIRS}\n") +string(REGEX MATCH "libraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/?(:?\n+)" _dummy "${_HAIKU_SEARCH_DIRS}\n") set(CMAKE_HAIKU_SECONDARY_ARCH "${CMAKE_MATCH_2}") if(NOT CMAKE_HAIKU_SECONDARY_ARCH) @@ -53,14 +61,12 @@ else() endif() list(APPEND CMAKE_SYSTEM_PREFIX_PATH - /boot/common/non-packaged - /boot/common + /boot/system/non-packaged /boot/system ) LIST(APPEND CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES - /boot/common/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} - /boot/common/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} + /boot/system/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} /boot/system/develop/headers/os /boot/system/develop/headers/os/app /boot/system/develop/headers/os/device @@ -108,8 +114,7 @@ LIST(APPEND CMAKE_HAIKU_CXX_INCLUDE_DIRECTORIES LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_HAIKU_C_INCLUDE_DIRECTORIES}) LIST(APPEND CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES - /boot/common/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} - /boot/common/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} + /boot/system/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} /boot/system/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR} ) @@ -120,6 +125,6 @@ LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES}) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "/boot/common" CACHE PATH + set(CMAKE_INSTALL_PREFIX "/boot/system" CACHE PATH "Install path prefix, prepended onto install directories." FORCE) endif() diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 2bb7a20..5c5b360 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -87,6 +87,7 @@ macro(__windows_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES ${__WINDOWS_GNU_LD_RESPONSE}) set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) # We prefer "@" for response files but it is not supported by gcc 3. @@ -103,7 +104,9 @@ macro(__windows_compiler_gnu lang) endif() # The GNU 3.x compilers do not support response files (only linkers). set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 0) - elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS) + # Link libraries are generated only for the front-end. + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 0) + else() # Use "@" to pass the response file to the front-end. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") endif() diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e29aaf4..5732170 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -241,7 +241,7 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") set(CMAKE_${lang}_COMPILE_OBJECT - "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<OBJECT_DIR>/${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}") + "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB>${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> -E <SOURCE>${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 8a03b29..617761b 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -39,8 +39,13 @@ set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG") set (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib") set (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") +foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) + set(CMAKE_C_${type}_USE_WATCOM_QUOTE 1) + set(CMAKE_CXX_${type}_USE_WATCOM_QUOTE 1) +endforeach() + set(CMAKE_C_CREATE_IMPORT_LIBRARY - "wlib -c -q -n -b <TARGET_IMPLIB> +'<TARGET_UNQUOTED>'") + "wlib -c -q -n -b <TARGET_IMPLIB> +<TARGET_QUOTED>") set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) set(CMAKE_C_LINK_EXECUTABLE @@ -65,11 +70,10 @@ set(CMAKE_C_CREATE_PREPROCESSED_SOURCE set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}") -set(CMAKE_CXX_CREATE_SHARED_MODULE - "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") set(CMAKE_CXX_CREATE_SHARED_LIBRARY - ${CMAKE_CXX_CREATE_SHARED_MODULE} - ${CMAKE_CXX_CREATE_IMPORT_LIBRARY}) + "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option implib=<TARGET_IMPLIB> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") +string(REPLACE " option implib=<TARGET_IMPLIB>" "" + CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") # create a C shared library set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) @@ -78,7 +82,7 @@ set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) set(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE}) # create a C++ static library -set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b '<TARGET_UNQUOTED>' <LINK_FLAGS> <OBJECTS> ") +set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b <TARGET_QUOTED> <LINK_FLAGS> <OBJECTS> ") # create a C static library set(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) @@ -94,16 +98,18 @@ if(NOT _CMAKE_WATCOM_VERSION) set(WATCOM17) set(WATCOM18) set(WATCOM19) - if("${_compiler_version}" LESS 12.70) - set(WATCOM16 1) - endif() - if("${_compiler_version}" EQUAL 12.70) - set(WATCOM17 1) - endif() - if("${_compiler_version}" EQUAL 12.80) - set(WATCOM18 1) - endif() - if("${_compiler_version}" EQUAL 12.90) - set(WATCOM19 1) + if("${_compiler_id}" STREQUAL "OpenWatcom") + if("${_compiler_version}" VERSION_LESS 1.7) + set(WATCOM16 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.7) + set(WATCOM17 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.8) + set(WATCOM18 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.9) + set(WATCOM19 1) + endif() endif() endif() diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index 0fe0b32..e034a28 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -104,6 +104,18 @@ function(ProcessorCount var) string(REGEX MATCHALL "Number of CPUs = ([0-9]+)" procs "${machinfo_output}") set(count "${CMAKE_MATCH_1}") #message("ProcessorCount: trying machinfo '${ProcessorCount_cmd_machinfo}'") + else() + find_program(ProcessorCount_cmd_mpsched mpsched) + mark_as_advanced(ProcessorCount_cmd_mpsched) + if(ProcessorCount_cmd_mpsched) + execute_process(COMMAND ${ProcessorCount_cmd_mpsched} -s + OUTPUT_QUIET + ERROR_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE mpsched_output) + string(REGEX MATCHALL "Processor Count *: *([0-9]+)" procs "${mpsched_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying mpsched -s '${ProcessorCount_cmd_mpsched}'") + endif() endif() endif() diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 8baf896..aca8996 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -141,7 +141,7 @@ macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target) set(_moc_extra_parameters_file @${_moc_parameters_file}) add_custom_command(OUTPUT ${outfile} COMMAND Qt4::moc ${_moc_extra_parameters_file} - DEPENDS ${infile} + DEPENDS ${infile} ${_moc_parameters_file} ${_moc_working_dir} VERBATIM) endmacro () diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 654b4d0..127012f 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -426,6 +426,7 @@ function(add_jar _TARGET_NAME) set(_JAVA_DEPENDS) set(_JAVA_COMPILE_DEPENDS) set(_JAVA_RESOURCE_FILES) + set(_JAVA_RESOURCE_FILES_RELATIVE) foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES}) get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT) get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE) @@ -462,7 +463,8 @@ function(add_jar _TARGET_NAME) __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE} "Copying ${_JAVA_SOURCE_FILE} to the build directory") - list(APPEND _JAVA_RESOURCE_FILES ${_JAVA_SOURCE_FILE}) + list(APPEND _JAVA_RESOURCE_FILES ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}) + list(APPEND _JAVA_RESOURCE_FILES_RELATIVE ${_JAVA_SOURCE_FILE}) endif () endforeach() @@ -529,7 +531,7 @@ function(add_jar _TARGET_NAME) OUTPUT ${_JAVA_JAR_OUTPUT_PATH} COMMAND ${Java_JAR_EXECUTABLE} -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE} - ${_JAVA_RESOURCE_FILES} @java_class_filelist + ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist COMMAND ${CMAKE_COMMAND} -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR} -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME} @@ -549,7 +551,7 @@ function(add_jar _TARGET_NAME) OUTPUT ${_JAVA_JAR_OUTPUT_PATH} COMMAND ${Java_JAR_EXECUTABLE} -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE} - ${_JAVA_RESOURCE_FILES} @java_class_filelist + ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist COMMAND ${CMAKE_COMMAND} -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR} -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME} diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 7478310..cba22af 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -98,7 +98,9 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR}) endif(QT_INCLUDE_DIRS_NO_SYSTEM) endif() - set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + if(QT_USE_${module} OR QT_IS_STATIC) + set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + endif() set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS}) if(QT_IS_STATIC) set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES}) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 11ca205..23bf933 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -200,6 +200,7 @@ macro(SWIG_ADD_MODULE name language) MODULE ${swig_generated_sources} ${swig_other_sources}) + set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES NO_SONAME ON) string(TOLOWER "${language}" swig_lowercase_language) if ("${swig_lowercase_language}" STREQUAL "octave") set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") diff --git a/Modules/WIX.template.in b/Modules/WIX.template.in index 59a75c7..bbb7c88 100644 --- a/Modules/WIX.template.in +++ b/Modules/WIX.template.in @@ -40,5 +40,7 @@ <FeatureRef Id="ProductFeature"/> <UIRef Id="$(var.CPACK_WIX_UI_REF)" /> + + <?include "properties.wxi"?> </Product> </Wix> diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 175a034..27d099d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -18,12 +18,34 @@ else() endif() if(HAVE_ELF_H) set(CMAKE_USE_ELF_PARSER 1) +elseif(HAIKU) + # On Haiku, we need to include elf32.h from the private headers + set(CMake_HAIKU_INCLUDE_DIRS + /boot/system/develop/headers/private/system + /boot/system/develop/headers/private/system/arch/x86 + ) + + set(CMAKE_REQUIRED_INCLUDES ${CMake_HAIKU_INCLUDE_DIRS}) + CHECK_INCLUDE_FILE("elf32.h" HAVE_ELF32_H) + unset(CMAKE_REQUIRED_INCLUDES) + + if(HAVE_ELF32_H) + set(CMAKE_USE_ELF_PARSER 1) + else() + unset(CMake_HAIKU_INCLUDE_DIRS) + set(CMAKE_USE_ELF_PARSER) + endif() else() set(CMAKE_USE_ELF_PARSER) endif() set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) +# ensure Unicode friendly APIs are used on Windows +if(WIN32) + add_definitions(-DUNICODE -D_UNICODE) +endif() + # configure the .h file configure_file( "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in" @@ -52,6 +74,7 @@ include_directories( ${CMAKE_EXPAT_INCLUDES} ${CMAKE_TAR_INCLUDES} ${CMAKE_COMPRESS_INCLUDES} + ${CMake_HAIKU_INCLUDE_DIRS} ) # let cmake know it is supposed to use it @@ -399,7 +422,6 @@ if (WIN32) cmGlobalVisualStudio12Generator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h - cmGlobalWatcomWMakeGenerator.cxx cmIDEFlagTable.h cmIDEOptions.cxx cmIDEOptions.h @@ -419,6 +441,15 @@ if (WIN32) endif() endif () +# Watcom support +if(WIN32 OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + set_property(SOURCE cmake.cxx APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_USE_WMAKE) + list(APPEND SRCS + cmGlobalWatcomWMakeGenerator.cxx + cmGlobalWatcomWMakeGenerator.h + ) +endif() + # Ninja support set(SRCS ${SRCS} cmGlobalNinjaGenerator.cxx @@ -562,7 +593,11 @@ if(WIN32) set(CPACK_SRCS ${CPACK_SRCS} CPack/WiX/cmCPackWIXGenerator.cxx CPack/WiX/cmWIXSourceWriter.cxx + CPack/WiX/cmWIXDirectoriesSourceWriter.cxx + CPack/WiX/cmWIXFeaturesSourceWriter.cxx + CPack/WiX/cmWIXFilesSourceWriter.cxx CPack/WiX/cmWIXRichTextFormatWriter.cxx + CPack/WiX/cmWIXPatch.cxx CPack/WiX/cmWIXPatchParser.cxx ) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3a53bc4..27f2e91 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 0) -set(CMake_VERSION_PATCH 0) -set(CMake_VERSION_RC 3) +set(CMake_VERSION_PATCH 20140401) +#set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 43119d6..a385e40 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -1,6 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator - Copyright 2000-2013 Kitware, Inc., Insight Software Consortium + Copyright 2000-2014 Kitware, Inc., Insight Software Consortium Distributed under the OSI-approved BSD License (the "License"); see accompanying file Copyright.txt for details. @@ -19,6 +19,9 @@ #include <CPack/cmCPackComponentGroup.h> #include "cmWIXSourceWriter.h" +#include "cmWIXDirectoriesSourceWriter.h" +#include "cmWIXFeaturesSourceWriter.h" +#include "cmWIXFilesSourceWriter.h" #include "cmWIXRichTextFormatWriter.h" #include <cmsys/SystemTools.hxx> @@ -28,11 +31,9 @@ #include <rpc.h> // for GUID generation -#include <sys/types.h> -#include <sys/stat.h> - cmCPackWIXGenerator::cmCPackWIXGenerator(): - HasDesktopShortcuts(false) + HasDesktopShortcuts(false), + Patch(Logger) { } @@ -44,15 +45,9 @@ int cmCPackWIXGenerator::InitializeInternal() return this->Superclass::InitializeInternal(); } -bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command) +bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command) { - std::string cpackTopLevel; - if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) - { - return false; - } - - std::string logFileName = cpackTopLevel + "/wix.log"; + std::string logFileName = this->CPackTopLevel + "/wix.log"; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Running WiX command: " << command << std::endl); @@ -81,7 +76,7 @@ bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command) } bool cmCPackWIXGenerator::RunCandleCommand( - const std::string& sourceFile, const std::string& objectFile) + std::string const& sourceFile, std::string const& objectFile) { std::string executable; if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable)) @@ -108,7 +103,7 @@ bool cmCPackWIXGenerator::RunCandleCommand( return RunWiXCommand(command.str()); } -bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) +bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) { std::string executable; if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable)) @@ -121,8 +116,8 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); - for(extension_set_t::const_iterator i = LightExtensions.begin(); - i != LightExtensions.end(); ++i) + for(extension_set_t::const_iterator i = this->LightExtensions.begin(); + i != this->LightExtensions.end(); ++i) { command << " -ext " << QuotePath(*i); } @@ -182,15 +177,14 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() "you might want to set this explicitly." << std::endl); } - std::string cpackTopLevel; - if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) + if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel)) { return false; } if(GetOption("CPACK_WIX_LICENSE_RTF") == 0) { - std::string licenseFilename = cpackTopLevel + "/License.rtf"; + std::string licenseFilename = this->CPackTopLevel + "/License.rtf"; SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str()); if(!CreateLicenseFile()) @@ -213,7 +207,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() { std::string defaultRef = "WixUI_InstallDir"; - if(Components.size()) + if(this->Components.size()) { defaultRef = "WixUI_FeatureTree"; } @@ -221,17 +215,24 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() SetOption("CPACK_WIX_UI_REF", defaultRef.c_str()); } - CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions); - CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions); + const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT"); + if(packageContact != 0 && + GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0) + { + SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact); + } + + CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions); + CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions); - LightExtensions.insert("WixUIExtension"); - CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions); - CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions); + this->LightExtensions.insert("WixUIExtension"); + CollectExtensions("CPACK_WIX_EXTENSIONS", this->LightExtensions); + CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions); const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); if(patchFilePath) { - LoadPatchFragments(patchFilePath); + this->Patch.LoadFragments(patchFilePath); } return true; @@ -244,10 +245,8 @@ bool cmCPackWIXGenerator::PackageFilesImpl() return false; } - if(!CreateWiXVariablesIncludeFile()) - { - return false; - } + CreateWiXVariablesIncludeFile(); + CreateWiXPropertiesIncludeFile(); if(!CreateWiXSourceFiles()) { @@ -257,9 +256,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl() AppendUserSuppliedExtraSources(); std::stringstream objectFiles; - for(size_t i = 0; i < WixSources.size(); ++i) + for(size_t i = 0; i < this->WixSources.size(); ++i) { - const std::string& sourceFilename = WixSources[i]; + std::string const& sourceFilename = this->WixSources[i]; std::string objectFilename = cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj"; @@ -282,7 +281,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources() const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES"); if(!cpackWixExtraSources) return; - cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources); + cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources); } void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) @@ -297,22 +296,18 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) for(size_t i = 0; i < expandedExtraObjects.size(); ++i) { - stream << " " << QuotePath(expandedExtraObjects[i]); + stream << " " << QuotePath(expandedExtraObjects[i]); } } -bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() +void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() { - std::string cpackTopLevel; - if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) - { - return false; - } - std::string includeFilename = - cpackTopLevel + "/cpack_variables.wxi"; + this->CPackTopLevel + "/cpack_variables.wxi"; + + cmWIXSourceWriter includeFile( + this->Logger, includeFilename, true); - cmWIXSourceWriter includeFile(Logger, includeFilename, true); CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID"); CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID"); CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR"); @@ -326,12 +321,39 @@ bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() GetOption("CPACK_PACKAGE_NAME")); CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER"); CopyDefinition(includeFile, "CPACK_WIX_UI_REF"); +} - return true; +void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile() +{ + std::string includeFilename = + this->CPackTopLevel + "/properties.wxi"; + + cmWIXSourceWriter includeFile( + this->Logger, includeFilename, true); + + std::string prefix = "CPACK_WIX_PROPERTY_"; + std::vector<std::string> options = GetOptions(); + + for(size_t i = 0; i < options.size(); ++i) + { + std::string const& name = options[i]; + + if(name.length() > prefix.length() && + name.substr(0, prefix.length()) == prefix) + { + std::string id = name.substr(prefix.length()); + std::string value = GetOption(name.c_str()); + + includeFile.BeginElement("Property"); + includeFile.AddAttribute("Id", id); + includeFile.AddAttribute("Value", value); + includeFile.EndElement("Property"); + } + } } void cmCPackWIXGenerator::CopyDefinition( - cmWIXSourceWriter &source, const std::string &name) + cmWIXSourceWriter &source, std::string const& name) { const char* value = GetOption(name.c_str()); if(value) @@ -341,7 +363,7 @@ void cmCPackWIXGenerator::CopyDefinition( } void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, - const std::string& name, const std::string& value) + std::string const& name, std::string const& value) { std::stringstream tmp; tmp << name << "=\"" << value << '"'; @@ -352,81 +374,47 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, bool cmCPackWIXGenerator::CreateWiXSourceFiles() { - std::string cpackTopLevel; - if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel)) - { - return false; - } - std::string directoryDefinitionsFilename = - cpackTopLevel + "/directories.wxs"; + this->CPackTopLevel + "/directories.wxs"; - WixSources.push_back(directoryDefinitionsFilename); + this->WixSources.push_back(directoryDefinitionsFilename); - cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename); + cmWIXDirectoriesSourceWriter directoryDefinitions( + this->Logger, directoryDefinitionsFilename); directoryDefinitions.BeginElement("Fragment"); - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "TARGETDIR"); - directoryDefinitions.AddAttribute("Name", "SourceDir"); - - directoryDefinitions.BeginElement("Directory"); - if(GetArchitecture() == "x86") - { - directoryDefinitions.AddAttribute("Id", "ProgramFilesFolder"); - } - else - { - directoryDefinitions.AddAttribute("Id", "ProgramFiles64Folder"); - } - - std::vector<std::string> install_root; - - std::string tmp; - if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", tmp)) + std::string installRoot; + if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot)) { return false; } - cmSystemTools::SplitPath(tmp.c_str(), install_root); - - if(!install_root.empty() && install_root.back().empty()) - { - install_root.pop_back(); - } - - for(size_t i = 1; i < install_root.size(); ++i) - { - directoryDefinitions.BeginElement("Directory"); - - if(i == install_root.size() - 1) - { - directoryDefinitions.AddAttribute("Id", "INSTALL_ROOT"); - } - else - { - std::stringstream ss; - ss << "INSTALL_PREFIX_" << i; - directoryDefinitions.AddAttribute("Id", ss.str()); - } + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "TARGETDIR"); + directoryDefinitions.AddAttribute("Name", "SourceDir"); - directoryDefinitions.AddAttribute("Name", install_root[i]); - } + size_t installRootSize = + directoryDefinitions.BeginInstallationPrefixDirectory( + GetProgramFilesFolderId(), installRoot); std::string fileDefinitionsFilename = - cpackTopLevel + "/files.wxs"; + this->CPackTopLevel + "/files.wxs"; + + this->WixSources.push_back(fileDefinitionsFilename); - WixSources.push_back(fileDefinitionsFilename); + cmWIXFilesSourceWriter fileDefinitions( + this->Logger, fileDefinitionsFilename); - cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename); fileDefinitions.BeginElement("Fragment"); std::string featureDefinitionsFilename = - cpackTopLevel +"/features.wxs"; + this->CPackTopLevel +"/features.wxs"; - WixSources.push_back(featureDefinitionsFilename); + this->WixSources.push_back(featureDefinitionsFilename); + + cmWIXFeaturesSourceWriter featureDefinitions( + this->Logger, featureDefinitionsFilename); - cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename); featureDefinitions.BeginElement("Fragment"); featureDefinitions.BeginElement("Feature"); @@ -439,13 +427,15 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() { return false; } - featureDefinitions.AddAttribute("Title", cpackPackageName); + featureDefinitions.AddAttribute("Title", cpackPackageName); featureDefinitions.AddAttribute("Level", "1"); - if(!CreateCMakePackageRegistryEntry(featureDefinitions)) + const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY"); + if(package) { - return false; + featureDefinitions.CreateCMakePackageRegistryEntry( + package, GetOption("CPACK_WIX_UPGRADE_GUID")); } if(!CreateFeatureHierarchy(featureDefinitions)) @@ -471,7 +461,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() else { for(std::map<std::string, cmCPackComponent>::const_iterator - i = Components.begin(); i != Components.end(); ++i) + i = this->Components.begin(); i != this->Components.end(); ++i) { cmCPackComponent const& component = i->second; @@ -513,31 +503,51 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() featureDefinitions.EndElement("Fragment"); fileDefinitions.EndElement("Fragment"); - for(size_t i = 1; i < install_root.size(); ++i) - { - directoryDefinitions.EndElement("Directory"); - } - - directoryDefinitions.EndElement("Directory"); + directoryDefinitions.EndInstallationPrefixDirectory( + installRootSize); if(hasShortcuts) { - CreateStartMenuFolder(directoryDefinitions); + directoryDefinitions.EmitStartMenuFolder( + GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER")); } if(this->HasDesktopShortcuts) { - CreateDesktopFolder(directoryDefinitions); + directoryDefinitions.EmitDesktopFolder(); } directoryDefinitions.EndElement("Directory"); directoryDefinitions.EndElement("Fragment"); + if(!GenerateMainSourceFileFromTemplate()) + { + return false; + } + + return this->Patch.CheckForUnappliedFragments(); +} + +std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const +{ + if(GetArchitecture() == "x86") + { + return "ProgramFilesFolder"; + } + else + { + return "ProgramFiles64Folder"; + } +} + +bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate() +{ std::string wixTemplate = FindTemplate("WIX.template.in"); if(GetOption("CPACK_WIX_TEMPLATE") != 0) { wixTemplate = GetOption("CPACK_WIX_TEMPLATE"); } + if(wixTemplate.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -545,7 +555,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return false; } - std::string mainSourceFilePath = cpackTopLevel + "/main.wxs"; + std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs"; if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str())) { @@ -556,68 +566,13 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return false; } - WixSources.push_back(mainSourceFilePath); - - std::string fragmentList; - for(cmWIXPatchParser::fragment_map_t::const_iterator - i = Fragments.begin(); i != Fragments.end(); ++i) - { - if(!fragmentList.empty()) - { - fragmentList += ", "; - } - - fragmentList += "'"; - fragmentList += i->first; - fragmentList += "'"; - } - - if(fragmentList.size()) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Some XML patch fragments did not have matching IDs: " << - fragmentList << std::endl); - return false; - } - - return true; -} - -bool cmCPackWIXGenerator::CreateCMakePackageRegistryEntry( - cmWIXSourceWriter& featureDefinitions) -{ - const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY"); - if(!package) - { - return true; - } - - featureDefinitions.BeginElement("Component"); - featureDefinitions.AddAttribute("Id", "CM_PACKAGE_REGISTRY"); - featureDefinitions.AddAttribute("Directory", "TARGETDIR"); - featureDefinitions.AddAttribute("Guid", "*"); - - std::string registryKey = - std::string("Software\\Kitware\\CMake\\Packages\\") + package; - - std::string upgradeGuid = GetOption("CPACK_WIX_UPGRADE_GUID"); - - featureDefinitions.BeginElement("RegistryValue"); - featureDefinitions.AddAttribute("Root", "HKLM"); - featureDefinitions.AddAttribute("Key", registryKey); - featureDefinitions.AddAttribute("Name", upgradeGuid); - featureDefinitions.AddAttribute("Type", "string"); - featureDefinitions.AddAttribute("Value", "[INSTALL_ROOT]"); - featureDefinitions.AddAttribute("KeyPath", "yes"); - featureDefinitions.EndElement("RegistryValue"); - - featureDefinitions.EndElement("Component"); + this->WixSources.push_back(mainSourceFilePath); return true; } bool cmCPackWIXGenerator::CreateFeatureHierarchy( - cmWIXSourceWriter& featureDefinitions) + cmWIXFeaturesSourceWriter& featureDefinitions) { for(std::map<std::string, cmCPackComponentGroup>::const_iterator i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i) @@ -625,105 +580,30 @@ bool cmCPackWIXGenerator::CreateFeatureHierarchy( cmCPackComponentGroup const& group = i->second; if(group.ParentGroup == 0) { - if(!EmitFeatureForComponentGroup(featureDefinitions, group)) - { - return false; - } + featureDefinitions.EmitFeatureForComponentGroup(group); } } for(std::map<std::string, cmCPackComponent>::const_iterator - i = Components.begin(); i != Components.end(); ++i) + i = this->Components.begin(); i != this->Components.end(); ++i) { cmCPackComponent const& component = i->second; if(!component.Group) { - if(!EmitFeatureForComponent(featureDefinitions, component)) - { - return false; - } - } - } - - return true; -} - -bool cmCPackWIXGenerator::EmitFeatureForComponentGroup( - cmWIXSourceWriter& featureDefinitions, - cmCPackComponentGroup const& group) -{ - featureDefinitions.BeginElement("Feature"); - featureDefinitions.AddAttribute("Id", "CM_G_" + group.Name); - - if(group.IsExpandedByDefault) - { - featureDefinitions.AddAttribute("Display", "expand"); - } - - featureDefinitions.AddAttributeUnlessEmpty( - "Title", group.DisplayName); - - featureDefinitions.AddAttributeUnlessEmpty( - "Description", group.Description); - - for(std::vector<cmCPackComponentGroup*>::const_iterator - i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i) - { - if(!EmitFeatureForComponentGroup(featureDefinitions, **i)) - { - return false; - } - } - - for(std::vector<cmCPackComponent*>::const_iterator - i = group.Components.begin(); i != group.Components.end(); ++i) - { - if(!EmitFeatureForComponent(featureDefinitions, **i)) - { - return false; + featureDefinitions.EmitFeatureForComponent(component); } } - featureDefinitions.EndElement("Feature"); - - return true; -} - -bool cmCPackWIXGenerator::EmitFeatureForComponent( - cmWIXSourceWriter& featureDefinitions, - cmCPackComponent const& component) -{ - featureDefinitions.BeginElement("Feature"); - featureDefinitions.AddAttribute("Id", "CM_C_" + component.Name); - - featureDefinitions.AddAttributeUnlessEmpty( - "Title", component.DisplayName); - - featureDefinitions.AddAttributeUnlessEmpty( - "Description", component.Description); - - if(component.IsRequired) - { - featureDefinitions.AddAttribute("Absent", "disallow"); - } - - if(component.IsHidden) - { - featureDefinitions.AddAttribute("Display", "hidden"); - } - - featureDefinitions.EndElement("Feature"); - return true; } bool cmCPackWIXGenerator::AddComponentsToFeature( std::string const& rootPath, std::string const& featureId, - cmWIXSourceWriter& directoryDefinitions, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions, + cmWIXDirectoriesSourceWriter& directoryDefinitions, + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions, shortcut_map_t& shortcutMap) { featureDefinitions.BeginElement("FeatureRef"); @@ -768,8 +648,8 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( std::string const& cpackComponentName, std::string const& featureId, shortcut_map_t& shortcutMap, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions) + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions) { bool thisHasDesktopShortcuts = false; @@ -799,6 +679,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.BeginElement("DirectoryRef"); fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + fileDefinitions.BeginElement("Component"); fileDefinitions.AddAttribute("Id", componentId); fileDefinitions.AddAttribute("Guid", "*"); @@ -809,63 +690,34 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( std::string const& id = i->first; cmWIXShortcut const& shortcut = i->second; - std::string shortcutId = std::string("CM_S") + id; - std::string fileId = std::string("CM_F") + id; - - fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", shortcutId); - fileDefinitions.AddAttribute("Name", shortcut.textLabel); - std::string target = "[#" + fileId + "]"; - fileDefinitions.AddAttribute("Target", target); - fileDefinitions.AddAttribute("WorkingDirectory", - shortcut.workingDirectoryId); - fileDefinitions.EndElement("Shortcut"); + fileDefinitions.EmitShortcut(id, shortcut, false); - if (shortcut.desktop) + if(shortcut.desktop) { - thisHasDesktopShortcuts = true; + thisHasDesktopShortcuts = true; } } if(cpackComponentName.empty()) { - CreateUninstallShortcut(cpackPackageName, fileDefinitions); + fileDefinitions.EmitUninstallShortcut(cpackPackageName); } - fileDefinitions.BeginElement("RemoveFolder"); - fileDefinitions.AddAttribute("Id", + fileDefinitions.EmitRemoveFolder( "CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix); - fileDefinitions.AddAttribute("On", "uninstall"); - fileDefinitions.EndElement("RemoveFolder"); std::string registryKey = std::string("Software\\") + cpackVendor + "\\" + cpackPackageName; - fileDefinitions.BeginElement("RegistryValue"); - fileDefinitions.AddAttribute("Root", "HKCU"); - fileDefinitions.AddAttribute("Key", registryKey); - - std::string valueName; - if(!cpackComponentName.empty()) - { - valueName = cpackComponentName + "_"; - } - valueName += "installed"; - - fileDefinitions.AddAttribute("Name", valueName); - fileDefinitions.AddAttribute("Type", "integer"); - fileDefinitions.AddAttribute("Value", "1"); - fileDefinitions.AddAttribute("KeyPath", "yes"); - fileDefinitions.EndElement("RegistryValue"); + fileDefinitions.EmitStartMenuShortcutRegistryValue( + registryKey, cpackComponentName); fileDefinitions.EndElement("Component"); fileDefinitions.EndElement("DirectoryRef"); - featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", componentId); - featureDefinitions.EndElement("ComponentRef"); + featureDefinitions.EmitComponentRef(componentId); - if (thisHasDesktopShortcuts) + if(thisHasDesktopShortcuts) { this->HasDesktopShortcuts = true; componentId = "CM_DESKTOP_SHORTCUT" + idSuffix; @@ -876,7 +728,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( fileDefinitions.AddAttribute("Id", componentId); fileDefinitions.AddAttribute("Guid", "*"); - for (shortcut_map_t::const_iterator + for(shortcut_map_t::const_iterator i = shortcutMap.begin(); i != shortcutMap.end(); ++i) { std::string const& id = i->first; @@ -885,34 +737,16 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( if (!shortcut.desktop) continue; - std::string shortcutId = std::string("CM_DS") + id; - std::string fileId = std::string("CM_F") + id; - - fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", shortcutId); - fileDefinitions.AddAttribute("Name", shortcut.textLabel); - std::string target = "[#" + fileId + "]"; - fileDefinitions.AddAttribute("Target", target); - fileDefinitions.AddAttribute("WorkingDirectory", - shortcut.workingDirectoryId); - fileDefinitions.EndElement("Shortcut"); + fileDefinitions.EmitShortcut(id, shortcut, true); } - fileDefinitions.BeginElement("RegistryValue"); - fileDefinitions.AddAttribute("Root", "HKCU"); - fileDefinitions.AddAttribute("Key", registryKey); - fileDefinitions.AddAttribute("Name", valueName + "_desktop"); - fileDefinitions.AddAttribute("Type", "integer"); - fileDefinitions.AddAttribute("Value", "1"); - fileDefinitions.AddAttribute("KeyPath", "yes"); - fileDefinitions.EndElement("RegistryValue"); + fileDefinitions.EmitDesktopShortcutRegistryValue( + registryKey, cpackComponentName); fileDefinitions.EndElement("Component"); fileDefinitions.EndElement("DirectoryRef"); - featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", componentId); - featureDefinitions.EndElement("ComponentRef"); + featureDefinitions.EmitComponentRef(componentId); } featureDefinitions.EndElement("FeatureRef"); @@ -920,19 +754,6 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts( return true; } -void cmCPackWIXGenerator::CreateUninstallShortcut( - std::string const& packageName, - cmWIXSourceWriter& fileDefinitions) -{ - fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", "UNINSTALL"); - fileDefinitions.AddAttribute("Name", "Uninstall " + packageName); - fileDefinitions.AddAttribute("Description", "Uninstalls " + packageName); - fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe"); - fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]"); - fileDefinitions.EndElement("Shortcut"); -} - bool cmCPackWIXGenerator::CreateLicenseFile() { std::string licenseSourceFilename; @@ -981,11 +802,11 @@ bool cmCPackWIXGenerator::CreateLicenseFile() } void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( - const std::string& topdir, - const std::string& directoryId, - cmWIXSourceWriter& directoryDefinitions, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions, + std::string const& topdir, + std::string const& directoryId, + cmWIXDirectoriesSourceWriter& directoryDefinitions, + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions, const std::vector<std::string>& packageExecutables, const std::vector<std::string>& desktopExecutables, shortcut_map_t& shortcutMap) @@ -993,6 +814,16 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmsys::Directory dir; dir.Load(topdir.c_str()); + if(dir.GetNumberOfFiles() == 2) + { + std::string componentId = fileDefinitions.EmitComponentCreateFolder( + directoryId, GenerateGUID()); + + featureDefinitions.EmitComponentRef(componentId); + + return; + } + for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i) { std::string fileName = dir.GetFile(static_cast<unsigned long>(i)); @@ -1026,44 +857,15 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( desktopExecutables, shortcutMap); - ApplyPatchFragment(subDirectoryId, directoryDefinitions); + this->Patch.ApplyFragment(subDirectoryId, directoryDefinitions); directoryDefinitions.EndElement("Directory"); } else { - std::string componentId = std::string("CM_C") + id; - std::string fileId = std::string("CM_F") + id; - - fileDefinitions.BeginElement("DirectoryRef"); - fileDefinitions.AddAttribute("Id", directoryId); - - fileDefinitions.BeginElement("Component"); - fileDefinitions.AddAttribute("Id", componentId); - fileDefinitions.AddAttribute("Guid", "*"); + std::string componentId = fileDefinitions.EmitComponentFile( + directoryId, id, fullPath, this->Patch); - fileDefinitions.BeginElement("File"); - fileDefinitions.AddAttribute("Id", fileId); - fileDefinitions.AddAttribute("Source", fullPath); - fileDefinitions.AddAttribute("KeyPath", "yes"); - - mode_t fileMode = 0; - cmSystemTools::GetPermissions(fullPath.c_str(), fileMode); - - if(!(fileMode & S_IWRITE)) - { - fileDefinitions.AddAttribute("ReadOnly", "yes"); - } - - ApplyPatchFragment(fileId, fileDefinitions); - fileDefinitions.EndElement("File"); - - ApplyPatchFragment(componentId, fileDefinitions); - fileDefinitions.EndElement("Component"); - fileDefinitions.EndElement("DirectoryRef"); - - featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", componentId); - featureDefinitions.EndElement("ComponentRef"); + featureDefinitions.EmitComponentRef(componentId); for(size_t j = 0; j < packageExecutables.size(); ++j) { @@ -1092,7 +894,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( } bool cmCPackWIXGenerator::RequireOption( - const std::string& name, std::string &value) const + std::string const& name, std::string &value) const { const char* tmp = GetOption(name.c_str()); if(tmp) @@ -1140,13 +942,13 @@ std::string cmCPackWIXGenerator::GenerateGUID() return cmSystemTools::UpperCase(result); } -std::string cmCPackWIXGenerator::QuotePath(const std::string& path) +std::string cmCPackWIXGenerator::QuotePath(std::string const& path) { return std::string("\"") + path + '"'; } std::string cmCPackWIXGenerator::GetRightmostExtension( - const std::string& filename) + std::string const& filename) { std::string extension; @@ -1159,7 +961,7 @@ std::string cmCPackWIXGenerator::GetRightmostExtension( return cmSystemTools::LowerCase(extension); } -std::string cmCPackWIXGenerator::PathToId(const std::string& path) +std::string cmCPackWIXGenerator::PathToId(std::string const& path) { id_map_t::const_iterator i = PathToIdMap.find(path); if(i != PathToIdMap.end()) return i->second; @@ -1168,7 +970,7 @@ std::string cmCPackWIXGenerator::PathToId(const std::string& path) return id; } -std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path) +std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path) { std::vector<std::string> components; cmSystemTools::SplitPath(path.c_str(), components, false); @@ -1222,7 +1024,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path) } std::string cmCPackWIXGenerator::CreateHashedId( - const std::string& path, const std::string& normalizedFilename) + std::string const& path, std::string const& normalizedFilename) { cmsys::auto_ptr<cmCryptoHash> sha1 = cmCryptoHash::New("SHA1"); std::string hash = sha1->HashString(path.c_str()); @@ -1245,7 +1047,7 @@ std::string cmCPackWIXGenerator::CreateHashedId( } std::string cmCPackWIXGenerator::NormalizeComponentForId( - const std::string& component, size_t& replacementCount) + std::string const& component, size_t& replacementCount) { std::string result; result.resize(component.size()); @@ -1276,7 +1078,7 @@ bool cmCPackWIXGenerator::IsLegalIdCharacter(char c) } void cmCPackWIXGenerator::CollectExtensions( - const std::string& variableName, extension_set_t& extensions) + std::string const& variableName, extension_set_t& extensions) { const char *variableContent = GetOption(variableName.c_str()); if(!variableContent) return; @@ -1292,7 +1094,7 @@ void cmCPackWIXGenerator::CollectExtensions( } void cmCPackWIXGenerator::AddCustomFlags( - const std::string& variableName, std::ostream& stream) + std::string const& variableName, std::ostream& stream) { const char *variableContent = GetOption(variableName.c_str()); if(!variableContent) return; @@ -1306,69 +1108,3 @@ void cmCPackWIXGenerator::AddCustomFlags( stream << " " << QuotePath(*i); } } - -void cmCPackWIXGenerator::CreateStartMenuFolder( - cmWIXSourceWriter& directoryDefinitions) -{ - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder"); - - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); - directoryDefinitions.AddAttribute("Name", startMenuFolder); - directoryDefinitions.EndElement("Directory"); - - directoryDefinitions.EndElement("Directory"); -} - -void cmCPackWIXGenerator::CreateDesktopFolder( - cmWIXSourceWriter& directoryDefinitions) -{ - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "DesktopFolder"); - directoryDefinitions.AddAttribute("Name", "Desktop"); - directoryDefinitions.EndElement("Directory"); -} - -void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath) -{ - cmWIXPatchParser parser(Fragments, Logger); - parser.ParseFile(patchFilePath.c_str()); -} - -void cmCPackWIXGenerator::ApplyPatchFragment( - const std::string& id, cmWIXSourceWriter& writer) -{ - cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id); - if(i == Fragments.end()) return; - - const cmWIXPatchElement& fragment = i->second; - for(cmWIXPatchElement::child_list_t::const_iterator - j = fragment.children.begin(); j != fragment.children.end(); ++j) - { - ApplyPatchElement(**j, writer); - } - - Fragments.erase(i); -} - -void cmCPackWIXGenerator::ApplyPatchElement( - const cmWIXPatchElement& element, cmWIXSourceWriter& writer) -{ - writer.BeginElement(element.name); - - for(cmWIXPatchElement::attributes_t::const_iterator - i = element.attributes.begin(); i != element.attributes.end(); ++i) - { - writer.AddAttribute(i->first, i->second); - } - - for(cmWIXPatchElement::child_list_t::const_iterator - i = element.children.begin(); i != element.children.end(); ++i) - { - ApplyPatchElement(**i, writer); - } - - writer.EndElement(element.name); -} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 1de4810..4c9f8c7 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -13,25 +13,18 @@ #ifndef cmCPackWIXGenerator_h #define cmCPackWIXGenerator_h -#include "cmWIXPatchParser.h" +#include "cmWIXPatch.h" +#include "cmWIXShortcut.h" #include <CPack/cmCPackGenerator.h> #include <string> #include <map> -struct cmWIXShortcut -{ - cmWIXShortcut() - :desktop(false) - {} - - std::string textLabel; - std::string workingDirectoryId; - bool desktop; -}; - class cmWIXSourceWriter; +class cmWIXDirectoriesSourceWriter; +class cmWIXFilesSourceWriter; +class cmWIXFeaturesSourceWriter; /** \class cmCPackWIXGenerator * \brief A generator for WIX files @@ -78,48 +71,39 @@ private: bool PackageFilesImpl(); - bool CreateWiXVariablesIncludeFile(); + void CreateWiXVariablesIncludeFile(); + + void CreateWiXPropertiesIncludeFile(); void CopyDefinition( - cmWIXSourceWriter &source, const std::string &name); + cmWIXSourceWriter &source, std::string const& name); void AddDefinition(cmWIXSourceWriter& source, - const std::string& name, const std::string& value); + std::string const& name, std::string const& value); bool CreateWiXSourceFiles(); - bool CreateCMakePackageRegistryEntry( - cmWIXSourceWriter& featureDefinitions); + std::string GetProgramFilesFolderId() const; - bool CreateFeatureHierarchy( - cmWIXSourceWriter& featureDefinitions); - - bool EmitFeatureForComponentGroup( - cmWIXSourceWriter& featureDefinitions, - cmCPackComponentGroup const& group); + bool GenerateMainSourceFileFromTemplate(); - bool EmitFeatureForComponent( - cmWIXSourceWriter& featureDefinitions, - cmCPackComponent const& component); + bool CreateFeatureHierarchy( + cmWIXFeaturesSourceWriter& featureDefinitions); bool AddComponentsToFeature( std::string const& rootPath, std::string const& featureId, - cmWIXSourceWriter& directoryDefinitions, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions, + cmWIXDirectoriesSourceWriter& directoryDefinitions, + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions, shortcut_map_t& shortcutMap); bool CreateStartMenuShortcuts( std::string const& cpackComponentName, std::string const& featureId, shortcut_map_t& shortcutMap, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions); - - void CreateUninstallShortcut( - std::string const& packageName, - cmWIXSourceWriter& fileDefinitions); + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions); void AppendUserSuppliedExtraSources(); @@ -127,60 +111,49 @@ private: bool CreateLicenseFile(); - bool RunWiXCommand(const std::string& command); + bool RunWiXCommand(std::string const& command); bool RunCandleCommand( - const std::string& sourceFile, const std::string& objectFile); + std::string const& sourceFile, std::string const& objectFile); - bool RunLightCommand(const std::string& objectFiles); + bool RunLightCommand(std::string const& objectFiles); - void AddDirectoryAndFileDefinitons(const std::string& topdir, - const std::string& directoryId, - cmWIXSourceWriter& directoryDefinitions, - cmWIXSourceWriter& fileDefinitions, - cmWIXSourceWriter& featureDefinitions, + void AddDirectoryAndFileDefinitons(std::string const& topdir, + std::string const& directoryId, + cmWIXDirectoriesSourceWriter& directoryDefinitions, + cmWIXFilesSourceWriter& fileDefinitions, + cmWIXFeaturesSourceWriter& featureDefinitions, const std::vector<std::string>& pkgExecutables, const std::vector<std::string>& desktopExecutables, shortcut_map_t& shortcutMap); - bool RequireOption(const std::string& name, std::string& value) const; + bool RequireOption(std::string const& name, std::string& value) const; std::string GetArchitecture() const; static std::string GenerateGUID(); - static std::string QuotePath(const std::string& path); + static std::string QuotePath(std::string const& path); - static std::string GetRightmostExtension(const std::string& filename); + static std::string GetRightmostExtension(std::string const& filename); - std::string PathToId(const std::string& path); + std::string PathToId(std::string const& path); - std::string CreateNewIdForPath(const std::string& path); + std::string CreateNewIdForPath(std::string const& path); static std::string CreateHashedId( - const std::string& path, const std::string& normalizedFilename); + std::string const& path, std::string const& normalizedFilename); std::string NormalizeComponentForId( - const std::string& component, size_t& replacementCount); + std::string const& component, size_t& replacementCount); static bool IsLegalIdCharacter(char c); void CollectExtensions( - const std::string& variableName, extension_set_t& extensions); + std::string const& variableName, extension_set_t& extensions); void AddCustomFlags( - const std::string& variableName, std::ostream& stream); - - void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions); - - void CreateDesktopFolder(cmWIXSourceWriter& directoryDefinitions); - - void LoadPatchFragments(const std::string& patchFilePath); - - void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer); - - void ApplyPatchElement(const cmWIXPatchElement& element, - cmWIXSourceWriter& writer); + std::string const& variableName, std::ostream& stream); std::vector<std::string> WixSources; id_map_t PathToIdMap; @@ -189,9 +162,11 @@ private: extension_set_t CandleExtensions; extension_set_t LightExtensions; - cmWIXPatchParser::fragment_map_t Fragments; - bool HasDesktopShortcuts; + + std::string CPackTopLevel; + + cmWIXPatch Patch; }; #endif diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx new file mode 100644 index 0000000..a93f89b --- /dev/null +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx @@ -0,0 +1,87 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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. +============================================================================*/ + +#include "cmWIXDirectoriesSourceWriter.h" + +cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger, + std::string const& filename): + cmWIXSourceWriter(logger, filename) +{ + +} + +void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder( + std::string const& startMenuFolder) +{ + BeginElement("Directory"); + AddAttribute("Id", "ProgramMenuFolder"); + + BeginElement("Directory"); + AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + AddAttribute("Name", startMenuFolder); + EndElement("Directory"); + + EndElement("Directory"); +} + +void cmWIXDirectoriesSourceWriter::EmitDesktopFolder() +{ + BeginElement("Directory"); + AddAttribute("Id", "DesktopFolder"); + AddAttribute("Name", "Desktop"); + EndElement("Directory"); +} + +size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory( + std::string const& programFilesFolderId, + std::string const& installRootString) +{ + BeginElement("Directory"); + AddAttribute("Id", programFilesFolderId); + + std::vector<std::string> installRoot; + + cmSystemTools::SplitPath(installRootString.c_str(), installRoot); + + if(!installRoot.empty() && installRoot.back().empty()) + { + installRoot.pop_back(); + } + + for(size_t i = 1; i < installRoot.size(); ++i) + { + BeginElement("Directory"); + + if(i == installRoot.size() - 1) + { + AddAttribute("Id", "INSTALL_ROOT"); + } + else + { + std::stringstream tmp; + tmp << "INSTALL_PREFIX_" << i; + AddAttribute("Id", tmp.str()); + } + + AddAttribute("Name", installRoot[i]); + } + + return installRoot.size(); +} + +void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size) +{ + for(size_t i = 0; i < size; ++i) + { + EndElement("Directory"); + } +} diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h new file mode 100644 index 0000000..f51fdb4 --- /dev/null +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h @@ -0,0 +1,42 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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. +============================================================================*/ + +#ifndef cmWIXDirectoriesSourceWriter_h +#define cmWIXDirectoriesSourceWriter_h + +#include "cmWIXSourceWriter.h" + +#include <CPack/cmCPackGenerator.h> + +#include <string> + +/** \class cmWIXDirectoriesSourceWriter + * \brief Helper class to generate directories.wxs + */ +class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter +{ +public: + cmWIXDirectoriesSourceWriter(cmCPackLog* logger, + std::string const& filename); + + void EmitStartMenuFolder(std::string const& startMenuFolder); + + void EmitDesktopFolder(); + + size_t BeginInstallationPrefixDirectory( + std::string const& programFilesFolderId, + std::string const& installRootString); + + void EndInstallationPrefixDirectory(size_t size); +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx new file mode 100644 index 0000000..0bcfc38 --- /dev/null +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx @@ -0,0 +1,102 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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. +============================================================================*/ + +#include "cmWIXFeaturesSourceWriter.h" + +cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger, + std::string const& filename): + cmWIXSourceWriter(logger, filename) +{ + +} + +void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry( + std::string const& package, + std::string const& upgradeGuid) +{ + BeginElement("Component"); + AddAttribute("Id", "CM_PACKAGE_REGISTRY"); + AddAttribute("Directory", "TARGETDIR"); + AddAttribute("Guid", "*"); + + std::string registryKey = + std::string("Software\\Kitware\\CMake\\Packages\\") + package; + + BeginElement("RegistryValue"); + AddAttribute("Root", "HKLM"); + AddAttribute("Key", registryKey); + AddAttribute("Name", upgradeGuid); + AddAttribute("Type", "string"); + AddAttribute("Value", "[INSTALL_ROOT]"); + AddAttribute("KeyPath", "yes"); + EndElement("RegistryValue"); + + EndElement("Component"); +} + +void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup( + cmCPackComponentGroup const& group) +{ + BeginElement("Feature"); + AddAttribute("Id", "CM_G_" + group.Name); + + if(group.IsExpandedByDefault) + { + AddAttribute("Display", "expand"); + } + + AddAttributeUnlessEmpty("Title", group.DisplayName); + AddAttributeUnlessEmpty("Description", group.Description); + + for(std::vector<cmCPackComponentGroup*>::const_iterator + i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i) + { + EmitFeatureForComponentGroup(**i); + } + + for(std::vector<cmCPackComponent*>::const_iterator + i = group.Components.begin(); i != group.Components.end(); ++i) + { + EmitFeatureForComponent(**i); + } + + EndElement("Feature"); +} + +void cmWIXFeaturesSourceWriter::EmitFeatureForComponent( + cmCPackComponent const& component) +{ + BeginElement("Feature"); + AddAttribute("Id", "CM_C_" + component.Name); + + AddAttributeUnlessEmpty("Title", component.DisplayName); + AddAttributeUnlessEmpty("Description", component.Description); + + if(component.IsRequired) + { + AddAttribute("Absent", "disallow"); + } + + if(component.IsHidden) + { + AddAttribute("Display", "hidden"); + } + + EndElement("Feature"); +} + +void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id) +{ + BeginElement("ComponentRef"); + AddAttribute("Id", id); + EndElement("ComponentRef"); +} diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h new file mode 100644 index 0000000..7670417 --- /dev/null +++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h @@ -0,0 +1,39 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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. +============================================================================*/ + +#ifndef cmWIXFeaturesSourceWriter_h +#define cmWIXFeaturesSourceWriter_h + +#include "cmWIXSourceWriter.h" +#include <CPack/cmCPackGenerator.h> + +/** \class cmWIXFeaturesSourceWriter + * \brief Helper class to generate features.wxs + */ +class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter +{ +public: + cmWIXFeaturesSourceWriter(cmCPackLog* logger, + std::string const& filename); + + void CreateCMakePackageRegistryEntry( + std::string const& package, + std::string const& upgradeGuid); + + void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group); + + void EmitFeatureForComponent(const cmCPackComponent& component); + + void EmitComponentRef(std::string const& id); +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx new file mode 100644 index 0000000..3fd959e --- /dev/null +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -0,0 +1,171 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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. +============================================================================*/ + +#include "cmWIXFilesSourceWriter.h" + +#include <sys/types.h> +#include <sys/stat.h> + +cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, + std::string const& filename): + cmWIXSourceWriter(logger, filename) +{ + +} + +void cmWIXFilesSourceWriter::EmitShortcut( + std::string const& id, + cmWIXShortcut const& shortcut, + bool desktop) +{ + std::string shortcutId; + + if(desktop) + { + shortcutId = "CM_DS"; + } + else + { + shortcutId = "CM_S"; + } + + shortcutId += id; + + std::string fileId = std::string("CM_F") + id; + + BeginElement("Shortcut"); + AddAttribute("Id", shortcutId); + AddAttribute("Name", shortcut.textLabel); + std::string target = "[#" + fileId + "]"; + AddAttribute("Target", target); + AddAttribute("WorkingDirectory", shortcut.workingDirectoryId); + EndElement("Shortcut"); +} + +void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id) +{ + BeginElement("RemoveFolder"); + AddAttribute("Id", id); + AddAttribute("On", "uninstall"); + EndElement("RemoveFolder"); +} + +void cmWIXFilesSourceWriter::EmitStartMenuShortcutRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName) +{ + EmitInstallRegistryValue(registryKey, cpackComponentName, std::string()); +} + +void cmWIXFilesSourceWriter::EmitDesktopShortcutRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName) +{ + EmitInstallRegistryValue(registryKey, cpackComponentName, "_desktop"); +} + +void cmWIXFilesSourceWriter::EmitInstallRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName, + std::string const& suffix) +{ + std::string valueName; + if(!cpackComponentName.empty()) + { + valueName = cpackComponentName + "_"; + } + + valueName += "installed"; + valueName += suffix; + + BeginElement("RegistryValue"); + AddAttribute("Root", "HKCU"); + AddAttribute("Key", registryKey); + AddAttribute("Name", valueName); + AddAttribute("Type", "integer"); + AddAttribute("Value", "1"); + AddAttribute("KeyPath", "yes"); + EndElement("RegistryValue"); +} + +void cmWIXFilesSourceWriter::EmitUninstallShortcut( + std::string const& packageName) +{ + BeginElement("Shortcut"); + AddAttribute("Id", "UNINSTALL"); + AddAttribute("Name", "Uninstall " + packageName); + AddAttribute("Description", "Uninstalls " + packageName); + AddAttribute("Target", "[SystemFolder]msiexec.exe"); + AddAttribute("Arguments", "/x [ProductCode]"); + EndElement("Shortcut"); +} + +std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder( + std::string const& directoryId, std::string const& guid) +{ + std::string componentId = + std::string("CM_C_EMPTY_") + directoryId; + + BeginElement("DirectoryRef"); + AddAttribute("Id", directoryId); + + BeginElement("Component"); + AddAttribute("Id", componentId); + AddAttribute("Guid", guid); + + BeginElement("CreateFolder"); + + EndElement("CreateFolder"); + EndElement("Component"); + EndElement("DirectoryRef"); + + return componentId; +} + +std::string cmWIXFilesSourceWriter::EmitComponentFile( + std::string const& directoryId, + std::string const& id, + std::string const& filePath, + cmWIXPatch &patch) +{ + std::string componentId = std::string("CM_C") + id; + std::string fileId = std::string("CM_F") + id; + + BeginElement("DirectoryRef"); + AddAttribute("Id", directoryId); + + BeginElement("Component"); + AddAttribute("Id", componentId); + AddAttribute("Guid", "*"); + + BeginElement("File"); + AddAttribute("Id", fileId); + AddAttribute("Source", filePath); + AddAttribute("KeyPath", "yes"); + + mode_t fileMode = 0; + cmSystemTools::GetPermissions(filePath.c_str(), fileMode); + + if(!(fileMode & S_IWRITE)) + { + AddAttribute("ReadOnly", "yes"); + } + + patch.ApplyFragment(fileId, *this); + EndElement("File"); + + patch.ApplyFragment(componentId, *this); + EndElement("Component"); + EndElement("DirectoryRef"); + + return componentId; +} diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h new file mode 100644 index 0000000..13122c2 --- /dev/null +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h @@ -0,0 +1,66 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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. +============================================================================*/ + +#ifndef cmWIXFilesSourceWriter_h +#define cmWIXFilesSourceWriter_h + +#include "cmWIXSourceWriter.h" +#include "cmWIXShortcut.h" +#include "cmWIXPatch.h" + +#include <CPack/cmCPackGenerator.h> + +/** \class cmWIXFilesSourceWriter + * \brief Helper class to generate files.wxs + */ +class cmWIXFilesSourceWriter : public cmWIXSourceWriter +{ +public: + cmWIXFilesSourceWriter(cmCPackLog* logger, + std::string const& filename); + + void EmitShortcut( + std::string const& id, + cmWIXShortcut const& shortcut, + bool desktop); + + void EmitRemoveFolder(std::string const& id); + + void EmitStartMenuShortcutRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName); + + void EmitDesktopShortcutRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName); + + void EmitUninstallShortcut(std::string const& packageName); + + std::string EmitComponentCreateFolder( + std::string const& directoryId, + std::string const& guid); + + std::string EmitComponentFile( + std::string const& directoryId, + std::string const& id, + std::string const& filePath, + cmWIXPatch &patch); + +private: + void EmitInstallRegistryValue( + std::string const& registryKey, + std::string const& cpackComponentName, + std::string const& suffix); +}; + + +#endif diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx new file mode 100644 index 0000000..b5202e0 --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatch.cxx @@ -0,0 +1,91 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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 "cmWIXPatch.h" + +#include <CPack/cmCPackGenerator.h> + +cmWIXPatch::cmWIXPatch(cmCPackLog* logger): + Logger(logger) +{ + +} + +void cmWIXPatch::LoadFragments(std::string const& patchFilePath) +{ + cmWIXPatchParser parser(Fragments, Logger); + parser.ParseFile(patchFilePath.c_str()); +} + +void cmWIXPatch::ApplyFragment( + std::string const& id, cmWIXSourceWriter& writer) +{ + cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id); + if(i == Fragments.end()) return; + + const cmWIXPatchElement& fragment = i->second; + for(cmWIXPatchElement::child_list_t::const_iterator + j = fragment.children.begin(); j != fragment.children.end(); ++j) + { + ApplyElement(**j, writer); + } + + Fragments.erase(i); +} + +void cmWIXPatch::ApplyElement( + const cmWIXPatchElement& element, cmWIXSourceWriter& writer) +{ + writer.BeginElement(element.name); + + for(cmWIXPatchElement::attributes_t::const_iterator + i = element.attributes.begin(); i != element.attributes.end(); ++i) + { + writer.AddAttribute(i->first, i->second); + } + + for(cmWIXPatchElement::child_list_t::const_iterator + i = element.children.begin(); i != element.children.end(); ++i) + { + ApplyElement(**i, writer); + } + + writer.EndElement(element.name); +} + + +bool cmWIXPatch::CheckForUnappliedFragments() +{ + std::string fragmentList; + for(cmWIXPatchParser::fragment_map_t::const_iterator + i = Fragments.begin(); i != Fragments.end(); ++i) + { + if(!fragmentList.empty()) + { + fragmentList += ", "; + } + + fragmentList += "'"; + fragmentList += i->first; + fragmentList += "'"; + } + + if(fragmentList.size()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Some XML patch fragments did not have matching IDs: " << + fragmentList << std::endl); + return false; + } + + return true; +} diff --git a/Source/CPack/WiX/cmWIXPatch.h b/Source/CPack/WiX/cmWIXPatch.h new file mode 100644 index 0000000..7b7b2f1 --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatch.h @@ -0,0 +1,45 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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. +============================================================================*/ + +#ifndef cmWIXPatch_h +#define cmWIXPatch_h + +#include "cmWIXSourceWriter.h" +#include "cmWIXPatchParser.h" + +#include <string> + +/** \class cmWIXPatch + * \brief Class that maintains and applies patch fragments + */ +class cmWIXPatch +{ +public: + cmWIXPatch(cmCPackLog* logger); + + void LoadFragments(std::string const& patchFilePath); + + void ApplyFragment(std::string const& id, cmWIXSourceWriter& writer); + + bool CheckForUnappliedFragments(); + +private: + void ApplyElement(const cmWIXPatchElement& element, + cmWIXSourceWriter& writer); + + cmCPackLog* Logger; + + cmWIXPatchParser::fragment_map_t Fragments; +}; + + +#endif diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index 7ceaf1f..ef67b23 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -34,12 +34,11 @@ cmWIXPatchParser::cmWIXPatchParser( } -void cmWIXPatchParser::StartElement(const char *name, const char **atts) +void cmWIXPatchParser::StartElement(const std::string& name, const char **atts) { - std::string name_str = name; if(State == BEGIN_DOCUMENT) { - if(name_str == "CPackWiXPatch") + if(name == "CPackWiXPatch") { State = BEGIN_FRAGMENTS; } @@ -50,7 +49,7 @@ void cmWIXPatchParser::StartElement(const char *name, const char **atts) } else if(State == BEGIN_FRAGMENTS) { - if(name_str == "CPackWiXFragment") + if(name == "CPackWiXFragment") { State = INSIDE_FRAGMENT; StartFragment(atts); @@ -107,12 +106,11 @@ void cmWIXPatchParser::StartFragment(const char **attributes) } } -void cmWIXPatchParser::EndElement(const char *name) +void cmWIXPatchParser::EndElement(const std::string& name) { - std::string name_str = name; if(State == INSIDE_FRAGMENT) { - if(name_str == "CPackWiXFragment") + if(name == "CPackWiXFragment") { State = BEGIN_FRAGMENTS; ElementStack.clear(); @@ -132,7 +130,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg) Valid = false; } -void cmWIXPatchParser::ReportValidationError(const std::string& message) +void cmWIXPatchParser::ReportValidationError(std::string const& message) { ReportError(XML_GetCurrentLineNumber(Parser), XML_GetCurrentColumnNumber(Parser), diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h index 91b3b66..acfb4c0 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.h +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -43,14 +43,14 @@ public: cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger); private: - virtual void StartElement(const char *name, const char **atts); + virtual void StartElement(const std::string& name, const char **atts); void StartFragment(const char **attributes); - virtual void EndElement(const char *name); + virtual void EndElement(const std::string& name); virtual void ReportError(int line, int column, const char* msg); - void ReportValidationError(const std::string& message); + void ReportValidationError(std::string const& message); bool IsValid() const; diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index ddc1d71..f27caa9 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -15,7 +15,7 @@ #include <cmVersion.h> cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter( - const std::string& filename): + std::string const& filename): File(filename.c_str(), std::ios::binary) { StartGroup(); @@ -33,7 +33,7 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter() File.put(0); } -void cmWIXRichTextFormatWriter::AddText(const std::string& text) +void cmWIXRichTextFormatWriter::AddText(std::string const& text) { typedef unsigned char rtf_byte_t; @@ -167,12 +167,12 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix() ControlWord("fs20"); } -void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword) +void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword) { File << "\\" << keyword; } -void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword) +void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword) { File << "\\*\\" << keyword; } diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h index 2b665d4..f6327fb 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h @@ -22,10 +22,10 @@ class cmWIXRichTextFormatWriter { public: - cmWIXRichTextFormatWriter(const std::string& filename); + cmWIXRichTextFormatWriter(std::string const& filename); ~cmWIXRichTextFormatWriter(); - void AddText(const std::string& text); + void AddText(std::string const& text); private: void WriteHeader(); @@ -35,8 +35,8 @@ private: void WriteDocumentPrefix(); - void ControlWord(const std::string& keyword); - void NewControlWord(const std::string& keyword); + void ControlWord(std::string const& keyword); + void NewControlWord(std::string const& keyword); void StartGroup(); void EndGroup(); diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h new file mode 100644 index 0000000..93095e0 --- /dev/null +++ b/Source/CPack/WiX/cmWIXShortcut.h @@ -0,0 +1,29 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2014 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. +============================================================================*/ + +#ifndef cmWIXFilesShortcut_h +#define cmWIXFilesShortcut_h + +#include <string> + +struct cmWIXShortcut +{ + cmWIXShortcut() + :desktop(false) + {} + + std::string textLabel; + std::string workingDirectoryId; + bool desktop; +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index e83c226..aad19da 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -17,7 +17,7 @@ #include <windows.h> cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, - const std::string& filename, + std::string const& filename, bool isIncludeFile): Logger(logger), File(filename.c_str()), @@ -51,7 +51,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter() EndElement(Elements.back()); } -void cmWIXSourceWriter::BeginElement(const std::string& name) +void cmWIXSourceWriter::BeginElement(std::string const& name) { if(State == BEGIN) { @@ -101,7 +101,7 @@ void cmWIXSourceWriter::EndElement(std::string const& name) } void cmWIXSourceWriter::AddProcessingInstruction( - const std::string& target, const std::string& content) + std::string const& target, std::string const& content) { if(State == BEGIN) { @@ -116,7 +116,7 @@ void cmWIXSourceWriter::AddProcessingInstruction( } void cmWIXSourceWriter::AddAttribute( - const std::string& key, const std::string& value) + std::string const& key, std::string const& value) { std::string utf8 = WindowsCodepageToUtf8(value); @@ -124,7 +124,7 @@ void cmWIXSourceWriter::AddAttribute( } void cmWIXSourceWriter::AddAttributeUnlessEmpty( - const std::string& key, const std::string& value) + std::string const& key, std::string const& value) { if(value.size()) { @@ -132,7 +132,7 @@ void cmWIXSourceWriter::AddAttributeUnlessEmpty( } } -std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value) +std::string cmWIXSourceWriter::WindowsCodepageToUtf8(std::string const& value) { if(value.empty()) { @@ -184,7 +184,7 @@ void cmWIXSourceWriter::Indent(size_t count) } std::string cmWIXSourceWriter::EscapeAttributeValue( - const std::string& value) + std::string const& value) { std::string result; result.reserve(value.size()); diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 894ad78..65b7240 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -26,24 +26,24 @@ class cmWIXSourceWriter { public: cmWIXSourceWriter(cmCPackLog* logger, - const std::string& filename, bool isIncludeFile = false); + std::string const& filename, bool isIncludeFile = false); ~cmWIXSourceWriter(); - void BeginElement(const std::string& name); + void BeginElement(std::string const& name); - void EndElement(const std::string& name); + void EndElement(std::string const& name); void AddProcessingInstruction( - const std::string& target, const std::string& content); + std::string const& target, std::string const& content); void AddAttribute( - const std::string& key, const std::string& value); + std::string const& key, std::string const& value); void AddAttributeUnlessEmpty( - const std::string& key, const std::string& value); + std::string const& key, std::string const& value); - static std::string WindowsCodepageToUtf8(const std::string& value); + static std::string WindowsCodepageToUtf8(std::string const& value); private: enum State @@ -56,7 +56,7 @@ private: void Indent(size_t count); - static std::string EscapeAttributeValue(const std::string& value); + static std::string EscapeAttributeValue(std::string const& value); cmCPackLog* Logger; diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx index f93eca8..77f11cb 100644 --- a/Source/CPack/cmCPackComponentGroup.cxx +++ b/Source/CPack/cmCPackComponentGroup.cxx @@ -16,7 +16,8 @@ #include <string> //---------------------------------------------------------------------- -unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const +unsigned long cmCPackComponent::GetInstalledSize( + const std::string& installDir) const { if (this->TotalSize != 0) { @@ -37,7 +38,7 @@ unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const //---------------------------------------------------------------------- unsigned long -cmCPackComponent::GetInstalledSizeInKbytes(const char* installDir) const +cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const { unsigned long result = (GetInstalledSize(installDir) + 512) / 1024; return result? result : 1; diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h index abae372..0679638 100644 --- a/Source/CPack/cmCPackComponentGroup.h +++ b/Source/CPack/cmCPackComponentGroup.h @@ -94,11 +94,11 @@ public: /// Get the total installed size of all of the files in this /// component, in bytes. installDir is the directory into which the /// component was installed. - unsigned long GetInstalledSize(const char* installDir) const; + unsigned long GetInstalledSize(const std::string& installDir) const; /// Identical to GetInstalledSize, but returns the result in /// kilobytes. - unsigned long GetInstalledSizeInKbytes(const char* installDir) const; + unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const; private: mutable unsigned long TotalSize; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0162d55..936942b 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -403,9 +403,39 @@ int cmCPackDebGenerator::createDeb() if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) { cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); } - cmd += " \""; - cmd += cmakeExecutable; - cmd += "\" -E tar cfz data.tar.gz "; + + const char* debian_compression_type = + this->GetOption("CPACK_DEBIAN_COMPRESSION_TYPE"); + if(!debian_compression_type) + { + debian_compression_type = "gzip"; + } + + std::string cmake_tar = " ", compression_modifier = "a", compression_suffix; + if(!strcmp(debian_compression_type, "lzma")) { + compression_suffix = ".lzma"; + } else if(!strcmp(debian_compression_type, "xz")) { + compression_suffix = ".xz"; + } else if(!strcmp(debian_compression_type, "bzip2")) { + compression_suffix = ".bz2"; + compression_modifier = "j"; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else if(!strcmp(debian_compression_type, "gzip")) { + compression_suffix = ".gz"; + compression_modifier = "z"; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else if(!strcmp(debian_compression_type, "none")) { + compression_suffix = ""; + compression_modifier = ""; + cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E "; + } else { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error unrecognized compression type: " + << debian_compression_type << std::endl); + } + + cmd += cmake_tar + "tar c" + compression_modifier + "f data.tar" + + compression_suffix; // now add all directories which have to be compressed // collect all top level install dirs for that @@ -444,13 +474,13 @@ int cmCPackDebGenerator::createDeb() std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/Deb.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Working directory: " << toplevel << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -493,9 +523,7 @@ int cmCPackDebGenerator::createDeb() { cmd = this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); } - cmd += " \""; - cmd += cmakeExecutable; - cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums"; + cmd += cmake_tar + "tar czf control.tar.gz ./control ./md5sums"; const char* controlExtra = this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); if( controlExtra ) @@ -506,7 +534,7 @@ int cmCPackDebGenerator::createDeb() controlExtraList.begin(); i != controlExtraList.end(); ++i) { std::string filenamename = - cmsys::SystemTools::GetFilenameName(i->c_str()); + cmsys::SystemTools::GetFilenameName(*i); std::string localcopy = this->GetOption("WDIR"); localcopy += "/"; localcopy += filenamename; @@ -514,7 +542,7 @@ int cmCPackDebGenerator::createDeb() if( cmsys::SystemTools::CopyFileIfDifferent( i->c_str(), localcopy.c_str()) ) { - // debian is picky and need relative to ./ path in the tar.gz + // debian is picky and need relative to ./ path in the tar.* cmd += " ./"; cmd += filenamename; } @@ -528,17 +556,17 @@ int cmCPackDebGenerator::createDeb() std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/Deb.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Working directory: " << toplevel << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } - // ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz + // ar -r your-package-name.deb debian-binary control.tar.* data.tar.* // since debian packages require BSD ar (most Linux distros and even // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here. std::vector<std::string> arFiles; @@ -546,7 +574,7 @@ int cmCPackDebGenerator::createDeb() topLevelString += "/"; arFiles.push_back(topLevelString + "debian-binary"); arFiles.push_back(topLevelString + "control.tar.gz"); - arFiles.push_back(topLevelString + "data.tar.gz"); + arFiles.push_back(topLevelString + "data.tar" + compression_suffix); std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); outputFileName += "/"; outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME"); @@ -588,9 +616,9 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (NULL != GetOption(groupVar.c_str())) + if (NULL != GetOption(groupVar)) { - return std::string(GetOption(groupVar.c_str())); + return std::string(GetOption(groupVar)); } else { diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 96491aa..9cdf5aa 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -254,7 +254,7 @@ int cmCPackGenerator::InstallProject() // If the project is a CMAKE project then run pre-install // and then read the cmake_install script to run it if ( !this->InstallProjectViaInstallCMakeProjects( - setDestDir, bareTempInstallDirectory.c_str()) ) + setDestDir, bareTempInstallDirectory) ) { return 0; } @@ -269,7 +269,7 @@ int cmCPackGenerator::InstallProject() //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallCommands( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { (void) setDestDir; const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS"); @@ -285,7 +285,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( it != installCommandsVector.end(); ++it ) { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << it->c_str() + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl); std::string output; int retVal = 1; @@ -296,12 +296,12 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/InstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << it->c_str() << std::endl + ofs << "# Run command: " << *it << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << it->c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" + "Problem running install command: " << *it << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -312,7 +312,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstalledDirectories( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { (void)setDestDir; (void)tempInstallDirectory; @@ -329,7 +329,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( ++it ) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, - "Create ignore files regex for: " << it->c_str() << std::endl); + "Create ignore files regex for: " << *it << std::endl); ignoreFilesRegex.push_back(it->c_str()); } } @@ -349,7 +349,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( return 0; } std::vector<std::string>::iterator it; - const char* tempDir = tempInstallDirectory; + const std::string& tempDir = tempInstallDirectory; for ( it = installDirectoriesVector.begin(); it != installDirectoriesVector.end(); ++it ) @@ -357,9 +357,9 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( std::list<std::pair<std::string,std::string> > symlinkedFiles; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl); cmsys::Glob gl; - std::string top = it->c_str(); + std::string top = *it; it ++; - std::string subdir = it->c_str(); + std::string subdir = *it; std::string findExpr = top; findExpr += "/*"; cmCPackLogger(cmCPackLog::LOG_OUTPUT, @@ -385,7 +385,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( if ( regIt->find(inFile.c_str()) ) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: " - << inFile.c_str() << std::endl); + << inFile << std::endl); skip = true; } } @@ -397,7 +397,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(top.c_str(), gfit->c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " - << inFile.c_str() << " -> " << filePath.c_str() << std::endl); + << inFile << " -> " << filePath << std::endl); /* If the file is a symlink we will have to re-create it */ if ( cmSystemTools::FileIsSymlink(inFile.c_str())) { @@ -416,7 +416,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( ) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " - << inFile.c_str() << " -> " << filePath.c_str() << std::endl); + << inFile << " -> " << filePath << std::endl); return 0; } } @@ -457,7 +457,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallScript( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const std::string& tempInstallDirectory) { const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT"); @@ -473,7 +473,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( it != cmakeScriptsVector.end(); ++it ) { - std::string installScript = it->c_str(); + std::string installScript = *it; cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install script: " << installScript << std::endl); @@ -499,7 +499,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( } else { - this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory); + this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Using non-DESTDIR install... (this->SetOption)" << std::endl); @@ -509,9 +509,9 @@ int cmCPackGenerator::InstallProjectViaInstallScript( } this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR", - tempInstallDirectory); + tempInstallDirectory.c_str()); this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR", - tempInstallDirectory); + tempInstallDirectory.c_str()); int res = this->MakefileMap->ReadListFile(0, installScript.c_str()); if ( cmSystemTools::GetErrorOccuredFlag() || !res ) { @@ -524,7 +524,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( - bool setDestDir, const char* baseTempInstallDirectory) + bool setDestDir, const std::string& baseTempInstallDirectory) { const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); @@ -562,13 +562,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << std::endl); return 0; } - std::string installDirectory = it->c_str(); + std::string installDirectory = *it; ++it; - std::string installProjectName = it->c_str(); + std::string installProjectName = *it; ++it; - std::string installComponent = it->c_str(); + std::string installComponent = *it; ++it; - std::string installSubDirectory = it->c_str(); + std::string installSubDirectory = *it; std::string installFile = installDirectory + "/cmake_install.cmake"; std::vector<std::string> componentsVector; @@ -586,7 +586,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // Determine the installation types for this project (if provided). std::string installTypesVar = "CPACK_" + cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES"; - const char *installTypes = this->GetOption(installTypesVar.c_str()); + const char *installTypes = this->GetOption(installTypesVar); if (installTypes && *installTypes) { std::vector<std::string> installTypesVector; @@ -596,15 +596,15 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( installTypeIt != installTypesVector.end(); ++installTypeIt) { - this->GetInstallationType(installProjectName.c_str(), - installTypeIt->c_str()); + this->GetInstallationType(installProjectName, + *installTypeIt); } } // Determine the set of components that will be used in this project std::string componentsVar = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent); - const char *components = this->GetOption(componentsVar.c_str()); + const char *components = this->GetOption(componentsVar); if (components && *components) { cmSystemTools::ExpandListArgument(components, componentsVector); @@ -613,7 +613,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( compIt != componentsVector.end(); ++compIt) { - GetComponent(installProjectName.c_str(), compIt->c_str()); + GetComponent(installProjectName, *compIt); } componentInstall = true; } @@ -623,7 +623,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( componentsVector.push_back(installComponent); } - const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG"); + const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG"); + std::string buildConfig = buildConfigCstr ? buildConfigCstr : ""; cmGlobalGenerator* globalGenerator = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator( cmakeGenerator); @@ -640,7 +641,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM"); std::vector<std::string> buildCommand; globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram, - installProjectName.c_str(), installDirectory.c_str(), + installProjectName, installDirectory, globalGenerator->GetPreinstallTargetName(), buildConfig, false); std::string buildCommandStr = @@ -662,14 +663,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << buildCommandStr.c_str() << std::endl - << "# Directory: " << installDirectory.c_str() << std::endl + ofs << "# Run command: " << buildCommandStr << std::endl + << "# Directory: " << installDirectory << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << buildCommandStr.c_str() + "Problem running install command: " << buildCommandStr << std::endl - << "Please check " << tmpFile.c_str() << " for errors" + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } @@ -822,9 +823,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( << "'" << std::endl); } - if ( buildConfig && *buildConfig ) + if (!buildConfig.empty()) { - mf->AddDefinition("BUILD_TYPE", buildConfig); + mf->AddDefinition("BUILD_TYPE", buildConfig.c_str()); } std::string installComponentLowerCase = cmSystemTools::LowerCase(installComponent); @@ -931,19 +932,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string absoluteDestFileComponent = std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" + GetComponentInstallDirNameSuffix(installComponent); - if (NULL != this->GetOption(absoluteDestFileComponent.c_str())) + if (NULL != this->GetOption(absoluteDestFileComponent)) { std::string absoluteDestFilesListComponent = - this->GetOption(absoluteDestFileComponent.c_str()); + this->GetOption(absoluteDestFileComponent); absoluteDestFilesListComponent +=";"; absoluteDestFilesListComponent += mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); - this->SetOption(absoluteDestFileComponent.c_str(), + this->SetOption(absoluteDestFileComponent, absoluteDestFilesListComponent.c_str()); } else { - this->SetOption(absoluteDestFileComponent.c_str(), + this->SetOption(absoluteDestFileComponent, mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); } } @@ -972,7 +973,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName) } //---------------------------------------------------------------------- -void cmCPackGenerator::SetOptionIfNotSet(const char* op, +void cmCPackGenerator::SetOptionIfNotSet(const std::string& op, const char* value) { const char* def = this->MakefileMap->GetDefinition(op); @@ -984,12 +985,8 @@ void cmCPackGenerator::SetOptionIfNotSet(const char* op, } //---------------------------------------------------------------------- -void cmCPackGenerator::SetOption(const char* op, const char* value) +void cmCPackGenerator::SetOption(const std::string& op, const char* value) { - if ( !op ) - { - return; - } if ( !value ) { this->MakefileMap->RemoveDefinition(op); @@ -1004,7 +1001,7 @@ void cmCPackGenerator::SetOption(const char* op, const char* value) int cmCPackGenerator::DoPackage() { cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "Create package using " << this->Name.c_str() << std::endl); + "Create package using " << this->Name << std::endl); // Prepare CPack internal name and check // values for many CPACK_xxx vars @@ -1092,7 +1089,7 @@ int cmCPackGenerator::DoPackage() * may update this during PackageFiles. * (either putting several names or updating the provided one) */ - packageFileNames.push_back(tempPackageFileName); + packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : ""); toplevel = tempDirectory; if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) { @@ -1142,7 +1139,7 @@ int cmCPackGenerator::DoPackage() } //---------------------------------------------------------------------- -int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf) +int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf) { this->MakefileMap = mf; this->Name = name; @@ -1176,19 +1173,19 @@ int cmCPackGenerator::InitializeInternal() } //---------------------------------------------------------------------- -bool cmCPackGenerator::IsSet(const char* name) const +bool cmCPackGenerator::IsSet(const std::string& name) const { return this->MakefileMap->IsSet(name); } //---------------------------------------------------------------------- -bool cmCPackGenerator::IsOn(const char* name) const +bool cmCPackGenerator::IsOn(const std::string& name) const { return cmSystemTools::IsOn(GetOption(name)); } //---------------------------------------------------------------------- -const char* cmCPackGenerator::GetOption(const char* op) const +const char* cmCPackGenerator::GetOption(const std::string& op) const { const char* ret = this->MakefileMap->GetDefinition(op); if(!ret) @@ -1202,6 +1199,12 @@ const char* cmCPackGenerator::GetOption(const char* op) const } //---------------------------------------------------------------------- +std::vector<std::string> cmCPackGenerator::GetOptions() const +{ + return this->MakefileMap->GetDefinitions(); +} + +//---------------------------------------------------------------------- int cmCPackGenerator::PackageFiles() { return 0; @@ -1266,7 +1269,7 @@ std::string cmCPackGenerator::FindTemplate(const char* name) << (name ? name : "(NULL)") << std::endl); std::string ffile = this->MakefileMap->GetModulesFile(name); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " - << ffile.c_str() << std::endl); + << ffile << std::endl); return ffile; } @@ -1425,14 +1428,14 @@ std::string cmCPackGenerator::GetComponentPackageFileName( std::string suffix="-"+groupOrComponentName; /* check if we should use DISPLAY name */ std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME"; - if (IsOn(dispNameVar.c_str())) + if (IsOn(dispNameVar)) { /* the component Group case */ if (isGroupName) { std::string groupDispVar = "CPACK_COMPONENT_GROUP_" + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; - const char* groupDispName = GetOption(groupDispVar.c_str()); + const char* groupDispName = GetOption(groupDispVar); if (groupDispName) { suffix = "-"+std::string(groupDispName); @@ -1443,7 +1446,7 @@ std::string cmCPackGenerator::GetComponentPackageFileName( { std::string dispVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; - const char* dispName = GetOption(dispVar.c_str()); + const char* dispName = GetOption(dispVar); if(dispName) { suffix = "-"+std::string(dispName); @@ -1480,8 +1483,8 @@ bool cmCPackGenerator::WantsComponentInstallation() const //---------------------------------------------------------------------- cmCPackInstallationType* -cmCPackGenerator::GetInstallationType(const char *projectName, - const char *name) +cmCPackGenerator::GetInstallationType(const std::string& projectName, + const std::string& name) { (void) projectName; bool hasInstallationType = this->InstallationTypes.count(name) != 0; @@ -1494,7 +1497,7 @@ cmCPackGenerator::GetInstallationType(const char *projectName, installType->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { installType->DisplayName = displayName; @@ -1512,7 +1515,8 @@ cmCPackGenerator::GetInstallationType(const char *projectName, //---------------------------------------------------------------------- cmCPackComponent* -cmCPackGenerator::GetComponent(const char *projectName, const char *name) +cmCPackGenerator::GetComponent(const std::string& projectName, + const std::string& name) { bool hasComponent = this->Components.count(name) != 0; cmCPackComponent *component = &this->Components[name]; @@ -1523,7 +1527,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) + cmsys::SystemTools::UpperCase(name); component->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { component->DisplayName = displayName; @@ -1533,23 +1537,23 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) component->DisplayName = component->Name; } component->IsHidden - = this->IsOn((macroPrefix + "_HIDDEN").c_str()); + = this->IsOn(macroPrefix + "_HIDDEN"); component->IsRequired - = this->IsOn((macroPrefix + "_REQUIRED").c_str()); + = this->IsOn(macroPrefix + "_REQUIRED"); component->IsDisabledByDefault - = this->IsOn((macroPrefix + "_DISABLED").c_str()); + = this->IsOn(macroPrefix + "_DISABLED"); component->IsDownloaded - = this->IsOn((macroPrefix + "_DOWNLOADED").c_str()) + = this->IsOn(macroPrefix + "_DOWNLOADED") || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); - const char* archiveFile = this->GetOption((macroPrefix + - "_ARCHIVE_FILE").c_str()); + const char* archiveFile = this->GetOption(macroPrefix + + "_ARCHIVE_FILE"); if (archiveFile && *archiveFile) { component->ArchiveFile = archiveFile; } - const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str()); + const char* groupName = this->GetOption(macroPrefix + "_GROUP"); if (groupName && *groupName) { component->Group = GetComponentGroup(projectName, groupName); @@ -1561,7 +1565,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) } const char* description - = this->GetOption((macroPrefix + "_DESCRIPTION").c_str()); + = this->GetOption(macroPrefix + "_DESCRIPTION"); if (description && *description) { component->Description = description; @@ -1569,7 +1573,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) // Determine the installation types. const char *installTypes - = this->GetOption((macroPrefix + "_INSTALL_TYPES").c_str()); + = this->GetOption(macroPrefix + "_INSTALL_TYPES"); if (installTypes && *installTypes) { std::vector<std::string> installTypesVector; @@ -1580,12 +1584,12 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) ++installTypesIt) { component->InstallationTypes.push_back( - this->GetInstallationType(projectName, installTypesIt->c_str())); + this->GetInstallationType(projectName, *installTypesIt)); } } // Determine the component dependencies. - const char *depends = this->GetOption((macroPrefix + "_DEPENDS").c_str()); + const char *depends = this->GetOption(macroPrefix + "_DEPENDS"); if (depends && *depends) { std::vector<std::string> dependsVector; @@ -1596,7 +1600,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) ++dependIt) { cmCPackComponent *child = GetComponent(projectName, - dependIt->c_str()); + *dependIt); component->Dependencies.push_back(child); child->ReverseDependencies.push_back(component); } @@ -1607,7 +1611,8 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) //---------------------------------------------------------------------- cmCPackComponentGroup* -cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) +cmCPackGenerator::GetComponentGroup(const std::string& projectName, + const std::string& name) { (void) projectName; std::string macroPrefix = "CPACK_COMPONENT_GROUP_" @@ -1619,7 +1624,7 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) // Define the group group->Name = name; const char* displayName - = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + = this->GetOption(macroPrefix + "_DISPLAY_NAME"); if (displayName && *displayName) { group->DisplayName = displayName; @@ -1630,17 +1635,17 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) } const char* description - = this->GetOption((macroPrefix + "_DESCRIPTION").c_str()); + = this->GetOption(macroPrefix + "_DESCRIPTION"); if (description && *description) { group->Description = description; } group->IsBold - = this->IsOn((macroPrefix + "_BOLD_TITLE").c_str()); + = this->IsOn(macroPrefix + "_BOLD_TITLE"); group->IsExpandedByDefault - = this->IsOn((macroPrefix + "_EXPANDED").c_str()); + = this->IsOn(macroPrefix + "_EXPANDED"); const char* parentGroupName - = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str()); + = this->GetOption(macroPrefix + "_PARENT_GROUP"); if (parentGroupName && *parentGroupName) { group->ParentGroup = GetComponentGroup(projectName, parentGroupName); diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index bb33aa0..efd3bef 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -90,7 +90,7 @@ public: /** * Initialize generator */ - int Initialize(const char* name, cmMakefile* mf); + int Initialize(const std::string& name, cmMakefile* mf); /** * Construct generator @@ -99,11 +99,12 @@ public: virtual ~cmCPackGenerator(); //! Set and get the options - void SetOption(const char* op, const char* value); - void SetOptionIfNotSet(const char* op, const char* value); - const char* GetOption(const char* op) const; - bool IsSet(const char* name) const; - bool IsOn(const char* name) const; + void SetOption(const std::string& op, const char* value); + void SetOptionIfNotSet(const std::string& op, const char* value); + const char* GetOption(const std::string& op) const; + std::vector<std::string> GetOptions() const; + bool IsSet(const std::string& name) const; + bool IsOn(const std::string& name) const; //! Set the logger void SetLogger(cmCPackLog* log) { this->Logger = log; } @@ -189,13 +190,13 @@ protected: //! Run install commands if specified virtual int InstallProjectViaInstallCommands( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstallScript( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstalledDirectories( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); virtual int InstallProjectViaInstallCMakeProjects( - bool setDestDir, const char* tempInstallDirectory); + bool setDestDir, const std::string& tempInstallDirectory); /** * The various level of support of @@ -244,12 +245,14 @@ protected: * @return true if component installation is supported and wanted. */ virtual bool WantsComponentInstallation() const; - virtual cmCPackInstallationType* GetInstallationType(const char *projectName, - const char* name); - virtual cmCPackComponent* GetComponent(const char *projectName, - const char* name); - virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName, - const char* name); + virtual cmCPackInstallationType* GetInstallationType( + const std::string& projectName, + const std::string& name); + virtual cmCPackComponent* GetComponent(const std::string& projectName, + const std::string& name); + virtual cmCPackComponentGroup* GetComponentGroup( + const std::string& projectName, + const std::string& name); cmSystemTools::OutputOption GeneratorVerbose; std::string Name; diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index b36c2a2..9faf2b0 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -151,7 +151,8 @@ cmCPackGeneratorFactory::~cmCPackGeneratorFactory() } //---------------------------------------------------------------------- -cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name) +cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator( + const std::string& name) { cmCPackGenerator* gen = this->NewGeneratorInternal(name); if ( !gen ) @@ -165,12 +166,8 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name) //---------------------------------------------------------------------- cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( - const char* name) + const std::string& name) { - if ( !name ) - { - return 0; - } cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it = this->GeneratorCreators.find(name); if ( it == this->GeneratorCreators.end() ) @@ -181,11 +178,11 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( } //---------------------------------------------------------------------- -void cmCPackGeneratorFactory::RegisterGenerator(const char* name, +void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name, const char* generatorDescription, CreateGeneratorCall* createGenerator) { - if ( !name || !createGenerator ) + if ( !createGenerator ) { cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR, "Cannot register generator" << std::endl); diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index dff2e49..010777f 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -31,26 +31,26 @@ public: ~cmCPackGeneratorFactory(); //! Get the generator - cmCPackGenerator* NewGenerator(const char* name); + cmCPackGenerator* NewGenerator(const std::string& name); void DeleteGenerator(cmCPackGenerator* gen); typedef cmCPackGenerator* CreateGeneratorCall(); - void RegisterGenerator(const char* name, + void RegisterGenerator(const std::string& name, const char* generatorDescription, CreateGeneratorCall* createGenerator); void SetLogger(cmCPackLog* logger) { this->Logger = logger; } - typedef std::map<cmStdString, cmStdString> DescriptionsMap; + typedef std::map<std::string, std::string> DescriptionsMap; const DescriptionsMap& GetGeneratorsList() const { return this->GeneratorDescriptions; } private: - cmCPackGenerator* NewGeneratorInternal(const char* name); + cmCPackGenerator* NewGeneratorInternal(const std::string& name); std::vector<cmCPackGenerator*> Generators; - typedef std::map<cmStdString, CreateGeneratorCall*> t_GeneratorCreatorsMap; + typedef std::map<std::string, CreateGeneratorCall*> t_GeneratorCreatorsMap; t_GeneratorCreatorsMap GeneratorCreators; DescriptionsMap GeneratorDescriptions; cmCPackLog* Logger; diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 4e8bf0f..7befca0 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -169,27 +169,27 @@ void cmCPackLog::Log(int tag, const char* file, int line, { if ( error && !this->ErrorPrefix.empty() ) { - *this->DefaultError << this->ErrorPrefix.c_str(); + *this->DefaultError << this->ErrorPrefix; } else if ( warning && !this->WarningPrefix.empty() ) { - *this->DefaultError << this->WarningPrefix.c_str(); + *this->DefaultError << this->WarningPrefix; } else if ( output && !this->OutputPrefix.empty() ) { - *this->DefaultOutput << this->OutputPrefix.c_str(); + *this->DefaultOutput << this->OutputPrefix; } else if ( verbose && !this->VerbosePrefix.empty() ) { - *this->DefaultOutput << this->VerbosePrefix.c_str(); + *this->DefaultOutput << this->VerbosePrefix; } else if ( debug && !this->DebugPrefix.empty() ) { - *this->DefaultOutput << this->DebugPrefix.c_str(); + *this->DefaultOutput << this->DebugPrefix; } else if ( !this->Prefix.empty() ) { - *this->DefaultOutput << this->Prefix.c_str(); + *this->DefaultOutput << this->Prefix; } if ( useFileAndLine ) { diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 62bfa91..0113698 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -83,10 +83,10 @@ int cmCPackNSISGenerator::PackageFiles() fileN = fileN.substr(fileN.find('/')+1, std::string::npos); } cmSystemTools::ReplaceString(fileN, "/", "\\"); - str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl; + str << " Delete \"$INSTDIR\\" << fileN << "\"" << std::endl; } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " - << str.str().c_str() << std::endl); + << str.str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); std::vector<std::string> dirs; this->GetListOfSubdirectories(toplevel.c_str(), dirs); @@ -117,14 +117,14 @@ int cmCPackNSISGenerator::PackageFiles() } } cmSystemTools::ReplaceString(fileN, "/", "\\"); - dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl; + dstr << " RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl; if (!componentName.empty()) { this->Components[componentName].Directories.push_back(fileN); } } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " - << dstr.str().c_str() << std::endl); + << dstr.str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str()); @@ -320,7 +320,7 @@ int cmCPackNSISGenerator::PackageFiles() std::string nsisCmd = "\""; nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM"); nsisCmd += "\" \"" + nsisFileName + "\""; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd.c_str() + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd << std::endl); std::string output; int retVal = 1; @@ -329,12 +329,12 @@ int cmCPackNSISGenerator::PackageFiles() if ( !res || retVal ) { cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << nsisCmd.c_str() << std::endl + ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: " - << nsisCmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << nsisCmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } return 1; @@ -427,7 +427,7 @@ int cmCPackNSISGenerator::InitializeInternal() std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION"; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " - << nsisCmd.c_str() << std::endl); + << nsisCmd << std::endl); std::string output; int retVal = 1; bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), @@ -442,13 +442,13 @@ int cmCPackNSISGenerator::InitializeInternal() std::string tmpFile = topDir ? topDir : "."; tmpFile += "/NSISOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << nsisCmd.c_str() << std::endl + ofs << "# Run command: " << nsisCmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: " - << nsisCmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << nsisCmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return 0; } if ( versionRex.find(output)) @@ -470,7 +470,7 @@ int cmCPackNSISGenerator::InitializeInternal() { // No version check for NSIS cvs build cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS " - << versionRexCVS.match(1).c_str() << std::endl); + << versionRexCVS.match(1) << std::endl); } this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str()); this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin"); @@ -629,7 +629,7 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str, // if so add a desktop link std::string desktop = "CPACK_CREATE_DESKTOP_LINK_"; desktop += linkName; - if(this->IsSet(desktop.c_str())) + if(this->IsSet(desktop)) { str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n"; str << " CreateShortCut \"$DESKTOP\\" @@ -844,12 +844,12 @@ CreateComponentDescription(cmCPackComponent *component, std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/CompressZip.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << cmd.c_str() << std::endl + ofs << "# Run command: " << cmd << std::endl << "# Output:" << std::endl - << output.c_str() << std::endl; + << output << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: " - << cmd.c_str() << std::endl - << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + << cmd << std::endl + << "Please check " << tmpFile << " for errors" << std::endl); return ""; } @@ -891,7 +891,7 @@ CreateComponentDescription(cmCPackComponent *component, path = *pathIt; cmSystemTools::ReplaceString(path, "/", "\\"); macrosOut << " Delete \"$INSTDIR\\" - << path.c_str() + << path << "\"\n"; } for (pathIt = component->Directories.begin(); @@ -901,7 +901,7 @@ CreateComponentDescription(cmCPackComponent *component, path = *pathIt; cmSystemTools::ReplaceString(path, "/", "\\"); macrosOut << " RMDir \"$INSTDIR\\" - << path.c_str() + << path << "\"\n"; } macrosOut << " noremove_" << component->Name << ":\n"; diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 76e15fb..28c7f1d 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -227,7 +227,7 @@ int cmCPackOSXX11Generator::InitializeInternal() //---------------------------------------------------------------------- /* -bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name) +bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name) { std::string uname = cmSystemTools::UpperCase(name); std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; @@ -271,8 +271,8 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name) */ //---------------------------------------------------------------------- -bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name, - const char* dir, const char* outputFileName /* = 0 */, +bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name, + const std::string& dir, const char* outputFileName /* = 0 */, bool copyOnly /* = false */) { std::string inFName = "CPack."; @@ -288,7 +288,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name, if ( !outputFileName ) { - outputFileName = name; + outputFileName = name.c_str(); } std::string destFileName = dir; diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index b7bd243..9d0a6d1 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -37,8 +37,9 @@ protected: virtual const char* GetPackagingInstallPrefix(); virtual const char* GetOutputExtension() { return ".dmg"; } - //bool CopyCreateResourceFile(const char* name, const char* dir); - bool CopyResourcePlistFile(const char* name, const char* dir, + //bool CopyCreateResourceFile(const std::string& name, + // const std::string& dir); + bool CopyResourcePlistFile(const std::string& name, const std::string& dir, const char* outputFileName = 0, bool copyOnly = false); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index c5b9c6f..d736948 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -43,14 +43,14 @@ bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const } //---------------------------------------------------------------------- -int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir, - const char* script, - const char* name) +int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir, + const std::string& script, + const std::string& name) { std::string dst = resdir; dst += "/"; dst += name; - cmSystemTools::CopyFileAlways(script, dst.c_str()); + cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str()); cmSystemTools::SetPermissions(dst.c_str(),0777); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : " << script << "\ninto " << dst.c_str() << @@ -553,8 +553,9 @@ int cmCPackPackageMakerGenerator::InitializeInternal() } //---------------------------------------------------------------------- -bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, - const char* dirName) +bool cmCPackPackageMakerGenerator::CopyCreateResourceFile( + const std::string& name, + const std::string& dirName) { std::string uname = cmSystemTools::UpperCase(name); std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; @@ -563,7 +564,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str() << " not specified. It should point to " - << (name ? name : "(NULL)") + << (!name.empty() ? name : "<empty>") << ".rtf, " << name << ".html, or " << name << ".txt file" << std::endl); return false; @@ -571,7 +572,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, if ( !cmSystemTools::FileExists(inFileName) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find " - << (name ? name : "(NULL)") + << (!name.empty() ? name : "<empty>") << " resource file: " << inFileName << std::endl); return false; } @@ -600,12 +601,13 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, return true; } -bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name, - const char* outName) +bool cmCPackPackageMakerGenerator::CopyResourcePlistFile( + const std::string& name, + const char* outName) { if (!outName) { - outName = name; + outName = name.c_str(); } std::string inFName = "CPack."; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index ba3d968..e350a60 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -38,9 +38,9 @@ public: virtual bool SupportsComponentInstallation() const; protected: - int CopyInstallScript(const char* resdir, - const char* script, - const char* name); + int CopyInstallScript(const std::string& resdir, + const std::string& script, + const std::string& name); virtual int InitializeInternal(); int PackageFiles(); virtual const char* GetOutputExtension() { return ".dmg"; } @@ -51,8 +51,9 @@ protected: // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased // version of name) specifies the input file to use for this file, // which will be configured via ConfigureFile. - bool CopyCreateResourceFile(const char* name, const char *dirName); - bool CopyResourcePlistFile(const char* name, const char* outName = 0); + bool CopyCreateResourceFile(const std::string& name, + const std::string& dirName); + bool CopyResourcePlistFile(const std::string& name, const char* outName = 0); // Run PackageMaker with the given command line, which will (if // successful) produce the given package file. Returns true if diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 66a4194..c6171dc 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -272,9 +272,9 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix( // the current COMPONENT belongs to. std::string groupVar = "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; - if (NULL != GetOption(groupVar.c_str())) + if (NULL != GetOption(groupVar)) { - return std::string(GetOption(groupVar.c_str())); + return std::string(GetOption(groupVar)); } else { diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 8342fee..6c1d201 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -43,7 +43,7 @@ int cmCPackSTGZGenerator::InitializeInternal() if ( inFile.empty() ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find template file: " - << inFile.c_str() << std::endl); + << inFile << std::endl); return 0; } this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str()); @@ -134,6 +134,6 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) cmSystemTools::ReplaceString(res, headerLengthTag, buffer); // Write in file - *os << res.c_str(); + *os << res; return this->Superclass::GenerateHeader(os); } diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index a19b778..9eabdca 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -68,7 +68,7 @@ int cpackUnknownArgument(const char*, void*) //---------------------------------------------------------------------------- struct cpackDefinitions { - typedef std::map<cmStdString, cmStdString> MapType; + typedef std::map<std::string, std::string> MapType; MapType Map; cmCPackLog *Log; }; @@ -91,7 +91,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, value = value.c_str() + pos + 1; def->Map[key] = value; cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " - << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl); + << key << " to \"" << value << "\"" << std::endl); return 1; } @@ -195,7 +195,7 @@ int main (int argc, char const* const* argv) } cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, - "Read CPack config file: " << cpackConfigFile.c_str() << std::endl); + "Read CPack config file: " << cpackConfigFile << std::endl); cmake cminst; cminst.RemoveUnscriptableCommands(); @@ -262,21 +262,21 @@ int main (int argc, char const* const* argv) cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile.c_str()); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, - "Read CPack configuration file: " << cpackConfigFile.c_str() + "Read CPack configuration file: " << cpackConfigFile << std::endl); if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reading CPack config file: \"" - << cpackConfigFile.c_str() << "\"" << std::endl); + << cpackConfigFile << "\"" << std::endl); return 1; } } else if ( cpackConfigFileSpecified ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, - "Cannot find CPack config file: \"" << cpackConfigFile.c_str() - << "\"" << std::endl); + "Cannot find CPack config file: \"" << + cpackConfigFile << "\"" << std::endl); return 1; } @@ -326,7 +326,7 @@ int main (int argc, char const* const* argv) cdit != definitions.Map.end(); ++cdit ) { - globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str()); + globalMF->AddDefinition(cdit->first, cdit->second.c_str()); } const char* cpackModulesPath = diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 381c70c..3014a93 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -225,35 +225,35 @@ private: return true; } - virtual void StartElement(const char* name, const char**) + virtual void StartElement(const std::string& name, const char**) { this->CData.clear(); - if(strcmp(name, "log") == 0) + if(name == "log") { this->Rev = Revision(); this->Changes.clear(); } // affected-files can contain blocks of // modified, unknown, renamed, kind-changed, removed, conflicts, added - else if(strcmp(name, "modified") == 0 - || strcmp(name, "renamed") == 0 - || strcmp(name, "kind-changed") == 0) + else if(name == "modified" + || name == "renamed" + || name == "kind-changed") { this->CurChange = Change(); this->CurChange.Action = 'M'; } - else if(strcmp(name, "added") == 0) + else if(name == "added") { this->CurChange = Change(); this->CurChange = 'A'; } - else if(strcmp(name, "removed") == 0) + else if(name == "removed") { this->CurChange = Change(); this->CurChange = 'D'; } - else if(strcmp(name, "unknown") == 0 - || strcmp(name, "conflicts") == 0) + else if(name == "unknown" + || name == "conflicts") { // Should not happen here this->CurChange = Change(); @@ -265,27 +265,27 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "log") == 0) + if(name == "log") { this->BZR->DoRevision(this->Rev, this->Changes); } - else if((strcmp(name, "file") == 0 || strcmp(name, "directory") == 0) - && !this->CData.empty()) + else if(!this->CData.empty() && + (name == "file" || name == "directory")) { this->CurChange.Path.assign(&this->CData[0], this->CData.size()); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "symlink") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "symlink") { // symlinks have an arobase at the end in the log this->CurChange.Path.assign(&this->CData[0], this->CData.size()-1); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "committer") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "committer") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); if(this->EmailRegex.find(this->Rev.Author)) @@ -294,15 +294,15 @@ private: this->Rev.EMail = this->EmailRegex.match(2); } } - else if(strcmp(name, "timestamp") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "timestamp") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "message") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "message") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "revno") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "revno") { this->Rev.Rev.assign(&this->CData[0], this->CData.size()); } @@ -409,7 +409,7 @@ bool cmCTestBZR::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -418,7 +418,7 @@ bool cmCTestBZR::UpdateImpl() bzr_update.push_back(this->CommandLineTool.c_str()); bzr_update.push_back("pull"); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { bzr_update.push_back(ai->c_str()); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 0fac136..4a3eec5 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -241,11 +241,11 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) { // Make the generator available for the Build call below. cm.SetGlobalGenerator(cm.CreateGlobalGenerator( - this->BuildGenerator.c_str())); + this->BuildGenerator)); cm.SetGeneratorToolset(this->BuildGeneratorToolset); // Load the cache to make CMAKE_MAKE_PROGRAM available. - cm.GetCacheManager()->LoadCache(this->BinaryDir.c_str()); + cm.GetCacheManager()->LoadCache(this->BinaryDir); } else { @@ -295,9 +295,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) config = "Debug"; } int retVal = cm.GetGlobalGenerator()->Build( - this->SourceDir.c_str(), this->BinaryDir.c_str(), - this->BuildProject.c_str(), tarIt->c_str(), - &output, this->BuildMakeProgram.c_str(), + this->SourceDir, this->BinaryDir, + this->BuildProject, *tarIt, + &output, this->BuildMakeProgram, config, !this->BuildNoClean, false, remainingTime); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index ca50c64..d1e9a4d 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -54,7 +54,7 @@ protected: std::string &cmakeOutString, std::string &cwd, cmake *cm); - cmStdString Output; + std::string Output; std::string BuildGenerator; std::string BuildGeneratorToolset; diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 12ff718..f81083a 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -101,8 +101,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() } if ( this->GlobalGenerator ) { - if ( strcmp(this->GlobalGenerator->GetName(), - cmakeGeneratorName) != 0 ) + if ( this->GlobalGenerator->GetName() != cmakeGeneratorName ) { delete this->GlobalGenerator; this->GlobalGenerator = 0; @@ -130,11 +129,12 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string buildCommand = this->GlobalGenerator-> - GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration, - cmakeBuildAdditionalFlags, true); + GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "", + cmakeBuildConfiguration, + cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", true); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" - << buildCommand.c_str() << "\n"); + << buildCommand << "\n"); this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str()); } else @@ -151,7 +151,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() "\n" "Alternatively, set CTEST_BUILD_COMMAND to build the project " "with a custom command line."; - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return 0; } } diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index 08887fe..2632ebc 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_build";} + virtual std::string GetName() const { return "ctest_build";} virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index c5deb96..7922c9a 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -380,7 +380,7 @@ int cmCTestBuildHandler::ProcessHandler() // Create lists of regular expression strings for errors, error exceptions, // warnings and warning exceptions. - std::vector<cmStdString>::size_type cc; + std::vector<std::string>::size_type cc; for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ ) { this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]); @@ -400,7 +400,7 @@ int cmCTestBuildHandler::ProcessHandler() } // Pre-compile regular expressions objects for all regular expressions - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; #define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \ regexes.clear(); \ @@ -409,7 +409,7 @@ int cmCTestBuildHandler::ProcessHandler() for ( it = strings.begin(); it != strings.end(); ++it ) \ { \ cmCTestLog(this->CTest, DEBUG, "Add " #strings ": " \ - << it->c_str() << std::endl); \ + << *it << std::endl); \ regexes.push_back(it->c_str()); \ } cmCTestBuildHandlerPopulateRegexVector( @@ -602,7 +602,7 @@ void cmCTestBuildHandler::GenerateXMLLaunched(std::ostream& os) // Sort XML fragments in chronological order. cmFileTimeComparison ftc; FragmentCompare fragmentCompare(&ftc); - typedef std::set<cmStdString, FragmentCompare> Fragments; + typedef std::set<std::string, FragmentCompare> Fragments; Fragments fragments(fragmentCompare); // Identify fragments on disk. @@ -889,7 +889,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal, const char* dir, int timeout, std::ostream& ofs) { // First generate the command and arguments - std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -897,7 +897,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, } std::vector<const char*> argv; - for(std::vector<cmStdString>::const_iterator a = args.begin(); + for(std::vector<std::string>::const_iterator a = args.begin(); a != args.end(); ++a) { argv.push_back(a->c_str()); @@ -1133,7 +1133,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, errorwarning.PostContext = ""; // Copy pre-context to report - std::deque<cmStdString>::iterator pcit; + std::deque<std::string>::iterator pcit; for ( pcit = this->PreContext.begin(); pcit != this->PreContext.end(); ++pcit ) diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index ff7cfd6..09346f9 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -97,10 +97,10 @@ private: double StartBuildTime; double EndBuildTime; - std::vector<cmStdString> CustomErrorMatches; - std::vector<cmStdString> CustomErrorExceptions; - std::vector<cmStdString> CustomWarningMatches; - std::vector<cmStdString> CustomWarningExceptions; + std::vector<std::string> CustomErrorMatches; + std::vector<std::string> CustomErrorExceptions; + std::vector<std::string> CustomWarningMatches; + std::vector<std::string> CustomWarningExceptions; std::vector<std::string> ReallyCustomWarningMatches; std::vector<std::string> ReallyCustomWarningExceptions; std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex; @@ -121,8 +121,8 @@ private: size_t BuildOutputLogSize; std::vector<char> CurrentProcessingLine; - cmStdString SimplifySourceDir; - cmStdString SimplifyBuildDir; + std::string SimplifySourceDir; + std::string SimplifyBuildDir; size_t OutputLineCounter; typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector; t_ErrorsAndWarningsVector ErrorsAndWarnings; @@ -130,7 +130,7 @@ private: size_t PostContextCount; size_t MaxPreContext; size_t MaxPostContext; - std::deque<cmStdString> PreContext; + std::deque<std::string> PreContext; int TotalErrors; int TotalWarnings; diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 17dbb55..ab363d0 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -99,7 +99,7 @@ bool cmCTestCVS::UpdateImpl() opts = "-dP"; } } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); // Specify the start time for nightly testing. if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -112,7 +112,7 @@ bool cmCTestCVS::UpdateImpl() cvs_update.push_back(this->CommandLineTool.c_str()); cvs_update.push_back("-z3"); cvs_update.push_back("update"); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { cvs_update.push_back(ai->c_str()); @@ -308,7 +308,7 @@ bool cmCTestCVS::WriteXMLUpdates(std::ostream& xml) " Gathering version information (one . per updated file):\n" " " << std::flush); - for(std::map<cmStdString, Directory>::const_iterator + for(std::map<std::string, Directory>::const_iterator di = this->Dirs.begin(); di != this->Dirs.end(); ++di) { this->WriteXMLDirectory(xml, di->first, di->second); diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h index b7fe567..64e1747 100644 --- a/Source/CTest/cmCTestCVS.h +++ b/Source/CTest/cmCTestCVS.h @@ -32,8 +32,8 @@ private: virtual bool WriteXMLUpdates(std::ostream& xml); // Update status for files in each directory. - class Directory: public std::map<cmStdString, PathStatus> {}; - std::map<cmStdString, Directory> Dirs; + class Directory: public std::map<std::string, PathStatus> {}; + std::map<std::string, Directory> Dirs; std::string ComputeBranchFlag(std::string const& dir); void LoadRevisions(std::string const& file, const char* branchFlag, diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 5eed409..1aa8768 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -69,7 +69,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() cmOStringStream e; e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return 0; } diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index b592c5a..7941d4e 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -38,7 +38,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_configure";} + virtual std::string GetName() const { return "ctest_configure";} cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index 7c41298..a6e39a4 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -76,7 +76,7 @@ int cmCTestConfigureHandler::ProcessHandler() cmGeneratedFileStream ofs; this->StartLogFile("Configure", ofs); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: " - << cCommand.c_str() << std::endl); + << cCommand << std::endl); res = this->CTest->RunMakeCommand(cCommand.c_str(), &output, &retVal, buildDirectory.c_str(), 0, ofs); @@ -99,7 +99,7 @@ int cmCTestConfigureHandler::ProcessHandler() { os << retVal; } - os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>" + os << "<ConfigureCommand>" << cCommand << "</ConfigureCommand>" << std::endl; cmCTestLog(this->CTest, DEBUG, "End" << std::endl); os << "<Log>" << cmXMLSafe(output) << "</Log>" << std::endl; diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index 72ff720..41f016b 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -25,7 +25,8 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() { this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND"); - + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS"); cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>( this->CTest->GetInitializedHandler("coverage")); if ( !handler ) diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 11bb411..5762e07 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_coverage";} + virtual std::string GetName() const { return "ctest_coverage";} cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand); @@ -56,7 +56,7 @@ protected: }; bool LabelsMentioned; - std::set<cmStdString> Labels; + std::set<std::string> Labels; }; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 3c65c55..cb6e56e 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -157,7 +157,7 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log) logGlob += this->CTest->GetCurrentTag(); logGlob += "/CoverageLog*"; cmsys::Glob gl; - gl.FindFiles(logGlob.c_str()); + gl.FindFiles(logGlob); std::vector<std::string> const& files = gl.GetFiles(); for(std::vector<std::string>::const_iterator fi = files.begin(); fi != files.end(); ++fi) @@ -241,7 +241,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), fBinDir.c_str()); // Always check parent directory of the file. - std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str()); + std::string fileDir = cmSystemTools::GetFilenamePath(fFile); std::string checkDir; // We also need to check the binary/source directory pair. @@ -269,7 +269,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, fFile.c_str(), checkDir.c_str()); if ( ndc.size() ) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of " << file << std::endl); return false; } @@ -296,7 +296,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, checkDir = fSrcDir; } fFile = checkDir + "/" + relPath; - fFile = cmSystemTools::GetFilenamePath(fFile.c_str()); + fFile = cmSystemTools::GetFilenamePath(fFile); if ( fileDir == fFile ) { @@ -308,7 +308,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, fFile.c_str(), checkDir.c_str()); if ( ndc.size() ) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str() + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of: " << file << std::endl); return false; } @@ -363,7 +363,7 @@ int cmCTestCoverageHandler::ProcessHandler() // setup the regex exclude stuff this->CustomCoverageExcludeRegex.clear(); - std::vector<cmStdString>::iterator rexIt; + std::vector<std::string>::iterator rexIt; for ( rexIt = this->CustomCoverageExclude.begin(); rexIt != this->CustomCoverageExclude.end(); ++ rexIt ) @@ -383,6 +383,12 @@ int cmCTestCoverageHandler::ProcessHandler() { return error; } + file_count += this->HandleLCovCoverage(&cont); + error = cont.Error; + if ( file_count < 0 ) + { + return error; + } file_count += this->HandleTracePyCoverage(&cont); error = cont.Error; if ( file_count < 0 ) @@ -477,7 +483,7 @@ int cmCTestCoverageHandler::ProcessHandler() { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: " - << fullFileName.c_str() + << fullFileName << std::endl); continue; } @@ -488,7 +494,7 @@ int cmCTestCoverageHandler::ProcessHandler() if ( !cmSystemTools::FileExists(fullFileName.c_str()) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: " - << fullFileName.c_str() << std::endl); + << fullFileName << std::endl); continue; } @@ -503,7 +509,7 @@ int cmCTestCoverageHandler::ProcessHandler() } const std::string fileName - = cmSystemTools::GetFilenameName(fullFileName.c_str()); + = cmSystemTools::GetFilenameName(fullFileName); std::string shortFileName = this->CTest->GetShortPathToFile(fullFileName.c_str()); const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov @@ -516,7 +522,7 @@ int cmCTestCoverageHandler::ProcessHandler() if ( !ifs) { cmOStringStream ostr; - ostr << "Cannot open source file: " << fullFileName.c_str(); + ostr << "Cannot open source file: " << fullFileName; errorsWhileAccumulating.push_back(ostr.str()); error ++; continue; @@ -535,7 +541,7 @@ int cmCTestCoverageHandler::ProcessHandler() cc != fcov.size() -1 ) { cmOStringStream ostr; - ostr << "Problem reading source file: " << fullFileName.c_str() + ostr << "Problem reading source file: " << fullFileName << " line:" << cc << " out total: " << fcov.size()-1; errorsWhileAccumulating.push_back(ostr.str()); error ++; @@ -605,7 +611,7 @@ int cmCTestCoverageHandler::ProcessHandler() if (!ifs) { cmOStringStream ostr; - ostr << "Cannot open source file: " << fullPath.c_str(); + ostr << "Cannot open source file: " << fullPath; errorsWhileAccumulating.push_back(ostr.str()); error ++; continue; @@ -613,7 +619,7 @@ int cmCTestCoverageHandler::ProcessHandler() int untested = 0; std::string line; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Actually performing coverage for: " << i->c_str() << std::endl); + "Actually performing coverage for: " << *i << std::endl); while (cmSystemTools::GetLineFromStream(ifs, line)) { covLogFile << "\t\t<Line Number=\"" << untested << "\" Count=\"0\">" @@ -647,7 +653,7 @@ int cmCTestCoverageHandler::ProcessHandler() ++ erIt ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - " " << erIt->c_str() << std::endl); + " " << *erIt << std::endl); } } @@ -713,19 +719,19 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) this->CustomCoverageExclude); this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB", this->ExtraCoverageGlobs); - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for ( it = this->CustomCoverageExclude.begin(); it != this->CustomCoverageExclude.end(); ++ it ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: " - << it->c_str() << std::endl); + << *it << std::endl); } for ( it = this->ExtraCoverageGlobs.begin(); it != this->ExtraCoverageGlobs.end(); ++it) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage glob: " - << it->c_str() << std::endl); + << *it << std::endl); } } @@ -871,9 +877,22 @@ int cmCTestCoverageHandler::HandleGCovCoverage( { std::string gcovCommand = this->CTest->GetCTestConfiguration("CoverageCommand"); + if (gcovCommand.empty()) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Could not find gcov." << std::endl); + return 0; + } std::string gcovExtraFlags = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); + // Immediately skip to next coverage option since codecov is only for Intel + // compiler + if ( gcovCommand == "codecov" ) + { + return 0; + } + // Style 1 std::string st1gcovOutputRex1 = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$"; @@ -941,7 +960,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // Call gcov to get coverage data for this *.gcda file: // - std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); + std::string fileDir = cmSystemTools::GetFilenamePath(*it); std::string command = "\"" + gcovCommand + "\" " + gcovExtraFlags + " " + "-o \"" + fileDir + "\" " + @@ -953,17 +972,17 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string output = ""; std::string errors = ""; int retVal = 0; - *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl; - *cont->OFS << " Command: " << command.c_str() << std::endl; + *cont->OFS << "* Run coverage for: " << fileDir << std::endl; + *cont->OFS << " Command: " << command << std::endl; int res = this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal, tempDir.c_str(), 0 /*this->TimeOut*/); - *cont->OFS << " Output: " << output.c_str() << std::endl; - *cont->OFS << " Errors: " << errors.c_str() << std::endl; + *cont->OFS << " Output: " << output << std::endl; + *cont->OFS << " Errors: " << errors << std::endl; if ( ! res ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Problem running coverage on file: " << it->c_str() << std::endl); + "Problem running coverage on file: " << *it << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, "Command produced error: " << errors << std::endl); cont->Error ++; @@ -972,7 +991,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( if ( retVal != 0 ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: " - << retVal << " while processing: " << it->c_str() << std::endl); + << retVal << " while processing: " << *it << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, "Command produced error: " << cont->Error << std::endl); } @@ -983,8 +1002,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( << "--------------------------------------------------------------" << std::endl); - std::vector<cmStdString> lines; - std::vector<cmStdString>::iterator line; + std::vector<std::string> lines; + std::vector<std::string>::iterator line; cmSystemTools::Split(output.c_str(), lines); @@ -993,7 +1012,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string sourceFile; std::string gcovFile; - cmCTestLog(this->CTest, DEBUG, "Line: [" << line->c_str() << "]" + cmCTestLog(this->CTest, DEBUG, "Line: [" << *line << "]" << std::endl); if ( line->size() == 0 ) @@ -1139,7 +1158,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( !cmSystemTools::StringStartsWith(line->c_str(), "Removing ")) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Unknown gcov output line: [" << line->c_str() << "]" + "Unknown gcov output line: [" << *line << "]" << std::endl); cont->Error ++; //abort(); @@ -1232,8 +1251,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( if ( IsFileInDir(sourceFile, cont->SourceDir) ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " - << sourceFile.c_str() << std::endl); - *cont->OFS << " produced in source dir: " << sourceFile.c_str() + << sourceFile << std::endl); + *cont->OFS << " produced in source dir: " << sourceFile << std::endl; actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); @@ -1241,8 +1260,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( else if ( IsFileInDir(sourceFile, cont->BinaryDir) ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " - << sourceFile.c_str() << std::endl); - *cont->OFS << " produced in binary dir: " << sourceFile.c_str() + << sourceFile << std::endl); + *cont->OFS << " produced in binary dir: " << sourceFile << std::endl; actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); @@ -1256,19 +1275,19 @@ int cmCTestCoverageHandler::HandleGCovCoverage( "Something went wrong" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Cannot find file: [" - << sourceFile.c_str() << "]" << std::endl); + << sourceFile << "]" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in source dir: [" - << cont->SourceDir.c_str() << "]" + << cont->SourceDir << "]" << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " or binary dir: [" << cont->BinaryDir.size() << "]" << std::endl); *cont->OFS << " Something went wrong. Cannot find file: " - << sourceFile.c_str() - << " in source dir: " << cont->SourceDir.c_str() - << " or binary dir: " << cont->BinaryDir.c_str() << std::endl; + << sourceFile + << " in source dir: " << cont->SourceDir + << " or binary dir: " << cont->BinaryDir << std::endl; missingFiles.insert(sourceFile); } @@ -1290,6 +1309,270 @@ int cmCTestCoverageHandler::HandleGCovCoverage( return file_count; } +//---------------------------------------------------------------------- +int cmCTestCoverageHandler::HandleLCovCoverage( + cmCTestCoverageHandlerContainer* cont) +{ + std::string lcovCommand + = this->CTest->GetCTestConfiguration("CoverageCommand"); + std::string lcovExtraFlags + = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); + if ( lcovCommand != "codecov" ) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Not a valid Intel Coverage command." + << std::endl); + return 0; + } + // There is only percentage completed output from LCOV + std::string st2lcovOutputRex3 = "[0-9]+%"; + cmsys::RegularExpression st2re3(st2lcovOutputRex3.c_str()); + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " This is coverage command: " << lcovCommand + << std::endl); + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " These are coverage command flags: " << lcovExtraFlags + << std::endl); + + std::vector<std::string> files; + this->FindLCovFiles(files); + std::vector<std::string>::iterator it; + + if ( files.size() == 0 ) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Cannot find any LCov coverage files." + << std::endl); + // No coverage files is a valid thing, so the exit code is 0 + return 0; + } + std::string testingDir = this->CTest->GetBinaryDir(); + std::string tempDir = testingDir; + std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); + + std::set<std::string> missingFiles; + + std::string actualSourceFile = ""; + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Processing coverage (each . represents one file):" << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); + int file_count = 0; + + // make sure output from lcov is in English! + cmCTestCoverageHandlerLocale locale_C; + static_cast<void>(locale_C); + + // In intel compiler we have to call codecov only once in each executable + // directory. It collects all *.dyn files to generate .dpi file. + for ( it = files.begin(); it != files.end(); ++ it ) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); + std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); + cmSystemTools::ChangeDirectory(fileDir.c_str()); + std::string command = "\"" + lcovCommand + "\" " + + lcovExtraFlags + " "; + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Current coverage dir: " + << fileDir.c_str() << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() + << std::endl); + + std::string output = ""; + std::string errors = ""; + int retVal = 0; + *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl; + *cont->OFS << " Command: " << command.c_str() << std::endl; + int res = this->CTest->RunCommand(command.c_str(), &output, &errors, + &retVal, fileDir.c_str(), 0 /*this->TimeOut*/); + + *cont->OFS << " Output: " << output.c_str() << std::endl; + *cont->OFS << " Errors: " << errors.c_str() << std::endl; + if ( ! res ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Problem running coverage on file: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Command produced error: " << errors << std::endl); + cont->Error ++; + continue; + } + if ( retVal != 0 ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: " + << retVal << " while processing: " << it->c_str() << std::endl); + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Command produced error: " << cont->Error << std::endl); + } + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "--------------------------------------------------------------" + << std::endl + << output << std::endl + << "--------------------------------------------------------------" + << std::endl); + + std::vector<std::string> lines; + std::vector<std::string>::iterator line; + + cmSystemTools::Split(output.c_str(), lines); + + for ( line = lines.begin(); line != lines.end(); ++line) + { + std::string sourceFile; + std::string lcovFile; + + if ( line->size() == 0 ) + { + // Ignore empty line + } + // Look for LCOV files in binary directory + // Intel Compiler creates a CodeCoverage dir for each subfolder and + // each subfolder has LCOV files + cmsys::Glob gl; + gl.RecurseOn(); + gl.RecurseThroughSymlinksOff(); + std::string dir; + std::vector<std::string> lcovFiles; + dir = this->CTest->GetBinaryDir(); + std::string daGlob; + daGlob = dir; + daGlob += "/*.LCOV"; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " looking for LCOV files in: " << daGlob << std::endl); + gl.FindFiles(daGlob); + // Keep a list of all LCOV files + lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(), + gl.GetFiles().end()); + + for(std::vector<std::string>::iterator a = lcovFiles.begin(); + a != lcovFiles.end(); ++a) + { + lcovFile = *a; + cmsys::ifstream srcead(lcovFile.c_str()); + if ( ! srcead ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " + << lcovFile << std::endl); + } + std::string srcname; + + int success = cmSystemTools::GetLineFromStream(srcead, srcname); + if ( !success ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Error while parsing lcov file '" << lcovFile << "':" + << " No source file name found!" << std::endl); + return 0; + } + srcname = srcname.substr(18); + // We can directly read found LCOV files to determine the source + // files + sourceFile = srcname; + actualSourceFile = srcname; + + for(std::vector<std::string>::iterator t = lcovFiles.begin(); + t != lcovFiles.end(); ++t) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found LCOV File: " + << *t << std::endl); + } + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SourceFile: " + << sourceFile << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "lCovFile: " + << lcovFile << std::endl); + + // If we have some LCOV files to process + if ( !lcovFile.empty() && !actualSourceFile.empty() ) + { + cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec + = cont->TotalCoverage[actualSourceFile]; + + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in lcovFile: " + << lcovFile << std::endl); + + cmsys::ifstream ifile(lcovFile.c_str()); + if ( ! ifile ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " + << lcovFile << std::endl); + } + else + { + long cnt = -1; + std::string nl; + + // Skip the first line + cmSystemTools::GetLineFromStream(ifile, nl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "File is ready, start reading." << std::endl); + while ( cmSystemTools::GetLineFromStream(ifile, nl) ) + { + cnt ++; + + // Skip empty lines + if ( !nl.size() ) + { + continue; + } + + // Skip unused lines + if ( nl.size() < 12 ) + { + continue; + } + + // Read the coverage count from the beginning of the lcov + // output line + std::string prefix = nl.substr(0, 17); + int cov = atoi(prefix.c_str()); + + // Read the line number starting at the 17th character of the + // lcov output line + std::string lineNumber = nl.substr(17, 7); + + int lineIdx = atoi(lineNumber.c_str())-1; + if ( lineIdx >= 0 ) + { + while ( vec.size() <= static_cast<size_t>(lineIdx) ) + { + vec.push_back(-1); + } + + // Initially all entries are -1 (not used). If we get coverage + // information, increment it to 0 first. + if ( vec[lineIdx] < 0 ) + { + if ( cov > 0 || prefix.find("#") != prefix.npos ) + { + vec[lineIdx] = 0; + } + } + + vec[lineIdx] += cov; + } + } + } + + actualSourceFile = ""; + } + } + } + + file_count++; + + if ( file_count % 50 == 0 ) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, " processed: " << file_count + << " out of " << files.size() << std::endl); + cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); + } + } + + cmSystemTools::ChangeDirectory(currentDirectory.c_str()); + return file_count; +} + //---------------------------------------------------------------------------- void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files) { @@ -1321,6 +1604,34 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files) } } +//---------------------------------------------------------------------------- +void cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) +{ + cmsys::Glob gl; + gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is + // used while compiling. + gl.RecurseThroughSymlinksOff(); + std::string prevBinaryDir; + cmSystemTools::ChangeDirectory( + this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); + + // Run profmerge to merge all *.dyn files into dpi files + cmSystemTools::RunSingleCommand("profmerge"); + + prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str(); + + // DPI file should appear in build directory + std::string daGlob; + daGlob = prevBinaryDir; + daGlob += "/*.dpi"; + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " looking for dpi files in: " << daGlob << std::endl); + gl.FindFiles(daGlob); + files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Now searching in: " << daGlob << std::endl); +} + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleTracePyCoverage( cmCTestCoverageHandlerContainer* cont) @@ -1358,24 +1669,24 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find source Python file corresponding to: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); continue; } std::string actualSourceFile = cmSystemTools::CollapseFullPath(fileName.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - " Check coverage for file: " << actualSourceFile.c_str() + " Check coverage for file: " << actualSourceFile << std::endl); cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec = &cont->TotalCoverage[actualSourceFile]; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - " in file: " << fileIt->c_str() << std::endl); + " in file: " << *fileIt << std::endl); cmsys::ifstream ifile(fileIt->c_str()); if ( ! ifile ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); } else { @@ -1423,7 +1734,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( // So, this will be set to 0. cov = 0; } - cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix.c_str() + cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix << " cov: " << cov << std::endl); // Read the line number starting at the 10th character of the gcov @@ -1498,7 +1809,7 @@ namespace //---------------------------------------------------------------------- int cmCTestCoverageHandler::RunBullseyeCoverageBranch( cmCTestCoverageHandlerContainer* cont, - std::set<cmStdString>& coveredFileNames, + std::set<std::string>& coveredFileNames, std::vector<std::string>& files, std::vector<std::string>& filesFullPath) { @@ -1536,10 +1847,10 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage file: " << - outputFile.c_str() << std::endl); + outputFile << std::endl); return 0; } - std::map<cmStdString, cmStdString> fileMap; + std::map<std::string, std::string> fileMap; std::vector<std::string>::iterator fp = filesFullPath.begin(); for(std::vector<std::string>::iterator f = files.begin(); f != files.end(); ++f, ++fp) @@ -1552,7 +1863,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( std::string lineIn; bool valid = false; // are we in a valid output file int line = 0; // line of the current file - cmStdString file; + std::string file; while(cmSystemTools::GetLineFromStream(fin, lineIn)) { bool startFile = false; @@ -1587,7 +1898,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( } count++; // move on one } - std::map<cmStdString, cmStdString>::iterator + std::map<std::string, std::string>::iterator i = fileMap.find(file); // if the file should be covered write out the header for that file if(i != fileMap.end()) @@ -1596,7 +1907,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( count++; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Produce coverage for file: " - << file.c_str() << " " << count + << file << " " << count << std::endl); // start the file output covLogFile << "\t<File Name=\"" @@ -1657,12 +1968,12 @@ int cmCTestCoverageHandler::RunBullseyeCommand( if(arg) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Run : " << program.c_str() << " " << arg << "\n"); + "Run : " << program << " " << arg << "\n"); } else { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Run : " << program.c_str() << "\n"); + "Run : " << program << "\n"); } // create a process object and start it cmCTestRunProcess runCoverageSrc; @@ -1680,7 +1991,7 @@ int cmCTestCoverageHandler::RunBullseyeCommand( if(!runCoverageSrc.StartProcess()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not run : " - << program.c_str() << " " << arg << "\n" + << program << " " << arg << "\n" << "kwsys process state : " << runCoverageSrc.GetProcessState()); return 0; @@ -1749,10 +2060,10 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file: " << - outputFile.c_str() << std::endl); + outputFile << std::endl); return 0; } - std::set<cmStdString> coveredFileNames; + std::set<std::string> coveredFileNames; while(cmSystemTools::GetLineFromStream(fin, stdline)) { // if we have a line of output from stdout @@ -1790,14 +2101,14 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: " - << file.c_str() + << file << std::endl); continue; } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Doing coverage for: " - << file.c_str() + << file << std::endl); coveredFiles.push_back(sourceFile); @@ -1808,7 +2119,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( total_tested += functionsCalled; total_untested += (totalFunctions - functionsCalled); - std::string fileName = cmSystemTools::GetFilenameName(file.c_str()); + std::string fileName = cmSystemTools::GetFilenameName(file); std::string shortFileName = this->CTest->GetShortPathToFile(file.c_str()); @@ -1824,7 +2135,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( cmet /= 2.0f; } cmet /= 100.0f; - tmpLog << stdline.c_str() << "\n"; + tmpLog << stdline << "\n"; tmpLog << fileName << "\n"; tmpLog << "functionsCalled: " << functionsCalled/100 << "\n"; tmpLog << "totalFunctions: " << totalFunctions/100 << "\n"; @@ -1951,7 +2262,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine( if(pos == inputLine.npos) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing string : " - << inputLine.c_str() << "\n"); + << inputLine << "\n"); return false; } // the source file has "" around it so extract out the file name @@ -1985,7 +2296,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine( if(pos != inputLine.npos) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing input : " - << inputLine.c_str() << " last pos not npos = " << pos << + << inputLine << " last pos not npos = " << pos << "\n"); } return true; @@ -2099,10 +2410,10 @@ void cmCTestCoverageHandler::WriteXMLLabels(std::ostream& os, //---------------------------------------------------------------------------- void -cmCTestCoverageHandler::SetLabelFilter(std::set<cmStdString> const& labels) +cmCTestCoverageHandler::SetLabelFilter(std::set<std::string> const& labels) { this->LabelFilter.clear(); - for(std::set<cmStdString>::const_iterator li = labels.begin(); + for(std::set<std::string>::const_iterator li = labels.begin(); li != labels.end(); ++li) { this->LabelFilter.insert(this->GetLabelId(*li)); @@ -2152,7 +2463,7 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles( { std::set<std::string> extraMatches; - for(std::vector<cmStdString>::iterator i = this->ExtraCoverageGlobs.begin(); + for(std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin(); i != this->ExtraCoverageGlobs.end(); ++i) { cmsys::Glob gl; diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 660f501..0a0fe81 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -55,7 +55,7 @@ public: void PopulateCustomVectors(cmMakefile *mf); /** Report coverage only for sources with these labels. */ - void SetLabelFilter(std::set<cmStdString> const& labels); + void SetLabelFilter(std::set<std::string> const& labels); private: bool ShouldIDoCoverage(const char* file, const char* srcDir, @@ -68,6 +68,10 @@ private: int HandleGCovCoverage(cmCTestCoverageHandlerContainer* cont); void FindGCovFiles(std::vector<std::string>& files); + //! Handle coverage using Intel's LCov + int HandleLCovCoverage(cmCTestCoverageHandlerContainer* cont); + void FindLCovFiles(std::vector<std::string>& files); + //! Handle coverage using xdebug php coverage int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont); @@ -81,7 +85,7 @@ private: int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont); int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont); int RunBullseyeCoverageBranch(cmCTestCoverageHandlerContainer* cont, - std::set<cmStdString>& coveredFileNames, + std::set<std::string>& coveredFileNames, std::vector<std::string>& files, std::vector<std::string>& filesFullPath); @@ -112,19 +116,19 @@ private: std::set<std::string> FindUncoveredFiles( cmCTestCoverageHandlerContainer* cont); - std::vector<cmStdString> CustomCoverageExclude; + std::vector<std::string> CustomCoverageExclude; std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex; - std::vector<cmStdString> ExtraCoverageGlobs; + std::vector<std::string> ExtraCoverageGlobs; // Map from source file to label ids. class LabelSet: public std::set<int> {}; - typedef std::map<cmStdString, LabelSet> LabelMapType; + typedef std::map<std::string, LabelSet> LabelMapType; LabelMapType SourceLabels; LabelMapType TargetDirs; // Map from label name to label id. - typedef std::map<cmStdString, int> LabelIdMapType; + typedef std::map<std::string, int> LabelIdMapType; LabelIdMapType LabelIdMap; std::vector<std::string> Labels; int GetLabelId(std::string const& label); diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx index abc33de..5ddef01 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx @@ -25,8 +25,8 @@ bool cmCTestEmptyBinaryDirectoryCommand if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) ) { cmOStringStream ostr; - ostr << "problem removing the binary directory: " << args[0].c_str(); - this->SetError(ostr.str().c_str()); + ostr << "problem removing the binary directory: " << args[0]; + this->SetError(ostr.str()); return false; } diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index 07e59a4..d182d17 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_empty_binary_directory";} + virtual std::string GetName() const { return "ctest_empty_binary_directory";} cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 0e0e797..aaa01b2 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -179,8 +179,8 @@ bool cmCTestGIT::UpdateByFetchAndReset() { opts = this->CTest->GetCTestConfiguration("GITUpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { git_fetch.push_back(ai->c_str()); diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 5338f30..2df2229 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -30,12 +30,8 @@ cmCTestGenericHandler::~cmCTestGenericHandler() } //---------------------------------------------------------------------- -void cmCTestGenericHandler::SetOption(const char* op, const char* value) +void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) { - if ( !op ) - { - return; - } if ( !value ) { cmCTestGenericHandler::t_StringToString::iterator remit @@ -51,14 +47,10 @@ void cmCTestGenericHandler::SetOption(const char* op, const char* value) } //---------------------------------------------------------------------- -void cmCTestGenericHandler::SetPersistentOption(const char* op, +void cmCTestGenericHandler::SetPersistentOption(const std::string& op, const char* value) { this->SetOption(op, value); - if ( !op ) - { - return; - } if ( !value ) { cmCTestGenericHandler::t_StringToString::iterator remit @@ -83,12 +75,12 @@ void cmCTestGenericHandler::Initialize() it != this->PersistentOptions.end(); ++ it ) { - this->Options[it->first.c_str()] = it->second.c_str(); + this->Options[it->first] = it->second.c_str(); } } //---------------------------------------------------------------------- -const char* cmCTestGenericHandler::GetOption(const char* op) +const char* cmCTestGenericHandler::GetOption(const std::string& op) { cmCTestGenericHandler::t_StringToString::iterator remit = this->Options.find(op); @@ -129,10 +121,10 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part, return false; } if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), - ostr.str().c_str(), xofs, true) ) + ostr.str(), xofs, true) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Cannot create resulting XML file: " << ostr.str().c_str() + "Cannot create resulting XML file: " << ostr.str() << std::endl); return false; } @@ -161,10 +153,10 @@ bool cmCTestGenericHandler::StartLogFile(const char* name, ostr << "_" << this->CTest->GetCurrentTag(); } ostr << ".log"; - if( !this->CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) ) + if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: " - << ostr.str().c_str() << std::endl); + << ostr.str() << std::endl); return false; } return true; diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index ba8febb..2788cba 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -71,12 +71,12 @@ public: cmCTestGenericHandler(); virtual ~cmCTestGenericHandler(); - typedef std::map<cmStdString,cmStdString> t_StringToString; + typedef std::map<std::string,std::string> t_StringToString; - void SetPersistentOption(const char* op, const char* value); - void SetOption(const char* op, const char* value); - const char* GetOption(const char* op); + void SetPersistentOption(const std::string& op, const char* value); + void SetOption(const std::string& op, const char* value); + const char* GetOption(const std::string& op); void SetCommand(cmCTestCommand* command) { diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx index 8c51102..5f570b5 100644 --- a/Source/CTest/cmCTestGlobalVC.cxx +++ b/Source/CTest/cmCTestGlobalVC.cxx @@ -132,7 +132,7 @@ bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml) this->WriteXMLGlobal(xml); - for(std::map<cmStdString, Directory>::const_iterator + for(std::map<std::string, Directory>::const_iterator di = this->Dirs.begin(); di != this->Dirs.end(); ++di) { this->WriteXMLDirectory(xml, di->first, di->second); diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h index a648a59..cb0d165 100644 --- a/Source/CTest/cmCTestGlobalVC.h +++ b/Source/CTest/cmCTestGlobalVC.h @@ -39,8 +39,8 @@ protected: }; // Update status for files in each directory. - class Directory: public std::map<cmStdString, File> {}; - std::map<cmStdString, Directory> Dirs; + class Directory: public std::map<std::string, File> {}; + std::map<std::string, Directory> Dirs; // Old and new repository revisions. std::string OldRevision; diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 86a7617..0f79d68 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -149,8 +149,8 @@ bool cmCTestHG::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("HGUpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { hg_update.push_back(ai->c_str()); @@ -189,10 +189,10 @@ private: return true; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CData.clear(); - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->Rev = Revision(); if(const char* rev = this->FindAttribute(atts, "revision")) @@ -208,29 +208,29 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->HG->DoRevision(this->Rev, this->Changes); } - else if(strcmp(name, "author") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "author") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); } - else if ( strcmp(name, "email") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "email") { this->Rev.EMail.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "date") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "date") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "msg") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "msg") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "files") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "files") { std::vector<std::string> paths = this->SplitCData(); for(unsigned int i = 0; i < paths.size(); ++i) @@ -242,7 +242,7 @@ private: this->Changes.push_back(this->CurChange); } } - else if(strcmp(name, "file_adds") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "file_adds") { std::string added_paths(this->CData.begin(), this->CData.end()); for(unsigned int i = 0; i < this->Changes.size(); ++i) @@ -253,7 +253,7 @@ private: } } } - else if(strcmp(name, "file_dels") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "file_dels") { std::string added_paths(this->CData.begin(), this->CData.end()); for(unsigned int i = 0; i < this->Changes.size(); ++i) diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 2e2feb0..0e29160 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -48,7 +48,7 @@ bool cmCTestHandlerCommand { cmOStringStream e; e << "called with unknown argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index cd3bd57..10a5199 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -567,7 +567,7 @@ void cmCTestLaunch::WriteXMLLabels(std::ostream& fxml) fxml << "\n"; fxml << "\t\t<!-- Interested parties -->\n"; fxml << "\t\t<Labels>\n"; - for(std::set<cmStdString>::const_iterator li = this->Labels.begin(); + for(std::set<std::string>::const_iterator li = this->Labels.begin(); li != this->Labels.end(); ++li) { fxml << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n"; @@ -680,8 +680,8 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname) continue; } - if(this->Match(line.c_str(), this->RegexWarning) && - !this->Match(line.c_str(), this->RegexWarningSuppress)) + if(this->Match(line, this->RegexWarning) && + !this->Match(line, this->RegexWarningSuppress)) { return true; } diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index f680d19..bc90d28 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -73,7 +73,7 @@ private: bool HaveErr; // Labels associated with the build rule. - std::set<cmStdString> Labels; + std::set<std::string> Labels; void LoadLabels(); bool SourceMatches(std::string const& lhs, std::string const& rhs); diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index b50170d..e239d46 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_memcheck";} + virtual std::string GetName() const { return "ctest_memcheck";} cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index fdce04d..ecaa474 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -49,21 +49,15 @@ class cmBoundsCheckerParser : public cmXMLParser { public: cmBoundsCheckerParser(cmCTest* c) { this->CTest = c;} - void StartElement(const char* name, const char** atts) + void StartElement(const std::string& name, const char** atts) { - if(strcmp(name, "MemoryLeak") == 0) + if(name == "MemoryLeak" || + name == "ResourceLeak") { this->Errors.push_back(cmCTestMemCheckHandler::MLK); } - if(strcmp(name, "ResourceLeak") == 0) - { - this->Errors.push_back(cmCTestMemCheckHandler::MLK); - } - if(strcmp(name, "Error") == 0) - { - this->ParseError(atts); - } - if(strcmp(name, "Dangling Pointer") == 0) + else if(name == "Error" || + name == "Dangling Pointer") { this->ParseError(atts); } @@ -79,7 +73,7 @@ public: ostr << "\n"; this->Log += ostr.str(); } - void EndElement(const char* ) + void EndElement(const std::string& ) { } @@ -246,8 +240,8 @@ int cmCTestMemCheckHandler::PostProcessHandler() void cmCTestMemCheckHandler::GenerateTestCommand( std::vector<std::string>& args, int test) { - std::vector<cmStdString>::size_type pp; - cmStdString index; + std::vector<std::string>::size_type pp; + std::string index; cmOStringStream stream; std::string memcheckcommand = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str()); @@ -255,9 +249,9 @@ void cmCTestMemCheckHandler::GenerateTestCommand( index = stream.str(); for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ ) { - cmStdString arg = this->MemoryTesterDynamicOptions[pp]; - cmStdString::size_type pos = arg.find("??"); - if (pos != cmStdString::npos) + std::string arg = this->MemoryTesterDynamicOptions[pp]; + std::string::size_type pos = arg.find("??"); + if (pos != std::string::npos) { arg.replace(pos, 2, index); } @@ -520,7 +514,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find memory checker suppression file: " << this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str() << std::endl); + "MemoryCheckSuppressionFile") << std::endl); return false; } std::string suppressions = "--suppressions=" @@ -575,12 +569,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() } default: cmCTestLog(this->CTest, ERROR_MESSAGE, - "Do not understand memory checker: " << this->MemoryTester.c_str() + "Do not understand memory checker: " << this->MemoryTester << std::endl); return false; } - std::vector<cmStdString>::size_type cc; + std::vector<std::string>::size_type cc; for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) { this->MemoryTesterGlobalResults[cc] = 0; @@ -627,7 +621,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( const std::string& str, std::string& log, int* results) { - std::vector<cmStdString> lines; + std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); cmOStringStream ostr; log = ""; @@ -636,7 +630,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( int defects = 0; - for( std::vector<cmStdString>::iterator i = lines.begin(); + for( std::vector<std::string>::iterator i = lines.begin(); i != lines.end(); ++i) { int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT; @@ -681,7 +675,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( const std::string& str, std::string& log, int* results) { - std::vector<cmStdString> lines; + std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); bool unlimitedOutput = false; if(str.find("CTEST_FULL_OUTPUT") != str.npos || @@ -864,10 +858,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( { log = ""; double sttime = cmSystemTools::GetTime(); - std::vector<cmStdString> lines; + std::vector<std::string> lines; cmSystemTools::Split(str.c_str(), lines); cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl); - std::vector<cmStdString>::size_type cc; + std::vector<std::string>::size_type cc; for ( cc = 0; cc < lines.size(); cc ++ ) { if(lines[cc] == BOUNDS_CHECKER_MARKER) @@ -891,7 +885,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( else if(!parser.ParseChunk(theLine.c_str(), theLine.size())) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Error in ParseChunk: " << theLine.c_str() + "Error in ParseChunk: " << theLine << std::endl); } } @@ -922,8 +916,8 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessBoundsCheckerTest for : " - << res.Name.c_str() << std::endl); - cmStdString ofile = testOutputFileName(test); + << res.Name << std::endl); + std::string ofile = testOutputFileName(test); if ( ofile.empty() ) { return; @@ -949,10 +943,10 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, cmSystemTools::Delay(1000); cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " - << this->BoundsCheckerDPBDFile.c_str() << std::endl); + << this->BoundsCheckerDPBDFile << std::endl); cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " - << this->BoundsCheckerXMLFile.c_str() << std::endl); + << this->BoundsCheckerXMLFile << std::endl); } void @@ -961,7 +955,7 @@ cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessPurifyTest for : " - << res.Name.c_str() << std::endl); + << res.Name << std::endl); appendMemTesterOutput(res, test); } @@ -971,7 +965,7 @@ cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res, { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "PostProcessValgrindTest for : " - << res.Name.c_str() << std::endl); + << res.Name << std::endl); appendMemTesterOutput(res, test); } @@ -979,7 +973,7 @@ void cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, int test) { - cmStdString ofile = testOutputFileName(test); + std::string ofile = testOutputFileName(test); if ( ofile.empty() ) { @@ -1000,15 +994,15 @@ cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, } } -cmStdString +std::string cmCTestMemCheckHandler::testOutputFileName(int test) { - cmStdString index; + std::string index; cmOStringStream stream; stream << test; index = stream.str(); - cmStdString ofile = this->MemoryTesterOutputFile; - cmStdString::size_type pos = ofile.find("??"); + std::string ofile = this->MemoryTesterOutputFile; + std::string::size_type pos = ofile.find("??"); ofile.replace(pos, 2, index); if ( !cmSystemTools::FileExists(ofile.c_str()) ) diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 040d2e0..0521a48 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -89,8 +89,8 @@ private: std::string BoundsCheckerDPBDFile; std::string BoundsCheckerXMLFile; std::string MemoryTester; - std::vector<cmStdString> MemoryTesterDynamicOptions; - std::vector<cmStdString> MemoryTesterOptions; + std::vector<std::string> MemoryTesterDynamicOptions; + std::vector<std::string> MemoryTesterOptions; int MemoryTesterStyle; std::string MemoryTesterOutputFile; int MemoryTesterGlobalResults[NO_MEMORY_FAULT]; @@ -103,8 +103,8 @@ private: */ void GenerateDartOutput(std::ostream& os); - std::vector<cmStdString> CustomPreMemCheck; - std::vector<cmStdString> CustomPostMemCheck; + std::vector<std::string> CustomPreMemCheck; + std::vector<std::string> CustomPostMemCheck; //! Parse Valgrind/Purify/Bounds Checker result out of the output //string. After running, log holds the output and results hold the @@ -127,7 +127,7 @@ private: int test); ///! generate the output filename for the given test index - cmStdString testOutputFileName(int test); + std::string testOutputFileName(int test); }; #endif diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index ddd1707..b9e6721 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -369,7 +369,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() // Write list of failed tests fout << "---\n"; - for(std::vector<cmStdString>::iterator i = this->Failed->begin(); + for(std::vector<std::string>::iterator i = this->Failed->begin(); i != this->Failed->end(); ++i) { fout << i->c_str() << "\n"; @@ -672,7 +672,7 @@ void cmCTestMultiProcessHandler::PrintTestList() indexStr << " #" << p.Index << ":"; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex())) - << indexStr.str().c_str()); + << indexStr.str()); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl); //pop working dir diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index 1b53ec7..605de31 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -41,8 +41,8 @@ public: void PrintTestList(); void PrintLabels(); - void SetPassFailVectors(std::vector<cmStdString>* passed, - std::vector<cmStdString>* failed) + void SetPassFailVectors(std::vector<std::string>* passed, + std::vector<std::string>* failed) { this->Passed = passed; this->Failed = failed; @@ -107,9 +107,9 @@ protected: PropertiesMap Properties; std::map<int, bool> TestRunningMap; std::map<int, bool> TestFinishMap; - std::map<int, cmStdString> TestOutput; - std::vector<cmStdString>* Passed; - std::vector<cmStdString>* Failed; + std::map<int, std::string> TestOutput; + std::vector<std::string>* Passed; + std::vector<std::string>* Failed; std::vector<std::string> LastTestsFailed; std::set<std::string> LockedResources; std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index b09d6f5..0bb1a99 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -346,13 +346,13 @@ void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions) //The CTEST_P4_OPTIONS variable adds additional Perforce command line //options before the main command std::string opts = this->CTest->GetCTestConfiguration("P4Options"); - std::vector<cmStdString> args = + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { - P4Options.push_back(ai->c_str()); + P4Options.push_back(*ai); } } @@ -538,8 +538,8 @@ bool cmCTestP4::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { p4_sync.push_back(ai->c_str()); diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index 9c0af81..c95694a 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_read_custom_files";} + virtual std::string GetName() const { return "ctest_read_custom_files";} cmTypeMacro(cmCTestReadCustomFilesCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx index fe429bd..bdf9b9c 100644 --- a/Source/CTest/cmCTestRunScriptCommand.cxx +++ b/Source/CTest/cmCTestRunScriptCommand.cxx @@ -56,7 +56,7 @@ bool cmCTestRunScriptCommand &ret); cmOStringStream str; str << ret; - this->Makefile->AddDefinition(returnVariable.c_str(), str.str().c_str()); + this->Makefile->AddDefinition(returnVariable, str.str().c_str()); } } return true; diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index f34bd13..0998e5c 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -47,7 +47,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_run_script";} + virtual std::string GetName() const { return "ctest_run_script";} cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand); }; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index cdf90b9..385388d 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -334,9 +334,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) *this->TestHandler->LogFile << "Test Failed.\n"; } } - *this->TestHandler->LogFile << "\"" << this->TestProperties->Name.c_str() + *this->TestHandler->LogFile << "\"" << this->TestProperties->Name << "\" end time: " << this->CTest->CurrentTime() << std::endl - << "\"" << this->TestProperties->Name.c_str() << "\" time elapsed: " + << "\"" << this->TestProperties->Name << "\" time elapsed: " << buffer << std::endl << "----------------------------------------------------------" << std::endl << std::endl; @@ -388,8 +388,8 @@ void cmCTestRunTest::MemCheckPostProcess() } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": process test output now: " - << this->TestProperties->Name.c_str() << " " - << this->TestResult.Name.c_str() << std::endl); + << this->TestProperties->Name << " " + << this->TestResult.Name << std::endl); cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*> (this->TestHandler); switch ( handler->MemoryTesterStyle ) @@ -465,9 +465,9 @@ bool cmCTestRunTest::StartTest(size_t total) //Required file was not found this->TestProcess = new cmProcess; *this->TestHandler->LogFile << "Unable to find required file: " - << file.c_str() << std::endl; + << file << std::endl; cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: " - << file.c_str() << std::endl); + << file << std::endl); this->TestResult.Output = "Unable to find required file: " + file; this->TestResult.FullCommandLine = ""; this->TestResult.CompletionStatus = "Not Run"; @@ -482,9 +482,9 @@ bool cmCTestRunTest::StartTest(size_t total) // that has that information this->TestProcess = new cmProcess; *this->TestHandler->LogFile << "Unable to find executable: " - << args[1].c_str() << std::endl; + << args[1] << std::endl; cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: " - << args[1].c_str() << std::endl); + << args[1] << std::endl); this->TestResult.Output = "Unable to find executable: " + args[1]; this->TestResult.FullCommandLine = ""; this->TestResult.CompletionStatus = "Not Run"; @@ -711,7 +711,7 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) indexStr << " #" << this->Index << ":"; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex())) - << indexStr.str().c_str()); + << indexStr.str()); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth(); std::string outname = this->TestProperties->Name + " "; @@ -722,18 +722,18 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) << this->TestProperties->Name << std::endl; *this->TestHandler->LogFile << this->TestProperties->Index << "/" << this->TestHandler->TotalNumberOfTests - << " Test: " << this->TestProperties->Name.c_str() << std::endl; + << " Test: " << this->TestProperties->Name << std::endl; *this->TestHandler->LogFile << "Command: \"" << this->ActualCommand << "\""; for (std::vector<std::string>::iterator i = this->Arguments.begin(); i != this->Arguments.end(); ++i) { *this->TestHandler->LogFile - << " \"" << i->c_str() << "\""; + << " \"" << *i << "\""; } *this->TestHandler->LogFile << std::endl << "Directory: " << this->TestProperties->Directory << std::endl - << "\"" << this->TestProperties->Name.c_str() << "\" start time: " + << "\"" << this->TestProperties->Name << "\" start time: " << this->StartTime << std::endl; *this->TestHandler->LogFile @@ -741,9 +741,9 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total) << "----------------------------------------------------------" << std::endl; *this->TestHandler->LogFile - << this->ProcessOutput.c_str() << "<end of output>" << std::endl; + << this->ProcessOutput << "<end of output>" << std::endl; cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str()); cmCTestLog(this->CTest, DEBUG, "Testing " - << this->TestProperties->Name.c_str() << " ... "); + << this->TestProperties->Name << " ... "); } diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 2668c8e..86dc2f2 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -277,7 +277,7 @@ bool cmCTestSVN::UpdateImpl() { opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions"); } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); + std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); // Specify the start time for nightly testing. if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) @@ -287,7 +287,7 @@ bool cmCTestSVN::UpdateImpl() std::vector<char const*> svn_update; svn_update.push_back("update"); - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { svn_update.push_back(ai->c_str()); @@ -314,9 +314,9 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions"); - std::vector<cmStdString> parsedUserOptions = + std::vector<std::string> parsedUserOptions = cmSystemTools::ParseArguments(userOptions.c_str()); - for(std::vector<cmStdString>::iterator i = parsedUserOptions.begin(); + for(std::vector<std::string>::iterator i = parsedUserOptions.begin(); i != parsedUserOptions.end(); ++i) { args.push_back(i->c_str()); @@ -361,10 +361,10 @@ private: return true; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CData.clear(); - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->Rev = Revision(); this->Rev.SVNInfo = &SVNRepo; @@ -374,7 +374,7 @@ private: } this->Changes.clear(); } - else if(strcmp(name, "path") == 0) + else if(name == "path") { this->CurChange = Change(); if(const char* action = this->FindAttribute(atts, "action")) @@ -389,28 +389,28 @@ private: this->CData.insert(this->CData.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "logentry") == 0) + if(name == "logentry") { this->SVN->DoRevisionSVN(this->Rev, this->Changes); } - else if(strcmp(name, "path") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "path") { std::string orig_path(&this->CData[0], this->CData.size()); std::string new_path = SVNRepo.BuildLocalPath( orig_path ); this->CurChange.Path.assign(new_path); this->Changes.push_back(this->CurChange); } - else if(strcmp(name, "author") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "author") { this->Rev.Author.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "date") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "date") { this->Rev.Date.assign(&this->CData[0], this->CData.size()); } - else if(strcmp(name, "msg") == 0 && !this->CData.empty()) + else if(!this->CData.empty() && name == "msg") { this->Rev.Log.assign(&this->CData[0], this->CData.size()); } diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 00a0a09..567acfc 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -231,7 +231,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) cmSystemTools::GetCTestCommand() << "\n"); // now pass through all the other arguments - std::vector<cmStdString> &initArgs = + std::vector<std::string> &initArgs = this->CTest->GetInitialCommandLineArguments(); //*** need to make sure this does not have the current script *** for(size_t i=1; i < initArgs.size(); ++i) @@ -337,8 +337,8 @@ void cmCTestScriptHandler::CreateCMake() // Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR. // Also, some commands need Makefile->GetCurrentDirectory(). std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - this->Makefile->SetStartDirectory(cwd.c_str()); - this->Makefile->SetStartOutputDirectory(cwd.c_str()); + this->Makefile->SetStartDirectory(cwd); + this->Makefile->SetStartOutputDirectory(cwd); // remove all cmake commands which are not scriptable, since they can't be // used in ctest scripts @@ -426,7 +426,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" - << systemFile.c_str() << "\n"); + << systemFile << "\n"); return 2; } @@ -436,7 +436,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) for (std::map<std::string, std::string>::const_iterator it = defs.begin(); it != defs.end(); ++it) { - this->Makefile->AddDefinition(it->first.c_str(), it->second.c_str()); + this->Makefile->AddDefinition(it->first, it->second.c_str()); } // finally read in the script @@ -444,7 +444,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmSystemTools::GetErrorOccuredFlag()) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: " - << script.c_str() + << script << std::endl); // Reset the error flag so that it can run more than // one script with an error when you @@ -646,7 +646,7 @@ int cmCTestScriptHandler::RunCurrentScript() if (!this->CTestEnv.empty()) { std::vector<std::string> envArgs; - cmSystemTools::ExpandListArgument(this->CTestEnv.c_str(),envArgs); + cmSystemTools::ExpandListArgument(this->CTestEnv,envArgs); cmSystemTools::AppendEnv(envArgs); } @@ -766,13 +766,13 @@ int cmCTestScriptHandler::PerformExtraUpdates() // do an initial cvs update as required command = this->UpdateCmd; - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for (it = this->ExtraUpdates.begin(); it != this->ExtraUpdates.end(); ++ it ) { std::vector<std::string> cvsArgs; - cmSystemTools::ExpandListArgument(it->c_str(),cvsArgs); + cmSystemTools::ExpandListArgument(*it,cvsArgs); if (cvsArgs.size() == 2) { std::string fullCommand = command; @@ -781,7 +781,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() output = ""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: " - << fullCommand.c_str() << std::endl); + << fullCommand << std::endl); res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, &retVal, cvsArgs[0].c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -902,7 +902,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() command += "\""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " - << command.c_str() << std::endl); + << command << std::endl); res = cmSystemTools::RunSingleCommand(command.c_str(), &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -916,7 +916,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Write CMake output to file: " << cmakeOutputFile.c_str() + "Write CMake output to file: " << cmakeOutputFile << std::endl); cmGeneratedFileStream fout(cmakeOutputFile.c_str()); if ( fout ) @@ -927,7 +927,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open CMake output file: " - << cmakeOutputFile.c_str() << " for writing" << std::endl); + << cmakeOutputFile << " for writing" << std::endl); } } if (!res || retVal != 0) @@ -948,7 +948,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() output = ""; retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " - << command.c_str() << std::endl); + << command << std::endl); res = cmSystemTools::RunSingleCommand(command.c_str(), &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -962,13 +962,13 @@ int cmCTestScriptHandler::RunConfigurationDashboard() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to run cmake:" << std::endl - << cmakeFailedOuput.c_str() << std::endl); + << cmakeFailedOuput << std::endl); return 10; } cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to run ctest:" << std::endl - << "command: " << command.c_str() << std::endl - << "output: " << output.c_str() << std::endl); + << "command: " << command << std::endl + << "output: " << output << std::endl); if (!res) { return 11; diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 44e9dd0..42c2f20 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -138,26 +138,26 @@ private: // Try to remove the binary directory once static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath); - std::vector<cmStdString> ConfigurationScripts; + std::vector<std::string> ConfigurationScripts; std::vector<bool> ScriptProcessScope; bool Backup; bool EmptyBinDir; bool EmptyBinDirOnce; - cmStdString SourceDir; - cmStdString BinaryDir; - cmStdString BackupSourceDir; - cmStdString BackupBinaryDir; - cmStdString CTestRoot; - cmStdString CVSCheckOut; - cmStdString CTestCmd; - cmStdString UpdateCmd; - cmStdString CTestEnv; - cmStdString InitialCache; - cmStdString CMakeCmd; - cmStdString CMOutFile; - std::vector<cmStdString> ExtraUpdates; + std::string SourceDir; + std::string BinaryDir; + std::string BackupSourceDir; + std::string BackupBinaryDir; + std::string CTestRoot; + std::string CVSCheckOut; + std::string CTestCmd; + std::string UpdateCmd; + std::string CTestEnv; + std::string InitialCache; + std::string CMakeCmd; + std::string CMOutFile; + std::vector<std::string> ExtraUpdates; double MinimumInterval; double ContinuousDuration; diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index c6baf1c..740a7e1 100644 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -47,7 +47,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_sleep";} + virtual std::string GetName() const { return "ctest_sleep";} cmTypeMacro(cmCTestSleepCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 228a173..da46f4a 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -131,7 +131,7 @@ bool cmCTestStartCommand << " " << sourceDir << "\n" << "which is not an existing directory. " << "Set CTEST_CHECKOUT_COMMAND to a command line to create it."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -160,7 +160,7 @@ bool cmCTestStartCommand::InitialCheckout( { // Use a generic VC object to run and log the command. cmCTestVC vc(this->CTest, ofs); - vc.SetSourceDirectory(sourceDir.c_str()); + vc.SetSourceDirectory(sourceDir); if(!vc.InitialCheckout(initialCheckoutCommand)) { return false; diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index e5535c1..3b8843f 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -55,7 +55,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_start";} + virtual std::string GetName() const { return "ctest_start";} cmTypeMacro(cmCTestStartCommand, cmCTestCommand); diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 24974e3..07a994d 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -72,7 +72,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() if (notesFilesVariable) { std::vector<std::string> notesFiles; - std::vector<cmStdString> newNotesFiles; + cmCTest::VectorOfStrings newNotesFiles; cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles); std::vector<std::string>::iterator it; for ( it = notesFiles.begin(); @@ -89,7 +89,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() if (extraFilesVariable) { std::vector<std::string> extraFiles; - std::vector<cmStdString> newExtraFiles; + cmCTest::VectorOfStrings newExtraFiles; cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles); std::vector<std::string>::iterator it; for ( it = extraFiles.begin(); @@ -222,7 +222,7 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg) if(this->ArgumentDoing == ArgumentDoingFiles) { - cmStdString filename(arg); + std::string filename(arg); if(cmSystemTools::FileExists(filename.c_str())) { this->Files.insert(filename); diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 64c6cae..3673fbd 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_submit";} + virtual std::string GetName() const { return "ctest_submit";} cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 139f515..7c72cba 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -68,10 +68,10 @@ private: return val; } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { this->CurrentValue.clear(); - if(strcmp(name, "cdash") == 0) + if(name == "cdash") { this->CDashVersion = this->FindAttribute(atts, "version"); } @@ -82,9 +82,9 @@ private: this->CurrentValue.insert(this->CurrentValue.end(), data, data+length); } - virtual void EndElement(const char* name) + virtual void EndElement(const std::string& name) { - if(strcmp(name, "status") == 0) + if(name == "status") { std::string status = cmSystemTools::UpperCase(this->GetCurrentValue()); if(status == "OK" || status == "SUCCESS") @@ -100,15 +100,15 @@ private: this->Status = STATUS_ERROR; } } - else if(strcmp(name, "filename") == 0) + else if(name == "filename") { this->Filename = this->GetCurrentValue(); } - else if(strcmp(name, "md5") == 0) + else if(name == "md5") { this->MD5 = this->GetCurrentValue(); } - else if(strcmp(name, "message") == 0) + else if(name == "message") { this->Message = this->GetCurrentValue(); } @@ -170,10 +170,10 @@ void cmCTestSubmitHandler::Initialize() } //---------------------------------------------------------------------------- -bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; CURLcode res; @@ -217,30 +217,30 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; } - cmStdString upload_as + std::string upload_as = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file); struct stat st; if ( ::stat(local_file.c_str(), &st) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; } ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); - *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " - << upload_as.c_str() << std::endl; + *this->LogFile << "\tUpload file: " << local_file << " to " + << upload_as << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " - << local_file.c_str() << " to " - << upload_as.c_str() << std::endl); + << local_file << " to " + << upload_as << std::endl); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); @@ -290,11 +290,11 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << " Error when uploading file: " - << local_file.c_str() + << local_file << std::endl << " Error message was: " << error_buffer << std::endl @@ -324,10 +324,10 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, //---------------------------------------------------------------------------- // Uploading files is simpler -bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; CURLcode res; @@ -336,10 +336,10 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, /* In windows, this will init the winsock stuff */ ::curl_global_init(CURL_GLOBAL_ALL); - cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); - cmStdString curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); + std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); + std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); std::vector<std::string> args; - cmSystemTools::ExpandListArgument(curlopt.c_str(), args); + cmSystemTools::ExpandListArgument(curlopt, args); bool verifyPeerOff = false; bool verifyHostOff = false; for( std::vector<std::string>::iterator i = args.begin(); @@ -354,7 +354,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, verifyHostOff = true; } } - cmStdString::size_type kk; + std::string::size_type kk; cmCTest::SetOfStrings::const_iterator file; for ( file = files.begin(); file != files.end(); ++file ) { @@ -414,18 +414,18 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ::curl_easy_setopt(curl, CURLOPT_PUT, 1); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; } - cmStdString remote_file + std::string remote_file = remoteprefix + cmSystemTools::GetFilenameName(*file); - *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " - << remote_file.c_str() << std::endl; + *this->LogFile << "\tUpload file: " << local_file << " to " + << remote_file << std::endl; - cmStdString ofile = ""; + std::string ofile = ""; for ( kk = 0; kk < remote_file.size(); kk ++ ) { char c = remote_file[kk]; @@ -448,8 +448,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ofile.append(hexCh); } } - cmStdString upload_as - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + std::string upload_as + = url + ((url.find("?",0) == std::string::npos) ? "?" : "&") + "FileName=" + ofile; upload_as += "&MD5="; @@ -461,7 +461,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, else { char md5[33]; - cmSystemTools::ComputeFileMD5(local_file.c_str(), md5); + cmSystemTools::ComputeFileMD5(local_file, md5); md5[32] = 0; upload_as += md5; } @@ -470,7 +470,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, if ( ::stat(local_file.c_str(), &st) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; @@ -478,8 +478,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " - << local_file.c_str() << " to " - << upload_as.c_str() << " Size: " << st.st_size << std::endl); + << local_file << " to " + << upload_as << " Size: " << st.st_size << std::endl); // specify target ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str()); @@ -595,11 +595,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: " - << local_file.c_str() << std::endl); + << local_file << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << " Error when uploading file: " - << local_file.c_str() + << local_file << std::endl << " Error message was: " << error_buffer << std::endl; @@ -666,9 +666,9 @@ void cmCTestSubmitHandler //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::TriggerUsingHTTP( - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { CURL *curl; char error_buffer[1024]; @@ -721,10 +721,10 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); - cmStdString rfile + std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file); - cmStdString ofile = ""; - cmStdString::iterator kk; + std::string ofile = ""; + std::string::iterator kk; for ( kk = rfile.begin(); kk < rfile.end(); ++ kk) { char c = *kk; @@ -747,18 +747,18 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( ofile.append(hexCh); } } - cmStdString turl - = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + std::string turl + = url + ((url.find("?",0) == std::string::npos) ? "?" : "&") + "xmlfile=" + ofile; - *this->LogFile << "Trigger url: " << turl.c_str() << std::endl; + *this->LogFile << "Trigger url: " << turl << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: " - << turl.c_str() << std::endl); + << turl << std::endl); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_easy_setopt(curl, CURLOPT_URL, turl.c_str()); if ( curl_easy_perform(curl) ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when triggering: " - << turl.c_str() << std::endl); + << turl << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << "\tTriggering failed with error: " << error_buffer @@ -805,11 +805,11 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingSCP( - const cmStdString& scp_command, - const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) + const std::string& scp_command, + const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { if ( !scp_command.size() || !localprefix.size() || !files.size() || !remoteprefix.size() || !url.size() ) @@ -906,10 +906,10 @@ bool cmCTestSubmitHandler::SubmitUsingSCP( //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingCP( - const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& destination) + const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& destination) { if ( !localprefix.size() || !files.size() || !remoteprefix.size() || !destination.size() ) @@ -932,8 +932,8 @@ bool cmCTestSubmitHandler::SubmitUsingCP( std::string rfname = destination + "/" + remoteprefix + *file; cmSystemTools::CopyFileAlways(lfname.c_str(), rfname.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: " - << lfname.c_str() << " to " - << rfname.c_str() << std::endl); + << lfname << " to " + << rfname << std::endl); } std::string tagDoneFile = destination + "/" + remoteprefix + "DONE"; cmSystemTools::Touch(tagDoneFile.c_str(), true); @@ -947,17 +947,17 @@ bool cmCTestSubmitHandler::SubmitUsingCP( //---------------------------------------------------------------------------- #if defined(CTEST_USE_XMLRPC) -bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url) +bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url) { xmlrpc_env env; char ctestString[] = "CTest"; std::string ctestVersionString = cmVersion::GetCMakeVersion(); char* ctestVersion = const_cast<char*>(ctestVersionString.c_str()); - cmStdString realURL = url + "/" + remoteprefix + "/Command/"; + std::string realURL = url + "/" + remoteprefix + "/Command/"; /* Start up our XML-RPC client library. */ xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion); @@ -973,7 +973,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, { xmlrpc_value *result; - cmStdString local_file = *file; + std::string local_file = *file; if ( !cmSystemTools::FileExists(local_file.c_str()) ) { local_file = localprefix + "/" + *file; @@ -1045,10 +1045,10 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, return true; } #else -bool cmCTestSubmitHandler::SubmitUsingXMLRPC(cmStdString const&, - std::set<cmStdString> const&, - cmStdString const&, - cmStdString const&) +bool cmCTestSubmitHandler::SubmitUsingXMLRPC(std::string const&, + std::set<std::string> const&, + std::string const&, + std::string const&) { return false; } @@ -1085,7 +1085,7 @@ int cmCTestSubmitHandler::ProcessHandler() } if ( getenv("HTTP_PROXY_TYPE") ) { - cmStdString type = getenv("HTTP_PROXY_TYPE"); + std::string type = getenv("HTTP_PROXY_TYPE"); // HTTP/SOCKS4/SOCKS5 if ( type == "HTTP" ) { @@ -1122,7 +1122,7 @@ int cmCTestSubmitHandler::ProcessHandler() } if ( getenv("FTP_PROXY_TYPE") ) { - cmStdString type = getenv("FTP_PROXY_TYPE"); + std::string type = getenv("FTP_PROXY_TYPE"); // HTTP/SOCKS4/SOCKS5 if ( type == "HTTP" ) { @@ -1178,12 +1178,12 @@ int cmCTestSubmitHandler::ProcessHandler() this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml"); if(this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml")) { - cmCTest::VectorOfStrings gfiles; + std::vector<std::string> gfiles; std::string gpath = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag(); std::string::size_type glen = gpath.size() + 1; gpath = gpath + "/CoverageLog*"; - cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath.c_str() + cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath << std::endl); if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) ) { @@ -1191,7 +1191,7 @@ int cmCTestSubmitHandler::ProcessHandler() for ( cc = 0; cc < gfiles.size(); cc ++ ) { gfiles[cc] = gfiles[cc].substr(glen); - cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc].c_str() + cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc] << std::endl); this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str()); } @@ -1232,7 +1232,7 @@ int cmCTestSubmitHandler::ProcessHandler() cmCTest::SetOfStrings::iterator it; for ( it = files.begin(); it != files.end(); ++ it ) { - ofs << cnt << "\t" << it->c_str() << std::endl; + ofs << cnt << "\t" << *it << std::endl; cnt ++; } } @@ -1247,7 +1247,7 @@ int cmCTestSubmitHandler::ProcessHandler() } this->SetLogFile(&ofs); - cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); + std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod")); if ( dropMethod == "" || dropMethod == "ftp" ) { @@ -1448,7 +1448,7 @@ int cmCTestSubmitHandler::ProcessHandler() oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ChangeDirectory(buildDirectory.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Change directory: " - << buildDirectory.c_str() << std::endl); + << buildDirectory << std::endl); if ( !this->SubmitUsingCP( "Testing/"+this->CTest->GetCurrentTag(), diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 14eac80..accabd1 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -47,33 +47,33 @@ private: /** * Submit file using various ways */ - bool SubmitUsingFTP(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - bool SubmitUsingHTTP(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - bool SubmitUsingSCP(const cmStdString& scp_command, - const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool SubmitUsingCP( const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool TriggerUsingHTTP(const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); - - bool SubmitUsingXMLRPC(const cmStdString& localprefix, - const std::set<cmStdString>& files, - const cmStdString& remoteprefix, - const cmStdString& url); + bool SubmitUsingFTP(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + bool SubmitUsingHTTP(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + bool SubmitUsingSCP(const std::string& scp_command, + const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + + bool SubmitUsingCP( const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + + bool TriggerUsingHTTP(const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); + + bool SubmitUsingXMLRPC(const std::string& localprefix, + const std::set<std::string>& files, + const std::string& remoteprefix, + const std::string& url); typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar; @@ -82,10 +82,10 @@ private: std::string GetSubmitResultsPrefix(); class ResponseParser; - cmStdString HTTPProxy; + std::string HTTPProxy; int HTTPProxyType; - cmStdString HTTPProxyAuth; - cmStdString FTPProxy; + std::string HTTPProxyAuth; + std::string FTPProxy; int FTPProxyType; std::ostream* LogFile; bool SubmitPart[cmCTest::PartCount]; diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index 451ac99..a1e5f36 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_test";} + virtual std::string GetName() const { return "ctest_test";} cmTypeMacro(cmCTestTestCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3a04b33..1d1dde4 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -60,7 +60,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "subdirs";} + virtual std::string GetName() const { return "subdirs";} cmTypeMacro(cmCTestSubdirCommand, cmCommand); @@ -125,7 +125,7 @@ bool cmCTestSubdirCommand { std::string m = "Could not find include file: "; m += fname; - this->SetError(m.c_str()); + this->SetError(m); return false; } } @@ -157,7 +157,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_subdirectory";} + virtual std::string GetName() const { return "add_subdirectory";} cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand); @@ -213,7 +213,7 @@ bool cmCTestAddSubdirectoryCommand { std::string m = "Could not find include file: "; m += fname; - this->SetError(m.c_str()); + this->SetError(m); return false; } return true; @@ -243,7 +243,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_test";} + virtual std::string GetName() const { return "add_test";} cmTypeMacro(cmCTestAddTestCommand, cmCommand); @@ -287,7 +287,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_tests_properties";} + virtual std::string GetName() const { return "set_tests_properties";} cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand); @@ -540,8 +540,8 @@ int cmCTestTestHandler::ProcessHandler() this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile); this->LogFile = &mLogFile; - std::vector<cmStdString> passed; - std::vector<cmStdString> failed; + std::vector<std::string> passed; + std::vector<std::string> failed; int total; //start the real time clock @@ -569,7 +569,7 @@ int cmCTestTestHandler::ProcessHandler() { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl << "The following tests passed:" << std::endl); - for(std::vector<cmStdString>::iterator j = passed.begin(); + for(std::vector<std::string>::iterator j = passed.begin(); j != passed.end(); ++j) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j @@ -616,7 +616,7 @@ int cmCTestTestHandler::ProcessHandler() ofs << ftit->TestCount << ":" << ftit->Name << std::endl; cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3) << ftit->TestCount << " - " - << ftit->Name.c_str() << " (" + << ftit->Name << " (" << this->GetTestStatus(ftit->Status) << ")" << std::endl); } @@ -661,8 +661,8 @@ void cmCTestTestHandler::PrintLabelSummary() cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin(); cmCTestTestHandler::TestResultsVector::iterator ri = this->TestResults.begin(); - std::map<cmStdString, double> labelTimes; - std::set<cmStdString> labels; + std::map<std::string, double> labelTimes; + std::set<std::string> labels; // initialize maps std::string::size_type maxlen = 0; for(; it != this->TestList.end(); ++it) @@ -702,7 +702,7 @@ void cmCTestTestHandler::PrintLabelSummary() { cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:"); } - for(std::set<cmStdString>::const_iterator i = labels.begin(); + for(std::set<std::string>::const_iterator i = labels.begin(); i != labels.end(); ++i) { std::string label = *i; @@ -1022,7 +1022,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, { cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: " - << tag << " found [" << line.c_str() << "]" << std::endl); + << tag << " found [" << line << "]" << std::endl); ret = false; } return ret; @@ -1050,8 +1050,8 @@ bool cmCTestTestHandler::GetValue(const char* tag, } //--------------------------------------------------------------------- -void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed, - std::vector<cmStdString> &failed) +void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed, + std::vector<std::string> &failed) { this->ComputeTestList(); this->StartTest = this->CTest->CurrentTime(); @@ -1216,14 +1216,14 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) << "name=\"Command Line\"><Value>" << cmXMLSafe(result->FullCommandLine) << "</Value></NamedMeasurement>\n"; - std::map<cmStdString,cmStdString>::iterator measureIt; + std::map<std::string,std::string>::iterator measureIt; for ( measureIt = result->Properties->Measurements.begin(); measureIt != result->Properties->Measurements.end(); ++ measureIt ) { os << "\t\t\t<NamedMeasurement type=\"text/string\" " - << "name=\"" << measureIt->first.c_str() << "\"><Value>" + << "name=\"" << measureIt->first << "\"><Value>" << cmXMLSafe(measureIt->second) << "</Value></NamedMeasurement>\n"; } @@ -1328,9 +1328,9 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os, } //---------------------------------------------------------------------- -int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec) +int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec) { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for ( it = vec.begin(); it != vec.end(); ++it ) { int retVal = 0; @@ -1506,7 +1506,7 @@ std::string cmCTestTestHandler // then try with the exe extension else { - failed.push_back(attempted[ai].c_str()); + failed.push_back(attempted[ai]); tempPath = attempted[ai]; tempPath += cmSystemTools::GetExecutableExtension(); if(cmSystemTools::FileExists(tempPath.c_str()) @@ -1517,7 +1517,7 @@ std::string cmCTestTestHandler } else { - failed.push_back(tempPath.c_str()); + failed.push_back(tempPath); } } } @@ -1820,7 +1820,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() else if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: " - << lastTestsFailedLog.c_str() << + << lastTestsFailedLog << " while generating list of previously failed tests." << std::endl); } } @@ -1960,7 +1960,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages( << " " << k1 << "=\"" << v1 << "\"" << " " << k2 << "=\"" << v2 << "\"" << " encoding=\"none\"" - << "><Value>Image " << filename.c_str() + << "><Value>Image " << filename << " is empty</Value></NamedMeasurement>"; } else @@ -2014,10 +2014,10 @@ std::string cmCTestTestHandler::GenerateRegressionImages( << "\t\t\t<NamedMeasurement" << " name=\"" << measurementfile.match(idx) << "\"" << " text=\"text/string\"" - << "><Value>File " << filename.c_str() + << "><Value>File " << filename << " not found</Value></NamedMeasurement>" << std::endl; - cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename.c_str() + cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename << "\" not found." << std::endl); } cxml.erase(measurementfile.start(), @@ -2112,7 +2112,7 @@ bool cmCTestTestHandler::SetTestsProperties( const std::vector<std::string>& args) { std::vector<std::string>::const_iterator it; - std::vector<cmStdString> tests; + std::vector<std::string> tests; bool found = false; for ( it = args.begin(); it != args.end(); ++ it ) { @@ -2137,7 +2137,7 @@ bool cmCTestTestHandler::SetTestsProperties( break; } std::string val = *it; - std::vector<cmStdString>::const_iterator tit; + std::vector<std::string>::const_iterator tit; for ( tit = tests.begin(); tit != tests.end(); ++ tit ) { cmCTestTestHandler::ListOfTests::iterator rtit; @@ -2154,7 +2154,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ATTACHED_FILES" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector<std::string>::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2165,7 +2165,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ATTACHED_FILES_ON_FAIL" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector<std::string>::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2176,7 +2176,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "RESOURCE_LOCK" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector<std::string>::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2196,7 +2196,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "REQUIRED_FILES" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); for(std::vector<std::string>::iterator f = lval.begin(); f != lval.end(); ++f) @@ -2211,14 +2211,14 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "FAIL_REGULAR_EXPRESSION" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { rtit->ErrorRegularExpressions.push_back( std::pair<cmsys::RegularExpression, std::string>( cmsys::RegularExpression(crit->c_str()), - std::string(crit->c_str()))); + std::string(*crit))); } } if ( key == "PROCESSORS" ) @@ -2240,7 +2240,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "DEPENDS" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2250,7 +2250,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "ENVIRONMENT" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2260,7 +2260,7 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "LABELS" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { @@ -2284,14 +2284,14 @@ bool cmCTestTestHandler::SetTestsProperties( if ( key == "PASS_REGULAR_EXPRESSION" ) { std::vector<std::string> lval; - cmSystemTools::ExpandListArgument(val.c_str(), lval); + cmSystemTools::ExpandListArgument(val, lval); std::vector<std::string>::iterator crit; for ( crit = lval.begin(); crit != lval.end(); ++ crit ) { rtit->RequiredRegularExpressions.push_back( std::pair<cmsys::RegularExpression, std::string>( cmsys::RegularExpression(crit->c_str()), - std::string(crit->c_str()))); + std::string(*crit))); } } if ( key == "WORKING_DIRECTORY" ) @@ -2319,7 +2319,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) } if ( this->MemCheck ) { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; bool found = false; for ( it = this->CustomTestsIgnore.begin(); it != this->CustomTestsIgnore.end(); ++ it ) @@ -2339,7 +2339,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) } else { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; bool found = false; for ( it = this->CustomTestsIgnore.begin(); it != this->CustomTestsIgnore.end(); ++ it ) diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 63f9c93..fe43bb8 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -87,8 +87,8 @@ public: // ctest -j N will break for that feature struct cmCTestTestProperties { - cmStdString Name; - cmStdString Directory; + std::string Name; + std::string Directory; std::vector<std::string> Args; std::vector<std::string> RequiredFiles; std::vector<std::string> Depends; @@ -98,7 +98,7 @@ public: std::string> > ErrorRegularExpressions; std::vector<std::pair<cmsys::RegularExpression, std::string> > RequiredRegularExpressions; - std::map<cmStdString, cmStdString> Measurements; + std::map<std::string, std::string> Measurements; bool IsInBasedOnREOptions; bool WillFail; float Cost; @@ -162,7 +162,7 @@ protected: virtual int PreProcessHandler(); virtual int PostProcessHandler(); virtual void GenerateTestCommand(std::vector<std::string>& args, int test); - int ExecuteCommands(std::vector<cmStdString>& vec); + int ExecuteCommands(std::vector<std::string>& vec); void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result); void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result); @@ -177,7 +177,7 @@ protected: typedef std::vector<cmCTestTestResult> TestResultsVector; TestResultsVector TestResults; - std::vector<cmStdString> CustomTestsIgnore; + std::vector<std::string> CustomTestsIgnore; std::string StartTest; std::string EndTest; unsigned int StartTestTime; @@ -210,8 +210,8 @@ private: /** * Run the tests for a directory and any subdirectories */ - void ProcessDirectory(std::vector<cmStdString> &passed, - std::vector<cmStdString> &failed); + void ProcessDirectory(std::vector<std::string> &passed, + std::vector<std::string> &failed); /** * Get the list of tests in directory and subdirectories. @@ -251,8 +251,8 @@ private: void ExpandTestsToRunInformation(size_t numPossibleTests); void ExpandTestsToRunInformationForRerunFailed(); - std::vector<cmStdString> CustomPreTest; - std::vector<cmStdString> CustomPostTest; + std::vector<std::string> CustomPreTest; + std::vector<std::string> CustomPostTest; std::vector<int> TestsToRun; diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index a785bd8..fb80333 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_update";} + virtual std::string GetName() const { return "ctest_update";} cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 11474ec..fda61ea 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -331,7 +331,7 @@ int cmCTestUpdateHandler::DetectVCS(const char* dir) { std::string sourceDirectory = dir; cmCTestLog(this->CTest, DEBUG, "Check directory: " - << sourceDirectory.c_str() << std::endl); + << sourceDirectory << std::endl); sourceDirectory += "/.svn"; if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) { diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 731c1c7..f7de294 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -47,7 +47,7 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg) { if(this->ArgumentDoing == ArgumentDoingFiles) { - cmStdString filename(arg); + std::string filename(arg); if(cmSystemTools::FileExists(filename.c_str())) { this->Files.insert(filename); diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index e867fb6..4a07608 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ctest_upload";} + virtual std::string GetName() const { return "ctest_upload";} cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx index caf2e53..4c3f81b 100644 --- a/Source/CTest/cmCTestUploadHandler.cxx +++ b/Source/CTest/cmCTestUploadHandler.cxx @@ -64,7 +64,7 @@ int cmCTestUploadHandler::ProcessHandler() for ( it = this->Files.begin(); it != this->Files.end(); it ++ ) { cmCTestLog(this->CTest, OUTPUT, - "\tUpload file: " << it->c_str() << std::endl); + "\tUpload file: " << *it << std::endl); ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n" << "<Content encoding=\"base64\">\n"; ofs << this->CTest->Base64EncodeFile(*it); diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index fbee227..f89fa2b 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -63,9 +63,9 @@ bool cmCTestVC::InitialCheckout(const char* command) } // Construct the initial checkout command line. - std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); std::vector<char const*> vc_co; - for(std::vector<cmStdString>::const_iterator ai = args.begin(); + for(std::vector<std::string>::const_iterator ai = args.begin(); ai != args.end(); ++ai) { vc_co.push_back(ai->c_str()); diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index 528d0db..5bcfeac 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -182,7 +182,7 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line, // ( file , entry ) = "number_executed:timing_info" // ^COVERAGE("%RSEL","init",8,"FOR_LOOP",1)=1 // ( file , entry, line, IGNORE ) =number_executed - std::vector<cmStdString> args; + std::vector<std::string> args; std::string::size_type pos = line.find('(', 0); // if no ( is found, then return line has no coverage if(pos == std::string::npos) diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index 6226feb..6236211 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -122,7 +122,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d) glob.RecurseOn(); std::string pat = d; pat += "/*.m"; - glob.FindFiles(pat.c_str()); + glob.FindFiles(pat); std::vector<std::string>& files = glob.GetFiles(); std::vector<std::string>::iterator fileIt; for ( fileIt = files.begin(); fileIt != files.end(); @@ -140,7 +140,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d) bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine, std::string& filepath) { - std::map<cmStdString, cmStdString>::iterator i = + std::map<std::string, std::string>::iterator i = this->RoutineToDirectory.find(routine); if(i != this->RoutineToDirectory.end()) { diff --git a/Source/CTest/cmParseMumpsCoverage.h b/Source/CTest/cmParseMumpsCoverage.h index c1effa7..bc71891 100644 --- a/Source/CTest/cmParseMumpsCoverage.h +++ b/Source/CTest/cmParseMumpsCoverage.h @@ -44,7 +44,7 @@ protected: bool FindMumpsFile(std::string const& routine, std::string& filepath); protected: - std::map<cmStdString, cmStdString> RoutineToDirectory; + std::map<std::string, std::string> RoutineToDirectory; cmCTestCoverageHandlerContainer& Coverage; cmCTest* CTest; }; diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 1c26c1c..3b7f968 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -34,7 +34,7 @@ bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until) return true; } bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in, - cmStdString const& fileName) + std::string const& fileName) { cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector = this->Coverage.TotalCoverage[fileName]; @@ -166,7 +166,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::istream& in) // read the string data in.read(s, size-1); s[size-1] = 0; - cmStdString fileName = s; + std::string fileName = s; delete [] s; // read close quote if(in.get(c) && c != '"') diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h index 035a093..92a7634 100644 --- a/Source/CTest/cmParsePHPCoverage.h +++ b/Source/CTest/cmParsePHPCoverage.h @@ -35,7 +35,7 @@ private: bool ReadArraySize(std::istream& in, int& size); bool ReadFileInformation(std::istream& in); bool ReadInt(std::istream& in, int& v); - bool ReadCoverageArray(std::istream& in, cmStdString const&); + bool ReadCoverageArray(std::istream& in, std::string const&); bool ReadUntil(std::istream& in, char until); cmCTestCoverageHandlerContainer& Coverage; cmCTest* CTest; diff --git a/Source/CTest/cmParsePythonCoverage.cxx b/Source/CTest/cmParsePythonCoverage.cxx index 38a770a..2578bb8 100644 --- a/Source/CTest/cmParsePythonCoverage.cxx +++ b/Source/CTest/cmParsePythonCoverage.cxx @@ -20,9 +20,9 @@ public: protected: - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { - if(strcmp(name, "class") == 0) + if(name == "class") { int tagCount = 0; while(true) @@ -57,7 +57,7 @@ protected: ++tagCount; } } - else if(strcmp(name, "line") == 0) + else if(name == "line") { int tagCount = 0; int curNumber = -1; @@ -85,7 +85,7 @@ protected: } } - virtual void EndElement(const char*) {} + virtual void EndElement(const std::string&) {} private: diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 249137f..682f95f 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -19,9 +19,10 @@ #include "cmCursesDummyWidget.h" #include "../cmSystemTools.h" -cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key, - int labelwidth, - int entrywidth) : +cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( + const std::string& key, + int labelwidth, + int entrywidth) : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth) { this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key); @@ -31,7 +32,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key, } cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( - const char* key, const cmCacheManager::CacheIterator& it, bool isNew, + const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew, int labelwidth, int entrywidth) : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth) { @@ -50,7 +51,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( { case cmCacheManager::BOOL: this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1); - if (cmSystemTools::IsOn(it.GetValue())) + if (cmSystemTools::IsOn(it.GetValue().c_str())) { static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true); } @@ -93,7 +94,8 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } break; case cmCacheManager::UNINITIALIZED: - cmSystemTools::Error("Found an undefined variable: ", it.GetName()); + cmSystemTools::Error("Found an undefined variable: ", + it.GetName().c_str()); break; default: // TODO : put warning message here diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 1357a02..98107cc 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -18,8 +18,9 @@ class cmCursesCacheEntryComposite { public: - cmCursesCacheEntryComposite(const char* key, int labelwidth, int entrywidth); - cmCursesCacheEntryComposite(const char* key, + cmCursesCacheEntryComposite(const std::string& key, int labelwidth, + int entrywidth); + cmCursesCacheEntryComposite(const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew, int labelwidth, int entrywidth); ~cmCursesCacheEntryComposite(); diff --git a/Source/CursesDialog/cmCursesLabelWidget.cxx b/Source/CursesDialog/cmCursesLabelWidget.cxx index b5ed312..b50eb64 100644 --- a/Source/CursesDialog/cmCursesLabelWidget.cxx +++ b/Source/CursesDialog/cmCursesLabelWidget.cxx @@ -19,7 +19,7 @@ cmCursesLabelWidget::cmCursesLabelWidget(int width, int height, field_opts_off(this->Field, O_EDIT); field_opts_off(this->Field, O_ACTIVE); field_opts_off(this->Field, O_STATIC); - this->SetValue(name.c_str()); + this->SetValue(name); } cmCursesLabelWidget::~cmCursesLabelWidget() diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index d94cd37..0734927 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -84,9 +84,9 @@ cmCursesMainForm::~cmCursesMainForm() } // See if a cache entry is in the list of entries in the ui. -bool cmCursesMainForm::LookForCacheEntry(const char* key) +bool cmCursesMainForm::LookForCacheEntry(const std::string& key) { - if (!key || !this->Entries) + if (!this->Entries) { return false; } @@ -94,7 +94,7 @@ bool cmCursesMainForm::LookForCacheEntry(const char* key) std::vector<cmCursesCacheEntryComposite*>::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - if (!strcmp(key, (*it)->Key.c_str())) + if (key == (*it)->Key) { return true; } @@ -146,7 +146,7 @@ void cmCursesMainForm::InitializeUI() this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { - const char* key = i.GetName(); + std::string key = i.GetName(); if ( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) @@ -168,7 +168,7 @@ void cmCursesMainForm::InitializeUI() this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { - const char* key = i.GetName(); + std::string key = i.GetName(); if ( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 883a2b3..fba9bc5 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -51,7 +51,7 @@ public: * Returns true if an entry with the given key is in the * list of current composites. */ - bool LookForCacheEntry(const char* key); + bool LookForCacheEntry(const std::string& key); enum { MIN_WIDTH = 65, diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx index 652b2df..2f4b59e 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.cxx +++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx @@ -59,7 +59,6 @@ bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w) { return false; } - return false; } void cmCursesOptionsWidget::AddOption(std::string const & option ) @@ -74,7 +73,7 @@ void cmCursesOptionsWidget::NextOption() { this->CurrentOption = 0; } - this->SetValue(this->Options[this->CurrentOption].c_str()); + this->SetValue(this->Options[this->CurrentOption]); } void cmCursesOptionsWidget::PreviousOption() { @@ -86,10 +85,10 @@ void cmCursesOptionsWidget::PreviousOption() { this->CurrentOption--; } - this->SetValue(this->Options[this->CurrentOption].c_str()); + this->SetValue(this->Options[this->CurrentOption]); } -void cmCursesOptionsWidget::SetOption(const char* value) +void cmCursesOptionsWidget::SetOption(const std::string& value) { this->CurrentOption = 0; // default to 0 index this->SetValue(value); diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h index b52ac9d..5cee489 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.h +++ b/Source/CursesDialog/cmCursesOptionsWidget.h @@ -25,7 +25,7 @@ public: // when this widget has focus. Returns true if the input was // handled. virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w); - void SetOption(const char*); + void SetOption(const std::string&); void AddOption(std::string const &); void NextOption(); void PreviousOption(); diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx index 14c325b..cd93bc3 100644 --- a/Source/CursesDialog/cmCursesPathWidget.cxx +++ b/Source/CursesDialog/cmCursesPathWidget.cxx @@ -57,9 +57,9 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w) { glob = cstr + "*"; } - std::vector<cmStdString> dirs; + std::vector<std::string> dirs; - cmSystemTools::SimpleGlob(glob.c_str(), dirs, (this->Type == cmCacheManager::PATH?-1:0)); + cmSystemTools::SimpleGlob(glob, dirs, (this->Type == cmCacheManager::PATH?-1:0)); if ( this->CurrentIndex < dirs.size() ) { cstr = dirs[this->CurrentIndex]; @@ -74,7 +74,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w) cstr += "/"; } - this->SetString(cstr.c_str()); + this->SetString(cstr); touchwin(w); wrefresh(w); form_driver(form, REQ_END_FIELD); diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index bd1ff71..d25022d 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -195,7 +195,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, return true; } -void cmCursesStringWidget::SetString(const char* value) +void cmCursesStringWidget::SetString(const std::string& value) { this->SetValue(value); } diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h index e939049..dd8c02a 100644 --- a/Source/CursesDialog/cmCursesStringWidget.h +++ b/Source/CursesDialog/cmCursesStringWidget.h @@ -37,7 +37,7 @@ public: /** * Set/Get the string. */ - void SetString(const char* value); + void SetString(const std::string& value); const char* GetString(); virtual const char* GetValue(); diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx index 5dffcaa..e5363f4 100644 --- a/Source/CursesDialog/cmCursesWidget.cxx +++ b/Source/CursesDialog/cmCursesWidget.cxx @@ -46,10 +46,10 @@ void cmCursesWidget::Move(int x, int y, bool isNewPage) } } -void cmCursesWidget::SetValue(const char* value) +void cmCursesWidget::SetValue(const std::string& value) { this->Value = value; - set_field_buffer(this->Field, 0, value); + set_field_buffer(this->Field, 0, value.c_str()); } const char* cmCursesWidget::GetValue() diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h index 952c67a..d91a0cb 100644 --- a/Source/CursesDialog/cmCursesWidget.h +++ b/Source/CursesDialog/cmCursesWidget.h @@ -40,7 +40,7 @@ public: * Set/Get the value (setting the value also changes the contents * of the field buffer). */ - virtual void SetValue(const char* value); + virtual void SetValue(const std::string& value); virtual const char* GetValue(); /** diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 821121e..82fa3a3 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -14,6 +14,7 @@ #include <QDir> #include <QTranslator> #include <QLocale> +#include <QTextCodec> #include "QMacInstallDialog.h" #include "CMakeSetupDialog.h" #include "cmDocumentation.h" @@ -78,6 +79,11 @@ int main(int argc, char** argv) QApplication app(argc, argv); +#if defined(CMAKE_ENCODING_UTF8) + QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); + QTextCodec::setCodecForLocale(utf8_codec); +#endif + // clean out standard Qt paths for plugins, which we don't use anyway // when creating Mac bundles, it potentially causes problems foreach(QString p, QApplication::libraryPaths()) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index f62afd6..1a98cea 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -578,7 +578,8 @@ void CMakeSetupDialog::doInterrupt() void CMakeSetupDialog::doSourceBrowse() { QString dir = QFileDialog::getExistingDirectory(this, - tr("Enter Path to Source"), this->SourceDirectory->text()); + tr("Enter Path to Source"), this->SourceDirectory->text(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if(!dir.isEmpty()) { this->setSourceDirectory(dir); @@ -608,7 +609,8 @@ void CMakeSetupDialog::updateBinaryDirectory(const QString& dir) void CMakeSetupDialog::doBinaryBrowse() { QString dir = QFileDialog::getExistingDirectory(this, - tr("Enter Path to Build"), this->BinaryDirectory->currentText()); + tr("Enter Path to Build"), this->BinaryDirectory->currentText(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText()) { this->setBinaryDirectory(dir); diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 0fe5f8c..5f9ebaf 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -111,13 +111,13 @@ void QCMake::setBinaryDirectory(const QString& _dir) cmCacheManager::CacheIterator itm = cachem->NewIterator(); if ( itm.Find("CMAKE_HOME_DIRECTORY")) { - setSourceDirectory(QString::fromLocal8Bit(itm.GetValue())); + setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str())); } if ( itm.Find("CMAKE_GENERATOR")) { const char* extraGen = cachem->GetCacheValue("CMAKE_EXTRA_GENERATOR"); std::string curGen = cmExternalMakefileProjectGenerator:: - CreateFullGeneratorName(itm.GetValue(), extraGen); + CreateFullGeneratorName(itm.GetValue(), extraGen? extraGen : ""); this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); } } @@ -201,11 +201,11 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i.GetName()); + prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); int idx = props.indexOf(prop); if(idx == -1) { - toremove.append(QString::fromLocal8Bit(i.GetName())); + toremove.append(QString::fromLocal8Bit(i.GetName().c_str())); } else { @@ -286,15 +286,15 @@ QCMakePropertyList QCMake::properties() const } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i.GetName()); + prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING")); - prop.Value = QString::fromLocal8Bit(i.GetValue()); + prop.Value = QString::fromLocal8Bit(i.GetValue().c_str()); prop.Advanced = i.GetPropertyAsBool("ADVANCED"); if(i.GetType() == cmCacheManager::BOOL) { prop.Type = QCMakeProperty::BOOL; - prop.Value = cmSystemTools::IsOn(i.GetValue()); + prop.Value = cmSystemTools::IsOn(i.GetValue().c_str()); } else if(i.GetType() == cmCacheManager::PATH) { diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx index a0c5e17..41f98b5 100644 --- a/Source/QtDialog/QCMakeWidgets.cxx +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -67,7 +67,8 @@ void QCMakeFilePathEditor::chooseFile() title = title.arg(this->Variable); } this->fileDialogExists(true); - path = QFileDialog::getOpenFileName(this, title, info.absolutePath()); + path = QFileDialog::getOpenFileName(this, title, info.absolutePath(), + QString(), NULL, QFileDialog::DontResolveSymlinks); this->fileDialogExists(false); if(!path.isEmpty()) @@ -91,7 +92,8 @@ void QCMakePathEditor::chooseFile() title = title.arg(this->Variable); } this->fileDialogExists(true); - path = QFileDialog::getExistingDirectory(this, title, this->text()); + path = QFileDialog::getExistingDirectory(this, title, this->text(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); this->fileDialogExists(false); if(!path.isEmpty()) { diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h index 38ed208..f147ec0 100644 --- a/Source/cmAddCompileOptionsCommand.h +++ b/Source/cmAddCompileOptionsCommand.h @@ -35,7 +35,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "add_compile_options";} + virtual std::string GetName() const {return "add_compile_options";} cmTypeMacro(cmAddCompileOptionsCommand, cmCommand); }; diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 3de04f5..d5f00ff 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -273,7 +273,7 @@ bool cmAddCustomCommandCommand { // Lookup an existing command. if(cmSourceFile* sf = - this->Makefile->GetSourceFileWithOutput(output[0].c_str())) + this->Makefile->GetSourceFileWithOutput(output[0])) { if(cmCustomCommand* cc = sf->GetCustomCommand()) { @@ -286,9 +286,9 @@ bool cmAddCustomCommandCommand // No command for this output exists. cmOStringStream e; - e << "given APPEND option with output \"" << output[0].c_str() + e << "given APPEND option with output \"" << output[0] << "\" which is not already a custom command output."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -305,7 +305,7 @@ bool cmAddCustomCommandCommand { // Source is empty, use the target. std::vector<std::string> no_depends; - this->Makefile->AddCustomCommandToTarget(target.c_str(), no_depends, + this->Makefile->AddCustomCommandToTarget(target, no_depends, commandLines, cctype, comment, working.c_str(), escapeOldStyle); @@ -314,7 +314,7 @@ bool cmAddCustomCommandCommand { // Target is empty, use the output. this->Makefile->AddCustomCommandToOutput(output, depends, - main_dependency.c_str(), + main_dependency, commandLines, comment, working.c_str(), false, escapeOldStyle); @@ -324,7 +324,7 @@ bool cmAddCustomCommandCommand { bool okay = false; if(cmSourceFile* sf = - this->Makefile->GetSourceFileWithOutput(output[0].c_str())) + this->Makefile->GetSourceFileWithOutput(output[0])) { if(cmCustomCommand* cc = sf->GetCustomCommand()) { @@ -337,7 +337,7 @@ bool cmAddCustomCommandCommand cmOStringStream e; e << "could not locate source file with a custom command producing \"" << output[0] << "\" even though this command tried to create it!"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -367,7 +367,7 @@ bool cmAddCustomCommandCommand { e << "The SOURCE signatures of add_custom_command are no longer " "supported."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return false; @@ -375,8 +375,8 @@ bool cmAddCustomCommandCommand } // Use the old-style mode for backward compatibility. - this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends, - source.c_str(), commandLines, + this->Makefile->AddCustomCommandOldStyle(target, outputs, depends, + source, commandLines, comment); } @@ -397,7 +397,7 @@ cmAddCustomCommandCommand { std::string e = "attempted to have a file \"" + *o + "\" in a source directory as an output of custom command."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -409,7 +409,7 @@ cmAddCustomCommandCommand cmOStringStream msg; msg << "called with OUTPUT containing a \"" << (*o)[pos] << "\". This character is not allowed."; - this->SetError(msg.str().c_str()); + this->SetError(msg.str()); return false; } } diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index 114957f..1d6ddb2 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "add_custom_command";} + virtual std::string GetName() const {return "add_custom_command";} cmTypeMacro(cmAddCustomCommandCommand, cmCommand); protected: diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index e27d830..2fb0eb3 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -34,7 +34,7 @@ bool cmAddCustomTargetCommand e << "called with invalid target name \"" << targetName << "\". Target names may not contain a slash. " << "Use ADD_CUSTOM_COMMAND to generate files."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -149,7 +149,7 @@ bool cmAddCustomTargetCommand cmOStringStream msg; msg << "called with target name containing a \"" << targetName[pos] << "\". This character is not allowed."; - this->SetError(msg.str().c_str()); + this->SetError(msg.str()); return false; } @@ -187,7 +187,7 @@ bool cmAddCustomTargetCommand "\" is reserved or not valid for certain " "CMake features, such as generator expressions, and may result " "in undefined behavior."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { @@ -208,7 +208,7 @@ bool cmAddCustomTargetCommand std::string msg; if(!this->Makefile->EnforceUniqueName(targetName, msg, true)) { - this->SetError(msg.c_str()); + this->SetError(msg); return false; } } @@ -224,7 +224,7 @@ bool cmAddCustomTargetCommand // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = - this->Makefile->AddUtilityCommand(targetName.c_str(), excludeFromAll, + this->Makefile->AddUtilityCommand(targetName, excludeFromAll, working_directory.c_str(), depends, commandLines, escapeOldStyle, comment); diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h index d0fcdad..d2b00ad 100644 --- a/Source/cmAddCustomTargetCommand.h +++ b/Source/cmAddCustomTargetCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const + virtual std::string GetName() const {return "add_custom_target";} cmTypeMacro(cmAddCustomTargetCommand, cmCommand); diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h index d05f187..9800fd2 100644 --- a/Source/cmAddDefinitionsCommand.h +++ b/Source/cmAddDefinitionsCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "add_definitions";} + virtual std::string GetName() const {return "add_definitions";} cmTypeMacro(cmAddDefinitionsCommand, cmCommand); }; diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index b55334f..e897d81 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -38,7 +38,7 @@ bool cmAddDependenciesCommand cmOStringStream e; e << "Cannot add target-level dependencies to INTERFACE library " "target \"" << target_name << "\".\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -46,7 +46,7 @@ bool cmAddDependenciesCommand ++s; // skip over target_name for (; s != args.end(); ++s) { - target->AddUtility(s->c_str(), this->Makefile); + target->AddUtility(*s, this->Makefile); } } else diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h index 247cc54..db3712a 100644 --- a/Source/cmAddDependenciesCommand.h +++ b/Source/cmAddDependenciesCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_dependencies";} + virtual std::string GetName() const { return "add_dependencies";} cmTypeMacro(cmAddDependenciesCommand, cmCommand); }; diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 3f9400e..c30e764 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -101,7 +101,7 @@ bool cmAddExecutableCommand "\" is reserved or not valid for certain " "CMake features, such as generator expressions, and may result " "in undefined behavior."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { @@ -132,9 +132,9 @@ bool cmAddExecutableCommand } if (isAlias) { - if(!cmGeneratorExpression::IsValidTargetName(exename.c_str())) + if(!cmGeneratorExpression::IsValidTargetName(exename)) { - this->SetError(("Invalid name for ALIAS: " + exename).c_str()); + this->SetError("Invalid name for ALIAS: " + exename); return false; } if(excludeFromAll) @@ -151,7 +151,7 @@ bool cmAddExecutableCommand { cmOStringStream e; e << "ALIAS requires exactly one target argument."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -161,7 +161,7 @@ bool cmAddExecutableCommand cmOStringStream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is itself an ALIAS."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmTarget *aliasedTarget = @@ -172,7 +172,7 @@ bool cmAddExecutableCommand e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" does not already " "exist."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmTarget::TargetType type = aliasedTarget->GetType(); @@ -182,7 +182,7 @@ bool cmAddExecutableCommand e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is not an " "executable."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if(aliasedTarget->IsImported()) @@ -190,10 +190,10 @@ bool cmAddExecutableCommand cmOStringStream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is IMPORTED."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - this->Makefile->AddAlias(exename.c_str(), aliasedTarget); + this->Makefile->AddAlias(exename, aliasedTarget); return true; } @@ -206,12 +206,12 @@ bool cmAddExecutableCommand cmOStringStream e; e << "cannot create imported target \"" << exename << "\" because another target with the same name already exists."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Create the imported target. - this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE, + this->Makefile->AddImportedTarget(exename, cmTarget::EXECUTABLE, importGlobal); return true; } @@ -221,7 +221,7 @@ bool cmAddExecutableCommand std::string msg; if(!this->Makefile->EnforceUniqueName(exename, msg)) { - this->SetError(msg.c_str()); + this->SetError(msg); return false; } } diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h index 30ecce3..e134077 100644 --- a/Source/cmAddExecutableCommand.h +++ b/Source/cmAddExecutableCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_executable";} + virtual std::string GetName() const { return "add_executable";} cmTypeMacro(cmAddExecutableCommand, cmCommand); }; diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index e62a40e..cdc9f2a 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -53,7 +53,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting STATIC type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -66,7 +66,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting SHARED type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -79,7 +79,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting MODULE type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -92,7 +92,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting OBJECT type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -105,7 +105,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting UNKNOWN type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -118,7 +118,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting ALIAS type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -130,21 +130,21 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library specified with conflicting/multiple types."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if (isAlias) { cmOStringStream e; e << "INTERFACE library specified with conflicting ALIAS type."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if (excludeFromAll) { cmOStringStream e; e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -157,7 +157,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } ++s; @@ -177,7 +177,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "GLOBAL option may only be used with IMPORTED libraries."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } else @@ -192,14 +192,14 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "INTERFACE library requires no source arguments."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if (importGlobal && !importTarget) { cmOStringStream e; e << "INTERFACE library specified as GLOBAL, but not as IMPORTED."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -239,7 +239,7 @@ bool cmAddLibraryCommand "\" is reserved or not valid for certain " "CMake features, such as generator expressions, and may result " "in undefined behavior."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { @@ -250,9 +250,9 @@ bool cmAddLibraryCommand if (isAlias) { - if(!cmGeneratorExpression::IsValidTargetName(libName.c_str())) + if(!cmGeneratorExpression::IsValidTargetName(libName)) { - this->SetError(("Invalid name for ALIAS: " + libName).c_str()); + this->SetError("Invalid name for ALIAS: " + libName); return false; } if(excludeFromAll) @@ -269,7 +269,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "ALIAS requires exactly one target argument."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -279,7 +279,7 @@ bool cmAddLibraryCommand cmOStringStream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is itself an ALIAS."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmTarget *aliasedTarget = @@ -290,7 +290,7 @@ bool cmAddLibraryCommand e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" does not already " "exist."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmTarget::TargetType aliasedType = aliasedTarget->GetType(); @@ -303,7 +303,7 @@ bool cmAddLibraryCommand cmOStringStream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is not a library."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } if(aliasedTarget->IsImported()) @@ -311,10 +311,10 @@ bool cmAddLibraryCommand cmOStringStream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is IMPORTED."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - this->Makefile->AddAlias(libName.c_str(), aliasedTarget); + this->Makefile->AddAlias(libName, aliasedTarget); return true; } @@ -367,7 +367,7 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "Invalid name for IMPORTED INTERFACE library target: " << libName; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -378,12 +378,12 @@ bool cmAddLibraryCommand cmOStringStream e; e << "cannot create imported target \"" << libName << "\" because another target with the same name already exists."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Create the imported target. - this->Makefile->AddImportedTarget(libName.c_str(), type, importGlobal); + this->Makefile->AddImportedTarget(libName, type, importGlobal); return true; } @@ -402,7 +402,7 @@ bool cmAddLibraryCommand std::string msg; if(!this->Makefile->EnforceUniqueName(libName, msg)) { - this->SetError(msg.c_str()); + this->SetError(msg); return false; } } @@ -416,11 +416,11 @@ bool cmAddLibraryCommand { cmOStringStream e; e << "Invalid name for INTERFACE library target: " << libName; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - this->Makefile->AddLibrary(libName.c_str(), + this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll); @@ -442,7 +442,7 @@ bool cmAddLibraryCommand ++s; } - this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll); + this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll); return true; } diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index 1001043..350708b 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_library";} + virtual std::string GetName() const { return "add_library";} cmTypeMacro(cmAddLibraryCommand, cmCommand); }; diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 5b1c9c6..4ea2524 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -66,7 +66,7 @@ bool cmAddSubDirectoryCommand::InitialPass std::string error = "given source \""; error += srcArg; error += "\" which is not an existing directory."; - this->SetError(error.c_str()); + this->SetError(error); return false; } srcPath = cmSystemTools::CollapseFullPath(srcPath.c_str()); @@ -87,7 +87,7 @@ bool cmAddSubDirectoryCommand::InitialPass << this->Makefile->GetCurrentDirectory() << "\". " << "When specifying an out-of-tree source a binary directory " << "must be explicitly specified."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -121,7 +121,7 @@ bool cmAddSubDirectoryCommand::InitialPass binPath = cmSystemTools::CollapseFullPath(binPath.c_str()); // Add the subdirectory using the computed full paths. - this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(), + this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false, true); return true; diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h index 1e5b1ab..abf3efc 100644 --- a/Source/cmAddSubDirectoryCommand.h +++ b/Source/cmAddSubDirectoryCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_subdirectory";} + virtual std::string GetName() const { return "add_subdirectory";} cmTypeMacro(cmAddSubDirectoryCommand, cmCommand); }; diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index a9165f5..2531a1a 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -44,7 +44,7 @@ bool cmAddTestCommand // Create the test but add a generator only the first time it is // seen. This preserves behavior from before test generators. - cmTest* test = this->Makefile->GetTest(args[0].c_str()); + cmTest* test = this->Makefile->GetTest(args[0]); if(test) { // If the test was already added by a new-style signature do not @@ -54,13 +54,13 @@ bool cmAddTestCommand cmOStringStream e; e << " given test name \"" << args[0] << "\" which already exists in this directory."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } else { - test = this->Makefile->CreateTest(args[0].c_str()); + test = this->Makefile->CreateTest(args[0]); test->SetOldStyle(true); this->Makefile->AddTestGenerator(new cmTestGenerator(test)); } @@ -137,7 +137,7 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args) { cmOStringStream e; e << " given unknown argument:\n " << args[i] << "\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -157,17 +157,17 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args) } // Require a unique test name within the directory. - if(this->Makefile->GetTest(name.c_str())) + if(this->Makefile->GetTest(name)) { cmOStringStream e; e << " given test NAME \"" << name << "\" which already exists in this directory."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Add the test. - cmTest* test = this->Makefile->CreateTest(name.c_str()); + cmTest* test = this->Makefile->CreateTest(name); test->SetOldStyle(false); test->SetCommand(command); if(!working_directory.empty()) diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h index 9173454..624288f 100644 --- a/Source/cmAddTestCommand.h +++ b/Source/cmAddTestCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "add_test";} + virtual std::string GetName() const { return "add_test";} cmTypeMacro(cmAddTestCommand, cmCommand); private: diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index 01f64b7..d8c3c43 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -40,7 +40,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass } // was the list already populated - const char *def = this->Makefile->GetDefinition(args[1].c_str()); + const char *def = this->Makefile->GetDefinition(args[1]); if (def) { sourceListValue = def; @@ -72,7 +72,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass // add the file as a class file so // depends can be done cmSourceFile* sf = - this->Makefile->GetOrCreateSource(fullname.c_str()); + this->Makefile->GetOrCreateSource(fullname); sf->SetProperty("ABSTRACT","0"); if(!sourceListValue.empty()) { @@ -83,7 +83,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass } } } - this->Makefile->AddDefinition(args[1].c_str(), sourceListValue.c_str()); + this->Makefile->AddDefinition(args[1], sourceListValue.c_str()); return true; } diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h index 8b5fa8a..6615273 100644 --- a/Source/cmAuxSourceDirectoryCommand.h +++ b/Source/cmAuxSourceDirectoryCommand.h @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "aux_source_directory";} + virtual std::string GetName() const { return "aux_source_directory";} cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand); }; diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h index 52f0e9c..1fcae50 100644 --- a/Source/cmBreakCommand.h +++ b/Source/cmBreakCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "break";} + virtual std::string GetName() const {return "break";} cmTypeMacro(cmBreakCommand, cmCommand); }; diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index c06b8ad..93f7801 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -44,7 +44,7 @@ bool cmBuildCommand // Parse remaining arguments. const char* configuration = 0; const char* project_name = 0; - const char* target = 0; + std::string target; enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget }; Doing doing = DoingNone; for(unsigned int i=1; i < args.size(); ++i) @@ -74,13 +74,13 @@ bool cmBuildCommand else if(doing == DoingTarget) { doing = DoingNone; - target = args[i].c_str(); + target = args[i]; } else { cmOStringStream e; e << "unknown argument \"" << args[i] << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -107,7 +107,7 @@ bool cmBuildCommand std::string makecommand = this->Makefile->GetLocalGenerator() ->GetGlobalGenerator()->GenerateCMakeBuildCommand(target, configuration, - 0, true); + "", true); this->Makefile->AddDefinition(variable, makecommand.c_str()); @@ -136,8 +136,8 @@ bool cmBuildCommand } std::string makecommand = this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(), - 0, true); + ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType, + "", true); if(cacheValue) { diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 2160655..3fb618f 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -50,7 +50,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "build_command";} + virtual std::string GetName() const {return "build_command";} cmTypeMacro(cmBuildCommand, cmCommand); }; diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index e3528e1..c64209f 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -25,7 +25,7 @@ bool cmBuildNameCommand this->SetError("called with incorrect number of arguments"); return false; } - const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str()); + const char* cacheValue = this->Makefile->GetDefinition(args[0]); if(cacheValue) { // do we need to correct the value? @@ -36,7 +36,7 @@ bool cmBuildNameCommand cmSystemTools::ReplaceString(cv,"/", "_"); cmSystemTools::ReplaceString(cv,"(", "_"); cmSystemTools::ReplaceString(cv,")", "_"); - this->Makefile->AddCacheDefinition(args[0].c_str(), + this->Makefile->AddCacheDefinition(args[0], cv.c_str(), "Name of build.", cmCacheManager::STRING); @@ -71,7 +71,7 @@ bool cmBuildNameCommand cmSystemTools::ReplaceString(buildname, ")", "_"); - this->Makefile->AddCacheDefinition(args[0].c_str(), + this->Makefile->AddCacheDefinition(args[0], buildname.c_str(), "Name of build.", cmCacheManager::STRING); diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index 2f7acde..8f8038f 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmBuildNameCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - virtual const char* GetName() const {return "build_name";} + virtual std::string GetName() const {return "build_name";} virtual bool IsScriptable() const { return true; } virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 62f2383..5234538 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -53,7 +53,7 @@ bool cmCMakeHostSystemInformationCommand result_list += value; } - this->Makefile->AddDefinition(variable.c_str(), result_list.c_str()); + this->Makefile->AddDefinition(variable, result_list.c_str()); return true; } @@ -97,7 +97,7 @@ bool cmCMakeHostSystemInformationCommand else { std::string e = "does not recognize <key> " + key; - this->SetError(e.c_str()); + this->SetError(e); return false; } diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h index 27ba638..463b180 100644 --- a/Source/cmCMakeHostSystemInformationCommand.h +++ b/Source/cmCMakeHostSystemInformationCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const + virtual std::string GetName() const { return "cmake_host_system_information"; } diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index 6e2ca64..58b61de 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -79,8 +79,8 @@ bool cmCMakeMinimumRequired &required_patch, &required_tweak) < 2) { cmOStringStream e; - e << "could not parse VERSION \"" << version_string.c_str() << "\"."; - this->SetError(e.str().c_str()); + e << "could not parse VERSION \"" << version_string << "\"."; + this->SetError(e.str()); return false; } @@ -98,7 +98,7 @@ bool cmCMakeMinimumRequired { // The current version is too low. cmOStringStream e; - e << "CMake " << version_string.c_str() + e << "CMake " << version_string << " or higher is required. You are running version " << cmVersion::GetCMakeVersion(); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); @@ -135,7 +135,7 @@ bool cmCMakeMinimumRequired::EnforceUnknownArguments() cmOStringStream e; e << "called with unknown argument \"" << this->UnknownArguments[0] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } return true; diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h index 0cdd4c5..31b7271 100644 --- a/Source/cmCMakeMinimumRequired.h +++ b/Source/cmCMakeMinimumRequired.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "cmake_minimum_required";} + virtual std::string GetName() const {return "cmake_minimum_required";} cmTypeMacro(cmCMakeMinimumRequired, cmCommand); diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index f4be559..ddd5d6a 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -58,7 +58,7 @@ bool cmCMakePolicyCommand cmOStringStream e; e << "given unknown first argument \"" << args[0] << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -84,7 +84,7 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args) { cmOStringStream e; e << "SET given unrecognized policy status \"" << args[2] << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -116,7 +116,7 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args) cmOStringStream e; e << "GET given policy \"" << id << "\" which is not known to this " << "version of CMake."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -126,15 +126,15 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args) { case cmPolicies::OLD: // Report that the policy is set to OLD. - this->Makefile->AddDefinition(var.c_str(), "OLD"); + this->Makefile->AddDefinition(var, "OLD"); break; case cmPolicies::WARN: // Report that the policy is not set. - this->Makefile->AddDefinition(var.c_str(), ""); + this->Makefile->AddDefinition(var, ""); break; case cmPolicies::NEW: // Report that the policy is set to NEW. - this->Makefile->AddDefinition(var.c_str(), "NEW"); + this->Makefile->AddDefinition(var, "NEW"); break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h index 7e3f4e6..8dc8fbe 100644 --- a/Source/cmCMakePolicyCommand.h +++ b/Source/cmCMakePolicyCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "cmake_policy";} + virtual std::string GetName() const {return "cmake_policy";} cmTypeMacro(cmCMakePolicyCommand, cmCommand); private: diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index cb62f21..dd2a1b8 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -557,9 +557,9 @@ void CCONV *cmGetSource(void *arg, const char *name) sf->RealSourceFile = rsf; sf->FullPath = rsf->GetFullPath(); sf->SourceName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath.c_str()); + cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath); sf->SourceExtension = - cmSystemTools::GetFilenameLastExtension(sf->FullPath.c_str()); + cmSystemTools::GetFilenameLastExtension(sf->FullPath); // Store the proxy in the map so it can be re-used and deleted later. cmCPluginAPISourceFileMap::value_type entry(rsf, sf); @@ -583,7 +583,7 @@ void * CCONV cmAddSource(void *arg, void *arg2) } // Create the real cmSourceFile instance and copy over saved information. - cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath.c_str()); + cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath); rsf->GetProperties() = osf->Properties; for(std::vector<std::string>::iterator i = osf->Depends.begin(); i != osf->Depends.end(); ++i) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index acedc1a..9f711b7 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -78,7 +78,7 @@ struct tm* cmCTest::GetNightlyTime(std::string str, lctime->tm_mday, str.c_str()); cmCTestLog(this, OUTPUT, "Determine Nightly Start Time" << std::endl - << " Specified time: " << str.c_str() << std::endl); + << " Specified time: " << str << std::endl); //Convert the nightly start time to seconds. Since we are //providing only a time and a timezone, the current date of //the local machine is assumed. Consequently, nightlySeconds @@ -649,8 +649,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) { std::string src_dir - = this->GetCTestConfiguration("SourceDirectory").c_str(); - std::string bld_dir = this->GetCTestConfiguration("BuildDirectory").c_str(); + = this->GetCTestConfiguration("SourceDirectory"); + std::string bld_dir = this->GetCTestConfiguration("BuildDirectory"); this->DartVersion = 1; this->DropSiteCDash = false; for(Part p = PartStart; p != PartCount; p = Part(p+1)) @@ -681,14 +681,14 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) if ( !fname.empty() ) { cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " - << fname.c_str() << std::endl); + << fname << std::endl); bool readit = mf->ReadListFile(mf->GetCurrentListFile(), fname.c_str() ); if(!readit) { std::string m = "Could not find include file: "; m += fname; - command->SetError(m.c_str()); + command->SetError(m); return false; } } @@ -696,10 +696,10 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) { cmCTestLog(this, WARNING, "Cannot locate CTest configuration: in BuildDirectory: " - << bld_dir_fname.c_str() << std::endl); + << bld_dir_fname << std::endl); cmCTestLog(this, WARNING, "Cannot locate CTest configuration: in SourceDirectory: " - << src_dir_fname.c_str() << std::endl); + << src_dir_fname << std::endl); } this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", @@ -748,13 +748,13 @@ bool cmCTest::UpdateCTestConfiguration() } } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "UpdateCTestConfiguration from :" - << fileName.c_str() << "\n"); + << fileName << "\n"); if ( !cmSystemTools::FileExists(fileName.c_str()) ) { // No need to exit if we are not producing XML if ( this->ProduceXML ) { - cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName.c_str() + cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName << std::endl); return false; } @@ -762,7 +762,7 @@ bool cmCTest::UpdateCTestConfiguration() else { cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:" - << fileName.c_str() << "\n"); + << fileName << "\n"); // parse the dart test file cmsys::ifstream fin(fileName.c_str()); @@ -930,7 +930,7 @@ bool cmCTest::AddIfExists(Part part, const char* file) { std::string name = file; name += ".gz"; - if ( this->CTestFileExists(name.c_str()) ) + if ( this->CTestFileExists(name) ) { this->AddSubmitFile(part, file); } @@ -1153,7 +1153,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, int* retVal, const char* dir, int timeout, std::ostream& ofs) { // First generate the command and arguments - std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -1161,7 +1161,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, } std::vector<const char*> argv; - for(std::vector<cmStdString>::const_iterator a = args.begin(); + for(std::vector<std::string>::const_iterator a = args.begin(); a != args.end(); ++a) { argv.push_back(a->c_str()); @@ -1346,7 +1346,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, *output += oss.str(); if ( log ) { - *log << output->c_str(); + *log << *output; } cmSystemTools::ChangeDirectory(oldpath.c_str()); @@ -1562,7 +1562,7 @@ void cmCTest::AddSiteProperties(std::ostream& ostr) for(std::vector<std::string>::iterator i = args.begin(); i != args.end(); ++i) { - ostr << " <Label>" << i->c_str() << "</Label>\n"; + ostr << " <Label>" << *i << "</Label>\n"; } ostr << " </Labels>\n"; } @@ -1606,7 +1606,7 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os, for ( it = files.begin(); it != files.end(); it ++ ) { - cmCTestLog(this, OUTPUT, "\tAdd file: " << it->c_str() << std::endl); + cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl); std::string note_time = this->CurrentTime(); os << "<Note Name=\"" << cmXMLSafe(*it) << "\">\n" << "<Time>" << cmSystemTools::GetTime() << "</Time>\n" @@ -1624,8 +1624,8 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os, } else { - os << "Problem reading file: " << it->c_str() << std::endl; - cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << it->c_str() + os << "Problem reading file: " << *it << std::endl; + cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << *it << " while creating notes" << std::endl); } os << "</Text>\n" @@ -1637,7 +1637,7 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os, } //---------------------------------------------------------------------- -int cmCTest::GenerateNotesFile(const std::vector<cmStdString> &files) +int cmCTest::GenerateNotesFile(const VectorOfStrings &files) { cmGeneratedFileStream ofs; if ( !this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs) ) @@ -1658,7 +1658,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles) return 1; } - std::vector<cmStdString> files; + VectorOfStrings files; cmCTestLog(this, OUTPUT, "Create notes file" << std::endl); @@ -1675,7 +1675,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles) std::string cmCTest::Base64GzipEncodeFile(std::string file) { std::string tarFile = file + "_temp.tar.gz"; - std::vector<cmStdString> files; + std::vector<std::string> files; files.push_back(file); if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false)) @@ -1722,9 +1722,9 @@ std::string cmCTest::Base64EncodeFile(std::string file) //---------------------------------------------------------------------- -bool cmCTest::SubmitExtraFiles(const std::vector<cmStdString> &files) +bool cmCTest::SubmitExtraFiles(const VectorOfStrings &files) { - std::vector<cmStdString>::const_iterator it; + VectorOfStrings::const_iterator it; for ( it = files.begin(); it != files.end(); ++ it ) @@ -1732,7 +1732,7 @@ bool cmCTest::SubmitExtraFiles(const std::vector<cmStdString> &files) if ( !cmSystemTools::FileExists(it->c_str()) ) { cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: " - << it->c_str() << " to submit." + << *it << " to submit." << std::endl;); return false; } @@ -1749,7 +1749,7 @@ bool cmCTest::SubmitExtraFiles(const char* cfiles) return 1; } - std::vector<cmStdString> files; + VectorOfStrings files; cmCTestLog(this, OUTPUT, "Submit extra files" << std::endl); @@ -2126,7 +2126,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i, if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1) { i++; - this->AddCTestConfigurationOverwrite(args[i].c_str()); + this->AddCTestConfigurationOverwrite(args[i]); } if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1) { @@ -2246,7 +2246,7 @@ bool cmCTest::AddVariableDefinition(const std::string &arg) std::string value; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; - if (cmCacheManager::ParseEntry(arg.c_str(), name, value, type)) + if (cmCacheManager::ParseEntry(arg, name, value, type)) { this->Definitions[name] = value; return true; @@ -2319,7 +2319,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output) executeTests = false; cmCTestLog(this, ERROR_MESSAGE, "CTest -T called with incorrect option: " - << args[i].c_str() << std::endl); + << args[i] << std::endl); cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl << " " << ctestExec << " -T all" << std::endl << " " << ctestExec << " -T start" << std::endl @@ -2356,7 +2356,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output) { executeTests = false; cmCTestLog(this, ERROR_MESSAGE, - "CTest -M called with incorrect option: " << str.c_str() + "CTest -M called with incorrect option: " << str << std::endl); cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl << " " << ctestExec << " -M Continuous" << std::endl @@ -2527,11 +2527,11 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) std::string fname = dir; fname += "/CTestCustom.cmake"; cmCTestLog(this, DEBUG, "* Check for file: " - << fname.c_str() << std::endl); + << fname << std::endl); if ( cmSystemTools::FileExists(fname.c_str()) ) { cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: " - << fname.c_str() << std::endl); + << fname << std::endl); bool erroroc = cmSystemTools::GetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag(); @@ -2540,7 +2540,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) { cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: " - << fname.c_str() << std::endl); + << fname << std::endl); } found = true; if ( erroroc ) @@ -2552,7 +2552,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) std::string rexpr = dir; rexpr += "/CTestCustom.ctest"; cmCTestLog(this, DEBUG, "* Check for file: " - << rexpr.c_str() << std::endl); + << rexpr << std::endl); if ( !found && cmSystemTools::FileExists(rexpr.c_str()) ) { cmsys::Glob gl; @@ -2564,13 +2564,13 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) ++ fileIt ) { cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); if ( !mf->ReadListFile(0, fileIt->c_str()) || cmSystemTools::GetErrorOccuredFlag() ) { cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: " - << fileIt->c_str() << std::endl); + << *fileIt << std::endl); } } found = true; @@ -2584,7 +2584,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) { cmCTestLog(this, DEBUG, "* Read custom CTest configuration vectors for handler: " - << it->first.c_str() << " (" << it->second << ")" << std::endl); + << it->first << " (" << it->second << ")" << std::endl); it->second->PopulateCustomVectors(mf); } } @@ -2593,13 +2593,9 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf) } //---------------------------------------------------------------------- -void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, - VectorOfStrings& vec) +void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, + std::vector<std::string>& vec) { - if ( !def) - { - return; - } const char* dval = mf->GetDefinition(def); if ( !dval ) { @@ -2614,18 +2610,15 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, for ( it = slist.begin(); it != slist.end(); ++it ) { - cmCTestLog(this, DEBUG, " -- " << it->c_str() << std::endl); - vec.push_back(it->c_str()); + cmCTestLog(this, DEBUG, " -- " << *it << std::endl); + vec.push_back(*it); } } //---------------------------------------------------------------------- -void cmCTest::PopulateCustomInteger(cmMakefile* mf, const char* def, int& val) +void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def, + int& val) { - if ( !def) - { - return; - } const char* dval = mf->GetDefinition(def); if ( !dval ) { @@ -2702,7 +2695,7 @@ std::string cmCTest::GetShortPathToFile(const char* cfname) } //---------------------------------------------------------------------- -std::string cmCTest::GetCTestConfiguration(const char *name) +std::string cmCTest::GetCTestConfiguration(const std::string& name) { if ( this->CTestConfigurationOverwrites.find(name) != this->CTestConfigurationOverwrites.end() ) @@ -2847,9 +2840,8 @@ void cmCTest::AddSubmitFile(Part part, const char* name) } //---------------------------------------------------------------------- -void cmCTest::AddCTestConfigurationOverwrite(const char* encstr) +void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr) { - std::string overStr = encstr; size_t epos = overStr.find("="); if ( epos == overStr.npos ) { @@ -2857,7 +2849,7 @@ void cmCTest::AddCTestConfigurationOverwrite(const char* encstr) "CTest configuration overwrite specified in the wrong format." << std::endl << "Valid format is: --overwrite key=value" << std::endl - << "The specified was: --overwrite " << overStr.c_str() << std::endl); + << "The specified was: --overwrite " << overStr << std::endl); return; } std::string key = overStr.substr(0, epos); @@ -2877,7 +2869,7 @@ void cmCTest::SetConfigType(const char* ct) //---------------------------------------------------------------------- bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, - const char* dconfig, const char* cmake_var) + const char* dconfig, const std::string& cmake_var) { const char* ctvar; ctvar = mf->GetDefinition(cmake_var); @@ -2900,7 +2892,7 @@ bool cmCTest::RunCommand( const char* dir, double timeout) { - std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -2908,7 +2900,7 @@ bool cmCTest::RunCommand( } std::vector<const char*> argv; - for(std::vector<cmStdString>::const_iterator a = args.begin(); + for(std::vector<std::string>::const_iterator a = args.begin(); a != args.end(); ++a) { argv.push_back(a->c_str()); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index becb0f5..836e41d 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -70,8 +70,8 @@ public: { PartInfo(): Enabled(false) {} - void SetName(const char* name) { this->Name = name; } - const char* GetName() const { return this->Name.c_str(); } + void SetName(const std::string& name) { this->Name = name; } + const std::string& GetName() const { return this->Name; } void Enable() { this->Enabled = true; } operator bool() const { return this->Enabled; } @@ -101,8 +101,8 @@ public: if the string does not name a valid part. */ Part GetPartFromName(const char* name); - typedef std::vector<cmStdString> VectorOfStrings; - typedef std::set<cmStdString> SetOfStrings; + typedef std::vector<cmsys::String> VectorOfStrings; + typedef std::set<std::string> SetOfStrings; ///! Process Command line arguments int Run(std::vector<std::string> &, std::string* output = 0); @@ -172,7 +172,7 @@ public: std::string GetTestModelString(); static int GetTestModelFromString(const char* str); static std::string CleanString(const std::string& str); - std::string GetCTestConfiguration(const char *name); + std::string GetCTestConfiguration(const std::string& name); void SetCTestConfiguration(const char *name, const char* value); void EmptyCTestConfiguration(); @@ -185,9 +185,9 @@ public: //! Set the notes files to be created. void SetNotesFiles(const char* notes); - void PopulateCustomVector(cmMakefile* mf, const char* definition, - VectorOfStrings& vec); - void PopulateCustomInteger(cmMakefile* mf, const char* def, + void PopulateCustomVector(cmMakefile* mf, const std::string& definition, + std::vector<std::string>& vec); + void PopulateCustomInteger(cmMakefile* mf, const std::string& def, int& val); ///! Get the current time as string @@ -332,7 +332,7 @@ public: * Set the CTest variable from CMake variable */ bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, - const char* dconfig, const char* cmake_var); + const char* dconfig, const std::string& cmake_var); //! Make string safe to be send as an URL static std::string MakeURLSafe(const std::string&); @@ -349,14 +349,14 @@ public: //! Add overwrite to ctest configuration. // The format is key=value - void AddCTestConfigurationOverwrite(const char* encstr); + void AddCTestConfigurationOverwrite(const std::string& encstr); //! Create XML file that contains all the notes specified - int GenerateNotesFile(const std::vector<cmStdString> &files); + int GenerateNotesFile(const VectorOfStrings &files); //! Submit extra files to the server bool SubmitExtraFiles(const char* files); - bool SubmitExtraFiles(const std::vector<cmStdString> &files); + bool SubmitExtraFiles(const VectorOfStrings &files); //! Set the output log file name void SetOutputLogFileName(const char* name); @@ -391,7 +391,7 @@ public: //! Read the custom configuration files and apply them to the current ctest int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf); - std::vector<cmStdString> &GetInitialCommandLineArguments() + std::vector<std::string> &GetInitialCommandLineArguments() { return this->InitialCommandLineArguments; }; //! Set the track to submit to @@ -447,13 +447,13 @@ private: void DetermineNextDayStop(); // these are helper classes - typedef std::map<cmStdString,cmCTestGenericHandler*> t_TestingHandlers; + typedef std::map<std::string,cmCTestGenericHandler*> t_TestingHandlers; t_TestingHandlers TestingHandlers; bool ShowOnly; //! Map of configuration properties - typedef std::map<cmStdString, cmStdString> CTestConfigurationMap; + typedef std::map<std::string, std::string> CTestConfigurationMap; std::string CTestConfigFile; // TODO: The ctest configuration should be a hierarchy of @@ -463,7 +463,7 @@ private: CTestConfigurationMap CTestConfiguration; CTestConfigurationMap CTestConfigurationOverwrites; PartInfo Parts[PartCount]; - typedef std::map<cmStdString, Part> PartMapType; + typedef std::map<std::string, Part> PartMapType; PartMapType PartMap; std::string CurrentTag; @@ -556,7 +556,7 @@ private: int DartVersion; bool DropSiteCDash; - std::vector<cmStdString> InitialCommandLineArguments; + std::vector<std::string> InitialCommandLineArguments; int SubmitIndex; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 9e0064e..8f352b1 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -82,19 +82,19 @@ bool cmCacheManager::LoadCache(cmMakefile* mf) } -bool cmCacheManager::LoadCache(const char* path) +bool cmCacheManager::LoadCache(const std::string& path) { return this->LoadCache(path,true); } -bool cmCacheManager::LoadCache(const char* path, +bool cmCacheManager::LoadCache(const std::string& path, bool internal) { - std::set<cmStdString> emptySet; + std::set<std::string> emptySet; return this->LoadCache(path, internal, emptySet, emptySet); } -static bool ParseEntryWithoutType(const char* entry, +static bool ParseEntryWithoutType(const std::string& entry, std::string& var, std::string& value) { @@ -132,7 +132,7 @@ static bool ParseEntryWithoutType(const char* entry, return flag; } -bool cmCacheManager::ParseEntry(const char* entry, +bool cmCacheManager::ParseEntry(const std::string& entry, std::string& var, std::string& value, CacheEntryType& type) @@ -178,7 +178,7 @@ bool cmCacheManager::ParseEntry(const char* entry, return flag; } -void cmCacheManager::CleanCMakeFiles(const char* path) +void cmCacheManager::CleanCMakeFiles(const std::string& path) { std::string glob = path; glob += cmake::GetCMakeFilesDirectory(); @@ -193,10 +193,10 @@ void cmCacheManager::CleanCMakeFiles(const char* path) } } -bool cmCacheManager::LoadCache(const char* path, +bool cmCacheManager::LoadCache(const std::string& path, bool internal, - std::set<cmStdString>& excludes, - std::set<cmStdString>& includes) + std::set<std::string>& excludes, + std::set<std::string>& includes) { std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; @@ -428,7 +428,7 @@ bool cmCacheManager::SaveCache(cmMakefile* mf) } -bool cmCacheManager::SaveCache(const char* path) +bool cmCacheManager::SaveCache(const std::string& path) { std::string cacheFile = path; cacheFile += "/CMakeCache.txt"; @@ -500,7 +500,7 @@ bool cmCacheManager::SaveCache(const char* path) fout << "########################\n"; fout << "\n"; - for( std::map<cmStdString, CacheEntry>::const_iterator i = + for( std::map<std::string, CacheEntry>::const_iterator i = this->Cache.begin(); i != this->Cache.end(); ++i) { const CacheEntry& ce = (*i).second; @@ -578,7 +578,7 @@ bool cmCacheManager::SaveCache(const char* path) return true; } -bool cmCacheManager::DeleteCache(const char* path) +bool cmCacheManager::DeleteCache(const std::string& path) { std::string cacheFile = path; cmSystemTools::ConvertToUnixSlashes(cacheFile); @@ -644,13 +644,13 @@ void cmCacheManager::OutputHelpString(std::ostream& fout, fout << "\\n"; } oneLine = helpString.substr(pos, i - pos); - fout << oneLine.c_str() << "\n"; + fout << oneLine << "\n"; pos = i; } } } -void cmCacheManager::RemoveCacheEntry(const char* key) +void cmCacheManager::RemoveCacheEntry(const std::string& key) { CacheEntryMap::iterator i = this->Cache.find(key); if(i != this->Cache.end()) @@ -660,7 +660,8 @@ void cmCacheManager::RemoveCacheEntry(const char* key) } -cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key) +cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry( + const std::string& key) { CacheEntryMap::iterator i = this->Cache.find(key); if(i != this->Cache.end()) @@ -676,7 +677,7 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator( return CacheIterator(*this, key); } -const char* cmCacheManager::GetCacheValue(const char* key) const +const char* cmCacheManager::GetCacheValue(const std::string& key) const { CacheEntryMap::const_iterator i = this->Cache.find(key); if(i != this->Cache.end() && @@ -692,12 +693,12 @@ void cmCacheManager::PrintCache(std::ostream& out) const { out << "=================================================" << std::endl; out << "CMakeCache Contents:" << std::endl; - for(std::map<cmStdString, CacheEntry>::const_iterator i = + for(std::map<std::string, CacheEntry>::const_iterator i = this->Cache.begin(); i != this->Cache.end(); ++i) { if((*i).second.Type != INTERNAL) { - out << (*i).first.c_str() << " = " << (*i).second.Value.c_str() + out << (*i).first << " = " << (*i).second.Value << std::endl; } } @@ -708,7 +709,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const } -void cmCacheManager::AddCacheEntry(const char* key, +void cmCacheManager::AddCacheEntry(const std::string& key, const char* value, const char* helpString, CacheEntryType type) @@ -767,7 +768,7 @@ void cmCacheManager::CacheIterator::Begin() this->Position = this->Container.Cache.begin(); } -bool cmCacheManager::CacheIterator::Find(const char* key) +bool cmCacheManager::CacheIterator::Find(const std::string& key) { this->Position = this->Container.Cache.find(key); return !this->IsAtEnd(); @@ -807,13 +808,13 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const //---------------------------------------------------------------------------- const char* -cmCacheManager::CacheEntry::GetProperty(const char* prop) const +cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { return cmCacheManagerTypes[this->Type]; } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { return this->Value.c_str(); } @@ -823,14 +824,14 @@ cmCacheManager::CacheEntry::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheEntry::SetProperty(const char* prop, +void cmCacheManager::CacheEntry::SetProperty(const std::string& prop, const char* value) { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { this->Type = cmCacheManager::StringToType(value? value : "STRING"); } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { this->Value = value? value : ""; } @@ -841,15 +842,15 @@ void cmCacheManager::CacheEntry::SetProperty(const char* prop, } //---------------------------------------------------------------------------- -void cmCacheManager::CacheEntry::AppendProperty(const char* prop, +void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop, const char* value, bool asString) { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { this->Type = cmCacheManager::StringToType(value? value : "STRING"); } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { if(value) { @@ -867,7 +868,8 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop, } //---------------------------------------------------------------------------- -const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const +const char* cmCacheManager::CacheIterator::GetProperty( + const std::string& prop) const { if(!this->IsAtEnd()) { @@ -877,7 +879,8 @@ const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) +void cmCacheManager::CacheIterator::SetProperty(const std::string& p, + const char* v) { if(!this->IsAtEnd()) { @@ -886,7 +889,7 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::AppendProperty(const char* p, +void cmCacheManager::CacheIterator::AppendProperty(const std::string& p, const char* v, bool asString) { @@ -897,7 +900,8 @@ void cmCacheManager::CacheIterator::AppendProperty(const char* p, } //---------------------------------------------------------------------------- -bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const +bool cmCacheManager::CacheIterator::GetPropertyAsBool( + const std::string& prop) const { if(const char* value = this->GetProperty(prop)) { @@ -907,13 +911,14 @@ bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v) +void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v) { this->SetProperty(p, v ? "ON" : "OFF"); } //---------------------------------------------------------------------------- -bool cmCacheManager::CacheIterator::PropertyExists(const char* prop) const +bool cmCacheManager::CacheIterator::PropertyExists( + const std::string& prop) const { return this->GetProperty(prop)? true:false; } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index f487e8e..d9a9112 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -39,9 +39,9 @@ private: std::string Value; CacheEntryType Type; cmPropertyMap Properties; - const char* GetProperty(const char*) const; - void SetProperty(const char* property, const char* value); - void AppendProperty(const char* property, const char* value, + const char* GetProperty(const std::string&) const; + void SetProperty(const std::string& property, const char* value); + void AppendProperty(const std::string& property, const char* value, bool asString=false); bool Initialized; CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false) @@ -53,26 +53,26 @@ public: { public: void Begin(); - bool Find(const char*); + bool Find(const std::string&); bool IsAtEnd() const; void Next(); - const char *GetName() const { - return this->Position->first.c_str(); } - const char* GetProperty(const char*) const ; - bool GetPropertyAsBool(const char*) const ; - bool PropertyExists(const char*) const; - void SetProperty(const char* property, const char* value); - void AppendProperty(const char* property, const char* value, + std::string GetName() const { + return this->Position->first; } + const char* GetProperty(const std::string&) const ; + bool GetPropertyAsBool(const std::string&) const ; + bool PropertyExists(const std::string&) const; + void SetProperty(const std::string& property, const char* value); + void AppendProperty(const std::string& property, const char* value, bool asString=false); - void SetProperty(const char* property, bool value); - const char* GetValue() const { return this->GetEntry().Value.c_str(); } + void SetProperty(const std::string& property, bool value); + std::string GetValue() const { return this->GetEntry().Value; } bool GetValueAsBool() const; void SetValue(const char*); CacheEntryType GetType() const { return this->GetEntry().Type; } void SetType(CacheEntryType ty) { this->GetEntry().Type = ty; } bool Initialized() { return this->GetEntry().Initialized; } cmCacheManager &Container; - std::map<cmStdString, CacheEntry>::iterator Position; + std::map<std::string, CacheEntry>::iterator Position; CacheIterator(cmCacheManager &cm) : Container(cm) { this->Begin(); } @@ -108,19 +108,19 @@ public: ///! Load a cache for given makefile. Loads from ouput home. bool LoadCache(cmMakefile*); ///! Load a cache for given makefile. Loads from path/CMakeCache.txt. - bool LoadCache(const char* path); - bool LoadCache(const char* path, bool internal); - bool LoadCache(const char* path, bool internal, - std::set<cmStdString>& excludes, - std::set<cmStdString>& includes); + bool LoadCache(const std::string& path); + bool LoadCache(const std::string& path, bool internal); + bool LoadCache(const std::string& path, bool internal, + std::set<std::string>& excludes, + std::set<std::string>& includes); ///! Save cache for given makefile. Saves to ouput home CMakeCache.txt. bool SaveCache(cmMakefile*) ; ///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt - bool SaveCache(const char* path) ; + bool SaveCache(const std::string& path) ; ///! Delete the cache given - bool DeleteCache(const char* path); + bool DeleteCache(const std::string& path); ///! Print the cache to a stream void PrintCache(std::ostream&) const; @@ -129,20 +129,20 @@ public: cmCacheManager::CacheIterator GetCacheIterator(const char *key=0); ///! Remove an entry from the cache - void RemoveCacheEntry(const char* key); + void RemoveCacheEntry(const std::string& key); ///! Get the number of entries in the cache int GetSize() { return static_cast<int>(this->Cache.size()); } ///! Break up a line like VAR:type="value" into var, type and value - static bool ParseEntry(const char* entry, + static bool ParseEntry(const std::string& entry, std::string& var, std::string& value, CacheEntryType& type); ///! Get a value from the cache given a key - const char* GetCacheValue(const char* key) const; + const char* GetCacheValue(const std::string& key) const; /** Get the version of CMake that wrote the cache. */ unsigned int GetCacheMajorVersion() const @@ -153,20 +153,20 @@ public: protected: ///! Add an entry into the cache - void AddCacheEntry(const char* key, const char* value, + void AddCacheEntry(const std::string& key, const char* value, const char* helpString, CacheEntryType type); ///! Get a cache entry object for a key - CacheEntry *GetCacheEntry(const char *key); + CacheEntry *GetCacheEntry(const std::string& key); ///! Clean out the CMakeFiles directory if no CMakeCache.txt - void CleanCMakeFiles(const char* path); + void CleanCMakeFiles(const std::string& path); // Cache version info unsigned int CacheMajorVersion; unsigned int CacheMinorVersion; private: cmake* CMakeInstance; - typedef std::map<cmStdString, CacheEntry> CacheEntryMap; + typedef std::map<std::string, CacheEntry> CacheEntryMap; static void OutputHelpString(std::ostream& fout, const std::string& helpString); static void OutputKey(std::ostream& fout, std::string const& key); diff --git a/Source/cmCommand.h b/Source/cmCommand.h index e148857..b15869a 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -124,7 +124,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const = 0; + virtual std::string GetName() const = 0; /** * Enable the command. @@ -166,7 +166,7 @@ public: /** * Set the error message */ - void SetError(const char* e) + void SetError(const std::string& e) { this->Error = this->GetName(); this->Error += " "; diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index dbeeb07..a7f6b49 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -49,14 +49,14 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file) this->FileName = file; } -char* cmCommandArgumentParserHelper::AddString(const char* str) +char* cmCommandArgumentParserHelper::AddString(const std::string& str) { - if ( !str || !*str ) + if ( str.empty() ) { return this->EmptyVariable; } - char* stVal = new char[strlen(str)+1]; - strcpy(stVal, str); + char* stVal = new char[str.size()+1]; + strcpy(stVal, str.c_str()); this->Variables.push_back(stVal); return stVal; } @@ -79,7 +79,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, { if (this->EscapeQuotes) { - return this->AddString(cmSystemTools::EscapeQuotes(ptr).c_str()); + return this->AddString(cmSystemTools::EscapeQuotes(ptr)); } else { @@ -94,7 +94,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key, { if(this->EscapeQuotes) { - return this->AddString(cmSystemTools::EscapeQuotes(c).c_str()); + return this->AddString(cmSystemTools::EscapeQuotes(c)); } else { @@ -120,7 +120,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) { cmOStringStream ostr; ostr << this->FileLine; - return this->AddString(ostr.str().c_str()); + return this->AddString(ostr.str()); } const char* value = this->Makefile->GetDefinition(var); if(!value && !this->RemoveEmpty) @@ -144,16 +144,16 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) bt.push_back(lfc); msg << "uninitialized variable \'" << var << "\'"; this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str().c_str(), bt); + msg.str(), bt); } } return 0; } if (this->EscapeQuotes && value) { - return this->AddString(cmSystemTools::EscapeQuotes(value).c_str()); + return this->AddString(cmSystemTools::EscapeQuotes(value)); } - return this->AddString(value); + return this->AddString(value ? value : ""); } char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var) @@ -166,7 +166,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var) // then return an empty string if(!ret && this->RemoveEmpty) { - return this->AddString(ret); + return this->AddString(""); } // if the ret was not 0, then return it if(ret) @@ -181,7 +181,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var) std::string ref = "@"; ref += var; ref += "@"; - return this->AddString(ref.c_str()); + return this->AddString(ref); } char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2) @@ -293,7 +293,7 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb) if ( Verbose ) { std::cerr << "Expanding [" << str << "] produced: [" - << this->Result.c_str() << "]" << std::endl; + << this->Result << "]" << std::endl; } return 1; } diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index f8c672f..d375ae6 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -77,8 +77,8 @@ public: char BSLASHVariable[3]; private: - cmStdString::size_type InputBufferPos; - cmStdString InputBuffer; + std::string::size_type InputBufferPos; + std::string InputBuffer; std::vector<char> OutputBuffer; int CurrentLine; int Verbose; @@ -86,7 +86,7 @@ private: void Print(const char* place, const char* str); void SafePrintMissing(const char* str, int line, int cnt); - char* AddString(const char* str); + char* AddString(const std::string& str); void CleanupParser(); void SetError(std::string const& msg); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 1be5980..995f191 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -172,7 +172,7 @@ satisfy dependencies. //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const char* config, +::cmComputeLinkDepends(cmTarget const* target, const std::string& config, cmTarget const* head) { // Store context information. @@ -184,7 +184,8 @@ cmComputeLinkDepends this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. - this->Config = (config && *config)? config : 0; + this->HasConfig = !config.empty(); + this->Config = (this->HasConfig)? config : std::string(); this->LinkType = this->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. @@ -254,7 +255,8 @@ cmComputeLinkDepends::Compute() "---------------------------------------" "---------------------------------------\n"); fprintf(stderr, "Link dependency analysis for target %s, config %s\n", - this->Target->GetName(), this->Config?this->Config:"noconfig"); + this->Target->GetName().c_str(), + this->HasConfig?this->Config.c_str():"noconfig"); this->DisplayConstraintGraph(); } @@ -278,12 +280,12 @@ cmComputeLinkDepends::Compute() } //---------------------------------------------------------------------------- -std::map<cmStdString, int>::iterator +std::map<std::string, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(std::string const& item) { - std::map<cmStdString, int>::value_type + std::map<std::string, int>::value_type index_entry(item, static_cast<int>(this->EntryList.size())); - std::map<cmStdString, int>::iterator + std::map<std::string, int>::iterator lei = this->LinkEntryIndex.insert(index_entry).first; this->EntryList.push_back(LinkEntry()); this->InferredDependSets.push_back(0); @@ -296,7 +298,7 @@ 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); + std::map<std::string, int>::iterator lei = this->LinkEntryIndex.find(item); if(lei != this->LinkEntryIndex.end()) { // Yes. We do not need to follow the item's dependencies again. @@ -310,7 +312,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index, int index = lei->second; LinkEntry& entry = this->EntryList[index]; entry.Item = item; - entry.Target = this->FindTargetToLink(depender_index, entry.Item.c_str()); + entry.Target = this->FindTargetToLink(depender_index, entry.Item); entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' && item.substr(0, 10) != "-framework"); @@ -326,7 +328,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index, // Look for an old-style <item>_LIB_DEPENDS variable. std::string var = entry.Item; var += "_LIB_DEPENDS"; - if(const char* val = this->Makefile->GetDefinition(var.c_str())) + if(const char* val = this->Makefile->GetDefinition(var)) { // The item dependencies are known. Follow them. BFSEntry qe = {index, val}; @@ -422,7 +424,7 @@ cmComputeLinkDepends void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) { // Check if the target already has an entry. - std::map<cmStdString, int>::iterator lei = + std::map<std::string, int>::iterator lei = this->LinkEntryIndex.find(dep.Item); if(lei == this->LinkEntryIndex.end()) { @@ -433,7 +435,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) LinkEntry& entry = this->EntryList[lei->second]; entry.Item = dep.Item; entry.Target = this->FindTargetToLink(dep.DependerIndex, - dep.Item.c_str()); + dep.Item); // This item was added specifically because it is a dependent // shared library. It may get special treatment @@ -504,7 +506,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, { std::string var = *di; var += "_LINK_TYPE"; - if(const char* val = this->Makefile->GetDefinition(var.c_str())) + if(const char* val = this->Makefile->GetDefinition(var)) { if(strcmp(val, "debug") == 0) { @@ -620,7 +622,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, //---------------------------------------------------------------------------- cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, - const char* name) + const std::string& name) { // Look for a target in the scope of the depender. cmMakefile* mf = this->Makefile; @@ -968,14 +970,14 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) //---------------------------------------------------------------------------- void cmComputeLinkDepends::DisplayFinalEntries() { - fprintf(stderr, "target [%s] links to:\n", this->Target->GetName()); + fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str()); for(std::vector<LinkEntry>::const_iterator lei = this->FinalLinkEntries.begin(); lei != this->FinalLinkEntries.end(); ++lei) { if(lei->Target) { - fprintf(stderr, " target [%s]\n", lei->Target->GetName()); + fprintf(stderr, " target [%s]\n", lei->Target->GetName().c_str()); } else { @@ -998,7 +1000,7 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index, // directories of targets linked in another configuration as link // directories. if(cmTarget const* tgt - = this->FindTargetToLink(depender_index, item.c_str())) + = this->FindTargetToLink(depender_index, item)) { if(!tgt->IsImported()) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 9776f55..13fc993 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -32,7 +32,7 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const char* config, + cmComputeLinkDepends(cmTarget const* target, const std::string& config, cmTarget const* head); ~cmComputeLinkDepends(); @@ -68,7 +68,8 @@ private: bool DebugMode; // Configuration information. - const char* Config; + bool HasConfig; + std::string Config; cmTarget::LinkLibraryType LinkType; // Output information. @@ -76,18 +77,19 @@ private: typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType; - std::map<cmStdString, int>::iterator + std::map<std::string, int>::iterator AllocateLinkEntry(std::string const& item); int AddLinkEntry(int depender_index, std::string const& item); void AddVarLinkEntries(int depender_index, const char* value); void AddDirectLinkEntries(); void AddLinkEntries(int depender_index, std::vector<std::string> const& libs); - cmTarget const* FindTargetToLink(int depender_index, const char* name); + cmTarget const* FindTargetToLink(int depender_index, + const std::string& name); // One entry for each unique item. std::vector<LinkEntry> EntryList; - std::map<cmStdString, int> LinkEntryIndex; + std::map<std::string, int> LinkEntryIndex; // BFS of initial dependencies. struct BFSEntry diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6986965..ea8536f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -239,7 +239,7 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const char* config, +::cmComputeLinkInformation(cmTarget const* target, const std::string& config, cmTarget const* headTarget) { // Store context information. @@ -268,7 +268,7 @@ cmComputeLinkInformation // Get the language used for linking this target. this->LinkLanguage = this->Target->GetLinkerLanguage(config, headTarget); - if(!this->LinkLanguage) + if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the // initialization. @@ -293,7 +293,7 @@ cmComputeLinkInformation std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; loader_flag_var += "_FLAG"; - this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var.c_str()); + this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var); } // Get options needed to link libraries. @@ -317,8 +317,8 @@ cmComputeLinkInformation rtVar += this->LinkLanguage; rtVar += "_FLAG"; std::string rtSepVar = rtVar + "_SEP"; - this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar.c_str()); - this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar.c_str()); + this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar); + this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar); this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); @@ -330,7 +330,7 @@ cmComputeLinkInformation rlVar += "_RPATH_LINK_"; rlVar += this->LinkLanguage; rlVar += "_FLAG"; - this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar.c_str()); + this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar); } // Check if we need to include the runtime search path at link time. @@ -338,7 +338,7 @@ cmComputeLinkInformation std::string var = "CMAKE_SHARED_LIBRARY_LINK_"; var += this->LinkLanguage; var += "_WITH_RUNTIME_PATH"; - this->LinkWithRuntimePath = this->Makefile->IsOn(var.c_str()); + this->LinkWithRuntimePath = this->Makefile->IsOn(var); } // Check the platform policy for missing soname case. @@ -496,16 +496,17 @@ bool cmComputeLinkInformation::Compute() } // We require a link language for the target. - if(!this->LinkLanguage) + if(this->LinkLanguage.empty()) { cmSystemTools:: Error("CMake can not determine linker language for target: ", - this->Target->GetName()); + this->Target->GetName().c_str()); return false; } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config, this->HeadTarget); + cmComputeLinkDepends cld(this->Target, this->Config, + this->HeadTarget); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -592,7 +593,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) std::string libVar = "CMAKE_"; libVar += lang; libVar += "_IMPLICIT_LINK_LIBRARIES"; - if(const char* libs = this->Makefile->GetDefinition(libVar.c_str())) + if(const char* libs = this->Makefile->GetDefinition(libVar)) { std::vector<std::string> libsVec; cmSystemTools::ExpandListArgument(libs, libsVec); @@ -601,7 +602,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) { if(this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end()) { - this->AddItem(i->c_str(), 0); + this->AddItem(*i, 0); } } } @@ -611,7 +612,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) std::string dirVar = "CMAKE_"; dirVar += lang; dirVar += "_IMPLICIT_LINK_DIRECTORIES"; - if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str())) + if(const char* dirs = this->Makefile->GetDefinition(dirVar)) { std::vector<std::string> dirsVec; cmSystemTools::ExpandListArgument(dirs, dirsVec); @@ -624,7 +625,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget const* tgt) { // Compute the proper name to use to link this library. - const char* config = this->Config; + const std::string& config = this->Config; bool impexe = (tgt && tgt->IsExecutableWithExports()); if(impexe && !this->UseImportLibrary && !this->LoaderFlag) { @@ -819,7 +820,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() static_link_type_flag_var += this->LinkLanguage; static_link_type_flag_var += "_FLAGS"; static_link_type_flag = - this->Makefile->GetDefinition(static_link_type_flag_var.c_str()); + this->Makefile->GetDefinition(static_link_type_flag_var); std::string shared_link_type_flag_var = "CMAKE_"; shared_link_type_flag_var += target_type_str; @@ -827,7 +828,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() shared_link_type_flag_var += this->LinkLanguage; shared_link_type_flag_var += "_FLAGS"; shared_link_type_flag = - this->Makefile->GetDefinition(shared_link_type_flag_var.c_str()); + this->Makefile->GetDefinition(shared_link_type_flag_var); } // We can support link type switching only if all needed flags are @@ -902,7 +903,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo() // be the library name. Match index 3 will be the library // extension. reg = "^("; - for(std::set<cmStdString>::iterator p = this->LinkPrefixes.begin(); + for(std::set<std::string>::iterator p = this->LinkPrefixes.begin(); p != this->LinkPrefixes.end(); ++p) { reg += *p; @@ -1126,9 +1127,10 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. + std::string generator = this->GlobalGenerator->GetName(); if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && - (strstr(this->GlobalGenerator->GetName(), "Visual Studio") || - strstr(this->GlobalGenerator->GetName(), "Xcode"))) + (generator.find("Visual Studio") != generator.npos || + generator.find("Xcode") != generator.npos)) { std::string file = cmSystemTools::GetFilenameName(item); if(!this->ExtractAnyLibraryName.find(file.c_str())) @@ -1368,7 +1370,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item) // Add the item using the -framework option. this->Items.push_back(Item("-framework", false)); - fw = this->LocalGenerator->EscapeForShell(fw.c_str()); + fw = this->LocalGenerator->EscapeForShell(fw); this->Items.push_back(Item(fw, false)); } @@ -1417,7 +1419,7 @@ void cmComputeLinkInformation::ComputeFrameworkInfo() implicitDirVar += this->LinkLanguage; implicitDirVar += "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES"; if(const char* implicitDirs = - this->Makefile->GetDefinition(implicitDirVar.c_str())) + this->Makefile->GetDefinition(implicitDirVar)) { cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec); } @@ -1504,9 +1506,9 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, // Print the warning at most once for this item. std::string wid = "CMP0008-WARNING-GIVEN-"; wid += item; - if(!this->CMakeInstance->GetPropertyAsBool(wid.c_str())) + if(!this->CMakeInstance->GetPropertyAsBool(wid)) { - this->CMakeInstance->SetProperty(wid.c_str(), "1"); + this->CMakeInstance->SetProperty(wid, "1"); cmOStringStream w; w << (this->Makefile->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0008)) << "\n" @@ -1640,7 +1642,7 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os) // List the paths old behavior is adding. os << "and other libraries with known full path:\n"; - std::set<cmStdString> emitted; + std::set<std::string> emitted; for(std::vector<std::string>::const_iterator i = this->OldLinkDirItems.begin(); i != this->OldLinkDirItems.end(); ++i) @@ -1690,7 +1692,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() implicitDirVar += this->LinkLanguage; implicitDirVar += "_IMPLICIT_LINK_DIRECTORIES"; if(const char* implicitDirs = - this->Makefile->GetDefinition(implicitDirVar.c_str())) + this->Makefile->GetDefinition(implicitDirVar)) { cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec); } @@ -1708,7 +1710,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() implicitLibVar += this->LinkLanguage; implicitLibVar += "_IMPLICIT_LINK_LIBRARIES"; if(const char* implicitLibs = - this->Makefile->GetDefinition(implicitLibVar.c_str())) + this->Makefile->GetDefinition(implicitLibVar)) { cmSystemTools::ExpandListArgument(implicitLibs, implicitLibVec); } @@ -1856,7 +1858,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath) //---------------------------------------------------------------------------- static void cmCLI_ExpandListUnique(const char* str, std::vector<std::string>& out, - std::set<cmStdString>& emitted) + std::set<std::string>& emitted) { std::vector<std::string> tmp; cmSystemTools::ExpandListArgument(str, tmp); @@ -1894,7 +1896,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. - std::set<cmStdString> emitted; + std::set<std::string> emitted; if(use_install_rpath) { const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); @@ -1976,11 +1978,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, { std::string useVar = "CMAKE_" + *li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH"; - if(this->Makefile->IsOn(useVar.c_str())) + if(this->Makefile->IsOn(useVar)) { std::string dirVar = "CMAKE_" + *li + "_IMPLICIT_LINK_DIRECTORIES"; - if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str())) + if(const char* dirs = this->Makefile->GetDefinition(dirVar)) { cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted); } diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 356e6ed..e345fe2 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,7 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const char* config, + cmComputeLinkInformation(cmTarget const* target, const std::string& config, cmTarget const* headTarget); ~cmComputeLinkInformation(); bool Compute(); @@ -50,7 +50,7 @@ public: std::vector<std::string> const& GetDirectories(); std::vector<std::string> const& GetDepends(); std::vector<std::string> const& GetFrameworkPaths(); - const char* GetLinkLanguage() const { return this->LinkLanguage; } + std::string GetLinkLanguage() const { return this->LinkLanguage; } std::vector<std::string> const& GetRuntimeSearchPath(); std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; } std::string const& GetRuntimeSep() const { return this->RuntimeSep; } @@ -82,8 +82,8 @@ private: cmake* CMakeInstance; // Configuration information. - const char* Config; - const char* LinkLanguage; + std::string Config; + std::string LinkLanguage; bool LinkDependsNoShared; // Modes for dealing with dependent shared libraries. @@ -126,7 +126,7 @@ private: std::vector<std::string> StaticLinkExtensions; std::vector<std::string> SharedLinkExtensions; std::vector<std::string> LinkExtensions; - std::set<cmStdString> LinkPrefixes; + std::set<std::string> LinkPrefixes; cmsys::RegularExpression ExtractStaticLibraryName; cmsys::RegularExpression ExtractSharedLibraryName; cmsys::RegularExpression ExtractAnyLibraryName; @@ -153,7 +153,7 @@ private: // Framework info. void ComputeFrameworkInfo(); void AddFrameworkPath(std::string const& p); - std::set<cmStdString> FrameworkPathsEmmitted; + std::set<std::string> FrameworkPathsEmmitted; cmsys::RegularExpression SplitFramework; // Linker search path computation. @@ -165,14 +165,14 @@ private: void LoadImplicitLinkInfo(); void AddImplicitLinkInfo(); void AddImplicitLinkInfo(std::string const& lang); - std::set<cmStdString> ImplicitLinkDirs; - std::set<cmStdString> ImplicitLinkLibs; + std::set<std::string> ImplicitLinkDirs; + std::set<std::string> ImplicitLinkLibs; // Additional paths configured by the runtime linker std::vector<std::string> RuntimeLinkDirs; // Linker search path compatibility mode. - std::set<cmStdString> OldLinkDirMask; + std::set<std::string> OldLinkDirMask; std::vector<std::string> OldLinkDirItems; std::vector<std::string> OldUserFlagItems; bool OldLinkDirMode; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 9136869..5ba843f 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -211,10 +211,10 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // dependencies in all targets, because the generated build-systems can't // deal with config-specific dependencies. { - std::set<cmStdString> emitted; + std::set<std::string> emitted; { std::vector<std::string> tlibs; - depender->GetDirectLinkLibraries(0, tlibs, depender); + depender->GetDirectLinkLibraries("", tlibs, depender); // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); @@ -223,8 +223,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same library twice for this target. if(emitted.insert(*lib).second) { - this->AddTargetDepend(depender_index, lib->c_str(), true); - this->AddInterfaceDepends(depender_index, lib->c_str(), + this->AddTargetDepend(depender_index, *lib, true); + this->AddInterfaceDepends(depender_index, *lib, true, emitted); } } @@ -235,7 +235,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) it != configs.end(); ++it) { std::vector<std::string> tlibs; - depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); + depender->GetDirectLinkLibraries(*it, tlibs, depender); // A target should not depend on itself. emitted.insert(depender->GetName()); @@ -245,8 +245,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same library twice for this target. if(emitted.insert(*lib).second) { - this->AddTargetDepend(depender_index, lib->c_str(), true); - this->AddInterfaceDepends(depender_index, lib->c_str(), + this->AddTargetDepend(depender_index, *lib, true); + this->AddInterfaceDepends(depender_index, *lib, true, emitted); } } @@ -255,17 +255,17 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Loop over all utility dependencies. { - std::set<cmStdString> const& tutils = depender->GetUtilities(); - std::set<cmStdString> emitted; + std::set<std::string> const& tutils = depender->GetUtilities(); + std::set<std::string> emitted; // A target should not depend on itself. emitted.insert(depender->GetName()); - for(std::set<cmStdString>::const_iterator util = tutils.begin(); + for(std::set<std::string>::const_iterator util = tutils.begin(); util != tutils.end(); ++util) { // Don't emit the same utility twice for this target. if(emitted.insert(*util).second) { - this->AddTargetDepend(depender_index, util->c_str(), false); + this->AddTargetDepend(depender_index, *util, false); } } } @@ -274,8 +274,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, cmTarget const* dependee, - const char *config, - std::set<cmStdString> &emitted) + const std::string& config, + std::set<std::string> &emitted) { cmTarget const* depender = this->Targets[depender_index]; if(cmTarget::LinkInterface const* iface = @@ -288,8 +288,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, // Don't emit the same library twice for this target. if(emitted.insert(*lib).second) { - this->AddTargetDepend(depender_index, lib->c_str(), true); - this->AddInterfaceDepends(depender_index, lib->c_str(), + this->AddTargetDepend(depender_index, *lib, true); + this->AddInterfaceDepends(depender_index, *lib, true, emitted); } } @@ -298,9 +298,9 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, - const char* dependee_name, + const std::string& dependee_name, bool linking, - std::set<cmStdString> &emitted) + std::set<std::string> &emitted) { cmTarget const* depender = this->Targets[depender_index]; cmTarget const* dependee = @@ -317,7 +317,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, if(dependee) { - this->AddInterfaceDepends(depender_index, dependee, 0, emitted); + this->AddInterfaceDepends(depender_index, dependee, "", emitted); std::vector<std::string> configs; depender->GetMakefile()->GetConfigurations(configs); for (std::vector<std::string>::const_iterator it = configs.begin(); @@ -326,14 +326,14 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, // A target should not depend on itself. emitted.insert(depender->GetName()); this->AddInterfaceDepends(depender_index, dependee, - it->c_str(), emitted); + *it, emitted); } } } //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, - const char* dependee_name, + const std::string& dependee_name, bool linking) { // Get the depender. @@ -407,8 +407,8 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, if(dependee->IsImported()) { // Skip imported targets but follow their utility dependencies. - std::set<cmStdString> const& utils = dependee->GetUtilities(); - for(std::set<cmStdString>::const_iterator i = utils.begin(); + std::set<std::string> const& utils = dependee->GetUtilities(); + for(std::set<std::string>::const_iterator i = utils.begin(); i != utils.end(); ++i) { if(cmTarget const* transitive_dependee = @@ -435,22 +435,23 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, //---------------------------------------------------------------------------- void -cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name) +cmComputeTargetDepends::DisplayGraph(Graph const& graph, + const std::string& name) { - fprintf(stderr, "The %s target dependency graph is:\n", name); + fprintf(stderr, "The %s target dependency graph is:\n", name.c_str()); int n = static_cast<int>(graph.size()); for(int depender_index = 0; depender_index < n; ++depender_index) { EdgeList const& nl = graph[depender_index]; cmTarget const* depender = this->Targets[depender_index]; fprintf(stderr, "target %d is [%s]\n", - depender_index, depender->GetName()); + depender_index, depender->GetName().c_str()); for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int dependee_index = *ni; cmTarget const* dependee = this->Targets[dependee_index]; fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, - dependee->GetName(), ni->IsStrong()? "strong" : "weak"); + dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak"); } } fprintf(stderr, "\n"); @@ -472,7 +473,7 @@ cmComputeTargetDepends { int i = *ni; fprintf(stderr, " contains target %d [%s]\n", - i, this->Targets[i]->GetName()); + i, this->Targets[i]->GetName().c_str()); } } fprintf(stderr, "\n"); diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 6cd6da0..7553816 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -45,16 +45,18 @@ private: void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); - void AddTargetDepend(int depender_index, const char* dependee_name, + void AddTargetDepend(int depender_index, + const std::string& dependee_name, bool linking); void AddTargetDepend(int depender_index, cmTarget const* dependee, bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); - void AddInterfaceDepends(int depender_index, const char* dependee_name, - bool linking, std::set<cmStdString> &emitted); + void AddInterfaceDepends(int depender_index, + const std::string& dependee_name, + bool linking, std::set<std::string> &emitted); void AddInterfaceDepends(int depender_index, cmTarget const* dependee, - const char *config, - std::set<cmStdString> &emitted); + const std::string& config, + std::set<std::string> &emitted); cmGlobalGenerator* GlobalGenerator; bool DebugMode; bool NoCycles; @@ -71,7 +73,7 @@ private: typedef cmGraphAdjacencyList Graph; Graph InitialGraph; Graph FinalGraph; - void DisplayGraph(Graph const& graph, const char* name); + void DisplayGraph(Graph const& graph, const std::string& name); // Deal with connected components. void DisplayComponents(cmComputeComponentGraph const& ccg); diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index c5e95d0..2b0280d 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -16,4 +16,5 @@ #cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE #cmakedefine HAVE_UNSETENV #cmakedefine CMAKE_USE_ELF_PARSER +#cmakedefine CMAKE_ENCODING_UTF8 #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index f8ec642..395e6c8 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -38,7 +38,7 @@ bool cmConfigureFileCommand e << "input location\n" << " " << this->InputFile << "\n" << "is a directory but a file was expected."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -61,14 +61,14 @@ bool cmConfigureFileCommand { std::string e = "attempted to configure a file: " + this->OutputFile + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } std::string errorMessage; if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) { - this->SetError(errorMessage.c_str()); + this->SetError(errorMessage); return false; } this->CopyOnly = false; diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 86de92c..8155ef7 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -34,7 +34,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "configure_file";} + virtual std::string GetName() const { return "configure_file";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 7b52069..a3f3277 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -28,7 +28,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) const char* sourceDirectory = argv[2].c_str(); const char* projectName = 0; - const char* targetName = 0; + std::string targetName; std::vector<std::string> cmakeFlags; std::vector<std::string> compileDefs; std::string outputVariable; @@ -249,7 +249,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) si != sources.end(); ++si) { std::string ext = cmSystemTools::GetFilenameLastExtension(*si); - if(const char* lang = gg->GetLanguageFromExtension(ext.c_str())) + std::string lang = gg->GetLanguageFromExtension(ext.c_str()); + if(!lang.empty()) { testLangs.insert(lang); } @@ -283,7 +284,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { cmOStringStream e; e << "Failed to open\n" - << " " << outFileName.c_str() << "\n" + << " " << outFileName << "\n" << cmSystemTools::GetLastSystemError(); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return -1; @@ -306,13 +307,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; std::string rulesOverrideLang = rulesOverrideBase + "_" + *li; if(const char* rulesOverridePath = - this->Makefile->GetDefinition(rulesOverrideLang.c_str())) + this->Makefile->GetDefinition(rulesOverrideLang)) { fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(), rulesOverridePath); } else if(const char* rulesOverridePath2 = - this->Makefile->GetDefinition(rulesOverrideBase.c_str())) + this->Makefile->GetDefinition(rulesOverrideBase)) { fprintf(fout, "set(%s \"%s\")\n", rulesOverrideBase.c_str(), rulesOverridePath2); @@ -324,7 +325,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) li != testLangs.end(); ++li) { std::string langFlags = "CMAKE_" + *li + "_FLAGS"; - const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); + const char* flags = this->Makefile->GetDefinition(langFlags); fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(), lg->EscapeForCMake(flags?flags:"").c_str()); fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" @@ -356,7 +357,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) cmExportTryCompileFileGenerator tcfg; tcfg.SetExportFile((this->BinaryDirectory + fname).c_str()); tcfg.SetExports(targets); - tcfg.SetConfig(this->Makefile->GetDefinition( + tcfg.SetConfig(this->Makefile->GetSafeDefinition( "CMAKE_TRY_COMPILE_CONFIGURATION")); if(!tcfg.GenerateImportFile()) @@ -449,7 +450,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", this->BinaryDirectory.c_str()); /* Create the actual executable. */ - fprintf(fout, "add_executable(%s", targetName); + fprintf(fout, "add_executable(%s", targetName.c_str()); for(std::vector<std::string>::iterator si = sources.begin(); si != sources.end(); ++si) { @@ -465,12 +466,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (useOldLinkLibs) { fprintf(fout, - "target_link_libraries(%s ${LINK_LIBRARIES})\n",targetName); + "target_link_libraries(%s ${LINK_LIBRARIES})\n", + targetName.c_str()); } else { fprintf(fout, "target_link_libraries(%s %s)\n", - targetName, + targetName.c_str(), libsToLink.c_str()); } fclose(fout); @@ -482,7 +484,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::string output; // actually do the try compile now that everything is setup int res = this->Makefile->TryCompile(sourceDirectory, - this->BinaryDirectory.c_str(), + this->BinaryDirectory, projectName, targetName, this->SrcFileSignature, @@ -494,14 +496,14 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) } // set the result var to the return value to indicate success or failure - this->Makefile->AddCacheDefinition(argv[0].c_str(), + this->Makefile->AddCacheDefinition(argv[0], (res == 0 ? "TRUE" : "FALSE"), "Result of TRY_COMPILE", cmCacheManager::INTERNAL); if ( outputVariable.size() > 0 ) { - this->Makefile->AddDefinition(outputVariable.c_str(), output.c_str()); + this->Makefile->AddDefinition(outputVariable, output.c_str()); } if (this->SrcFileSignature) @@ -517,9 +519,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { cmOStringStream emsg; emsg << "Cannot copy output executable\n" - << " '" << this->OutputFile.c_str() << "'\n" + << " '" << this->OutputFile << "'\n" << "to destination specified by COPY_FILE:\n" - << " '" << copyFile.c_str() << "'\n"; + << " '" << copyFile << "'\n"; if(!this->FindErrorMessage.empty()) { emsg << this->FindErrorMessage.c_str(); @@ -538,7 +540,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if(!copyFileError.empty()) { - this->Makefile->AddDefinition(copyFileError.c_str(), + this->Makefile->AddDefinition(copyFileError, copyFileErrorMessage.c_str()); } } @@ -564,7 +566,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) cmsys::Directory dir; dir.Load(binDir); size_t fileNum; - std::set<cmStdString> deletedFiles; + std::set<std::string> deletedFiles; for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") && @@ -609,7 +611,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) } } -void cmCoreTryCompile::FindOutputFile(const char* targetName) +void cmCoreTryCompile::FindOutputFile(const std::string& targetName) { this->FindErrorMessage = ""; this->OutputFile = ""; diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index 5c67f13..3272462 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -44,7 +44,7 @@ public: TryCompileCode. The result is stored in OutputFile. If nothing is found, the error message is stored in FindErrorMessage. */ - void FindOutputFile(const char* targetName); + void FindOutputFile(const std::string& targetName); cmTypeMacro(cmCoreTryCompile, cmCommand); diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index de20cb7..02fb8cb 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -169,13 +169,13 @@ bool cmCreateTestSourceList // Construct the source list. std::string sourceListValue; { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver.c_str()); + cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver); sf->SetProperty("ABSTRACT","0"); sourceListValue = args[1]; } for(i = testsBegin; i != tests.end(); ++i) { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str()); + cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); sf->SetProperty("ABSTRACT","0"); sourceListValue += ";"; sourceListValue += *i; diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h index 8b1e4de..2f6b541 100644 --- a/Source/cmCreateTestSourceList.h +++ b/Source/cmCreateTestSourceList.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "create_test_sourcelist";} + virtual std::string GetName() const {return "create_test_sourcelist";} cmTypeMacro(cmCreateTestSourceList, cmCommand); }; diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 7f4b10f..0d3c6bb 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -35,18 +35,18 @@ cmsys::auto_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo) } //---------------------------------------------------------------------------- -std::string cmCryptoHash::HashString(const char* input) +std::string cmCryptoHash::HashString(const std::string& input) { this->Initialize(); - this->Append(reinterpret_cast<unsigned char const*>(input), - static_cast<int>(strlen(input))); + this->Append(reinterpret_cast<unsigned char const*>(&input[0]), + static_cast<int>(input.size())); return this->Finalize(); } //---------------------------------------------------------------------------- -std::string cmCryptoHash::HashFile(const char* file) +std::string cmCryptoHash::HashFile(const std::string& file) { - cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(file.c_str(), std::ios::in | cmsys_ios_binary); if(!fin) { return ""; diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 1bea9ab..88cd240 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -21,8 +21,8 @@ class cmCryptoHash public: virtual ~cmCryptoHash() {} static cmsys::auto_ptr<cmCryptoHash> New(const char* algo); - std::string HashString(const char* input); - std::string HashFile(const char* file); + std::string HashString(const std::string& input); + std::string HashFile(const std::string& file); protected: virtual void Initialize()=0; virtual void Append(unsigned char const*, int)=0; diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index b672148..ac2eef8 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -101,16 +101,6 @@ const std::vector<std::string>& cmCustomCommand::GetOutputs() const } //---------------------------------------------------------------------------- -const char* cmCustomCommand::GetWorkingDirectory() const -{ - if(this->WorkingDirectory.size() == 0) - { - return 0; - } - return this->WorkingDirectory.c_str(); -} - -//---------------------------------------------------------------------------- const std::vector<std::string>& cmCustomCommand::GetDepends() const { return this->Depends; diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 6851105..b5d7e62 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -42,12 +42,13 @@ public: /** Get the output file produced by the command. */ const std::vector<std::string>& GetOutputs() const; - /** Get the working directory. */ - const char* GetWorkingDirectory() const; - /** Get the vector that holds the list of dependencies. */ const std::vector<std::string>& GetDepends() const; + /** Get the working directory. */ + std::string const& GetWorkingDirectory() const + { return this->WorkingDirectory; } + /** Get the list of command lines. */ const cmCustomCommandLines& GetCommandLines() const; @@ -72,7 +73,7 @@ public: /** Backtrace of the command that created this custom command. */ cmListFileBacktrace const& GetBacktrace() const; - typedef std::pair<cmStdString, cmStdString> ImplicitDependsPair; + typedef std::pair<std::string, std::string> ImplicitDependsPair; class ImplicitDependsList: public std::vector<ImplicitDependsPair> {}; void SetImplicitDepends(ImplicitDependsList const&); void AppendImplicitDepends(ImplicitDependsList const&); diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index f24dfa2..cebd9f5 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -18,10 +18,10 @@ //---------------------------------------------------------------------------- cmCustomCommandGenerator::cmCustomCommandGenerator( - cmCustomCommand const& cc, const char* config, cmMakefile* mf): + cmCustomCommand const& cc, const std::string& config, cmMakefile* mf): CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()), OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()), - GE(new cmGeneratorExpression(cc.GetBacktrace())) + GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false) { } @@ -63,11 +63,49 @@ cmCustomCommandGenerator cmd += " "; if(this->OldStyle) { - cmd += this->LG->EscapeForShellOldStyle(arg.c_str()); + cmd += this->LG->EscapeForShellOldStyle(arg); } else { - cmd += this->LG->EscapeForShell(arg.c_str(), this->MakeVars); + cmd += this->LG->EscapeForShell(arg, this->MakeVars); } } } + +//---------------------------------------------------------------------------- +const char* cmCustomCommandGenerator::GetComment() const +{ + return this->CC.GetComment(); +} + +//---------------------------------------------------------------------------- +std::string cmCustomCommandGenerator::GetWorkingDirectory() const +{ + return this->CC.GetWorkingDirectory(); +} + +//---------------------------------------------------------------------------- +std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const +{ + return this->CC.GetOutputs(); +} + +//---------------------------------------------------------------------------- +std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const +{ + if (!this->DependsDone) + { + this->DependsDone = true; + std::vector<std::string> depends = this->CC.GetDepends(); + for(std::vector<std::string>::const_iterator + i = depends.begin(); + i != depends.end(); ++i) + { + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge + = this->GE->Parse(*i); + cmSystemTools::ExpandListArgument( + cge->Evaluate(this->Makefile, this->Config), this->Depends); + } + } + return this->Depends; +} diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 4e89f27..0d8a0a4 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -22,19 +22,27 @@ class cmGeneratorExpression; class cmCustomCommandGenerator { cmCustomCommand const& CC; - const char* Config; + std::string Config; cmMakefile* Makefile; cmLocalGenerator* LG; bool OldStyle; bool MakeVars; cmGeneratorExpression* GE; + mutable bool DependsDone; + mutable std::vector<std::string> Depends; public: - cmCustomCommandGenerator(cmCustomCommand const& cc, const char* config, + cmCustomCommandGenerator(cmCustomCommand const& cc, + const std::string& config, cmMakefile* mf); ~cmCustomCommandGenerator(); + cmCustomCommand const& GetCC() const { return this->CC; } unsigned int GetNumberOfCommands() const; std::string GetCommand(unsigned int c) const; void AppendArguments(unsigned int c, std::string& cmd) const; + const char* GetComment() const; + std::string GetWorkingDirectory() const; + std::vector<std::string> const& GetOutputs() const; + std::vector<std::string> const& GetDepends() const; }; #endif diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 1ad98af..6b729de 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -58,7 +58,7 @@ bool cmDefinePropertyCommand << "Valid scopes are " << "GLOBAL, DIRECTORY, TARGET, SOURCE, " << "TEST, VARIABLE, CACHED_VARIABLE."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -102,7 +102,7 @@ bool cmDefinePropertyCommand { cmOStringStream e; e << "given invalid argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -128,7 +128,7 @@ bool cmDefinePropertyCommand // Actually define the property. this->Makefile->GetCMakeInstance()->DefineProperty - (this->PropertyName.c_str(), scope, + (this->PropertyName, scope, this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited); return true; diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h index 8dc4d96..bc5c8a4 100644 --- a/Source/cmDefinePropertyCommand.h +++ b/Source/cmDefinePropertyCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "define_property";} + virtual std::string GetName() const { return "define_property";} cmTypeMacro(cmDefinePropertyCommand, cmCommand); private: diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 9d28700..babf1c4 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -28,7 +28,7 @@ void cmDefinitions::Reset(cmDefinitions* parent) //---------------------------------------------------------------------------- cmDefinitions::Def const& -cmDefinitions::GetInternal(const char* key) +cmDefinitions::GetInternal(const std::string& key) { MapType::const_iterator i = this->Map.find(key); if(i != this->Map.end()) @@ -46,7 +46,7 @@ cmDefinitions::GetInternal(const char* key) //---------------------------------------------------------------------------- cmDefinitions::Def const& -cmDefinitions::SetInternal(const char* key, Def const& def) +cmDefinitions::SetInternal(const std::string& key, Def const& def) { if(this->Up || def.Exists) { @@ -71,23 +71,23 @@ cmDefinitions::SetInternal(const char* key, Def const& def) } //---------------------------------------------------------------------------- -const char* cmDefinitions::Get(const char* key) +const char* cmDefinitions::Get(const std::string& key) { Def const& def = this->GetInternal(key); return def.Exists? def.c_str() : 0; } //---------------------------------------------------------------------------- -const char* cmDefinitions::Set(const char* key, const char* value) +const char* cmDefinitions::Set(const std::string& key, const char* value) { Def const& def = this->SetInternal(key, Def(value)); return def.Exists? def.c_str() : 0; } //---------------------------------------------------------------------------- -std::set<cmStdString> cmDefinitions::LocalKeys() const +std::set<std::string> cmDefinitions::LocalKeys() const { - std::set<cmStdString> keys; + std::set<std::string> keys; // Consider local definitions. for(MapType::const_iterator mi = this->Map.begin(); mi != this->Map.end(); ++mi) @@ -110,12 +110,12 @@ cmDefinitions cmDefinitions::Closure() const cmDefinitions::cmDefinitions(ClosureTag const&, cmDefinitions const* root): Up(0) { - std::set<cmStdString> undefined; + std::set<std::string> undefined; this->ClosureImpl(undefined, root); } //---------------------------------------------------------------------------- -void cmDefinitions::ClosureImpl(std::set<cmStdString>& undefined, +void cmDefinitions::ClosureImpl(std::set<std::string>& undefined, cmDefinitions const* defs) { // Consider local definitions. @@ -145,17 +145,17 @@ void cmDefinitions::ClosureImpl(std::set<cmStdString>& undefined, } //---------------------------------------------------------------------------- -std::set<cmStdString> cmDefinitions::ClosureKeys() const +std::set<std::string> cmDefinitions::ClosureKeys() const { - std::set<cmStdString> defined; - std::set<cmStdString> undefined; + std::set<std::string> defined; + std::set<std::string> undefined; this->ClosureKeys(defined, undefined); return defined; } //---------------------------------------------------------------------------- -void cmDefinitions::ClosureKeys(std::set<cmStdString>& defined, - std::set<cmStdString>& undefined) const +void cmDefinitions::ClosureKeys(std::set<std::string>& defined, + std::set<std::string>& undefined) const { // Consider local definitions. for(MapType::const_iterator mi = this->Map.begin(); @@ -165,7 +165,7 @@ void cmDefinitions::ClosureKeys(std::set<cmStdString>& defined, if(defined.find(mi->first) == defined.end() && undefined.find(mi->first) == undefined.end()) { - std::set<cmStdString>& m = mi->second.Exists? defined : undefined; + std::set<std::string>& m = mi->second.Exists? defined : undefined; m.insert(mi->first); } } diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 4834d84..d615fb0 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -35,28 +35,32 @@ public: /** Get the value associated with a key; null if none. Store the result locally if it came from a parent. */ - const char* Get(const char* key); + const char* Get(const std::string& key); /** Set (or unset if null) a value associated with a key. */ - const char* Set(const char* key, const char* value); + const char* Set(const std::string& key, const char* value); /** Get the set of all local keys. */ - std::set<cmStdString> LocalKeys() const; + std::set<std::string> LocalKeys() const; /** Compute the closure of all defined keys with values. This flattens the scope. The result has no parent. */ cmDefinitions Closure() const; /** Compute the set of all defined keys. */ - std::set<cmStdString> ClosureKeys() const; + std::set<std::string> ClosureKeys() const; private: // String with existence boolean. - struct Def: public cmStdString + struct Def: public std::string { - Def(): cmStdString(), Exists(false) {} - Def(const char* v): cmStdString(v?v:""), Exists(v?true:false) {} - Def(Def const& d): cmStdString(d), Exists(d.Exists) {} + private: + typedef std::string std_string; + public: + Def(): std_string(), Exists(false) {} + Def(const char* v): std_string(v?v:""), Exists(v?true:false) {} + Def(const std_string& v): std_string(v), Exists(true) {} + Def(Def const& d): std_string(d), Exists(d.Exists) {} bool Exists; }; static Def NoDef; @@ -65,22 +69,22 @@ private: cmDefinitions* Up; // Local definitions, set or unset. - typedef std::map<cmStdString, Def> MapType; + typedef std::map<std::string, Def> MapType; MapType Map; // Internal query and update methods. - Def const& GetInternal(const char* key); - Def const& SetInternal(const char* key, Def const& def); + Def const& GetInternal(const std::string& key); + Def const& SetInternal(const std::string& key, Def const& def); // Implementation of Closure() method. struct ClosureTag {}; cmDefinitions(ClosureTag const&, cmDefinitions const* root); - void ClosureImpl(std::set<cmStdString>& undefined, + void ClosureImpl(std::set<std::string>& undefined, cmDefinitions const* defs); // Implementation of ClosureKeys() method. - void ClosureKeys(std::set<cmStdString>& defined, - std::set<cmStdString>& undefined) const; + void ClosureKeys(std::set<std::string>& defined, + std::set<std::string>& undefined) const; }; #endif diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 1a0e93f..50a395e 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -47,7 +47,7 @@ bool cmDepends::Write(std::ostream &makeDepends, std::string srcLang = "CMAKE_DEPENDS_CHECK_"; srcLang += this->Language; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - const char* srcStr = mf->GetSafeDefinition(srcLang.c_str()); + const char* srcStr = mf->GetSafeDefinition(srcLang); std::vector<std::string> pairs; cmSystemTools::ExpandListArgument(srcStr, pairs); @@ -61,7 +61,7 @@ bool cmDepends::Write(std::ostream &makeDepends, std::string obj = *si++; // Make sure the object file is relative to the top of the build tree. - obj = this->LocalGenerator->Convert(obj.c_str(), + obj = this->LocalGenerator->Convert(obj, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); dependencies[obj].insert(src); @@ -297,7 +297,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends, } //---------------------------------------------------------------------------- -void cmDepends::SetIncludePathFromLanguage(const char* lang) +void cmDepends::SetIncludePathFromLanguage(const std::string& lang) { // Look for the new per "TARGET_" variant first: const char * includePath = 0; @@ -305,7 +305,7 @@ void cmDepends::SetIncludePathFromLanguage(const char* lang) includePathVar += lang; includePathVar += "_TARGET_INCLUDE_PATH"; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - includePath = mf->GetDefinition(includePathVar.c_str()); + includePath = mf->GetDefinition(includePathVar); if(includePath) { cmSystemTools::ExpandListArgument(includePath, this->IncludePath); @@ -316,7 +316,7 @@ void cmDepends::SetIncludePathFromLanguage(const char* lang) includePathVar = "CMAKE_"; includePathVar += lang; includePathVar += "_INCLUDE_PATH"; - includePath = mf->GetDefinition(includePathVar.c_str()); + includePath = mf->GetDefinition(includePathVar); if(includePath) { cmSystemTools::ExpandListArgument(includePath, this->IncludePath); diff --git a/Source/cmDepends.h b/Source/cmDepends.h index d787edd..b293c5b 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -41,7 +41,7 @@ public: void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; } /** Set the specific language to be scanned. */ - void SetLanguage(const char* lang) { this->Language = lang; } + void SetLanguage(const std::string& lang) { this->Language = lang; } /** Set the target build directory. */ void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; } @@ -114,7 +114,7 @@ protected: // The include file search path. std::vector<std::string> IncludePath; - void SetIncludePathFromLanguage(const char* lang); + void SetIncludePathFromLanguage(const std::string& lang); private: cmDepends(cmDepends const&); // Purposely not implemented. diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 4fc5efb..d26d3a9 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -37,7 +37,7 @@ cmDependsC::cmDependsC() //---------------------------------------------------------------------------- cmDependsC::cmDependsC(cmLocalGenerator* lg, const char* targetDir, - const char* lang, + const std::string& lang, const std::map<std::string, DependencyVector>* validDeps) : cmDepends(lg, targetDir) , ValidDeps(validDeps) @@ -54,14 +54,14 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg, std::string scanRegexVar = "CMAKE_"; scanRegexVar += lang; scanRegexVar += "_INCLUDE_REGEX_SCAN"; - if(const char* sr = mf->GetDefinition(scanRegexVar.c_str())) + if(const char* sr = mf->GetDefinition(scanRegexVar)) { scanRegex = sr; } std::string complainRegexVar = "CMAKE_"; complainRegexVar += lang; complainRegexVar += "_INCLUDE_REGEX_COMPLAIN"; - if(const char* cr = mf->GetDefinition(complainRegexVar.c_str())) + if(const char* cr = mf->GetDefinition(complainRegexVar)) { complainRegex = cr; } @@ -91,7 +91,7 @@ cmDependsC::~cmDependsC() { this->WriteCacheFile(); - for (std::map<cmStdString, cmIncludeLines*>::iterator it= + for (std::map<std::string, cmIncludeLines*>::iterator it= this->FileCache.begin(); it!=this->FileCache.end(); ++it) { delete it->second; @@ -116,7 +116,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, return false; } - std::set<cmStdString> dependencies; + std::set<std::string> dependencies; bool haveDeps = false; if (this->ValidDeps != 0) @@ -149,7 +149,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, this->Encountered.insert(*srcIt); } - std::set<cmStdString> scanned; + std::set<std::string> scanned; // Use reserve to allocate enough memory for tempPathStr // so that during the loops no memory is allocated or freed @@ -182,7 +182,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, } else { - std::map<cmStdString, cmStdString>::iterator + std::map<std::string, std::string>::iterator headerLocationIt=this->HeaderLocationCache.find(current.FileName); if (headerLocationIt!=this->HeaderLocationCache.end()) { @@ -224,7 +224,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, scanned.insert(fullName); // Check whether this file is already in the cache - std::map<cmStdString, cmIncludeLines*>::iterator fileIt= + std::map<std::string, cmIncludeLines*>::iterator fileIt= this->FileCache.find(fullName); if (fileIt!=this->FileCache.end()) { @@ -270,15 +270,15 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, // convert the dependencies to paths relative to the home output // directory. We must do the same here. internalDepends << obj << std::endl; - for(std::set<cmStdString>::const_iterator i=dependencies.begin(); + for(std::set<std::string>::const_iterator i=dependencies.begin(); i != dependencies.end(); ++i) { makeDepends << obj << ": " << - this->LocalGenerator->Convert(i->c_str(), + this->LocalGenerator->Convert(*i, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << std::endl; - internalDepends << " " << i->c_str() << std::endl; + internalDepends << " " << *i << std::endl; } makeDepends << std::endl; @@ -392,7 +392,7 @@ void cmDependsC::WriteCacheFile() const cacheOut << this->IncludeRegexComplainString << "\n\n"; cacheOut << this->IncludeRegexTransformString << "\n\n"; - for (std::map<cmStdString, cmIncludeLines*>::const_iterator fileIt= + for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt= this->FileCache.begin(); fileIt!=this->FileCache.end(); ++fileIt) { @@ -421,7 +421,7 @@ void cmDependsC::WriteCacheFile() const //---------------------------------------------------------------------------- void cmDependsC::Scan(std::istream& is, const char* directory, - const cmStdString& fullName) + const std::string& fullName) { cmIncludeLines* newCacheEntry=new cmIncludeLines; newCacheEntry->Used=true; diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index 16dfad7..07d3c21 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -25,7 +25,8 @@ public: /** Checking instances need to know the build directory name and the relative path from the build directory to the target file. */ cmDependsC(); - cmDependsC(cmLocalGenerator* lg, const char* targetDir, const char* lang, + cmDependsC(cmLocalGenerator* lg, const char* targetDir, + const std::string& lang, const std::map<std::string, DependencyVector>* validDeps); /** Virtual destructor to cleanup subclasses properly. */ @@ -40,7 +41,7 @@ protected: // Method to scan a single file. void Scan(std::istream& is, const char* directory, - const cmStdString& fullName); + const std::string& fullName); // Regular expression to identify C preprocessor include directives. cmsys::RegularExpression IncludeRegexLine; @@ -56,7 +57,7 @@ protected: // Regex to transform #include lines. std::string IncludeRegexTransformString; cmsys::RegularExpression IncludeRegexTransform; - typedef std::map<cmStdString, cmStdString> TransformRulesType; + typedef std::map<std::string, std::string> TransformRulesType; TransformRulesType TransformRules; void SetupTransforms(); void ParseTransform(std::string const& xform); @@ -66,8 +67,8 @@ public: // Data structures for dependency graph walk. struct UnscannedEntry { - cmStdString FileName; - cmStdString QuotedLocation; + std::string FileName; + std::string QuotedLocation; }; struct cmIncludeLines @@ -78,13 +79,13 @@ public: }; protected: const std::map<std::string, DependencyVector>* ValidDeps; - std::set<cmStdString> Encountered; + std::set<std::string> Encountered; std::queue<UnscannedEntry> Unscanned; - std::map<cmStdString, cmIncludeLines *> FileCache; - std::map<cmStdString, cmStdString> HeaderLocationCache; + std::map<std::string, cmIncludeLines *> FileCache; + std::map<std::string, std::string> HeaderLocationCache; - cmStdString CacheFileName; + std::string CacheFileName; void WriteCacheFile() const; void ReadCacheFile(); diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index d5472a1..79cb560 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -34,11 +34,11 @@ public: std::string Source; // Set of provided and required modules. - std::set<cmStdString> Provides; - std::set<cmStdString> Requires; + std::set<std::string> Provides; + std::set<std::string> Requires; // Set of files included in the translation unit. - std::set<cmStdString> Includes; + std::set<std::string> Includes; }; //---------------------------------------------------------------------------- @@ -98,24 +98,24 @@ class cmDependsFortranInternals { public: // The set of modules provided by this target. - std::set<cmStdString> TargetProvides; + std::set<std::string> TargetProvides; // Map modules required by this target to locations. - typedef std::map<cmStdString, cmStdString> TargetRequiresMap; + typedef std::map<std::string, std::string> TargetRequiresMap; TargetRequiresMap TargetRequires; // Information about each object file. - typedef std::map<cmStdString, cmDependsFortranSourceInfo> ObjectInfoMap; + typedef std::map<std::string, cmDependsFortranSourceInfo> ObjectInfoMap; ObjectInfoMap ObjectInfo; cmDependsFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src) { - std::map<cmStdString, cmDependsFortranSourceInfo>::iterator i = + std::map<std::string, cmDependsFortranSourceInfo>::iterator i = this->ObjectInfo.find(obj); if(i == this->ObjectInfo.end()) { - std::map<cmStdString, cmDependsFortranSourceInfo>::value_type + std::map<std::string, cmDependsFortranSourceInfo>::value_type entry(obj, cmDependsFortranSourceInfo()); i = this->ObjectInfo.insert(entry).first; i->second.Source = src; @@ -260,8 +260,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, cmGeneratedFileStream fiStream(fiName.c_str()); fiStream << "# The fortran modules provided by this target.\n"; fiStream << "provides\n"; - std::set<cmStdString> const& provides = this->Internal->TargetProvides; - for(std::set<cmStdString>::const_iterator i = provides.begin(); + std::set<std::string> const& provides = this->Internal->TargetProvides; + for(std::set<std::string>::const_iterator i = provides.begin(); i != provides.end(); ++i) { fiStream << " " << *i << "\n"; @@ -275,7 +275,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, cmGeneratedFileStream fcStream(fcName.c_str()); fcStream << "# Remove fortran modules provided by this target.\n"; fcStream << "FILE(REMOVE"; - for(std::set<cmStdString>::const_iterator i = provides.begin(); + for(std::set<std::string>::const_iterator i = provides.begin(); i != provides.end(); ++i) { std::string mod_upper = mod_dir; @@ -292,15 +292,15 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, stamp += ".mod.stamp"; fcStream << "\n"; fcStream << " \"" << - this->LocalGenerator->Convert(mod_lower.c_str(), + this->LocalGenerator->Convert(mod_lower, cmLocalGenerator::START_OUTPUT) << "\"\n"; fcStream << " \"" << - this->LocalGenerator->Convert(mod_upper.c_str(), + this->LocalGenerator->Convert(mod_upper, cmLocalGenerator::START_OUTPUT) << "\"\n"; fcStream << " \"" << - this->LocalGenerator->Convert(stamp.c_str(), + this->LocalGenerator->Convert(stamp, cmLocalGenerator::START_OUTPUT) << "\"\n"; } @@ -319,14 +319,14 @@ void cmDependsFortran::LocateModules() infoI != objInfo.end(); ++infoI) { cmDependsFortranSourceInfo const& info = infoI->second; - for(std::set<cmStdString>::const_iterator i = info.Provides.begin(); + for(std::set<std::string>::const_iterator i = info.Provides.begin(); i != info.Provides.end(); ++i) { // Include this module in the set provided by this target. this->Internal->TargetProvides.insert(*i); } - for(std::set<cmStdString>::const_iterator i = info.Requires.begin(); + for(std::set<std::string>::const_iterator i = info.Requires.begin(); i != info.Requires.end(); ++i) { // Include this module in the set required by this target. @@ -368,8 +368,8 @@ void cmDependsFortran::LocateModules() void cmDependsFortran::MatchLocalModules() { const char* stampDir = this->TargetDirectory.c_str(); - std::set<cmStdString> const& provides = this->Internal->TargetProvides; - for(std::set<cmStdString>::const_iterator i = provides.begin(); + std::set<std::string> const& provides = this->Internal->TargetProvides; + for(std::set<std::string>::const_iterator i = provides.begin(); i != provides.end(); ++i) { this->ConsiderModule(i->c_str(), stampDir); @@ -445,24 +445,24 @@ cmDependsFortran // Write the include dependencies to the output stream. internalDepends << obj << std::endl; internalDepends << " " << src << std::endl; - for(std::set<cmStdString>::const_iterator i = info.Includes.begin(); + for(std::set<std::string>::const_iterator i = info.Includes.begin(); i != info.Includes.end(); ++i) { makeDepends << obj << ": " << - this->LocalGenerator->Convert(i->c_str(), + this->LocalGenerator->Convert(*i, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << std::endl; - internalDepends << " " << i->c_str() << std::endl; + internalDepends << " " << *i << std::endl; } makeDepends << std::endl; // Write module requirements to the output stream. - for(std::set<cmStdString>::const_iterator i = info.Requires.begin(); + for(std::set<std::string>::const_iterator i = info.Requires.begin(); i != info.Requires.end(); ++i) { // Require only modules not provided in the same source. - if(std::set<cmStdString>::const_iterator(info.Provides.find(*i)) != + if(std::set<std::string>::const_iterator(info.Provides.find(*i)) != info.Provides.end()) { continue; @@ -480,7 +480,7 @@ cmDependsFortran proxy += "/"; proxy += *i; proxy += ".mod.proxy"; - proxy = this->LocalGenerator->Convert(proxy.c_str(), + proxy = this->LocalGenerator->Convert(proxy, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); @@ -497,7 +497,7 @@ cmDependsFortran { // This module is known. Depend on its timestamp file. std::string stampFile = - this->LocalGenerator->Convert(required->second.c_str(), + this->LocalGenerator->Convert(required->second, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); makeDepends << obj << ": " << stampFile << "\n"; @@ -510,7 +510,7 @@ cmDependsFortran if(this->FindModule(*i, module)) { module = - this->LocalGenerator->Convert(module.c_str(), + this->LocalGenerator->Convert(module, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); makeDepends << obj << ": " << module << "\n"; @@ -519,14 +519,14 @@ cmDependsFortran } // Write provided modules to the output stream. - for(std::set<cmStdString>::const_iterator i = info.Provides.begin(); + for(std::set<std::string>::const_iterator i = info.Provides.begin(); i != info.Provides.end(); ++i) { std::string proxy = stamp_dir; proxy += "/"; proxy += *i; proxy += ".mod.proxy"; - proxy = this->LocalGenerator->Convert(proxy.c_str(), + proxy = this->LocalGenerator->Convert(proxy, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); makeDepends << proxy << ": " << obj << ".provides" << std::endl; @@ -538,7 +538,7 @@ cmDependsFortran // Create a target to copy the module after the object file // changes. makeDepends << obj << ".provides.build:\n"; - for(std::set<cmStdString>::const_iterator i = info.Provides.begin(); + for(std::set<std::string>::const_iterator i = info.Provides.begin(); i != info.Provides.end(); ++i) { // Include this module in the set provided by this target. @@ -552,7 +552,7 @@ cmDependsFortran modFile += "/"; modFile += *i; modFile = - this->LocalGenerator->Convert(modFile.c_str(), + this->LocalGenerator->Convert(modFile, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::SHELL); std::string stampFile = stamp_dir; @@ -560,7 +560,7 @@ cmDependsFortran stampFile += m; stampFile += ".mod.stamp"; stampFile = - this->LocalGenerator->Convert(stampFile.c_str(), + this->LocalGenerator->Convert(stampFile, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::SHELL); makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " @@ -582,7 +582,7 @@ cmDependsFortran // the target finishes building. std::string driver = this->TargetDirectory; driver += "/build"; - driver = this->LocalGenerator->Convert(driver.c_str(), + driver = this->LocalGenerator->Convert(driver, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); makeDepends << driver << ": " << obj << ".provides.build\n"; @@ -666,7 +666,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) if(!cmSystemTools::CopyFileAlways(mod_upper.c_str(), stamp.c_str())) { std::cerr << "Error copying Fortran module from \"" - << mod_upper.c_str() << "\" to \"" << stamp.c_str() + << mod_upper << "\" to \"" << stamp << "\".\n"; return false; } @@ -681,7 +681,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) if(!cmSystemTools::CopyFileAlways(mod_lower.c_str(), stamp.c_str())) { std::cerr << "Error copying Fortran module from \"" - << mod_lower.c_str() << "\" to \"" << stamp.c_str() + << mod_lower << "\" to \"" << stamp << "\".\n"; return false; } @@ -689,9 +689,9 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) return true; } - std::cerr << "Error copying Fortran module \"" << args[2].c_str() - << "\". Tried \"" << mod_upper.c_str() - << "\" and \"" << mod_lower.c_str() << "\".\n"; + std::cerr << "Error copying Fortran module \"" << args[2] + << "\". Tried \"" << mod_upper + << "\" and \"" << mod_lower << "\".\n"; return false; } diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index c30d4bd..02f2d21 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -36,10 +36,10 @@ cmDependsJavaParserHelper::~cmDependsJavaParserHelper() } void cmDependsJavaParserHelper::CurrentClass -::AddFileNamesForPrinting(std::vector<cmStdString> *files, +::AddFileNamesForPrinting(std::vector<std::string> *files, const char* prefix, const char* sep) { - cmStdString rname = ""; + std::string rname = ""; if ( prefix ) { rname += prefix; @@ -76,7 +76,7 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass) { return; } - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for ( it = this->ClassesFound.begin(); it != this->ClassesFound.end(); it ++ ) @@ -91,7 +91,7 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass) void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass) { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for ( it = this->PackagesImport.begin(); it != this->PackagesImport.end(); it ++ ) @@ -256,19 +256,19 @@ void cmDependsJavaParserHelper::PrintClasses() std::cerr << "Error when parsing. No classes on class stack" << std::endl; abort(); } - std::vector<cmStdString> files = this->GetFilesProduced(); - std::vector<cmStdString>::iterator sit; + std::vector<std::string> files = this->GetFilesProduced(); + std::vector<std::string>::iterator sit; for ( sit = files.begin(); sit != files.end(); ++ sit ) { - std::cout << " " << sit->c_str() << ".class" << std::endl; + std::cout << " " << *sit << ".class" << std::endl; } } -std::vector<cmStdString> cmDependsJavaParserHelper::GetFilesProduced() +std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced() { - std::vector<cmStdString> files; + std::vector<std::string> files; CurrentClass* toplevel = &(*(this->ClassStack.begin())); std::vector<CurrentClass>::iterator it; for ( it = toplevel->NestedClasses->begin(); @@ -308,29 +308,29 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb) if ( this->CurrentPackage.size() > 0 ) { std::cout << "Current package is: " << - this->CurrentPackage.c_str() << std::endl; + this->CurrentPackage << std::endl; } std::cout << "Imports packages:"; if ( this->PackagesImport.size() > 0 ) { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for ( it = this->PackagesImport.begin(); it != this->PackagesImport.end(); ++ it ) { - std::cout << " " << it->c_str(); + std::cout << " " << *it; } } std::cout << std::endl; std::cout << "Depends on:"; if ( this->ClassesFound.size() > 0 ) { - std::vector<cmStdString>::iterator it; + std::vector<std::string>::iterator it; for ( it = this->ClassesFound.begin(); it != this->ClassesFound.end(); ++ it ) { - std::cout << " " << it->c_str(); + std::cout << " " << *it; } } std::cout << std::endl; @@ -419,8 +419,8 @@ int cmDependsJavaParserHelper::ParseFile(const char* file) return 0; } - cmStdString fullfile = ""; - cmStdString line; + std::string fullfile = ""; + std::string line; while ( cmSystemTools::GetLineFromStream(ifs, line) ) { fullfile += line + "\n"; diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h index 9807a04..5542018 100644 --- a/Source/cmDependsJavaParserHelper.h +++ b/Source/cmDependsJavaParserHelper.h @@ -59,15 +59,15 @@ public: const char* GetCurrentCombine() { return this->CurrentCombine.c_str(); } void UpdateCombine(const char* str1, const char* str2); - std::vector<cmStdString>& GetClassesFound() { return this->ClassesFound; } + std::vector<std::string>& GetClassesFound() { return this->ClassesFound; } - std::vector<cmStdString> GetFilesProduced(); + std::vector<std::string> GetFilesProduced(); private: class CurrentClass { public: - cmStdString Name; + std::string Name; std::vector<CurrentClass>* NestedClasses; CurrentClass() { @@ -93,16 +93,16 @@ private: { (*this) = c; } - void AddFileNamesForPrinting(std::vector<cmStdString> *files, + void AddFileNamesForPrinting(std::vector<std::string> *files, const char* prefix, const char* sep); }; - cmStdString CurrentPackage; - cmStdString::size_type InputBufferPos; - cmStdString InputBuffer; + std::string CurrentPackage; + std::string::size_type InputBufferPos; + std::string InputBuffer; std::vector<char> OutputBuffer; - std::vector<cmStdString> ClassesFound; - std::vector<cmStdString> PackagesImport; - cmStdString CurrentCombine; + std::vector<std::string> ClassesFound; + std::vector<std::string> PackagesImport; + std::string CurrentCombine; std::vector<CurrentClass> ClassStack; diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 9c27fc1..d421889 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -477,9 +477,9 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, } //---------------------------------------------------------------------------- -void cmDocumentation::SetName(const char* name) +void cmDocumentation::SetName(const std::string& name) { - this->NameString = name?name:""; + this->NameString = name; } //---------------------------------------------------------------------------- @@ -672,7 +672,7 @@ bool cmDocumentation::PrintFiles(std::ostream& os, for (std::vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) { - found = r.ProcessFile(i->c_str()) || found; + found = r.ProcessFile(*i) || found; } return found; } @@ -693,7 +693,7 @@ bool cmDocumentation::PrintHelpOneManual(std::ostream& os) return true; } // Argument was not a manual. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-manual is not an available manual. " << "Use --help-manual-list to see all available manuals.\n"; return false; @@ -715,7 +715,7 @@ bool cmDocumentation::PrintHelpOneCommand(std::ostream& os) return true; } // Argument was not a command. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-command is not a CMake command. " << "Use --help-command-list to see all commands.\n"; return false; @@ -737,7 +737,7 @@ bool cmDocumentation::PrintHelpOneModule(std::ostream& os) return true; } // Argument was not a module. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-module is not a CMake module.\n"; return false; } @@ -772,7 +772,7 @@ bool cmDocumentation::PrintHelpOneProperty(std::ostream& os) return true; } // Argument was not a property. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-property is not a CMake property. " << "Use --help-property-list to see all properties.\n"; return false; @@ -796,7 +796,7 @@ bool cmDocumentation::PrintHelpOnePolicy(std::ostream& os) } // Argument was not a policy. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-policy is not a CMake policy.\n"; return false; } @@ -817,7 +817,7 @@ bool cmDocumentation::PrintHelpOneVariable(std::ostream& os) return true; } // Argument was not a variable. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() + os << "Argument \"" << this->CurrentArgument << "\" to --help-variable is not a defined variable. " << "Use --help-variable-list to see all defined variables.\n"; return false; diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index d5a7dd5..56a4151 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -56,7 +56,7 @@ public: void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; } /** Set the program name for standard document generation. */ - void SetName(const char* name); + void SetName(const std::string& name); /** Set a section of the documentation. Typical sections include Name, Usage, Description, Options */ diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h index 636860d..d796da8 100644 --- a/Source/cmDocumentationSection.h +++ b/Source/cmDocumentationSection.h @@ -34,8 +34,8 @@ public: void Clear() { this->Entries.clear(); } /** Return the name of this section. */ - const char* GetName() const - { return this->Name.c_str(); } + std::string GetName() const + { return this->Name; } /** Return a pointer to the first entry of this section. */ const std::vector<cmDocumentationEntry> &GetEntries() const diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx index 6a0ab7b..944a000 100644 --- a/Source/cmDynamicLoader.cxx +++ b/Source/cmDynamicLoader.cxx @@ -23,7 +23,7 @@ public: static cmDynamicLoaderCache* GetInstance(); private: - std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle> CacheMap; + std::map<std::string, cmsys::DynamicLoader::LibraryHandle> CacheMap; static cmDynamicLoaderCache* Instance; }; @@ -47,7 +47,7 @@ void cmDynamicLoaderCache::CacheFile(const char* path, bool cmDynamicLoaderCache::GetCacheFile(const char* path, cmsys::DynamicLoader::LibraryHandle& p) { - std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle>::iterator it + std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it = this->CacheMap.find(path); if ( it != this->CacheMap.end() ) { @@ -59,7 +59,7 @@ bool cmDynamicLoaderCache::GetCacheFile(const char* path, bool cmDynamicLoaderCache::FlushCache(const char* path) { - std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle>::iterator it + std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it = this->CacheMap.find(path); bool ret = false; if ( it != this->CacheMap.end() ) @@ -73,7 +73,7 @@ bool cmDynamicLoaderCache::FlushCache(const char* path) void cmDynamicLoaderCache::FlushCache() { - for ( std::map<cmStdString, + for ( std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it = this->CacheMap.begin(); it != this->CacheMap.end(); it++ ) diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 353f2e9..dc6772c 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -23,6 +23,26 @@ #if defined(__OpenBSD__) # include <stdint.h> # include <elf_abi.h> +#elif defined(__HAIKU__) +# include <elf32.h> +# include <elf64.h> + typedef struct Elf32_Ehdr Elf32_Ehdr; + typedef struct Elf32_Shdr Elf32_Shdr; + typedef struct Elf32_Sym Elf32_Sym; + typedef struct Elf32_Rel Elf32_Rel; + typedef struct Elf32_Rela Elf32_Rela; +# define ELFMAG0 0x7F +# define ELFMAG1 'E' +# define ELFMAG2 'L' +# define ELFMAG3 'F' +# define ET_NONE 0 +# define ET_REL 1 +# define ET_EXEC 2 +# define ET_DYN 3 +# define ET_CORE 4 +# define EM_386 3 +# define EM_SPARC 2 +# define EM_PPC 20 #else # include <elf.h> #endif @@ -181,7 +201,7 @@ struct cmELFTypes32 static const char* GetName() { return "32-bit"; } }; -// Configure the implementation template for 32-bit ELF files. +// Configure the implementation template for 64-bit ELF files. struct cmELFTypes64 { typedef Elf64_Ehdr ELF_Ehdr; diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h index d472e99..dde5fcc 100644 --- a/Source/cmElseCommand.h +++ b/Source/cmElseCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "else";} + virtual std::string GetName() const { return "else";} cmTypeMacro(cmElseCommand, cmCommand); }; diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h index d811b35..c627cbe 100644 --- a/Source/cmElseIfCommand.h +++ b/Source/cmElseIfCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "elseif";} + virtual std::string GetName() const { return "elseif";} cmTypeMacro(cmElseIfCommand, cmCommand); }; diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index a248042..2b09e11 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "enable_language";} + virtual std::string GetName() const {return "enable_language";} cmTypeMacro(cmEnableLanguageCommand, cmCommand); }; diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h index e102f5e..d028c59 100644 --- a/Source/cmEnableTestingCommand.h +++ b/Source/cmEnableTestingCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "enable_testing";} + virtual std::string GetName() const { return "enable_testing";} cmTypeMacro(cmEnableTestingCommand, cmCommand); diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h index 44d29b5..c3be387 100644 --- a/Source/cmEndForEachCommand.h +++ b/Source/cmEndForEachCommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endforeach";} + virtual std::string GetName() const { return "endforeach";} cmTypeMacro(cmEndForEachCommand, cmCommand); }; diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h index 4fdca6b..3a42c17 100644 --- a/Source/cmEndFunctionCommand.h +++ b/Source/cmEndFunctionCommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endfunction";} + virtual std::string GetName() const { return "endfunction";} cmTypeMacro(cmEndFunctionCommand, cmCommand); }; diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h index 634da60..a8248c8 100644 --- a/Source/cmEndIfCommand.h +++ b/Source/cmEndIfCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endif";} + virtual std::string GetName() const { return "endif";} cmTypeMacro(cmEndIfCommand, cmCommand); }; diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h index db15f27..fdc04ee 100644 --- a/Source/cmEndMacroCommand.h +++ b/Source/cmEndMacroCommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endmacro";} + virtual std::string GetName() const { return "endmacro";} cmTypeMacro(cmEndMacroCommand, cmCommand); }; diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h index 41138d1..ec1cb65 100644 --- a/Source/cmEndWhileCommand.h +++ b/Source/cmEndWhileCommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "endwhile";} + virtual std::string GetName() const { return "endwhile";} cmTypeMacro(cmEndWhileCommand, cmCommand); }; diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 6c11345..9b59088 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -132,14 +132,14 @@ bool cmExecProgramCommand } std::string coutput = std::string(output, first, last-first+1); - this->Makefile->AddDefinition(output_variable.c_str(), coutput.c_str()); + this->Makefile->AddDefinition(output_variable, coutput.c_str()); } if ( return_variable.size() > 0 ) { char buffer[100]; sprintf(buffer, "%d", retVal); - this->Makefile->AddDefinition(return_variable.c_str(), buffer); + this->Makefile->AddDefinition(return_variable, buffer); } return true; diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h index 6d28cdc..23d10f9 100644 --- a/Source/cmExecProgramCommand.h +++ b/Source/cmExecProgramCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const + virtual std::string GetName() const {return "exec_program";} /** diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 994c170..40f70b8 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -191,7 +191,7 @@ bool cmExecuteProcessCommand { cmOStringStream e; e << " given unknown argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -200,7 +200,7 @@ bool cmExecuteProcessCommand { std::string e = "attempted to output into a file: " + output_file + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -326,12 +326,12 @@ bool cmExecuteProcessCommand // Store the output obtained. if(!output_variable.empty() && tempOutput.size()) { - this->Makefile->AddDefinition(output_variable.c_str(), + this->Makefile->AddDefinition(output_variable, &*tempOutput.begin()); } if(!merge_output && !error_variable.empty() && tempError.size()) { - this->Makefile->AddDefinition(error_variable.c_str(), + this->Makefile->AddDefinition(error_variable, &*tempError.begin()); } @@ -345,19 +345,19 @@ bool cmExecuteProcessCommand int v = cmsysProcess_GetExitValue(cp); char buf[100]; sprintf(buf, "%d", v); - this->Makefile->AddDefinition(result_variable.c_str(), buf); + this->Makefile->AddDefinition(result_variable, buf); } break; case cmsysProcess_State_Exception: - this->Makefile->AddDefinition(result_variable.c_str(), + this->Makefile->AddDefinition(result_variable, cmsysProcess_GetExceptionString(cp)); break; case cmsysProcess_State_Error: - this->Makefile->AddDefinition(result_variable.c_str(), + this->Makefile->AddDefinition(result_variable, cmsysProcess_GetErrorString(cp)); break; case cmsysProcess_State_Expired: - this->Makefile->AddDefinition(result_variable.c_str(), + this->Makefile->AddDefinition(result_variable, "Process terminated due to timeout"); break; } diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h index bd0f783..6906a08 100644 --- a/Source/cmExecuteProcessCommand.h +++ b/Source/cmExecuteProcessCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const + virtual std::string GetName() const {return "execute_process";} /** diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 308956a..e79206d 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -47,7 +47,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmOStringStream e; e << "given target \"" << te->GetName() << "\" more than once."; this->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace); + ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace); return false; } if (te->GetType() == cmTarget::INTERFACE_LIBRARY) @@ -106,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) ci = this->Configurations.begin(); ci != this->Configurations.end(); ++ci) { - this->GenerateImportConfig(os, ci->c_str(), missingTargets); + this->GenerateImportConfig(os, *ci, missingTargets); } this->GenerateMissingTargetsCheckCode(os, missingTargets); @@ -118,8 +118,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) void cmExportBuildFileGenerator ::GenerateImportTargetsConfig(std::ostream& os, - const char* config, std::string const& suffix, - std::vector<std::string> &missingTargets) + const std::string& config, + std::string const& suffix, + std::vector<std::string> &missingTargets) { for(std::vector<cmTarget*>::const_iterator tei = this->Exports.begin(); @@ -166,7 +167,8 @@ void cmExportBuildFileGenerator::SetExportSet(cmExportSet *exportSet) //---------------------------------------------------------------------------- void cmExportBuildFileGenerator -::SetImportLocationProperty(const char* config, std::string const& suffix, +::SetImportLocationProperty(const std::string& config, + std::string const& suffix, cmTarget* target, ImportPropertyMap& properties) { // Get the makefile in which to lookup target information. @@ -313,7 +315,7 @@ cmExportBuildFileGenerator << "consider using the APPEND option with multiple separate calls."; this->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace); + ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace); } std::string @@ -326,7 +328,7 @@ cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = - target->GetInstallNameDirForBuildTree(config.c_str()); + target->GetInstallNameDirForBuildTree(config); } return install_name_dir; diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index cea2099..c1bdb5b 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -52,7 +52,7 @@ protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream& os, - const char* config, + const std::string& config, std::string const& suffix, std::vector<std::string> &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, @@ -66,7 +66,7 @@ protected: int occurrences); /** Fill in properties indicating built file locations. */ - void SetImportLocationProperty(const char* config, + void SetImportLocationProperty(const std::string& config, std::string const& suffix, cmTarget* target, ImportPropertyMap& properties); diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index db56aaf..dcb77ba 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -92,7 +92,7 @@ bool cmExportCommand cmOStringStream e; e << "FILE option given filename \"" << this->Filename.GetString() << "\" which does not have an extension of \".cmake\".\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } fname = this->Filename.GetString(); @@ -106,7 +106,7 @@ bool cmExportCommand cmOStringStream e; e << "FILE option given filename \"" << fname << "\" which is in the source tree.\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -128,7 +128,7 @@ bool cmExportCommand { cmOStringStream e; e << "EXPORT signature does not recognise the APPEND option."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -137,7 +137,7 @@ bool cmExportCommand cmOStringStream e; e << "EXPORT signature does not recognise the " "EXPORT_LINK_INTERFACE_LIBRARIES option."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -147,7 +147,7 @@ bool cmExportCommand { cmOStringStream e; e << "Export set \"" << setName << "\" not found."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } this->ExportSet = setMap[setName]; @@ -164,18 +164,18 @@ bool cmExportCommand cmOStringStream e; e << "given ALIAS target \"" << *currentTarget << "\" which may not be exported."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - if(cmTarget* target = gg->FindTarget(0, currentTarget->c_str())) + if(cmTarget* target = gg->FindTarget(*currentTarget)) { if(target->GetType() == cmTarget::OBJECT_LIBRARY) { cmOStringStream e; e << "given OBJECT library \"" << *currentTarget << "\" which may not be exported."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -184,7 +184,7 @@ bool cmExportCommand cmOStringStream e; e << "given target \"" << *currentTarget << "\" which is not built by this project."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } targets.push_back(*currentTarget); @@ -229,7 +229,7 @@ bool cmExportCommand ci = configurationTypes.begin(); ci != configurationTypes.end(); ++ci) { - ebfg->AddConfiguration(ci->c_str()); + ebfg->AddConfiguration(*ci); } } else @@ -266,7 +266,7 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args) { cmOStringStream e; e << "PACKAGE given unknown argument: " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -284,7 +284,7 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args) cmOStringStream e; e << "PACKAGE given invalid package name \"" << package << "\". " << "Package names must match \"" << packageExpr << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index c0e445f..f9506bb 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "export";} + virtual std::string GetName() const { return "export";} cmTypeMacro(cmExportCommand, cmCommand); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4a161ee..b38c48b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -35,7 +35,7 @@ cmExportFileGenerator::cmExportFileGenerator() } //---------------------------------------------------------------------------- -void cmExportFileGenerator::AddConfiguration(const char* config) +void cmExportFileGenerator::AddConfiguration(const std::string& config) { this->Configurations.push_back(config); } @@ -117,12 +117,12 @@ bool cmExportFileGenerator::GenerateImportFile() //---------------------------------------------------------------------------- void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, - const char* config, + const std::string& config, std::vector<std::string> &missingTargets) { // Construct the property configuration suffix. std::string suffix = "_"; - if(config && *config) + if(!config.empty()) { suffix += cmSystemTools::UpperCase(config); } @@ -136,7 +136,8 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, } //---------------------------------------------------------------------------- -void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, +void cmExportFileGenerator::PopulateInterfaceProperty( + const std::string& propName, cmTarget *target, ImportPropertyMap &properties) { @@ -148,8 +149,9 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, } //---------------------------------------------------------------------------- -void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, - const char *outputName, +void cmExportFileGenerator::PopulateInterfaceProperty( + const std::string& propName, + const std::string& outputName, cmTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, @@ -273,7 +275,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n" " \"" << *li << "\""; - target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + target->GetMakefile()->IssueMessage(messageType, e.str()); } if (isSubDirectory(li->c_str(), installDir)) { @@ -284,7 +286,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the build directory."; - target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + target->GetMakefile()->IssueMessage(messageType, e.str()); } if (!inSourceBuild) { @@ -293,7 +295,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the source directory."; - target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + target->GetMakefile()->IssueMessage(messageType, e.str()); } } } @@ -343,7 +345,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( true); this->ReplaceInstallPrefix(dirs); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); - std::string exportDirs = cge->Evaluate(target->GetMakefile(), 0, + std::string exportDirs = cge->Evaluate(target->GetMakefile(), "", false, target); if (cge->GetHadContextSensitiveCondition()) @@ -391,7 +393,8 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( } //---------------------------------------------------------------------------- -void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, +void cmExportFileGenerator::PopulateInterfaceProperty( + const std::string& propName, cmTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, ImportPropertyMap &properties, @@ -403,7 +406,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget const* tgt, const char *prop, +void getPropertyContents(cmTarget const* tgt, const std::string& prop, std::set<std::string> &ifaceProperties) { const char *p = tgt->GetProperty(prop); @@ -423,7 +426,7 @@ void getPropertyContents(cmTarget const* tgt, const char *prop, //---------------------------------------------------------------------------- void getCompatibleInterfaceProperties(cmTarget *target, std::set<std::string> &ifaceProperties, - const char *config) + const std::string& config) { cmComputeLinkInformation *info = target->GetLinkInformation(config); @@ -487,7 +490,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, 0); + getCompatibleInterfaceProperties(target, ifaceProperties, ""); std::vector<std::string> configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -495,14 +498,14 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector<std::string>::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str()); + getCompatibleInterfaceProperties(target, ifaceProperties, *ci); } } for (std::set<std::string>::const_iterator it = ifaceProperties.begin(); it != ifaceProperties.end(); ++it) { - this->PopulateInterfaceProperty(("INTERFACE_" + *it).c_str(), + this->PopulateInterfaceProperty("INTERFACE_" + *it, target, properties); } } @@ -684,7 +687,7 @@ cmExportFileGenerator::ReplaceInstallPrefix(std::string &) //---------------------------------------------------------------------------- void cmExportFileGenerator -::SetImportLinkInterface(const char* config, std::string const& suffix, +::SetImportLinkInterface(const std::string& config, std::string const& suffix, cmGeneratorExpression::PreprocessContext preprocessRule, cmTarget* target, ImportPropertyMap& properties, std::vector<std::string>& missingTargets) @@ -709,7 +712,7 @@ cmExportFileGenerator const char *propContent; if (const char *prop_suffixed = target->GetProperty( - ("LINK_INTERFACE_LIBRARIES" + suffix).c_str())) + "LINK_INTERFACE_LIBRARIES" + suffix)) { propContent = prop_suffixed; } @@ -759,7 +762,8 @@ cmExportFileGenerator //---------------------------------------------------------------------------- void cmExportFileGenerator -::SetImportDetailProperties(const char* config, std::string const& suffix, +::SetImportDetailProperties(const std::string& config, + std::string const& suffix, cmTarget* target, ImportPropertyMap& properties, std::vector<std::string>& missingTargets ) @@ -825,7 +829,7 @@ void cmExportFileGenerator ::SetImportLinkProperty(std::string const& suffix, cmTarget* target, - const char* propName, + const std::string& propName, std::vector<std::string> const& entries, ImportPropertyMap& properties, std::vector<std::string>& missingTargets @@ -861,11 +865,11 @@ cmExportFileGenerator //---------------------------------------------------------------------------- void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os, - const char* config) + const std::string& config) { os << "#----------------------------------------------------------------\n" << "# Generated CMake target import file"; - if(config) + if(!config.empty()) { os << " for configuration \"" << config << "\".\n"; } @@ -996,7 +1000,7 @@ cmExportFileGenerator //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportPropertyCode(std::ostream& os, const char* config, +::GenerateImportPropertyCode(std::ostream& os, const std::string& config, cmTarget const* target, ImportPropertyMap const& properties) { @@ -1010,7 +1014,7 @@ cmExportFileGenerator << config << "\"\n"; os << "set_property(TARGET " << targetName << " APPEND PROPERTY IMPORTED_CONFIGURATIONS "; - if(config && *config) + if(!config.empty()) { os << cmSystemTools::UpperCase(config); } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 57ab378..abd8ad5 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -50,32 +50,33 @@ public: const char *GetMainExportFileName() const; /** Set the namespace in which to place exported target names. */ - void SetNamespace(const char* ns) { this->Namespace = ns; } + void SetNamespace(const std::string& ns) { this->Namespace = ns; } std::string GetNamespace() const { return this->Namespace; } void SetExportOld(bool exportOld) { this->ExportOld = exportOld; } /** Add a configuration to be exported. */ - void AddConfiguration(const char* config); + void AddConfiguration(const std::string& config); /** Actually generate the export file. Returns whether there was an error. */ bool GenerateImportFile(); protected: - typedef std::map<cmStdString, cmStdString> ImportPropertyMap; + typedef std::map<std::string, std::string> ImportPropertyMap; // Generate per-configuration target information to the given output // stream. - void GenerateImportConfig(std::ostream& os, const char* config, + void GenerateImportConfig(std::ostream& os, const std::string& config, std::vector<std::string> &missingTargets); // Methods to implement export file code generation. - void GenerateImportHeaderCode(std::ostream& os, const char* config = 0); + void GenerateImportHeaderCode(std::ostream& os, + const std::string& config = ""); void GenerateImportFooterCode(std::ostream& os); void GenerateImportVersionCode(std::ostream& os); void GenerateImportTargetCode(std::ostream& os, cmTarget const* target); - void GenerateImportPropertyCode(std::ostream& os, const char* config, + void GenerateImportPropertyCode(std::ostream& os, const std::string& config, cmTarget const* target, ImportPropertyMap const& properties); void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, @@ -90,12 +91,12 @@ protected: // Collect properties with detailed information about targets beyond // their location on disk. - void SetImportDetailProperties(const char* config, + void SetImportDetailProperties(const std::string& config, std::string const& suffix, cmTarget* target, ImportPropertyMap& properties, std::vector<std::string>& missingTargets); void SetImportLinkProperty(std::string const& suffix, - cmTarget* target, const char* propName, + cmTarget* target, const std::string& propName, std::vector<std::string> const& entries, ImportPropertyMap& properties, std::vector<std::string>& missingTargets); @@ -105,7 +106,7 @@ protected: /** Each subclass knows where the target files are located. */ virtual void GenerateImportTargetsConfig(std::ostream& os, - const char* config, + const std::string& config, std::string const& suffix, std::vector<std::string> &missingTargets) = 0; @@ -116,7 +117,7 @@ protected: cmMakefile* mf, cmTarget* depender, cmTarget* dependee) = 0; - void PopulateInterfaceProperty(const char *, + void PopulateInterfaceProperty(const std::string&, cmTarget *target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, @@ -125,7 +126,7 @@ protected: cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); - void PopulateInterfaceProperty(const char *propName, cmTarget *target, + void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); void PopulateCompatibleInterfaceProperties(cmTarget *target, ImportPropertyMap &properties); @@ -137,7 +138,8 @@ protected: ImportPropertyMap &properties, std::vector<std::string> &missingTargets); - void SetImportLinkInterface(const char* config, std::string const& suffix, + void SetImportLinkInterface(const std::string& config, + std::string const& suffix, cmGeneratorExpression::PreprocessContext preprocessRule, cmTarget* target, ImportPropertyMap& properties, std::vector<std::string>& missingTargets); @@ -174,7 +176,7 @@ protected: std::set<cmTarget*> ExportedTargets; private: - void PopulateInterfaceProperty(const char *, const char *, + void PopulateInterfaceProperty(const std::string&, const std::string&, cmTarget *target, cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b579963..a83a228 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -211,7 +211,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) ci = this->Configurations.begin(); ci != this->Configurations.end(); ++ci) { - if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) + if(!this->GenerateImportFileConfig(*ci, missingTargets)) { result = false; } @@ -240,7 +240,8 @@ cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input) //---------------------------------------------------------------------------- bool -cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, +cmExportInstallFileGenerator::GenerateImportFileConfig( + const std::string& config, std::vector<std::string> &missingTargets) { // Skip configurations not enabled for this export. @@ -254,7 +255,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, fileName += "/"; fileName += this->FileBase; fileName += "-"; - if(config && *config) + if(!config.empty()) { fileName += cmSystemTools::LowerCase(config); } @@ -270,7 +271,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, { std::string se = cmSystemTools::GetLastSystemError(); cmOStringStream e; - e << "cannot write to file \"" << fileName.c_str() + e << "cannot write to file \"" << fileName << "\": " << se; cmSystemTools::Error(e.str().c_str()); return false; @@ -296,7 +297,8 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, void cmExportInstallFileGenerator ::GenerateImportTargetsConfig(std::ostream& os, - const char* config, std::string const& suffix, + const std::string& config, + std::string const& suffix, std::vector<std::string> &missingTargets) { // Add each target in the set to the export. @@ -355,7 +357,8 @@ cmExportInstallFileGenerator //---------------------------------------------------------------------------- void cmExportInstallFileGenerator -::SetImportLocationProperty(const char* config, std::string const& suffix, +::SetImportLocationProperty(const std::string& config, + std::string const& suffix, cmInstallTargetGenerator* itgen, ImportPropertyMap& properties, std::set<std::string>& importedLocations diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 7c634a4..b851ad5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -41,7 +41,7 @@ public: /** Get the per-config file generated for each configuraiton. This maps from the configuration name to the file temporary location for installation. */ - std::map<cmStdString, cmStdString> const& GetConfigImportFiles() + std::map<std::string, std::string> const& GetConfigImportFiles() { return this->ConfigImportFiles; } /** Compute the globbing expression used to load per-config import @@ -52,7 +52,7 @@ protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream& os, - const char* config, + const std::string& config, std::string const& suffix, std::vector<std::string> &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, @@ -72,11 +72,11 @@ protected: /** Generate a per-configuration file for the targets. */ - bool GenerateImportFileConfig(const char* config, + bool GenerateImportFileConfig(const std::string& config, std::vector<std::string> &missingTargets); /** Fill in properties indicating installed file locations. */ - void SetImportLocationProperty(const char* config, + void SetImportLocationProperty(const std::string& config, std::string const& suffix, cmInstallTargetGenerator* itgen, ImportPropertyMap& properties, @@ -92,7 +92,7 @@ protected: std::string ImportPrefix; // The import file generated for each configuration. - std::map<cmStdString, cmStdString> ConfigImportFiles; + std::map<std::string, std::string> ConfigImportFiles; }; #endif diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index 5d6f094..688d2eb 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -83,9 +83,9 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const cmake* cm = this->Makefile->GetCMakeInstance(); cmGlobalGenerator* global = cm->GetGlobalGenerator(); const std::vector<cmLocalGenerator *>& locals = global->GetLocalGenerators(); - std::map<cmStdString, cmStdString> libDepsOld; - std::map<cmStdString, cmStdString> libDepsNew; - std::map<cmStdString, cmStdString> libTypes; + std::map<std::string, std::string> libDepsOld; + std::map<std::string, std::string> libDepsNew; + std::map<std::string, std::string> libTypes; for(std::vector<cmLocalGenerator *>::const_iterator i = locals.begin(); i != locals.end(); ++i) { @@ -138,7 +138,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const break; } std::string lib = li->first; - if(cmTarget* libtgt = global->FindTarget(0, lib.c_str())) + if(cmTarget* libtgt = global->FindTarget(lib)) { // Handle simple output name changes. This command is // deprecated so we do not support full target name @@ -175,7 +175,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const fout << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n"; fout << "if(" << vertest << ")\n"; fout << " # Information for CMake 2.6 and above.\n"; - for(std::map<cmStdString, cmStdString>::const_iterator + for(std::map<std::string, std::string>::const_iterator i = libDepsNew.begin(); i != libDepsNew.end(); ++i) { @@ -186,7 +186,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const } fout << "else()\n"; fout << " # Information for CMake 2.4 and lower.\n"; - for(std::map<cmStdString, cmStdString>::const_iterator + for(std::map<std::string, std::string>::const_iterator i = libDepsOld.begin(); i != libDepsOld.end(); ++i) { @@ -195,7 +195,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n"; } } - for(std::map<cmStdString, cmStdString>::const_iterator i = libTypes.begin(); + for(std::map<std::string, std::string>::const_iterator i = libTypes.begin(); i != libTypes.end(); ++i) { if(i->second != "general") diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h index 29b568f..2ea4e79 100644 --- a/Source/cmExportLibraryDependenciesCommand.h +++ b/Source/cmExportLibraryDependenciesCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmExportLibraryDependenciesCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "export_library_dependencies";} + virtual std::string GetName() const { return "export_library_dependencies";} virtual bool IsDiscouraged() const { return true; } virtual void FinalPass(); diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index a8a91d6..3350d7c 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -46,8 +46,9 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) return true; } -std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName, - cmTarget const* tgt, +std::string cmExportTryCompileFileGenerator::FindTargets( + const std::string& propName, + cmTarget const* tgt, std::set<cmTarget const*> &emitted) { const char *prop = tgt->GetProperty(propName); @@ -101,7 +102,7 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, { const std::string libs = i->second.GetValue(); - std::string evalResult = this->FindTargets(i->first.c_str(), + std::string evalResult = this->FindTargets(i->first, target, emitted); std::vector<std::string> depends; @@ -128,7 +129,7 @@ cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = - target->GetInstallNameDirForBuildTree(config.c_str()); + target->GetInstallNameDirForBuildTree(config); } return install_name_dir; diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 71ac0dd..ec70d81 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -23,14 +23,14 @@ public: /** Set the list of targets to export. */ void SetExports(const std::vector<cmTarget const*> &exports) { this->Exports = exports; } - void SetConfig(const char *config) { this->Config = config; } + void SetConfig(const std::string& config) { this->Config = config; } protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream&, - const char*, + const std::string&, std::string const&, std::vector<std::string>&) {} virtual void HandleMissingTarget(std::string&, @@ -46,12 +46,12 @@ protected: std::string InstallNameDir(cmTarget* target, const std::string& config); private: - std::string FindTargets(const char *prop, cmTarget const* tgt, + std::string FindTargets(const std::string& prop, cmTarget const* tgt, std::set<cmTarget const*> &emitted); std::vector<cmTarget const*> Exports; - const char *Config; + std::string Config; }; #endif diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h index 4b76b33..8d6b2cd 100644 --- a/Source/cmExprParserHelper.h +++ b/Source/cmExprParserHelper.h @@ -49,8 +49,8 @@ public: const char* GetError() { return this->ErrorString.c_str(); } private: - cmStdString::size_type InputBufferPos; - cmStdString InputBuffer; + std::string::size_type InputBufferPos; + std::string InputBuffer; std::vector<char> OutputBuffer; int CurrentLine; int Verbose; diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index 0d42c35..9264671 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -20,13 +20,13 @@ void cmExternalMakefileProjectGenerator } std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName( - const char* globalGenerator, - const char* extraGenerator) + const std::string& globalGenerator, + const std::string& extraGenerator) { std::string fullName; - if (globalGenerator) + if (!globalGenerator.empty()) { - if (extraGenerator && *extraGenerator) + if (!extraGenerator.empty()) { fullName = extraGenerator; fullName += " - "; @@ -36,22 +36,22 @@ std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName( return fullName; } -const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName( - const char* fullName) +std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName( + const std::string& fullName) { // at least one global generator must be supported assert(!this->SupportedGlobalGenerators.empty()); - if (fullName==0) + if (fullName.empty()) { - return 0; + return ""; } std::string currentName = fullName; // if we get only the short name, take the first global generator as default if (currentName == this->GetName()) { - return this->SupportedGlobalGenerators[0].c_str(); + return this->SupportedGlobalGenerators[0]; } // otherwise search for the matching global generator @@ -60,11 +60,11 @@ const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName( it != this->SupportedGlobalGenerators.end(); ++it) { - if (this->CreateFullGeneratorName(it->c_str(), this->GetName()) + if (this->CreateFullGeneratorName(*it, this->GetName()) == currentName) { - return it->c_str(); + return *it; } } - return 0; + return ""; } diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index bce441d..cba1c76 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -37,10 +37,10 @@ public: virtual ~cmExternalMakefileProjectGenerator() {} ///! Get the name for this generator. - virtual const char* GetName() const = 0; + virtual std::string GetName() const = 0; /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const = 0; + const std::string& fullName) const = 0; virtual void EnableLanguage(std::vector<std::string> const& languages, cmMakefile *, bool optional); @@ -53,12 +53,13 @@ public: {return this->SupportedGlobalGenerators;} ///! Get the name of the global generator for the given full name - const char* GetGlobalGeneratorName(const char* fullName); + std::string GetGlobalGeneratorName(const std::string& fullName); /** Create a full name from the given global generator name and the * extra generator name */ - static std::string CreateFullGeneratorName(const char* globalGenerator, - const char* extraGenerator); + static std::string CreateFullGeneratorName( + const std::string& globalGenerator, + const std::string& extraGenerator); ///! Generate the project files, the Makefiles have already been generated virtual void Generate() = 0; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 548c88b..e99bf04 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -38,7 +38,7 @@ http://forums.codeblocks.org/index.php/topic,6789.0.html //---------------------------------------------------------------------------- void cmExtraCodeBlocksGenerator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates CodeBlocks project files."; @@ -61,7 +61,7 @@ cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() void cmExtraCodeBlocksGenerator::Generate() { // for each sub project in the project create a codeblocks project - for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -243,7 +243,7 @@ void cmExtraCodeBlocksGenerator Tree tree; // build tree of virtual folders - for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it != this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -334,7 +334,7 @@ void cmExtraCodeBlocksGenerator if (strcmp(makefile->GetStartOutputDirectory(), makefile->GetHomeOutputDirectory())==0) { - this->AppendTarget(fout, ti->first.c_str(), 0, + this->AppendTarget(fout, ti->first, 0, make.c_str(), makefile, compiler.c_str()); } } @@ -350,7 +350,7 @@ void cmExtraCodeBlocksGenerator break; } - this->AppendTarget(fout, ti->first.c_str(), 0, + this->AppendTarget(fout, ti->first, 0, make.c_str(), makefile, compiler.c_str()); break; case cmTarget::EXECUTABLE: @@ -359,11 +359,11 @@ void cmExtraCodeBlocksGenerator case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: { - this->AppendTarget(fout, ti->first.c_str(), &ti->second, + this->AppendTarget(fout, ti->first, &ti->second, make.c_str(), makefile, compiler.c_str()); std::string fastTarget = ti->first; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget.c_str(), &ti->second, + this->AppendTarget(fout, fastTarget, &ti->second, make.c_str(), makefile, compiler.c_str()); } break; @@ -411,14 +411,16 @@ void cmExtraCodeBlocksGenerator // check whether it is a C/C++ implementation file bool isCFile = false; - if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C')) + std::string lang = (*si)->GetLanguage(); + if (lang == "C" || lang == "CXX") { + std::string srcext = (*si)->GetExtension(); for(std::vector<std::string>::const_iterator ext = mf->GetSourceExtensions().begin(); ext != mf->GetSourceExtensions().end(); ++ext) { - if ((*si)->GetExtension() == *ext) + if (srcext == *ext) { isCFile = true; break; @@ -497,7 +499,7 @@ void cmExtraCodeBlocksGenerator sit!=otherFiles.end(); ++sit) { - fout<<" <Unit filename=\""<< sit->c_str() <<"\">\n" + fout<<" <Unit filename=\""<< *sit <<"\">\n" " </Unit>\n"; } @@ -536,7 +538,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile( // Generate the xml code for one target. void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, - const char* targetName, + const std::string& targetName, cmTarget* target, const char* make, const cmMakefile* makefile, @@ -624,7 +626,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, if (!systemIncludeDirs.empty()) { std::vector<std::string> dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs); + cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); for(std::vector<std::string>::const_iterator dirIt=dirs.begin(); dirIt != dirs.end(); ++dirIt) @@ -638,7 +640,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, if (!systemIncludeDirs.empty()) { std::vector<std::string> dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs); + cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); for(std::vector<std::string>::const_iterator dirIt=dirs.begin(); dirIt != dirs.end(); ++dirIt) @@ -651,7 +653,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, dirIt != uniqIncludeDirs.end(); ++dirIt) { - fout <<" <Add directory=\"" << dirIt->c_str() << "\" />\n"; + fout <<" <Add directory=\"" << *dirIt << "\" />\n"; } fout<<" </Compiler>\n"; @@ -695,7 +697,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) std::string hostSystemName = mf->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); - std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str()); + std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compiler = "gcc"; // default to gcc if (compilerId == "MSVC") { @@ -713,7 +715,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) { compiler = "icc"; } - else if (compilerId == "Watcom") + else if (compilerId == "Watcom" || compilerId == "OpenWatcom") { compiler = "ow"; } @@ -756,10 +758,12 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target) // Create the command line for building the given target using the selected // make std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( - const std::string& make, const char* makefile, const char* target) + const std::string& make, const char* makefile, + const std::string& target) { std::string command = make; - if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) + std::string generator = this->GlobalGenerator->GetName(); + if (generator == "NMake Makefiles") { // For Windows ConvertToOutputPath already adds quotes when required. // These need to be escaped, see @@ -770,7 +774,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( command += " VERBOSE=1 "; command += target; } - else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0) + else if (generator == "MinGW Makefiles") { // no escaping of spaces in this case, see // http://public.kitware.com/Bug/view.php?id=10014 @@ -781,7 +785,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( command += " VERBOSE=1 "; command += target; } - else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) + else if (generator == "Ninja") { command += " -v "; command += target; diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index e0a64ca..0435ad8 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -28,14 +28,14 @@ class cmExtraCodeBlocksGenerator : public cmExternalMakefileProjectGenerator public: cmExtraCodeBlocksGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmExtraCodeBlocksGenerator::GetActualName();} - static const char* GetActualName() { return "CodeBlocks";} + static std::string GetActualName() { return "CodeBlocks";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraCodeBlocksGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); private: @@ -49,9 +49,9 @@ private: std::string GetCBCompilerId(const cmMakefile* mf); int GetCBTargetType(cmTarget* target); std::string BuildMakeCommand(const std::string& make, const char* makefile, - const char* target); + const std::string& target); void AppendTarget(cmGeneratedFileStream& fout, - const char* targetName, + const std::string& targetName, cmTarget* target, const char* make, const cmMakefile* makefile, diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index ff84fb7..1cbd057 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -28,7 +28,7 @@ //---------------------------------------------------------------------------- void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry, - const char*) const + const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates CodeLite project files."; @@ -60,7 +60,7 @@ void cmExtraCodeLiteGenerator::Generate() // loop projects and locate the root project. // and extract the information for creating the worspace - for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -85,7 +85,7 @@ void cmExtraCodeLiteGenerator::Generate() } // for each sub project in the workspace create a codelite project - for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -220,14 +220,16 @@ void cmExtraCodeLiteGenerator { // check whether it is a C/C++ implementation file bool isCFile = false; - if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C')) + std::string lang = (*si)->GetLanguage(); + if (lang == "C" || lang == "CXX") { + std::string srcext = (*si)->GetExtension(); for(std::vector<std::string>::const_iterator ext = mf->GetSourceExtensions().begin(); ext != mf->GetSourceExtensions().end(); ++ext) { - if ((*si)->GetExtension() == *ext) + if (srcext == *ext) { isCFile = true; break; @@ -309,7 +311,7 @@ void cmExtraCodeLiteGenerator { std::string relativePath = cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str()); - fout<< " <File Name=\"" << relativePath.c_str() << "\"/>\n"; + fout<< " <File Name=\"" << relativePath << "\"/>\n"; } fout<< " </VirtualDirectory>\n"; fout<< " <VirtualDirectory Name=\"include\">\n"; @@ -320,7 +322,7 @@ void cmExtraCodeLiteGenerator { std::string relativePath = cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str()); - fout << " <File Name=\"" << relativePath.c_str() << "\"/>\n"; + fout << " <File Name=\"" << relativePath << "\"/>\n"; } fout << " </VirtualDirectory>\n"; @@ -402,7 +404,7 @@ cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(const cmMakefile* mf) const compilerIdVar = "CMAKE_C_COMPILER_ID"; } - std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str()); + std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compiler = "gnu g++"; // default to g++ // Since we need the compiler for parsing purposes only diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h index 984313e..6b4965d 100644 --- a/Source/cmExtraCodeLiteGenerator.h +++ b/Source/cmExtraCodeLiteGenerator.h @@ -35,14 +35,14 @@ protected: public: cmExtraCodeLiteGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmExtraCodeLiteGenerator::GetActualName();} - static const char* GetActualName() { return "CodeLite";} + static std::string GetActualName() { return "CodeLite";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraCodeLiteGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 74ba9a6..fcb95a0 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -45,7 +45,7 @@ cmExtraEclipseCDT4Generator //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates Eclipse CDT 4.0 project files."; @@ -205,7 +205,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_"; cacheEntryName += envVar; const char* cacheValue = mf->GetCacheManager()->GetCacheValue( - cacheEntryName.c_str()); + cacheEntryName); // now we have both, decide which one to use std::string valueToUse; @@ -219,7 +219,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, // The variable is in the env, but not in the cache. Use it and put it // in the cache valueToUse = envVarValue; - mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(), + mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmCacheManager::STRING, true); mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); @@ -240,7 +240,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, if (valueToUse.find(envVarValue) == std::string::npos) { valueToUse = envVarValue; - mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(), + mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmCacheManager::STRING, true); mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); @@ -624,7 +624,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( this->AppendLinkedResource(fout, "[Subprojects]", "virtual:/virtual", VirtualFolder); - for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it != this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -981,7 +981,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string systemIncludeDirs = mf->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); std::vector<std::string> dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs); + cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); this->AppendIncludeDirectories(fout, dirs, emmited); } compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); @@ -990,7 +990,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string systemIncludeDirs = mf->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS"); std::vector<std::string> dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs); + cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); this->AppendIncludeDirectories(fout, dirs, emmited); } @@ -1292,7 +1292,7 @@ void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout, std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path); fout << "<target name=\"" << prefix << targetXml << "\"" - " path=\"" << pathXml.c_str() << "\"" + " path=\"" << pathXml << "\"" " targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n" "<buildCommand>" << cmExtraEclipseCDT4Generator::GetEclipsePath(make) diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index d88b247..ef99760 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -33,14 +33,14 @@ public: return new cmExtraEclipseCDT4Generator; } - virtual const char* GetName() const { + virtual std::string GetName() const { return cmExtraEclipseCDT4Generator::GetActualName(); } - static const char* GetActualName() { return "Eclipse CDT4"; } + static std::string GetActualName() { return "Eclipse CDT4"; } virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void EnableLanguage(std::vector<std::string> const& languages, cmMakefile *, bool optional); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index a0d37d4..567542e 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -25,7 +25,7 @@ //---------------------------------------------------------------------------- void cmExtraKateGenerator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates Kate project files."; @@ -52,7 +52,7 @@ void cmExtraKateGenerator::Generate() this->ProjectName = this->GenerateProjectName(mf->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), this->GetPathBasename(mf->GetHomeOutputDirectory())); - this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0); + this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja"); this->CreateKateProjectFile(mf); this->CreateDummyKateProjectFile(mf); diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index 6ced5fe..f800feb 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -28,14 +28,14 @@ class cmExtraKateGenerator : public cmExternalMakefileProjectGenerator public: cmExtraKateGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmExtraKateGenerator::GetActualName();} - static const char* GetActualName() { return "Kate";} + static std::string GetActualName() { return "Kate";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraKateGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); private: diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 604bfcc..ec5ffc2 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -41,7 +41,7 @@ http://sublimetext.info/docs/en/reference/build_systems.html //---------------------------------------------------------------------------- void cmExtraSublimeTextGenerator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates Sublime Text 2 project files."; @@ -64,7 +64,7 @@ cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator() void cmExtraSublimeTextGenerator::Generate() { // for each sub project in the project create a sublime text 2 project - for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -177,7 +177,7 @@ void cmExtraSublimeTextGenerator:: if (strcmp(makefile->GetStartOutputDirectory(), makefile->GetHomeOutputDirectory())==0) { - this->AppendTarget(fout, ti->first.c_str(), *lg, 0, + this->AppendTarget(fout, ti->first, *lg, 0, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); } @@ -194,7 +194,7 @@ void cmExtraSublimeTextGenerator:: break; } - this->AppendTarget(fout, ti->first.c_str(), *lg, 0, + this->AppendTarget(fout, ti->first, *lg, 0, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); break; @@ -204,12 +204,12 @@ void cmExtraSublimeTextGenerator:: case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: { - this->AppendTarget(fout, ti->first.c_str(), *lg, &ti->second, + this->AppendTarget(fout, ti->first, *lg, &ti->second, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); std::string fastTarget = ti->first; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget.c_str(), *lg, &ti->second, + this->AppendTarget(fout, fastTarget, *lg, &ti->second, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); } @@ -223,7 +223,7 @@ void cmExtraSublimeTextGenerator:: void cmExtraSublimeTextGenerator:: AppendTarget(cmGeneratedFileStream& fout, - const char* targetName, + const std::string& targetName, cmLocalGenerator* lg, cmTarget* target, const char* make, @@ -290,7 +290,7 @@ void cmExtraSublimeTextGenerator:: // Ninja uses ninja.build files (look for a way to get the output file name // from cmMakefile or something) std::string makefileName; - if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) + if (this->GlobalGenerator->GetName() == "Ninja") { makefileName = "build.ninja"; } @@ -315,11 +315,13 @@ void cmExtraSublimeTextGenerator:: // Create the command line for building the given target using the selected // make std::string cmExtraSublimeTextGenerator::BuildMakeCommand( - const std::string& make, const char* makefile, const char* target) + const std::string& make, const char* makefile, + const std::string& target) { std::string command = "\""; command += make + "\""; - if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) + std::string generator = this->GlobalGenerator->GetName(); + if (generator == "NMake Makefiles") { std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); command += ", \"/NOLOGO\", \"/f\", \""; @@ -328,7 +330,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( command += target; command += "\""; } - else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) + else if (generator == "Ninja") { std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); command += ", \"-f\", \""; @@ -340,7 +342,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand( else { std::string makefileName; - if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0) + if (generator == "MinGW Makefiles") { // no escaping of spaces in this case, see // http://public.kitware.com/Bug/view.php?id=10014 @@ -369,12 +371,12 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, std::string flags; cmMakefile *makefile = lg->GetMakefile(); - const char* language = source->GetLanguage(); - if (language == NULL) + std::string language = source->GetLanguage(); + if (language.empty()) { language = "C"; } - const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); // Add language-specific flags. lg->AddLanguageFlags(flags, language, config); @@ -423,12 +425,8 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, { std::set<std::string> defines; cmMakefile *makefile = lg->GetMakefile(); - const char* language = source->GetLanguage(); - if (language == NULL) - { - language = ""; - } - const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + const std::string& language = source->GetLanguage(); + const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); // Add the export symbol definition for shared library objects. if(const char* exportMacro = target->GetExportMacro()) @@ -442,7 +440,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(config); - lg->AppendDefines(defines, source->GetProperty(defPropName.c_str())); + lg->AppendDefines(defines, source->GetProperty(defPropName)); } std::string definesString; diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index 7902593..4173b7d 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -31,15 +31,15 @@ public: typedef std::map<std::string, std::vector<std::string> > MapSourceFileFlags; cmExtraSublimeTextGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmExtraSublimeTextGenerator::GetActualName();} - static const char* GetActualName() + static std::string GetActualName() { return "Sublime Text 2";} static cmExternalMakefileProjectGenerator* New() { return new cmExtraSublimeTextGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); private: @@ -60,12 +60,12 @@ private: * specified target. */ std::string BuildMakeCommand(const std::string& make, const char* makefile, - const char* target); + const std::string& target); /** Appends the specified target to the generated project file as a Sublime * Text build system. */ void AppendTarget(cmGeneratedFileStream& fout, - const char* targetName, + const std::string& targetName, cmLocalGenerator* lg, cmTarget* target, const char* make, diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 4dd81be..0a36b82 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -48,7 +48,7 @@ bool cmFLTKWrapUICommand for(std::vector<std::string>::iterator i = (newArgs.begin() + 1); i != newArgs.end(); i++) { - cmSourceFile *curr = this->Makefile->GetSource(i->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(*i); // if we should use the source GUI // to generate .cxx and .h files if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) @@ -78,19 +78,19 @@ bool cmFLTKWrapUICommand commandLines.push_back(commandLine); // Add command for generating the .h and .cxx files - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; const char* no_comment = 0; const char* no_working_dir = 0; - this->Makefile->AddCustomCommandToOutput(cxxres.c_str(), + this->Makefile->AddCustomCommandToOutput(cxxres, depends, no_main_dependency, commandLines, no_comment, no_working_dir); - this->Makefile->AddCustomCommandToOutput(hname.c_str(), + this->Makefile->AddCustomCommandToOutput(hname, depends, no_main_dependency, commandLines, no_comment, no_working_dir); - cmSourceFile *sf = this->Makefile->GetSource(cxxres.c_str()); + cmSourceFile *sf = this->Makefile->GetSource(cxxres); sf->AddDepend(hname.c_str()); sf->AddDepend(origname.c_str()); this->GeneratedSourcesClasses.push_back(sf); @@ -110,7 +110,7 @@ bool cmFLTKWrapUICommand } std::string varName = this->Target; varName += "_FLTK_UI_SRCS"; - this->Makefile->AddDefinition(varName.c_str(), sourceListValue.c_str()); + this->Makefile->AddDefinition(varName, sourceListValue.c_str()); return true; } diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h index b94390c..617fcd9 100644 --- a/Source/cmFLTKWrapUICommand.h +++ b/Source/cmFLTKWrapUICommand.h @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "fltk_wrap_ui";} + virtual std::string GetName() const { return "fltk_wrap_ui";} private: /** diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index e79bc6c..5bfb664 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -174,7 +174,7 @@ bool cmFileCommand } std::string e = "does not recognize sub-command "+subCommand; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -205,7 +205,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, std::string e = "attempted to write a file: " + fileName + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -235,7 +235,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, std::string error = "Internal CMake error when trying to open file: "; error += fileName.c_str(); error += " for writing."; - this->SetError(error.c_str()); + this->SetError(error); return false; } file << message; @@ -295,7 +295,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args) std::string error = "Internal CMake error when trying to open file: "; error += fileName.c_str(); error += " for reading."; - this->SetError(error.c_str()); + this->SetError(error); return false; } @@ -359,7 +359,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args) } } } - this->Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable, output.c_str()); return true; } @@ -371,23 +371,23 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args) { cmOStringStream e; e << args[0] << " requires a file name and output variable"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str())); if(hash.get()) { - std::string out = hash->HashFile(args[1].c_str()); + std::string out = hash->HashFile(args[1]); if(!out.empty()) { - this->Makefile->AddDefinition(args[2].c_str(), out.c_str()); + this->Makefile->AddDefinition(args[2], out.c_str()); return true; } cmOStringStream e; e << args[0] << " failed to read file \"" << args[1] << "\": " << cmSystemTools::GetLastSystemError(); - this->SetError(e.str().c_str()); + this->SetError(e.str()); } return false; #else @@ -481,7 +481,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) cmOStringStream e; e << "STRINGS option LIMIT_INPUT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } arg_mode = arg_none; @@ -494,7 +494,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) cmOStringStream e; e << "STRINGS option LIMIT_OUTPUT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } arg_mode = arg_none; @@ -507,7 +507,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) cmOStringStream e; e << "STRINGS option LIMIT_COUNT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } limit_count = count; @@ -521,7 +521,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) cmOStringStream e; e << "STRINGS option LENGTH_MINIMUM value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } minlen = len; @@ -535,7 +535,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) cmOStringStream e; e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } maxlen = len; @@ -548,7 +548,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) cmOStringStream e; e << "STRINGS option REGEX value \"" << args[i] << "\" could not be compiled."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } have_regex = true; @@ -559,7 +559,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) cmOStringStream e; e << "STRINGS given unknown argument \"" << args[i] << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -586,7 +586,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) { cmOStringStream e; e << "STRINGS file \"" << fileName << "\" cannot be read."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -709,7 +709,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) } // Save the output in a makefile variable. - this->Makefile->AddDefinition(outVar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outVar, output.c_str()); return true; } @@ -844,7 +844,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, } } - this->Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable, output.c_str()); return true; } @@ -873,14 +873,14 @@ bool cmFileCommand::HandleMakeDirectoryCommand( { std::string e = "attempted to create a directory: " + *cdir + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } if ( !cmSystemTools::MakeDirectory(cdir->c_str()) ) { std::string error = "problem creating directory: " + *cdir; - this->SetError(error.c_str()); + this->SetError(error); return false; } } @@ -926,7 +926,7 @@ cmFileCommand::HandleDifferentCommand(std::vector<std::string> const& args) { cmOStringStream e; e << "DIFFERENT given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1041,7 +1041,7 @@ protected: { cmOStringStream e; e << this->Name << " cannot set permissions on \"" << toFile << "\""; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } return true; @@ -1065,7 +1065,7 @@ protected: { cmOStringStream e; e << this->Name << " given invalid permission \"" << arg << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } return true; @@ -1092,7 +1092,7 @@ protected: // The input file does not exist and installation is not optional. cmOStringStream e; e << this->Name << " cannot find \"" << fromFile << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1125,14 +1125,14 @@ protected: { cmOStringStream e; e << "option " << arg << " may not appear before PATTERN or REGEX."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } void NotAfterMatch(std::string const& arg) { cmOStringStream e; e << "option " << arg << " may not appear after PATTERN or REGEX."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } virtual void DefaultFilePermissions() @@ -1170,7 +1170,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args) { cmOStringStream e; e << "called with unknown argument \"" << args[i] << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1186,7 +1186,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args) { cmOStringStream e; e << this->Name << " given no DESTINATION"; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1366,7 +1366,7 @@ bool cmFileCopier::CheckValue(std::string const& arg) { cmOStringStream e; e << "could not compile PATTERN \"" << arg << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } } @@ -1382,7 +1382,7 @@ bool cmFileCopier::CheckValue(std::string const& arg) { cmOStringStream e; e << "could not compile REGEX \"" << arg << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } break; @@ -1462,7 +1462,7 @@ bool cmFileCopier::Install(const char* fromFile, const char* toFile) { cmOStringStream e; e << "INSTALL encountered an empty string input file name."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1504,7 +1504,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile) cmOStringStream e; e << this->Name << " cannot read symlink \"" << fromFile << "\" to duplicate at \"" << toFile << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1537,7 +1537,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile) cmOStringStream e; e << this->Name << " cannot duplicate symlink \"" << fromFile << "\" at \"" << toFile << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } } @@ -1569,7 +1569,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile, cmOStringStream e; e << this->Name << " cannot copy file \"" << fromFile << "\" to \"" << toFile << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1588,7 +1588,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile, cmOStringStream e; e << this->Name << " cannot set modification time on \"" << toFile << "\""; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } } @@ -1619,7 +1619,7 @@ bool cmFileCopier::InstallDirectory(const char* source, cmOStringStream e; e << this->Name << " cannot make directory \"" << destination << "\": " << cmSystemTools::GetLastSystemError(); - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } @@ -1910,7 +1910,7 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg) e << "INSTALL called with old-style " << arg << " argument. " << "This script was generated with an older version of CMake. " << "Re-run this cmake version on your build tree."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); this->Doing = DoingError; } else @@ -1976,7 +1976,7 @@ bool cmFileInstaller { cmOStringStream e; e << "Option TYPE given unknown value \"" << stype << "\"."; - this->FileCommand->SetError(e.str().c_str()); + this->FileCommand->SetError(e.str()); return false; } return true; @@ -2047,7 +2047,7 @@ bool cmFileInstaller::HandleInstallDestination() "absolute path or remove DESTDIR environment variable." "\nDESTINATION=\n"; message += destination; - this->FileCommand->SetError(message.c_str()); + this->FileCommand->SetError(message); return false; } } @@ -2061,7 +2061,7 @@ bool cmFileInstaller::HandleInstallDestination() { std::string errstring = "cannot create directory: " + destination + ". Maybe need administrative privileges."; - this->FileCommand->SetError(errstring.c_str()); + this->FileCommand->SetError(errstring); return false; } } @@ -2069,7 +2069,7 @@ bool cmFileInstaller::HandleInstallDestination() { std::string errstring = "INSTALL destination: " + destination + " is not a directory."; - this->FileCommand->SetError(errstring.c_str()); + this->FileCommand->SetError(errstring); return false; } return true; @@ -2118,7 +2118,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args) { cmOStringStream e; e << "RPATH_CHANGE given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -2141,7 +2141,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args) { cmOStringStream e; e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } bool success = true; @@ -2157,7 +2157,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args) << "to the file:\n" << " " << file << "\n" << emsg; - this->SetError(e.str().c_str()); + this->SetError(e.str()); success = false; } if(success) @@ -2203,7 +2203,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args) { cmOStringStream e; e << "RPATH_REMOVE given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -2216,7 +2216,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args) { cmOStringStream e; e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } bool success = true; @@ -2230,7 +2230,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args) e << "RPATH_REMOVE could not remove RPATH from file:\n" << " " << file << "\n" << emsg; - this->SetError(e.str().c_str()); + this->SetError(e.str()); success = false; } if(success) @@ -2284,7 +2284,7 @@ cmFileCommand::HandleRPathCheckCommand(std::vector<std::string> const& args) { cmOStringStream e; e << "RPATH_CHECK given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -2337,7 +2337,7 @@ bool cmFileCommand::HandleRelativePathCommand( std::string errstring = "RELATIVE_PATH must be passed a full path to the directory: " + directoryName; - this->SetError(errstring.c_str()); + this->SetError(errstring); return false; } if(!cmSystemTools::FileIsFullPath(fileName.c_str())) @@ -2345,13 +2345,13 @@ bool cmFileCommand::HandleRelativePathCommand( std::string errstring = "RELATIVE_PATH must be passed a full path to the file: " + fileName; - this->SetError(errstring.c_str()); + this->SetError(errstring); return false; } std::string res = cmSystemTools::RelativePath(directoryName.c_str(), fileName.c_str()); - this->Makefile->AddDefinition(outVar.c_str(), + this->Makefile->AddDefinition(outVar, res.c_str()); return true; } @@ -2389,7 +2389,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args) << "to\n" << " " << newname << "\n" << "because: " << err << "\n"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } return true; @@ -2539,6 +2539,11 @@ namespace { if (total > 0.0) { this->CurrentPercentage = static_cast<int>(value/total*100.0 + 0.5); + if(this->CurrentPercentage > 100) + { + // Avoid extra progress reports for unexpected data beyond total. + this->CurrentPercentage = 100; + } } bool updated = (OldPercentage != this->CurrentPercentage); @@ -2649,7 +2654,7 @@ namespace { { \ std::string e(errstr); \ e += ::curl_easy_strerror(result); \ - this->SetError(e.c_str()); \ + this->SetError(e); \ return false; \ } @@ -2785,7 +2790,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) std::string err = "DOWNLOAD EXPECTED_HASH expects ALGO=value but got: "; err += *i; - this->SetError(err.c_str()); + this->SetError(err); return false; } std::string algo = i->substr(0, pos); @@ -2795,7 +2800,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) { std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: "; err += algo; - this->SetError(err.c_str()); + this->SetError(err); return false; } hashMatchMSG = algo + " hash"; @@ -2809,7 +2814,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) if(cmSystemTools::FileExists(file.c_str()) && hash.get()) { std::string msg; - std::string actualHash = hash->HashFile(file.c_str()); + std::string actualHash = hash->HashFile(file); if(actualHash == expectedHash) { msg = "returning early; file already exists with expected "; @@ -2819,7 +2824,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) { cmOStringStream result; result << (int)0 << ";\"" << msg; - this->Makefile->AddDefinition(statusVar.c_str(), + this->Makefile->AddDefinition(statusVar, result.str().c_str()); } return true; @@ -2828,14 +2833,14 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) // Make sure parent directory exists so we can write to the file // as we receive downloaded bits from curl... // - std::string dir = cmSystemTools::GetFilenamePath(file.c_str()); + std::string dir = cmSystemTools::GetFilenamePath(file); if(!cmSystemTools::FileExists(dir.c_str()) && !cmSystemTools::MakeDirectory(dir.c_str())) { std::string errstring = "DOWNLOAD error: cannot create directory '" + dir + "' - Specify file by full path name and verify that you " "have directory creation and file write privileges."; - this->SetError(errstring.c_str()); + this->SetError(errstring); return false; } @@ -2954,7 +2959,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) { cmOStringStream result; result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\""; - this->Makefile->AddDefinition(statusVar.c_str(), + this->Makefile->AddDefinition(statusVar, result.str().c_str()); } @@ -2969,7 +2974,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) // if (hash.get()) { - std::string actualHash = hash->HashFile(file.c_str()); + std::string actualHash = hash->HashFile(file); if (actualHash.size() == 0) { this->SetError("DOWNLOAD cannot compute hash on downloaded file"); @@ -2986,7 +2991,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) << " status: [" << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"]" << std::endl ; - this->SetError(oss.str().c_str()); + this->SetError(oss.str()); return false; } } @@ -3000,12 +3005,12 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) if(verboseLog.size()) { - this->Makefile->AddDefinition(verboseLog.c_str(), + this->Makefile->AddDefinition(verboseLog, &*chunkDebug.begin()); } } - this->Makefile->AddDefinition(verboseLog.c_str(), + this->Makefile->AddDefinition(verboseLog, &*chunkDebug.begin()); } @@ -3102,7 +3107,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) { std::string errStr = "UPLOAD cannot open file '"; errStr += filename + "' for reading."; - this->SetError(errStr.c_str()); + this->SetError(errStr); return false; } @@ -3111,7 +3116,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) { std::string errStr = "UPLOAD cannot stat file '"; errStr += filename + "'."; - this->SetError(errStr.c_str()); + this->SetError(errStr); fclose(fin); return false; } @@ -3217,7 +3222,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) { cmOStringStream result; result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\""; - this->Makefile->AddDefinition(statusVar.c_str(), + this->Makefile->AddDefinition(statusVar, result.str().c_str()); } @@ -3246,7 +3251,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) log += "\n"; } - this->Makefile->AddDefinition(logVar.c_str(), log.c_str()); + this->Makefile->AddDefinition(logVar, log.c_str()); } return true; @@ -3368,7 +3373,7 @@ bool cmFileCommand::HandleTimestampCommand( { std::string e = " TIMESTAMP sub-command does not recognize option " + args[argsIndex] + "."; - this->SetError(e.c_str()); + this->SetError(e); return false; } } @@ -3376,7 +3381,7 @@ bool cmFileCommand::HandleTimestampCommand( cmTimestamp timestamp; std::string result = timestamp.FileModificationTime( filename.c_str(), formatString, utcFlag); - this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str()); + this->Makefile->AddDefinition(outputVariable, result.c_str()); return true; } diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index ba45815..8d66fdf 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "file";} + virtual std::string GetName() const { return "file";} cmTypeMacro(cmFileCommand, cmCommand); diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 02f10c0..5727470 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -43,13 +43,13 @@ private: class HashString { public: - size_t operator()(const cmStdString& s) const + size_t operator()(const std::string& s) const { return h(s.c_str()); } cmsys::hash<const char*> h; }; - typedef cmsys::hash_map<cmStdString, + typedef cmsys::hash_map<std::string, cmFileTimeComparison_Type, HashString> FileStatsMap; FileStatsMap Files; #endif diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index ae15ee7..e4e819a 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -237,7 +237,7 @@ void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths, for(std::vector<std::string>::const_iterator it = in_paths.begin(); it != in_paths.end(); ++it) { - std::string dir = it->c_str(); + std::string dir = *it; if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/') { dir += "/"; @@ -268,7 +268,7 @@ void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths, } //---------------------------------------------------------------------------- -void cmFindBase::AddCMakePrefixPath(const char* variable) +void cmFindBase::AddCMakePrefixPath(const std::string& variable) { // Get a path from a CMake variable. if(const char* varPath = this->Makefile->GetDefinition(variable)) @@ -280,11 +280,11 @@ void cmFindBase::AddCMakePrefixPath(const char* variable) } //---------------------------------------------------------------------------- -void cmFindBase::AddEnvPrefixPath(const char* variable) +void cmFindBase::AddEnvPrefixPath(const std::string& variable) { // Get a path from the environment. std::vector<std::string> tmp; - cmSystemTools::GetPath(tmp, variable); + cmSystemTools::GetPath(tmp, variable.c_str()); this->AddPrefixPaths(tmp, EnvPath); } @@ -323,7 +323,7 @@ void cmFindBase::AddCMakeVariablePath() var += this->CMakePathName; var += "_PATH"; this->AddCMakePrefixPath("CMAKE_PREFIX_PATH"); - this->AddCMakePath(var.c_str()); + this->AddCMakePath(var); if(this->CMakePathName == "PROGRAM") { @@ -360,7 +360,7 @@ void cmFindBase::AddCMakeSystemVariablePath() var += this->CMakePathName; var += "_PATH"; this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH"); - this->AddCMakePath(var.c_str()); + this->AddCMakePath(var); if(this->CMakePathName == "PROGRAM") { @@ -466,7 +466,7 @@ void cmFindBase::PrintFindStuff() bool cmFindBase::CheckForVariableInCache() { if(const char* cacheValue = - this->Makefile->GetDefinition(this->VariableName.c_str())) + this->Makefile->GetDefinition(this->VariableName)) { cmCacheManager::CacheIterator it = this->Makefile->GetCacheManager()-> diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index 0562b1b..42d9bc1 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -42,14 +42,14 @@ protected: bool CheckForVariableInCache(); // use by command during find - cmStdString VariableDocumentation; - cmStdString VariableName; + std::string VariableDocumentation; + std::string VariableName; std::vector<std::string> Names; bool NamesPerDir; bool NamesPerDirAllowed; // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM - cmStdString EnvironmentPath; // LIB,INCLUDE + std::string EnvironmentPath; // LIB,INCLUDE bool AlreadyInCache; bool AlreadyInCacheWithoutMetaInfo; @@ -63,8 +63,8 @@ private: void AddUserGuessPath(); // Helpers. - void AddCMakePrefixPath(const char* variable); - void AddEnvPrefixPath(const char* variable); + void AddCMakePrefixPath(const std::string& variable); + void AddEnvPrefixPath(const std::string& variable); void AddPrefixPaths(std::vector<std::string> const& in_paths, PathType pathType); }; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index e8c8da3..10241f2 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -51,7 +51,7 @@ void cmFindCommon::SelectDefaultRootPathMode() std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_"; findRootPathVar += this->CMakePathName; std::string rootPathMode = - this->Makefile->GetSafeDefinition(findRootPathVar.c_str()); + this->Makefile->GetSafeDefinition(findRootPathVar); if (rootPathMode=="NEVER") { this->FindRootPathMode = RootPathModeNoRootPath; @@ -361,7 +361,7 @@ void cmFindCommon::AddUserPath(std::string const& p, // Expand using the view of the target application. std::string expanded = p; cmSystemTools::ExpandRegistryValues(expanded, view); - cmSystemTools::GlobDirs(expanded.c_str(), paths); + cmSystemTools::GlobDirs(expanded, paths); // Executables can be either 32-bit or 64-bit, so expand using the // alternative view. @@ -369,12 +369,12 @@ void cmFindCommon::AddUserPath(std::string const& p, { expanded = p; cmSystemTools::ExpandRegistryValues(expanded, other_view); - cmSystemTools::GlobDirs(expanded.c_str(), paths); + cmSystemTools::GlobDirs(expanded, paths); } } //---------------------------------------------------------------------------- -void cmFindCommon::AddCMakePath(const char* variable) +void cmFindCommon::AddCMakePath(const std::string& variable) { // Get a path from a CMake variable. if(const char* varPath = this->Makefile->GetDefinition(variable)) @@ -433,7 +433,7 @@ void cmFindCommon::AddPathInternal(std::string const& in_path, // Insert the path if has not already been emitted. if(this->SearchPathsEmitted.insert(fullPath).second) { - this->SearchPaths.push_back(fullPath.c_str()); + this->SearchPaths.push_back(fullPath); } } diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 6109a9f..5a905cd 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -56,14 +56,14 @@ protected: /** Compute the current default bundle/framework search policy. */ void SelectDefaultMacMode(); - cmStdString CMakePathName; + std::string CMakePathName; RootPathMode FindRootPathMode; bool CheckCommonArgument(std::string const& arg); void AddPathSuffix(std::string const& arg); void AddUserPath(std::string const& p, std::vector<std::string>& paths); - void AddCMakePath(const char* variable); + void AddCMakePath(const std::string& variable); void AddEnvPath(const char* variable); void AddPathsInternal(std::vector<std::string> const& in_paths, PathType pathType); @@ -81,7 +81,7 @@ protected: std::vector<std::string> UserPaths; std::vector<std::string> UserHints; std::vector<std::string> SearchPaths; - std::set<cmStdString> SearchPathsEmitted; + std::set<std::string> SearchPathsEmitted; bool SearchFrameworkFirst; bool SearchFrameworkOnly; diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index 3f0baa2..daf1d65 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -33,7 +33,7 @@ public: { return new cmFindFileCommand; } - virtual const char* GetName() const { return "find_file";} + virtual std::string GetName() const { return "find_file";} cmTypeMacro(cmFindFileCommand, cmFindPathCommand); }; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index de52df7..fe5e45f 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -37,7 +37,7 @@ bool cmFindLibraryCommand // value. if(this->AlreadyInCacheWithoutMetaInfo) { - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), "", + this->Makefile->AddCacheDefinition(this->VariableName, "", this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); } @@ -69,14 +69,14 @@ bool cmFindLibraryCommand if(library != "") { // Save the value in the cache - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(), this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); return true; } std::string notfound = this->VariableName + "-NOTFOUND"; - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName, notfound.c_str(), this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); @@ -368,8 +368,8 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path, // Search for a file matching the library name regex. std::string dir = path; cmSystemTools::ConvertToUnixSlashes(dir); - std::set<cmStdString> const& files = this->GG->GetDirectoryContent(dir); - for(std::set<cmStdString>::const_iterator fi = files.begin(); + std::set<std::string> const& files = this->GG->GetDirectoryContent(dir); + for(std::set<std::string>::const_iterator fi = files.begin(); fi != files.end(); ++fi) { std::string const& origName = *fi; diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index a9ec40e..e257174 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -49,7 +49,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "find_library";} + virtual std::string GetName() const {return "find_library";} cmTypeMacro(cmFindLibraryCommand, cmFindBase); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 73eba51..a790e00 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -223,7 +223,7 @@ bool cmFindPackageCommand } std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i]; - this->AddFindDefinition(req_var.c_str(), isRequired); + this->AddFindDefinition(req_var, isRequired); // Append to the list of required components. components += components_sep; @@ -255,7 +255,7 @@ bool cmFindPackageCommand e << "given CONFIGS option followed by invalid file name \"" << args[i] << "\". The names given must be file names without " << "a path and with a \".cmake\" extension."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } this->Configs.push_back(args[i]); @@ -268,8 +268,8 @@ bool cmFindPackageCommand else { cmOStringStream e; - e << "called with invalid argument \"" << args[i].c_str() << "\""; - this->SetError(e.str().c_str()); + e << "called with invalid argument \"" << args[i] << "\""; + this->SetError(e.str()); return false; } } @@ -286,7 +286,7 @@ bool cmFindPackageCommand { e << " " << doubledComponents[i] << "\n"; } - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -309,7 +309,7 @@ bool cmFindPackageCommand e << " " << args[*si] << "\n"; } e << "The options are incompatible."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -327,7 +327,7 @@ bool cmFindPackageCommand // another find_package(<name>) call. std::string mod = this->Name; mod += "_FIND_MODULE"; - if(this->Makefile->IsOn(mod.c_str())) + if(this->Makefile->IsOn(mod)) { if(this->Version.empty()) { @@ -335,17 +335,17 @@ bool cmFindPackageCommand // Requested version string. std::string ver = this->Name; ver += "_FIND_VERSION"; - this->Version = this->Makefile->GetSafeDefinition(ver.c_str()); + this->Version = this->Makefile->GetSafeDefinition(ver); // Whether an exact version is required. std::string exact = this->Name; exact += "_FIND_VERSION_EXACT"; - this->VersionExact = this->Makefile->IsOn(exact.c_str()); + this->VersionExact = this->Makefile->IsOn(exact); } if(components.empty()) { std::string components_var = this->Name + "_FIND_COMPONENTS"; - components = this->Makefile->GetSafeDefinition(components_var.c_str()); + components = this->Makefile->GetSafeDefinition(components_var); } } } @@ -373,7 +373,7 @@ bool cmFindPackageCommand std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_"; disableFindPackageVar += this->Name; - if(this->Makefile->IsOn(disableFindPackageVar.c_str())) + if(this->Makefile->IsOn(disableFindPackageVar)) { if (this->Required) { @@ -381,7 +381,7 @@ bool cmFindPackageCommand e << "for module " << this->Name << " called with REQUIRED, but " << disableFindPackageVar << " is enabled. A REQUIRED package cannot be disabled."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -488,7 +488,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // Store the list of components. std::string components_var = this->Name + "_FIND_COMPONENTS"; - this->AddFindDefinition(components_var.c_str(), components.c_str()); + this->AddFindDefinition(components_var, components.c_str()); if(this->Quiet) { @@ -496,7 +496,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // quietly. std::string quietly = this->Name; quietly += "_FIND_QUIETLY"; - this->AddFindDefinition(quietly.c_str(), "1"); + this->AddFindDefinition(quietly, "1"); } if(this->Required) @@ -505,7 +505,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // a fatal error if the package is not found. std::string req = this->Name; req += "_FIND_REQUIRED"; - this->AddFindDefinition(req.c_str(), "1"); + this->AddFindDefinition(req, "1"); } if(!this->Version.empty()) @@ -514,28 +514,29 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // package has been requested. std::string ver = this->Name; ver += "_FIND_VERSION"; - this->AddFindDefinition(ver.c_str(), this->Version.c_str()); + this->AddFindDefinition(ver, this->Version.c_str()); char buf[64]; sprintf(buf, "%u", this->VersionMajor); - this->AddFindDefinition((ver+"_MAJOR").c_str(), buf); + this->AddFindDefinition(ver+"_MAJOR", buf); sprintf(buf, "%u", this->VersionMinor); - this->AddFindDefinition((ver+"_MINOR").c_str(), buf); + this->AddFindDefinition(ver+"_MINOR", buf); sprintf(buf, "%u", this->VersionPatch); - this->AddFindDefinition((ver+"_PATCH").c_str(), buf); + this->AddFindDefinition(ver+"_PATCH", buf); sprintf(buf, "%u", this->VersionTweak); - this->AddFindDefinition((ver+"_TWEAK").c_str(), buf); + this->AddFindDefinition(ver+"_TWEAK", buf); sprintf(buf, "%u", this->VersionCount); - this->AddFindDefinition((ver+"_COUNT").c_str(), buf); + this->AddFindDefinition(ver+"_COUNT", buf); // Tell the module whether an exact version has been requested. std::string exact = this->Name; exact += "_FIND_VERSION_EXACT"; - this->AddFindDefinition(exact.c_str(), this->VersionExact? "1":"0"); + this->AddFindDefinition(exact, this->VersionExact? "1":"0"); } } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddFindDefinition(const char* var, const char* val) +void cmFindPackageCommand::AddFindDefinition(const std::string& var, + const char* val) { if(const char* old = this->Makefile->GetDefinition(var)) { @@ -552,17 +553,17 @@ void cmFindPackageCommand::AddFindDefinition(const char* var, const char* val) //---------------------------------------------------------------------------- void cmFindPackageCommand::RestoreFindDefinitions() { - for(std::map<cmStdString, OriginalDef>::iterator + for(std::map<std::string, OriginalDef>::iterator i = this->OriginalDefs.begin(); i != this->OriginalDefs.end(); ++i) { OriginalDef const& od = i->second; if(od.exists) { - this->Makefile->AddDefinition(i->first.c_str(), od.value.c_str()); + this->Makefile->AddDefinition(i->first, od.value.c_str()); } else { - this->Makefile->RemoveDefinition(i->first.c_str()); + this->Makefile->RemoveDefinition(i->first); } } } @@ -581,9 +582,9 @@ bool cmFindPackageCommand::FindModule(bool& found) found = true; std::string var = this->Name; var += "_FIND_MODULE"; - this->Makefile->AddDefinition(var.c_str(), "1"); + this->Makefile->AddDefinition(var, "1"); bool result = this->ReadListFile(mfile.c_str(), DoPolicyScope); - this->Makefile->RemoveDefinition(var.c_str()); + this->Makefile->RemoveDefinition(var); return result; } return true; @@ -601,7 +602,7 @@ bool cmFindPackageCommand::HandlePackageMode() upperFound += "_FOUND"; // Try to find the config file. - const char* def = this->Makefile->GetDefinition(this->Variable.c_str()); + const char* def = this->Makefile->GetDefinition(this->Variable); // Try to load the config file if the directory is known bool fileFound = false; @@ -626,14 +627,14 @@ bool cmFindPackageCommand::HandlePackageMode() this->FileFound = file; fileFound = true; } - def = this->Makefile->GetDefinition(this->Variable.c_str()); + def = this->Makefile->GetDefinition(this->Variable); } // Search for the config file if it is not already found. if(cmSystemTools::IsOff(def) || !fileFound) { fileFound = this->FindConfig(); - def = this->Makefile->GetDefinition(this->Variable.c_str()); + def = this->Makefile->GetDefinition(this->Variable); } // Sanity check. @@ -658,16 +659,16 @@ bool cmFindPackageCommand::HandlePackageMode() if(fileFound) { - if ((this->Makefile->IsDefinitionSet(foundVar.c_str())) - && (this->Makefile->IsOn(foundVar.c_str()) == false)) + if ((this->Makefile->IsDefinitionSet(foundVar)) + && (this->Makefile->IsOn(foundVar) == false)) { // by removing Foo_FOUND here if it is FALSE, we don't really change // the situation for the Config file which is about to be included, // but we make it possible to detect later on whether the Config file // has set Foo_FOUND to FALSE itself: - this->Makefile->RemoveDefinition(foundVar.c_str()); + this->Makefile->RemoveDefinition(foundVar); } - this->Makefile->RemoveDefinition(notFoundMessageVar.c_str()); + this->Makefile->RemoveDefinition(notFoundMessageVar); // Set the version variables before loading the config file. // It may override them. @@ -680,14 +681,14 @@ bool cmFindPackageCommand::HandlePackageMode() found = true; // Check whether the Config file has set Foo_FOUND to FALSE: - if ((this->Makefile->IsDefinitionSet(foundVar.c_str())) - && (this->Makefile->IsOn(foundVar.c_str()) == false)) + if ((this->Makefile->IsDefinitionSet(foundVar)) + && (this->Makefile->IsOn(foundVar) == false)) { // we get here if the Config file has set Foo_FOUND actively to FALSE found = false; configFileSetFOUNDFalse = true; notFoundMessage = this->Makefile->GetSafeDefinition( - notFoundMessageVar.c_str()); + notFoundMessageVar); } } else @@ -809,18 +810,18 @@ bool cmFindPackageCommand::HandlePackageMode() } // Set a variable marking whether the package was found. - this->Makefile->AddDefinition(foundVar.c_str(), found? "1":"0"); + this->Makefile->AddDefinition(foundVar, found? "1":"0"); // Set a variable naming the configuration file that was found. std::string fileVar = this->Name; fileVar += "_CONFIG"; if(found) { - this->Makefile->AddDefinition(fileVar.c_str(), this->FileFound.c_str()); + this->Makefile->AddDefinition(fileVar, this->FileFound.c_str()); } else { - this->Makefile->RemoveDefinition(fileVar.c_str()); + this->Makefile->RemoveDefinition(fileVar); } std::string consideredConfigsVar = this->Name; @@ -842,10 +843,10 @@ bool cmFindPackageCommand::HandlePackageMode() sep = ";"; } - this->Makefile->AddDefinition(consideredConfigsVar.c_str(), + this->Makefile->AddDefinition(consideredConfigsVar, consideredConfigFiles.c_str()); - this->Makefile->AddDefinition(consideredVersionsVar.c_str(), + this->Makefile->AddDefinition(consideredVersionsVar, consideredVersions.c_str()); return result; @@ -905,7 +906,7 @@ bool cmFindPackageCommand::FindConfig() help += this->Name; help += "."; // We force the value since we do not get here if it was already set. - this->Makefile->AddCacheDefinition(this->Variable.c_str(), + this->Makefile->AddCacheDefinition(this->Variable, init.c_str(), help.c_str(), cmCacheManager::PATH, true); return found; @@ -967,7 +968,7 @@ bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr) std::string e = "Error reading CMake code from \""; e += f; e += "\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -1047,14 +1048,14 @@ void cmFindPackageCommand::AppendSuccessInformation() std::string transitivePropName = "_CMAKE_"; transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY"; this->Makefile->GetCMakeInstance() - ->SetProperty(transitivePropName.c_str(), "False"); + ->SetProperty(transitivePropName, "False"); } std::string found = this->Name; found += "_FOUND"; std::string upperFound = cmSystemTools::UpperCase(found); - const char* upperResult = this->Makefile->GetDefinition(upperFound.c_str()); - const char* result = this->Makefile->GetDefinition(found.c_str()); + const char* upperResult = this->Makefile->GetDefinition(upperFound); + const char* result = this->Makefile->GetDefinition(found); bool packageFound = ((cmSystemTools::IsOn(result)) || (cmSystemTools::IsOn(upperResult))); @@ -1065,7 +1066,7 @@ void cmFindPackageCommand::AppendSuccessInformation() std::string quietInfoPropName = "_CMAKE_"; quietInfoPropName += this->Name; quietInfoPropName += "_QUIET"; - this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName.c_str(), + this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName, this->Quiet ? "TRUE" : "FALSE"); // set a global property to record the required version of this package @@ -1079,7 +1080,7 @@ void cmFindPackageCommand::AppendSuccessInformation() versionInfo += " "; versionInfo += this->Version; } - this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName.c_str(), + this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName, versionInfo.c_str()); if (this->Required) { @@ -1087,7 +1088,7 @@ void cmFindPackageCommand::AppendSuccessInformation() requiredInfoPropName += this->Name; requiredInfoPropName += "_TYPE"; this->Makefile->GetCMakeInstance()->SetProperty( - requiredInfoPropName.c_str(), "REQUIRED"); + requiredInfoPropName, "REQUIRED"); } @@ -1647,25 +1648,25 @@ void cmFindPackageCommand::StoreVersionFound() ver += "_VERSION"; if(this->VersionFound.empty()) { - this->Makefile->RemoveDefinition(ver.c_str()); + this->Makefile->RemoveDefinition(ver); } else { - this->Makefile->AddDefinition(ver.c_str(), this->VersionFound.c_str()); + this->Makefile->AddDefinition(ver, this->VersionFound.c_str()); } // Store the version components. char buf[64]; sprintf(buf, "%u", this->VersionFoundMajor); - this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf); + this->Makefile->AddDefinition(ver+"_MAJOR", buf); sprintf(buf, "%u", this->VersionFoundMinor); - this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf); + this->Makefile->AddDefinition(ver+"_MINOR", buf); sprintf(buf, "%u", this->VersionFoundPatch); - this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf); + this->Makefile->AddDefinition(ver+"_PATCH", buf); sprintf(buf, "%u", this->VersionFoundTweak); - this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf); + this->Makefile->AddDefinition(ver+"_TWEAK", buf); sprintf(buf, "%u", this->VersionFoundCount); - this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf); + this->Makefile->AddDefinition(ver+"_COUNT", buf); } //---------------------------------------------------------------------------- diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 0d80e48..2249459 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -49,7 +49,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "find_package";} + virtual std::string GetName() const { return "find_package";} cmTypeMacro(cmFindPackageCommand, cmFindCommon); private: @@ -57,7 +57,7 @@ private: void AppendToFoundProperty(bool found); void SetModuleVariables(const std::string& components); bool FindModule(bool& found); - void AddFindDefinition(const char* var, const char* val); + void AddFindDefinition(const std::string& var, const char* val); void RestoreFindDefinitions(); bool HandlePackageMode(); bool FindConfig(); @@ -96,19 +96,19 @@ private: friend class cmFindPackageFileList; struct OriginalDef { bool exists; std::string value; }; - std::map<cmStdString, OriginalDef> OriginalDefs; + std::map<std::string, OriginalDef> OriginalDefs; - cmStdString Name; - cmStdString Variable; - cmStdString Version; + std::string Name; + std::string Variable; + std::string Version; unsigned int VersionMajor; unsigned int VersionMinor; unsigned int VersionPatch; unsigned int VersionTweak; unsigned int VersionCount; bool VersionExact; - cmStdString FileFound; - cmStdString VersionFound; + std::string FileFound; + std::string VersionFound; unsigned int VersionFoundMajor; unsigned int VersionFoundMinor; unsigned int VersionFoundPatch; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 8459995..5531cdf 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -38,7 +38,7 @@ bool cmFindPathCommand if(this->AlreadyInCacheWithoutMetaInfo) { this->Makefile->AddCacheDefinition( - this->VariableName.c_str(), "", + this->VariableName, "", this->VariableDocumentation.c_str(), (this->IncludeFileInPath ? cmCacheManager::FILEPATH :cmCacheManager::PATH) @@ -51,14 +51,14 @@ bool cmFindPathCommand if(result.size() != 0) { this->Makefile->AddCacheDefinition - (this->VariableName.c_str(), result.c_str(), + (this->VariableName, result.c_str(), this->VariableDocumentation.c_str(), (this->IncludeFileInPath) ? cmCacheManager::FILEPATH :cmCacheManager::PATH); return true; } this->Makefile->AddCacheDefinition - (this->VariableName.c_str(), + (this->VariableName, (this->VariableName + "-NOTFOUND").c_str(), this->VariableDocumentation.c_str(), (this->IncludeFileInPath) ? @@ -89,9 +89,9 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file, std::string const& dir) { - cmStdString fileName = file; - cmStdString frameWorkName; - cmStdString::size_type pos = fileName.find("/"); + std::string fileName = file; + std::string frameWorkName; + std::string::size_type pos = fileName.find("/"); // if there is a / in the name try to find the header as a framework // For example bar/foo.h would look for: // bar.framework/Headers/foo.h @@ -128,7 +128,7 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file, } // if it is not found yet or not a framework header, then do a glob search // for all frameworks in the directory: dir/*.framework/Headers/<file> - cmStdString glob = dir; + std::string glob = dir; glob += "*.framework/Headers/"; glob += file; cmsys::Glob globIt; @@ -136,7 +136,7 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file, std::vector<std::string> files = globIt.GetFiles(); if(files.size()) { - cmStdString fheader = cmSystemTools::CollapseFullPath(files[0].c_str()); + std::string fheader = cmSystemTools::CollapseFullPath(files[0].c_str()); if(this->IncludeFileInPath) { return fheader; diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h index 8df4540..a51da79 100644 --- a/Source/cmFindPathCommand.h +++ b/Source/cmFindPathCommand.h @@ -49,7 +49,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "find_path";} + virtual std::string GetName() const {return "find_path";} cmTypeMacro(cmFindPathCommand, cmFindBase); bool IncludeFileInPath; diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index bb27753..f6e37f6 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -35,7 +35,7 @@ bool cmFindProgramCommand // value. if(this->AlreadyInCacheWithoutMetaInfo) { - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), "", + this->Makefile->AddCacheDefinition(this->VariableName, "", this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); } @@ -46,14 +46,14 @@ bool cmFindProgramCommand if(result != "") { // Save the value in the cache - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(), this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); return true; } - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + this->Makefile->AddCacheDefinition(this->VariableName, (this->VariableName + "-NOTFOUND").c_str(), this->VariableDocumentation.c_str(), cmCacheManager::FILEPATH); diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h index 7f4811c..70f758f 100644 --- a/Source/cmFindProgramCommand.h +++ b/Source/cmFindProgramCommand.h @@ -48,7 +48,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "find_program";} + virtual std::string GetName() const { return "find_program";} cmTypeMacro(cmFindProgramCommand, cmFindBase); diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index d697067..e3f66c1 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -35,9 +35,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // at end of for each execute recorded commands // store the old value std::string oldDef; - if (mf.GetDefinition(this->Args[0].c_str())) + if (mf.GetDefinition(this->Args[0])) { - oldDef = mf.GetDefinition(this->Args[0].c_str()); + oldDef = mf.GetDefinition(this->Args[0]); } std::vector<std::string>::const_iterator j = this->Args.begin(); ++j; @@ -47,7 +47,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, for( ; j != this->Args.end(); ++j) { // set the variable to the loop value - mf.AddDefinition(this->Args[0].c_str(),j->c_str()); + mf.AddDefinition(this->Args[0],j->c_str()); // Invoke all the functions that were collected in the block. cmExecutionStatus status; for(unsigned int c = 0; c < this->Functions.size(); ++c) @@ -58,13 +58,13 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, { inStatus.SetReturnInvoked(true); // restore the variable to its prior value - mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); + mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; } if (status.GetBreakInvoked()) { // restore the variable to its prior value - mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); + mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; } if(cmSystemTools::GetFatalErrorOccured() ) @@ -74,7 +74,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, } } // restore the variable to its prior value - mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str()); + mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; } else @@ -166,7 +166,7 @@ bool cmForEachCommand cmOStringStream str; str << "called with incorrect range specification: start "; str << start << ", stop " << stop << ", step " << step; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } std::vector<std::string> range; @@ -226,7 +226,7 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args) } else if(doing == DoingLists) { - const char* value = this->Makefile->GetDefinition(args[i].c_str()); + const char* value = this->Makefile->GetDefinition(args[i]); if(value && *value) { cmSystemTools::ExpandListArgument(value, f->Args, true); diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h index e548ba8..9b7c85a 100644 --- a/Source/cmForEachCommand.h +++ b/Source/cmForEachCommand.h @@ -59,7 +59,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "foreach";} + virtual std::string GetName() const { return "foreach";} cmTypeMacro(cmForEachCommand, cmCommand); private: diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 85b89d9..3ff527d 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -64,7 +64,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return this->Args[0].c_str(); } + virtual std::string GetName() const { return this->Args[0]; } cmTypeMacro(cmFunctionHelperCommand, cmCommand); @@ -89,7 +89,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass std::string errorMsg = "Function invoked with incorrect arguments for function named: "; errorMsg += this->Args[0]; - this->SetError(errorMsg.c_str()); + this->SetError(errorMsg); return false; } @@ -113,15 +113,15 @@ bool cmFunctionHelperCommand::InvokeInitialPass { cmOStringStream tmpStream; tmpStream << "ARGV" << t; - this->Makefile->AddDefinition(tmpStream.str().c_str(), + this->Makefile->AddDefinition(tmpStream.str(), expandedArgs[t].c_str()); - this->Makefile->MarkVariableAsUsed(tmpStream.str().c_str()); + this->Makefile->MarkVariableAsUsed(tmpStream.str()); } // define the formal arguments for (unsigned int j = 1; j < this->Args.size(); ++j) { - this->Makefile->AddDefinition(this->Args[j].c_str(), + this->Makefile->AddDefinition(this->Args[j], expandedArgs[j-1].c_str()); } @@ -219,8 +219,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, } std::string newName = "_" + this->Args[0]; - mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(), - newName.c_str()); + mf.GetCMakeInstance()->RenameCommand(this->Args[0], + newName); mf.AddCommand(f); // remove the function blocker now that the function is defined diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index a8bd3e7..2df435e 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -57,7 +57,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "function";} + virtual std::string GetName() const { return "function";} cmTypeMacro(cmFunctionCommand, cmCommand); }; diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 34efc15..78ad4b2 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -249,12 +249,7 @@ int cmGeneratedFileStreamBase::RenameFile(const char* oldname, } //---------------------------------------------------------------------------- -void cmGeneratedFileStream::SetName(const char* fname) +void cmGeneratedFileStream::SetName(const std::string& fname) { - if ( !fname ) - { - this->Name = ""; - return; - } this->Name = fname; } diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index 99f3b47..7adee7b 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -140,7 +140,7 @@ public: * Set name of the file that will hold the actual output. This method allows * the output file to be changed during the use of cmGeneratedFileStream. */ - void SetName(const char* fname); + void SetName(const std::string& fname); private: cmGeneratedFileStream(cmGeneratedFileStream const&); // not implemented diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 2e66d78..e127f3a 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -33,17 +33,17 @@ cmGeneratorExpression::cmGeneratorExpression( cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(std::string const& input) { - return this->Parse(input.c_str()); + return cmsys::auto_ptr<cmCompiledGeneratorExpression>( + new cmCompiledGeneratorExpression( + this->Backtrace, + input)); } //---------------------------------------------------------------------------- cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(const char* input) { - return cmsys::auto_ptr<cmCompiledGeneratorExpression>( - new cmCompiledGeneratorExpression( - this->Backtrace, - input)); + return this->Parse(std::string(input ? input : "")); } cmGeneratorExpression::~cmGeneratorExpression() @@ -52,7 +52,7 @@ cmGeneratorExpression::~cmGeneratorExpression() //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( - cmMakefile* mf, const char* config, bool quiet, + cmMakefile* mf, const std::string& config, bool quiet, cmTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker) const { @@ -66,7 +66,7 @@ const char *cmCompiledGeneratorExpression::Evaluate( //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( - cmMakefile* mf, const char* config, bool quiet, + cmMakefile* mf, const std::string& config, bool quiet, cmTarget const* headTarget, cmTarget const* currentTarget, cmGeneratorExpressionDAGChecker *dagChecker) const @@ -97,7 +97,7 @@ const char *cmCompiledGeneratorExpression::Evaluate( { this->Output += (*it)->Evaluate(&context, dagChecker); - for(std::set<cmStdString>::const_iterator + for(std::set<std::string>::const_iterator p = context.SeenTargetProperties.begin(); p != context.SeenTargetProperties.end(); ++p) { @@ -122,13 +122,13 @@ const char *cmCompiledGeneratorExpression::Evaluate( cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace const& backtrace, - const char *input) - : Backtrace(backtrace), Input(input ? input : ""), + const std::string& input) + : Backtrace(backtrace), Input(input), HadContextSensitiveCondition(false) { cmGeneratorExpressionLexer l; std::vector<cmGeneratorExpressionToken> tokens = - l.Tokenize(this->Input.c_str()); + l.Tokenize(this->Input); this->NeedsEvaluation = l.GetSawGeneratorExpression(); if (this->NeedsEvaluation) @@ -157,17 +157,24 @@ cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression() std::string cmGeneratorExpression::StripEmptyListElements( const std::string &input) { + if (input.find(';') == input.npos) + { + return input; + } std::string result; + result.reserve(input.size()); const char *c = input.c_str(); + const char *last = c; bool skipSemiColons = true; for ( ; *c; ++c) { - if(c[0] == ';') + if(*c == ';') { if(skipSemiColons) { - continue; + result.append(last, c - last); + last = c + 1; } skipSemiColons = true; } @@ -175,8 +182,8 @@ std::string cmGeneratorExpression::StripEmptyListElements( { skipSemiColons = false; } - result += *c; } + result.append(last); if (!result.empty() && *(result.end() - 1) == ';') { @@ -372,7 +379,7 @@ void cmGeneratorExpression::Split(const std::string &input, } if(!part.empty()) { - cmSystemTools::ExpandListArgument(part.c_str(), output); + cmSystemTools::ExpandListArgument(part, output); } } pos += 2; diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 4992e93..d0a6aef 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -16,8 +16,6 @@ #include "cmStandardIncludes.h" #include "cmListFileCache.h" -#include <stack> - #include <cmsys/RegularExpression.hxx> #include <cmsys/auto_ptr.hxx> @@ -78,12 +76,12 @@ private: class cmCompiledGeneratorExpression { public: - const char* Evaluate(cmMakefile* mf, const char* config, + const char* Evaluate(cmMakefile* mf, const std::string& config, bool quiet = false, cmTarget const* headTarget = 0, cmTarget const* currentTarget = 0, cmGeneratorExpressionDAGChecker *dagChecker = 0) const; - const char* Evaluate(cmMakefile* mf, const char* config, + const char* Evaluate(cmMakefile* mf, const std::string& config, bool quiet, cmTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker) const; @@ -92,7 +90,7 @@ public: std::set<cmTarget*> const& GetTargets() const { return this->DependTargets; } - std::set<cmStdString> const& GetSeenTargetProperties() const + std::set<std::string> const& GetSeenTargetProperties() const { return this->SeenTargetProperties; } std::set<cmTarget const*> const& GetAllTargetsSeen() const @@ -100,7 +98,7 @@ public: ~cmCompiledGeneratorExpression(); - std::string GetInput() const + std::string const& GetInput() const { return this->Input; } @@ -116,7 +114,7 @@ public: private: cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace, - const char *input); + const std::string& input); friend class cmGeneratorExpression; @@ -130,7 +128,7 @@ private: mutable std::set<cmTarget*> DependTargets; mutable std::set<cmTarget const*> AllTargetsSeen; - mutable std::set<cmStdString> SeenTargetProperties; + mutable std::set<std::string> SeenTargetProperties; mutable std::string Output; mutable bool HadContextSensitiveCondition; }; diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index e7e1d34..07efba9 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -42,12 +42,12 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( ) #undef TEST_TRANSITIVE_PROPERTY_METHOD { - std::map<cmStdString, std::set<cmStdString> >::const_iterator it + std::map<std::string, std::set<std::string> >::const_iterator it = top->Seen.find(target); if (it != top->Seen.end()) { - const std::set<cmStdString> &propSet = it->second; - const std::set<cmStdString>::const_iterator i = propSet.find(property); + const std::set<std::string> &propSet = it->second; + const std::set<std::string>::const_iterator i = propSet.find(property); if (i != propSet.end()) { this->CheckResult = ALREADY_SEEN; @@ -92,7 +92,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( << "Self reference on target \"" << context->HeadTarget->GetName() << "\".\n"; context->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), + ->IssueMessage(cmake::FATAL_ERROR, e.str(), parent->Backtrace); return; } @@ -103,7 +103,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( << " " << expr << "\n" << "Dependency loop found."; context->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), + ->IssueMessage(cmake::FATAL_ERROR, e.str(), context->Backtrace); } @@ -116,7 +116,7 @@ void cmGeneratorExpressionDAGChecker::ReportError( << (parent->Content ? parent->Content->GetOriginalExpression() : expr) << "\n"; context->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), + ->IssueMessage(cmake::FATAL_ERROR, e.str(), parent->Backtrace); parent = parent->Parent; ++loopStep; diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index b6effa1..6cbbd2a 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -77,7 +77,7 @@ private: const cmGeneratorExpressionDAGChecker * const Parent; const std::string Target; const std::string Property; - std::map<cmStdString, std::set<cmStdString> > Seen; + std::map<std::string, std::set<std::string> > Seen; const GeneratorExpressionContent * const Content; const cmListFileBacktrace Backtrace; Result CheckResult; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index bf85870..d41285d 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -33,7 +33,7 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( } //---------------------------------------------------------------------------- -void cmGeneratorExpressionEvaluationFile::Generate(const char *config, +void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, cmCompiledGeneratorExpression* inputExpression, std::map<std::string, std::string> &outputFiles) { @@ -50,7 +50,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const char *config, cmOStringStream e; e << "Evaluation file condition \"" << rawCondition << "\" did " "not evaluate to valid content. Got \"" << condResult << "\"."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } } @@ -72,7 +72,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const char *config, cmOStringStream e; e << "Evaluation file to be written multiple times for different " "configurations with different content:\n " << outputFileName; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -85,7 +85,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const char *config, { cmOStringStream e; e << "Evaluation file \"" << outputFileName << "\" cannot be written."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -109,7 +109,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() { cmOStringStream e; e << "Evaluation file \"" << this->Input << "\" cannot be read."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -135,14 +135,14 @@ void cmGeneratorExpressionEvaluationFile::Generate() if (allConfigs.empty()) { - this->Generate(0, inputExpression.get(), outputFiles); + this->Generate("", inputExpression.get(), outputFiles); } else { for(std::vector<std::string>::const_iterator li = allConfigs.begin(); li != allConfigs.end(); ++li) { - this->Generate(li->c_str(), inputExpression.get(), outputFiles); + this->Generate(*li, inputExpression.get(), outputFiles); if(cmSystemTools::GetFatalErrorOccured()) { return; diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 20ee5cb..f939916 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -32,7 +32,7 @@ public: std::vector<std::string> GetFiles() const { return this->Files; } private: - void Generate(const char *config, + void Generate(const std::string& config, cmCompiledGeneratorExpression* inputExpression, std::map<std::string, std::string> &outputFiles); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 7036992..14b2a1a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -39,7 +39,7 @@ void reportError(cmGeneratorExpressionContext *context, << " " << expr << "\n" << result; context->Makefile->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), + ->IssueMessage(cmake::FATAL_ERROR, e.str(), context->Backtrace); } @@ -393,8 +393,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode const std::string &lang) const { const char *compilerId = context->Makefile ? - context->Makefile->GetSafeDefinition(( - "CMAKE_" + lang + "_COMPILER_ID").c_str()) : ""; + context->Makefile->GetSafeDefinition( + "CMAKE_" + lang + "_COMPILER_ID") : ""; if (parameters.size() == 0) { return compilerId ? compilerId : ""; @@ -428,7 +428,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode ->GetPolicyWarning(cmPolicies::CMP0044); context->Makefile->GetCMakeInstance() ->IssueMessage(cmake::AUTHOR_WARNING, - e.str().c_str(), context->Backtrace); + e.str(), context->Backtrace); } case cmPolicies::OLD: return "1"; @@ -500,8 +500,8 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode const std::string &lang) const { const char *compilerVersion = context->Makefile ? - context->Makefile->GetSafeDefinition(( - "CMAKE_" + lang + "_COMPILER_VERSION").c_str()) : ""; + context->Makefile->GetSafeDefinition( + "CMAKE_" + lang + "_COMPILER_VERSION") : ""; if (parameters.size() == 0) { return compilerVersion ? compilerVersion : ""; @@ -689,7 +689,7 @@ static const struct ConfigurationNode : public cmGeneratorExpressionNode cmGeneratorExpressionDAGChecker *) const { context->HadContextSensitiveCondition = true; - return context->Config ? context->Config : ""; + return context->Config; } } configurationNode; @@ -718,13 +718,13 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode return std::string(); } context->HadContextSensitiveCondition = true; - if (!context->Config) + if (context->Config.empty()) { return parameters.front().empty() ? "1" : "0"; } if (cmsysString_strcasecmp(parameters.begin()->c_str(), - context->Config) == 0) + context->Config.c_str()) == 0) { return "1"; } @@ -747,7 +747,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode std::string mapProp = "MAP_IMPORTED_CONFIG_"; mapProp += cmSystemTools::UpperCase(context->Config); if(const char* mapValue = - context->CurrentTarget->GetProperty(mapProp.c_str())) + context->CurrentTarget->GetProperty(mapProp)) { cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue), mappedConfigs); @@ -800,7 +800,7 @@ static const char* targetPropertyTransitiveWhitelist[] = { #undef TRANSITIVE_PROPERTY_NAME -std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, +std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets, cmTarget const* target, cmTarget const* headTarget, cmGeneratorExpressionContext *context, @@ -811,23 +811,21 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, std::string sep; std::string depString; - for (std::vector<std::string>::const_iterator - it = libraries.begin(); - it != libraries.end(); ++it) + for (std::vector<cmTarget*>::const_iterator + it = targets.begin(); + it != targets.end(); ++it) { - if (*it == target->GetName()) + if (*it == target) { // Broken code can have a target in its own link interface. // Don't follow such link interface entries so as not to create a // self-referencing loop. continue; } - if (context->Makefile->FindTargetToUse(*it)) - { - depString += - sep + "$<TARGET_PROPERTY:" + *it + "," + interfacePropertyName + ">"; - sep = ";"; - } + depString += + sep + "$<TARGET_PROPERTY:" + + (*it)->GetName() + "," + interfacePropertyName + ">"; + sep = ";"; } cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString); std::string linkedTargetsContent = cge->Evaluate(context->Makefile, @@ -843,6 +841,27 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, return linkedTargetsContent; } +std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, + cmTarget const* target, + cmTarget const* headTarget, + cmGeneratorExpressionContext *context, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string &interfacePropertyName) +{ + std::vector<cmTarget*> tgts; + for (std::vector<std::string>::const_iterator + it = libraries.begin(); + it != libraries.end(); ++it) + { + if (cmTarget *tgt = context->Makefile->FindTargetToUse(*it)) + { + tgts.push_back(tgt); + } + } + return getLinkedTargetsContent(tgts, target, headTarget, context, + dagChecker, interfacePropertyName); +} + //---------------------------------------------------------------------------- static const struct TargetPropertyNode : public cmGeneratorExpressionNode { @@ -971,8 +990,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - const char *lang = target->GetLinkerLanguage(context->Config); - return lang ? lang : ""; + return target->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1004,7 +1022,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode break; } - const char *prop = target->GetProperty(propertyName.c_str()); + const char *prop = target->GetProperty(propertyName); if (dagCheckerParent) { @@ -1065,13 +1083,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode cmStrCmp(propertyName)) != transEnd) { - std::vector<std::string> libs; - target->GetTransitivePropertyLinkLibraries(context->Config, - headTarget, libs); - if (!libs.empty()) + std::vector<cmTarget*> tgts; + target->GetTransitivePropertyTargets(context->Config, + headTarget, tgts); + if (!tgts.empty()) { linkedTargetsContent = - getLinkedTargetsContent(libs, target, + getLinkedTargetsContent(tgts, target, headTarget, context, &dagChecker, interfacePropertyName); @@ -1080,9 +1098,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode else if (std::find_if(transBegin, transEnd, cmStrCmp(interfacePropertyName)) != transEnd) { - const cmTarget::LinkImplementation *impl = target->GetLinkImplementation( - context->Config, - headTarget); + const cmTarget::LinkImplementation *impl + = target->GetLinkImplementationLibraries(context->Config, + headTarget); if(impl) { linkedTargetsContent = @@ -1536,89 +1554,58 @@ TargetFilesystemArtifact<false, true, true, false> targetSoNameFileDirNode; static const cmGeneratorExpressionNode* GetNode(const std::string &identifier) { - if (identifier == "0") - return &zeroNode; - else if (identifier == "1") - return &oneNode; - else if (identifier == "AND") - return &andNode; - else if (identifier == "OR") - return &orNode; - else if (identifier == "NOT") - return ¬Node; - else if (identifier == "C_COMPILER_ID") - return &cCompilerIdNode; - else if (identifier == "CXX_COMPILER_ID") - return &cxxCompilerIdNode; - else if (identifier == "VERSION_GREATER") - return &versionGreaterNode; - else if (identifier == "VERSION_LESS") - return &versionLessNode; - else if (identifier == "VERSION_EQUAL") - return &versionEqualNode; - else if (identifier == "C_COMPILER_VERSION") - return &cCompilerVersionNode; - else if (identifier == "CXX_COMPILER_VERSION") - return &cxxCompilerVersionNode; - else if (identifier == "PLATFORM_ID") - return &platformIdNode; - else if (identifier == "CONFIGURATION") - return &configurationNode; - else if (identifier == "CONFIG") - return &configurationTestNode; - else if (identifier == "TARGET_FILE") - return &targetFileNode; - else if (identifier == "TARGET_LINKER_FILE") - return &targetLinkerFileNode; - else if (identifier == "TARGET_SONAME_FILE") - return &targetSoNameFileNode; - else if (identifier == "TARGET_FILE_NAME") - return &targetFileNameNode; - else if (identifier == "TARGET_LINKER_FILE_NAME") - return &targetLinkerFileNameNode; - else if (identifier == "TARGET_SONAME_FILE_NAME") - return &targetSoNameFileNameNode; - else if (identifier == "TARGET_FILE_DIR") - return &targetFileDirNode; - else if (identifier == "TARGET_LINKER_FILE_DIR") - return &targetLinkerFileDirNode; - else if (identifier == "TARGET_SONAME_FILE_DIR") - return &targetSoNameFileDirNode; - else if (identifier == "STREQUAL") - return &strEqualNode; - else if (identifier == "EQUAL") - return &equalNode; - else if (identifier == "LOWER_CASE") - return &lowerCaseNode; - else if (identifier == "UPPER_CASE") - return &upperCaseNode; - else if (identifier == "MAKE_C_IDENTIFIER") - return &makeCIdentifierNode; - else if (identifier == "BOOL") - return &boolNode; - else if (identifier == "ANGLE-R") - return &angle_rNode; - else if (identifier == "COMMA") - return &commaNode; - else if (identifier == "SEMICOLON") - return &semicolonNode; - else if (identifier == "TARGET_PROPERTY") - return &targetPropertyNode; - else if (identifier == "TARGET_NAME") - return &targetNameNode; - else if (identifier == "TARGET_POLICY") - return &targetPolicyNode; - else if (identifier == "BUILD_INTERFACE") - return &buildInterfaceNode; - else if (identifier == "INSTALL_INTERFACE") - return &installInterfaceNode; - else if (identifier == "INSTALL_PREFIX") - return &installPrefixNode; - else if (identifier == "JOIN") - return &joinNode; - else if (identifier == "LINK_ONLY") - return &linkOnlyNode; - return 0; + typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap; + static NodeMap nodeMap; + if (nodeMap.empty()) + { + nodeMap["0"] = &zeroNode; + nodeMap["1"] = &oneNode; + nodeMap["AND"] = &andNode; + nodeMap["OR"] = &orNode; + nodeMap["NOT"] = ¬Node; + nodeMap["C_COMPILER_ID"] = &cCompilerIdNode; + nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode; + nodeMap["VERSION_GREATER"] = &versionGreaterNode; + nodeMap["VERSION_LESS"] = &versionLessNode; + nodeMap["VERSION_EQUAL"] = &versionEqualNode; + nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode; + nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode; + nodeMap["PLATFORM_ID"] = &platformIdNode; + nodeMap["CONFIGURATION"] = &configurationNode; + nodeMap["CONFIG"] = &configurationTestNode; + nodeMap["TARGET_FILE"] = &targetFileNode; + nodeMap["TARGET_LINKER_FILE"] = &targetLinkerFileNode; + nodeMap["TARGET_SONAME_FILE"] = &targetSoNameFileNode; + nodeMap["TARGET_FILE_NAME"] = &targetFileNameNode; + nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerFileNameNode; + nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameFileNameNode; + nodeMap["TARGET_FILE_DIR"] = &targetFileDirNode; + nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerFileDirNode; + nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameFileDirNode; + nodeMap["STREQUAL"] = &strEqualNode; + nodeMap["EQUAL"] = &equalNode; + nodeMap["LOWER_CASE"] = &lowerCaseNode; + nodeMap["UPPER_CASE"] = &upperCaseNode; + nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode; + nodeMap["BOOL"] = &boolNode; + nodeMap["ANGLE-R"] = &angle_rNode; + nodeMap["COMMA"] = &commaNode; + nodeMap["SEMICOLON"] = &semicolonNode; + nodeMap["TARGET_PROPERTY"] = &targetPropertyNode; + nodeMap["TARGET_NAME"] = &targetNameNode; + nodeMap["TARGET_POLICY"] = &targetPolicyNode; + nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode; + nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode; + nodeMap["INSTALL_PREFIX"] = &installPrefixNode; + nodeMap["JOIN"] = &joinNode; + nodeMap["LINK_ONLY"] = &linkOnlyNode; + } + NodeMap::const_iterator i = nodeMap.find(identifier); + if (i == nodeMap.end()) + { + return 0; + } + return i->second; } diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 49e52df..a7099cb 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -25,9 +25,9 @@ struct cmGeneratorExpressionContext cmListFileBacktrace Backtrace; std::set<cmTarget*> DependTargets; std::set<cmTarget const*> AllTargets; - std::set<cmStdString> SeenTargetProperties; + std::set<std::string> SeenTargetProperties; cmMakefile *Makefile; - const char *Config; + std::string Config; cmTarget const* HeadTarget; // The target whose property is being evaluated. cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears // directly or indirectly in the property. diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx index cd71ec0..1c83466 100644 --- a/Source/cmGeneratorExpressionLexer.cxx +++ b/Source/cmGeneratorExpressionLexer.cxx @@ -32,52 +32,50 @@ static void InsertText(const char *upto, const char *c, //---------------------------------------------------------------------------- std::vector<cmGeneratorExpressionToken> -cmGeneratorExpressionLexer::Tokenize(const char *input) +cmGeneratorExpressionLexer::Tokenize(const std::string& input) { std::vector<cmGeneratorExpressionToken> result; - if (!input) - return result; - const char *c = input; + const char *c = input.c_str(); const char *upto = c; for ( ; *c; ++c) - { - if(c[0] == '$' && c[1] == '<') { - InsertText(upto, c, result); - upto = c; - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::BeginExpression, upto, 2)); - upto = c + 2; - ++c; - SawBeginExpression = true; - } - else if(c[0] == '>') - { - InsertText(upto, c, result); - upto = c; - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::EndExpression, upto, 1)); - upto = c + 1; - SawGeneratorExpression = SawBeginExpression; - } - else if(c[0] == ':') - { - InsertText(upto, c, result); - upto = c; - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::ColonSeparator, upto, 1)); - upto = c + 1; - } - else if(c[0] == ',') - { - InsertText(upto, c, result); - upto = c; - result.push_back(cmGeneratorExpressionToken( - cmGeneratorExpressionToken::CommaSeparator, upto, 1)); - upto = c + 1; - } + switch(*c) + { + case '$': + if(c[1] == '<') + { + InsertText(upto, c, result); + result.push_back(cmGeneratorExpressionToken( + cmGeneratorExpressionToken::BeginExpression, c, 2)); + upto = c + 2; + ++c; + SawBeginExpression = true; + } + break; + case '>': + InsertText(upto, c, result); + result.push_back(cmGeneratorExpressionToken( + cmGeneratorExpressionToken::EndExpression, c, 1)); + upto = c + 1; + SawGeneratorExpression = SawBeginExpression; + break; + case ':': + InsertText(upto, c, result); + result.push_back(cmGeneratorExpressionToken( + cmGeneratorExpressionToken::ColonSeparator, c, 1)); + upto = c + 1; + break; + case ',': + InsertText(upto, c, result); + result.push_back(cmGeneratorExpressionToken( + cmGeneratorExpressionToken::CommaSeparator, c, 1)); + upto = c + 1; + break; + default: + break; + } } InsertText(upto, c, result); diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h index 83d661d..1e2e8c2 100644 --- a/Source/cmGeneratorExpressionLexer.h +++ b/Source/cmGeneratorExpressionLexer.h @@ -43,7 +43,7 @@ class cmGeneratorExpressionLexer public: cmGeneratorExpressionLexer(); - std::vector<cmGeneratorExpressionToken> Tokenize(const char *input); + std::vector<cmGeneratorExpressionToken> Tokenize(const std::string& input); bool GetSawGeneratorExpression() const { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 175bb0e..b35e859 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -19,13 +19,203 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" #include "cmComputeLinkInformation.h" +#include "cmCustomCommandGenerator.h" #include <queue> #include "assert.h" //---------------------------------------------------------------------------- -cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) +void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib, + cmTarget *target, cmake *cm) +{ + if(!badObjLib.empty()) + { + cmOStringStream e; + e << "OBJECT library \"" << target->GetName() << "\" contains:\n"; + for(std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin(); + i != badObjLib.end(); ++i) + { + e << " " << (*i)->GetLocation().GetName() << "\n"; + } + e << "but may contain only headers and sources that compile."; + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + target->GetBacktrace()); + } +} + +struct ObjectSourcesTag {}; +struct CustomCommandsTag {}; +struct ExtraSourcesTag {}; +struct HeaderSourcesTag {}; +struct ExternalObjectsTag {}; +struct IDLSourcesTag {}; +struct ResxTag {}; +struct ModuleDefinitionFileTag {}; + +#if !defined(_MSC_VER) || _MSC_VER >= 1310 +template<typename Tag, typename OtherTag> +struct IsSameTag +{ + enum { + Result = false + }; +}; + +template<typename Tag> +struct IsSameTag<Tag, Tag> +{ + enum { + Result = true + }; +}; +#else +struct IsSameTagBase +{ + typedef char (&no_type)[1]; + typedef char (&yes_type)[2]; + template<typename T> struct Check; + template<typename T> static yes_type check(Check<T>*, Check<T>*); + static no_type check(...); +}; +template<typename Tag1, typename Tag2> +struct IsSameTag: public IsSameTagBase +{ + enum { + Result = (sizeof(check(static_cast< Check<Tag1>* >(0), + static_cast< Check<Tag2>* >(0))) == + sizeof(yes_type)) + }; +}; +#endif + +template<bool> +struct DoAccept +{ + template <typename T> static void Do(T&, cmSourceFile*) {} +}; + +template<> +struct DoAccept<true> +{ + static void Do(std::vector<cmSourceFile const*>& files, cmSourceFile* f) + { + files.push_back(f); + } + static void Do(cmGeneratorTarget::ResxData& data, cmSourceFile* f) + { + // Build and save the name of the corresponding .h file + // This relationship will be used later when building the project files. + // Both names would have been auto generated from Visual Studio + // where the user supplied the file name and Visual Studio + // appended the suffix. + std::string resx = f->GetFullPath(); + std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h"; + data.ExpectedResxHeaders.insert(hFileName); + data.ResxSources.push_back(f); + } + static void Do(std::string& data, cmSourceFile* f) + { + data = f->GetFullPath(); + } +}; + +//---------------------------------------------------------------------------- +template<typename Tag, typename DataType = std::vector<cmSourceFile const*> > +struct TagVisitor +{ + DataType& Data; + std::vector<cmSourceFile*> BadObjLibFiles; + cmTarget *Target; + cmGlobalGenerator *GlobalGenerator; + cmsys::RegularExpression Header; + bool IsObjLib; + + TagVisitor(cmTarget *target, DataType& data) + : Data(data), Target(target), + GlobalGenerator(target->GetMakefile() + ->GetLocalGenerator()->GetGlobalGenerator()), + Header(CM_HEADER_REGEX), + IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY) + { + } + + ~TagVisitor() + { + reportBadObjLib(this->BadObjLibFiles, this->Target, + this->GlobalGenerator->GetCMakeInstance()); + } + + void Accept(cmSourceFile *sf) + { + std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); + if(sf->GetCustomCommand()) + { + DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf); + } + else if(this->Target->GetType() == cmTarget::UTILITY) + { + DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf); + } + else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY")) + { + DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf); + } + else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT")) + { + DoAccept<IsSameTag<Tag, ExternalObjectsTag>::Result>::Do(this->Data, sf); + if(this->IsObjLib) + { + this->BadObjLibFiles.push_back(sf); + } + } + else if(!sf->GetLanguage().empty()) + { + DoAccept<IsSameTag<Tag, ObjectSourcesTag>::Result>::Do(this->Data, sf); + } + else if(ext == "def") + { + DoAccept<IsSameTag<Tag, ModuleDefinitionFileTag>::Result>::Do(this->Data, + sf); + if(this->IsObjLib) + { + this->BadObjLibFiles.push_back(sf); + } + } + else if(ext == "idl") + { + DoAccept<IsSameTag<Tag, IDLSourcesTag>::Result>::Do(this->Data, sf); + if(this->IsObjLib) + { + this->BadObjLibFiles.push_back(sf); + } + } + else if(ext == "resx") + { + DoAccept<IsSameTag<Tag, ResxTag>::Result>::Do(this->Data, sf); + } + else if(this->Header.find(sf->GetFullPath().c_str())) + { + DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf); + } + else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str())) + { + DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf); + } + else + { + DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf); + if(this->IsObjLib && ext != "txt") + { + this->BadObjLibFiles.push_back(sf); + } + } + } +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t), + SourceFileFlagsConstructed(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = this->Makefile->GetLocalGenerator(); @@ -39,20 +229,20 @@ int cmGeneratorTarget::GetType() const } //---------------------------------------------------------------------------- -const char *cmGeneratorTarget::GetName() const +std::string cmGeneratorTarget::GetName() const { return this->Target->GetName(); } //---------------------------------------------------------------------------- -const char *cmGeneratorTarget::GetProperty(const char *prop) const +const char *cmGeneratorTarget::GetProperty(const std::string& prop) const { return this->Target->GetProperty(prop); } //---------------------------------------------------------------------------- std::vector<cmSourceFile*> const* -cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const +cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { SourceEntriesType::const_iterator i = this->SourceEntries.find(sf); if(i != this->SourceEntries.end()) @@ -62,19 +252,13 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const return 0; } -static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, - const char *config, cmTarget *headTarget, +static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, + const std::string& config, + cmTarget *headTarget, cmGeneratorExpressionDAGChecker *dagChecker, std::vector<std::string>& result, bool excludeImported) { - cmTarget* depTgt = mf->FindTargetToUse(name); - - if (!depTgt) - { - return; - } - cmListFileBacktrace lfbt; if (const char* dirs = @@ -102,11 +286,31 @@ static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, } } +#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \ + { \ + std::vector<cmSourceFile*> sourceFiles; \ + this->Target->GetSourceFiles(sourceFiles); \ + TagVisitor<DATA ## Tag DATATYPE> visitor(this->Target, data); \ + for(std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \ + si != sourceFiles.end(); ++si) \ + { \ + visitor.Accept(*si); \ + } \ + } \ + + +#define IMPLEMENT_VISIT(DATA) \ + IMPLEMENT_VISIT_IMPL(DATA, EMPTY) \ + +#define EMPTY +#define COMMA , + //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &objs) const +cmGeneratorTarget +::GetObjectSources(std::vector<cmSourceFile const*> &data) const { - objs = this->ObjectSources; + IMPLEMENT_VISIT(ObjectSources); } //---------------------------------------------------------------------------- @@ -115,13 +319,14 @@ const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) return this->Objects[file]; } -void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name) +void cmGeneratorTarget::AddObject(cmSourceFile const* sf, + std::string const&name) { this->Objects[sf] = name; } //---------------------------------------------------------------------------- -void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf) +void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) { this->ExplicitObjectName.insert(sf); } @@ -135,58 +340,68 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const +void cmGeneratorTarget +::GetIDLSources(std::vector<cmSourceFile const*>& data) const { - srcs = this->ResxSources; + IMPLEMENT_VISIT(IDLSources); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& srcs) const +void +cmGeneratorTarget +::GetHeaderSources(std::vector<cmSourceFile const*>& data) const { - srcs = this->IDLSources; + IMPLEMENT_VISIT(HeaderSources); } //---------------------------------------------------------------------------- -void -cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& srcs) const +void cmGeneratorTarget +::GetExtraSources(std::vector<cmSourceFile const*>& data) const { - srcs = this->HeaderSources; + IMPLEMENT_VISIT(ExtraSources); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& srcs) const +void +cmGeneratorTarget +::GetCustomCommands(std::vector<cmSourceFile const*>& data) const { - srcs = this->ExtraSources; + IMPLEMENT_VISIT(CustomCommands); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& srcs) const +cmGeneratorTarget +::GetExternalObjects(std::vector<cmSourceFile const*>& data) const { - srcs = this->CustomCommands; + IMPLEMENT_VISIT(ExternalObjects); } //---------------------------------------------------------------------------- void cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const { - srcs = this->ExpectedResxHeaders; + ResxData data; + IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) + srcs = data.ExpectedResxHeaders; } //---------------------------------------------------------------------------- -void -cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& srcs) const +void cmGeneratorTarget +::GetResxSources(std::vector<cmSourceFile const*>& srcs) const { - srcs = this->ExternalObjects; + ResxData data; + IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) + srcs = data.ResxSources; } //---------------------------------------------------------------------------- -bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, - const char *config) const +bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, + const std::string& config) const { assert(this->GetType() != cmTarget::INTERFACE_LIBRARY); std::string config_upper; - if(config && *config) + if(!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } @@ -213,7 +428,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, = this->Target->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); std::vector<std::string> result; - for (std::set<cmStdString>::const_iterator + for (std::set<std::string>::const_iterator it = this->Target->GetSystemIncludeDirectories().begin(); it != this->Target->GetSystemIncludeDirectories().end(); ++it) { @@ -224,26 +439,25 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, &dagChecker), result); } - std::set<cmStdString> uniqueDeps; + std::set<cmTarget*> uniqueDeps; for(std::vector<std::string>::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { - if (uniqueDeps.insert(*li).second) + cmTarget* tgt = this->Makefile->FindTargetToUse(*li); + if (!tgt) { - cmTarget* tgt = this->Makefile->FindTargetToUse(*li); - - if (!tgt) - { - continue; - } + continue; + } - handleSystemIncludesDep(this->Makefile, *li, config, this->Target, + if (uniqueDeps.insert(tgt).second) + { + handleSystemIncludesDep(this->Makefile, tgt, config, this->Target, &dagChecker, result, excludeImported); - std::vector<std::string> deps; - tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps); + std::vector<cmTarget*> deps; + tgt->GetTransitivePropertyTargets(config, this->Target, deps); - for(std::vector<std::string>::const_iterator di = deps.begin(); + for(std::vector<cmTarget*>::const_iterator di = deps.begin(); di != deps.end(); ++di) { if (uniqueDeps.insert(*di).second) @@ -254,7 +468,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } } } - std::set<cmStdString> unique; + std::set<std::string> unique; for(std::vector<std::string>::iterator li = result.begin(); li != result.end(); ++li) { @@ -262,7 +476,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, unique.insert(*li); } result.clear(); - for(std::set<cmStdString>::iterator li = unique.begin(); + for(std::set<std::string>::iterator li = unique.begin(); li != unique.end(); ++li) { result.push_back(*li); @@ -278,7 +492,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } //---------------------------------------------------------------------------- -bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const +bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const { return this->Target->GetPropertyAsBool(prop); } @@ -290,102 +504,6 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::ClassifySources() -{ - cmsys::RegularExpression header(CM_HEADER_REGEX); - - cmTarget::TargetType targetType = this->Target->GetType(); - bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY; - - std::vector<cmSourceFile*> badObjLib; - std::vector<cmSourceFile*> sources; - this->Target->GetSourceFiles(sources); - for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); - si != sources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); - if(sf->GetCustomCommand()) - { - this->CustomCommands.push_back(sf); - } - else if(targetType == cmTarget::UTILITY) - { - this->ExtraSources.push_back(sf); - } - else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY")) - { - this->HeaderSources.push_back(sf); - } - else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT")) - { - this->ExternalObjects.push_back(sf); - if(isObjLib) { badObjLib.push_back(sf); } - } - else if(sf->GetLanguage()) - { - this->ObjectSources.push_back(sf); - } - else if(ext == "def") - { - this->ModuleDefinitionFile = sf->GetFullPath(); - if(isObjLib) { badObjLib.push_back(sf); } - } - else if(ext == "idl") - { - this->IDLSources.push_back(sf); - if(isObjLib) { badObjLib.push_back(sf); } - } - else if(ext == "resx") - { - // Build and save the name of the corresponding .h file - // This relationship will be used later when building the project files. - // Both names would have been auto generated from Visual Studio - // where the user supplied the file name and Visual Studio - // appended the suffix. - std::string resx = sf->GetFullPath(); - std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h"; - this->ExpectedResxHeaders.insert(hFileName); - this->ResxSources.push_back(sf); - } - else if(header.find(sf->GetFullPath().c_str())) - { - this->HeaderSources.push_back(sf); - } - else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str())) - { - // We only get here if a source file is not an external object - // and has an extension that is listed as an ignored file type. - // No message or diagnosis should be given. - this->ExtraSources.push_back(sf); - } - else - { - this->ExtraSources.push_back(sf); - if(isObjLib && ext != "txt") - { - badObjLib.push_back(sf); - } - } - } - - if(!badObjLib.empty()) - { - cmOStringStream e; - e << "OBJECT library \"" << this->Target->GetName() << "\" contains:\n"; - for(std::vector<cmSourceFile*>::iterator i = badObjLib.begin(); - i != badObjLib.end(); ++i) - { - e << " " << (*i)->GetLocation().GetName() << "\n"; - } - e << "but may contain only headers and sources that compile."; - this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } -} - -//---------------------------------------------------------------------------- void cmGeneratorTarget::LookupObjectLibraries() { std::vector<std::string> const& objLibs = @@ -438,6 +556,14 @@ void cmGeneratorTarget::LookupObjectLibraries() } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile() const +{ + std::string data; + IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string) + return data; +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const { @@ -448,9 +574,11 @@ cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const cmTarget* objLib = *ti; cmGeneratorTarget* ogt = this->GlobalGenerator->GetGeneratorTarget(objLib); - for(std::vector<cmSourceFile*>::const_iterator - si = ogt->ObjectSources.begin(); - si != ogt->ObjectSources.end(); ++si) + std::vector<cmSourceFile const*> objectSources; + ogt->GetObjectSources(objectSources); + for(std::vector<cmSourceFile const*>::const_iterator + si = objectSources.begin(); + si != objectSources.end(); ++si) { std::string obj = ogt->ObjectDirectory; obj += ogt->Objects[*si]; @@ -474,7 +602,7 @@ private: SourceEntry* CurrentEntry; std::queue<cmSourceFile*> SourceQueue; std::set<cmSourceFile*> SourcesQueued; - typedef std::map<cmStdString, cmSourceFile*> NameMapType; + typedef std::map<std::string, cmSourceFile*> NameMapType; NameMapType NameMap; void QueueSource(cmSourceFile* sf); @@ -483,6 +611,9 @@ private: bool IsUtility(std::string const& dep); void CheckCustomCommand(cmCustomCommand const& cc); void CheckCustomCommands(const std::vector<cmCustomCommand>& commands); + void FollowCommandDepends(cmCustomCommand const& cc, + const std::string& config, + std::set<std::string>& emitted); }; //---------------------------------------------------------------------------- @@ -567,7 +698,7 @@ void cmTargetTraceDependencies::FollowName(std::string const& name) if(i == this->NameMap.end()) { // Check if we know how to generate this file. - cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str()); + cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name); NameMapType::value_type entry(name, sf); i = this->NameMap.insert(entry).first; } @@ -622,14 +753,14 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) { // This is really only for compatibility so we do not need to // worry about configuration names and output names. - std::string tLocation = t->GetLocation(0); + std::string tLocation = t->GetLocationForBuild(); tLocation = cmSystemTools::GetFilenamePath(tLocation); std::string depLocation = cmSystemTools::GetFilenamePath(dep); depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str()); tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str()); if(depLocation == tLocation) { - this->Target->AddUtility(util.c_str()); + this->Target->AddUtility(util); return true; } } @@ -638,7 +769,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) { // The original name of the dependency was not a full path. It // must name a target, so add the target-level dependency. - this->Target->AddUtility(util.c_str()); + this->Target->AddUtility(util); return true; } } @@ -672,7 +803,7 @@ cmTargetTraceDependencies // this project. Add the target-level dependency to make // sure the executable is up to date before this custom // command possibly runs. - this->Target->AddUtility(command.c_str()); + this->Target->AddUtility(command); } } @@ -682,7 +813,7 @@ cmTargetTraceDependencies { const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*cli); - cge->Evaluate(this->Makefile, 0, true); + cge->Evaluate(this->Makefile, "", true); std::set<cmTarget*> geTargets = cge->GetTargets(); for(std::set<cmTarget*>::const_iterator it = geTargets.begin(); it != geTargets.end(); ++it) @@ -699,16 +830,41 @@ cmTargetTraceDependencies } // Queue the custom command dependencies. - std::vector<std::string> const& depends = cc.GetDepends(); + std::vector<std::string> configs; + std::set<std::string> emitted; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + for(std::vector<std::string>::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + this->FollowCommandDepends(cc, *ci, emitted); + } +} + +//---------------------------------------------------------------------------- +void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc, + const std::string& config, + std::set<std::string>& emitted) +{ + cmCustomCommandGenerator ccg(cc, config, this->Makefile); + + const std::vector<std::string>& depends = ccg.GetDepends(); + for(std::vector<std::string>::const_iterator di = depends.begin(); di != depends.end(); ++di) { std::string const& dep = *di; - if(!this->IsUtility(dep)) + if(emitted.insert(dep).second) { - // The dependency does not name a target and may be a file we - // know how to generate. Queue it. - this->FollowName(dep); + if(!this->IsUtility(dep)) + { + // The dependency does not name a target and may be a file we + // know how to generate. Queue it. + this->FollowName(dep); + } } } } @@ -743,15 +899,15 @@ void cmGeneratorTarget::TraceDependencies() } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetAppleArchs(const char* config, +void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector<std::string>& archVec) const { const char* archs = 0; - if(config && *config) + if(!config.empty()) { std::string defVarName = "OSX_ARCHITECTURES_"; defVarName += cmSystemTools::UpperCase(config); - archs = this->Target->GetProperty(defVarName.c_str()); + archs = this->Target->GetProperty(defVarName); } if(!archs) { @@ -784,13 +940,14 @@ const char* cmGeneratorTarget::GetCreateRuleVariable() const //---------------------------------------------------------------------------- std::vector<std::string> -cmGeneratorTarget::GetIncludeDirectories(const char *config) const +cmGeneratorTarget::GetIncludeDirectories(const std::string& config) const { return this->Target->GetIncludeDirectories(config); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GenerateTargetManifest(const char* config) const +void cmGeneratorTarget::GenerateTargetManifest( + const std::string& config) const { if (this->Target->IsImported()) { @@ -833,42 +990,42 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const f = dir; f += "/"; f += name; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } if(!soName.empty()) { f = dir; f += "/"; f += soName; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } if(!realName.empty()) { f = dir; f += "/"; f += realName; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } if(!pdbName.empty()) { f = dir; f += "/"; f += pdbName; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } if(!impName.empty()) { f = this->Target->GetDirectory(config, true); f += "/"; f += impName; - gg->AddToManifest(config? config:"", f); + gg->AddToManifest(config, f); } } bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { - int nameResult = strcmp(t1->GetName(), t2->GetName()); + int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str()); if (nameResult == 0) { return strcmp(t1->GetMakefile()->GetStartOutputDirectory(), @@ -876,3 +1033,97 @@ bool cmStrictTargetComparison::operator()(cmTarget const* t1, } return nameResult < 0; } + +//---------------------------------------------------------------------------- +struct cmGeneratorTarget::SourceFileFlags +cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const +{ + struct SourceFileFlags flags; + this->ConstructSourceFileFlags(); + std::map<cmSourceFile const*, SourceFileFlags>::iterator si = + this->SourceFlagsMap.find(sf); + if(si != this->SourceFlagsMap.end()) + { + flags = si->second; + } + else + { + // Handle the MACOSX_PACKAGE_LOCATION property on source files that + // were not listed in one of the other lists. + if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) + { + flags.MacFolder = location; + if(strcmp(location, "Resources") == 0) + { + flags.Type = cmGeneratorTarget::SourceFileTypeResource; + } + else + { + flags.Type = cmGeneratorTarget::SourceFileTypeMacContent; + } + } + } + return flags; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ConstructSourceFileFlags() const +{ + if(this->SourceFileFlagsConstructed) + { + return; + } + this->SourceFileFlagsConstructed = true; + + // Process public headers to mark the source files. + if(const char* files = this->Target->GetProperty("PUBLIC_HEADER")) + { + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + for(std::vector<std::string>::iterator it = relFiles.begin(); + it != relFiles.end(); ++it) + { + if(cmSourceFile* sf = this->Makefile->GetSource(*it)) + { + SourceFileFlags& flags = this->SourceFlagsMap[sf]; + flags.MacFolder = "Headers"; + flags.Type = cmGeneratorTarget::SourceFileTypePublicHeader; + } + } + } + + // Process private headers after public headers so that they take + // precedence if a file is listed in both. + if(const char* files = this->Target->GetProperty("PRIVATE_HEADER")) + { + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + for(std::vector<std::string>::iterator it = relFiles.begin(); + it != relFiles.end(); ++it) + { + if(cmSourceFile* sf = this->Makefile->GetSource(*it)) + { + SourceFileFlags& flags = this->SourceFlagsMap[sf]; + flags.MacFolder = "PrivateHeaders"; + flags.Type = cmGeneratorTarget::SourceFileTypePrivateHeader; + } + } + } + + // Mark sources listed as resources. + if(const char* files = this->Target->GetProperty("RESOURCE")) + { + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + for(std::vector<std::string>::iterator it = relFiles.begin(); + it != relFiles.end(); ++it) + { + if(cmSourceFile* sf = this->Makefile->GetSource(*it)) + { + SourceFileFlags& flags = this->SourceFlagsMap[sf]; + flags.MacFolder = "Resources"; + flags.Type = cmGeneratorTarget::SourceFileTypeResource; + } + } + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a4caba1..53e27c5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -27,24 +27,24 @@ public: cmGeneratorTarget(cmTarget*); int GetType() const; - const char *GetName() const; - const char *GetProperty(const char *prop) const; - bool GetPropertyAsBool(const char *prop) const; + std::string GetName() const; + const char *GetProperty(const std::string& prop) const; + bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector<cmSourceFile*>& files) const; - void GetObjectSources(std::vector<cmSourceFile*> &) const; + void GetObjectSources(std::vector<cmSourceFile const*> &) const; const std::string& GetObjectName(cmSourceFile const* file); - void AddObject(cmSourceFile *sf, std::string const&name); + void AddObject(cmSourceFile const* sf, std::string const&name); bool HasExplicitObjectName(cmSourceFile const* file) const; - void AddExplicitObjectName(cmSourceFile* sf); - - void GetResxSources(std::vector<cmSourceFile*>&) const; - void GetIDLSources(std::vector<cmSourceFile*>&) const; - void GetExternalObjects(std::vector<cmSourceFile*>&) const; - void GetHeaderSources(std::vector<cmSourceFile*>&) const; - void GetExtraSources(std::vector<cmSourceFile*>&) const; - void GetCustomCommands(std::vector<cmSourceFile*>&) const; + void AddExplicitObjectName(cmSourceFile const* sf); + + void GetResxSources(std::vector<cmSourceFile const*>&) const; + void GetIDLSources(std::vector<cmSourceFile const*>&) const; + void GetExternalObjects(std::vector<cmSourceFile const*>&) const; + void GetHeaderSources(std::vector<cmSourceFile const*>&) const; + void GetExtraSources(std::vector<cmSourceFile const*>&) const; + void GetCustomCommands(std::vector<cmSourceFile const*>&) const; void GetExpectedResxHeaders(std::set<std::string>&) const; cmTarget* Target; @@ -52,7 +52,7 @@ public: cmLocalGenerator* LocalGenerator; cmGlobalGenerator const* GlobalGenerator; - std::string ModuleDefinitionFile; + std::string GetModuleDefinitionFile() const; /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build @@ -61,7 +61,7 @@ public: void UseObjectLibraries(std::vector<std::string>& objs) const; - void GetAppleArchs(const char* config, + void GetAppleArchs(const std::string& config, std::vector<std::string>& archVec) const; ///! Return the rule variable used to create this type of target, @@ -69,12 +69,14 @@ public: const char* GetCreateRuleVariable() const; /** Get the include directories for this target. */ - std::vector<std::string> GetIncludeDirectories(const char *config) const; + std::vector<std::string> GetIncludeDirectories( + const std::string& config) const; - bool IsSystemIncludeDirectory(const char *dir, const char *config) const; + bool IsSystemIncludeDirectory(const std::string& dir, + const std::string& config) const; /** Add the target output files to the global generator manifest. */ - void GenerateTargetManifest(const char* config) const; + void GenerateTargetManifest(const std::string& config) const; /** * Trace through the source files in this target and add al source files @@ -82,31 +84,56 @@ public: */ void TraceDependencies(); - void ClassifySources(); void LookupObjectLibraries(); /** Get sources that must be built before the given source. */ - std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const; + std::vector<cmSourceFile*> const* + GetSourceDepends(cmSourceFile const* sf) const; + /** + * Flags for a given source file as used in this target. Typically assigned + * via SET_TARGET_PROPERTIES when the property is a list of source files. + */ + enum SourceFileType + { + SourceFileTypeNormal, + SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property + SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property + SourceFileTypeResource, // is in "RESOURCE" target property *or* + // has MACOSX_PACKAGE_LOCATION=="Resources" + SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources" + }; + struct SourceFileFlags + { + SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {} + SourceFileFlags(SourceFileFlags const& r): + Type(r.Type), MacFolder(r.MacFolder) {} + SourceFileType Type; + const char* MacFolder; // location inside Mac content folders + }; + + struct SourceFileFlags + GetTargetSourceFileFlags(const cmSourceFile* sf) const; + + struct ResxData { + mutable std::set<std::string> ExpectedResxHeaders; + mutable std::vector<cmSourceFile const*> ResxSources; + }; private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector<cmSourceFile*> Depends; }; - typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType; + typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType; SourceEntriesType SourceEntries; - std::vector<cmSourceFile*> CustomCommands; - std::vector<cmSourceFile*> ExtraSources; - std::vector<cmSourceFile*> HeaderSources; - std::vector<cmSourceFile*> ExternalObjects; - std::vector<cmSourceFile*> IDLSources; - std::vector<cmSourceFile*> ResxSources; std::map<cmSourceFile const*, std::string> Objects; std::set<cmSourceFile const*> ExplicitObjectName; - std::set<std::string> ExpectedResxHeaders; - std::vector<cmSourceFile*> ObjectSources; std::vector<cmTarget*> ObjectLibraries; mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache; + void ConstructSourceFileFlags() const; + mutable bool SourceFileFlagsConstructed; + mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index e7ad91a..e88f498 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -49,10 +49,10 @@ bool cmGetCMakePropertyCommand } else if ( args[1] == "COMPONENTS" ) { - const std::set<cmStdString>* components + const std::set<std::string>* components = this->Makefile->GetLocalGenerator()->GetGlobalGenerator() ->GetInstallComponents(); - std::set<cmStdString>::const_iterator compIt; + std::set<std::string>::const_iterator compIt; output = ""; for (compIt = components->begin(); compIt != components->end(); ++compIt) { @@ -66,14 +66,14 @@ bool cmGetCMakePropertyCommand else { const char *prop = - this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str()); + this->Makefile->GetCMakeInstance()->GetProperty(args[1]); if (prop) { output = prop; } } - this->Makefile->AddDefinition(variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(variable, output.c_str()); return true; } diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h index 6c58bb4..1511406 100644 --- a/Source/cmGetCMakePropertyCommand.h +++ b/Source/cmGetCMakePropertyCommand.h @@ -37,7 +37,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_cmake_property";} + virtual std::string GetName() const { return "get_cmake_property";} cmTypeMacro(cmGetCMakePropertyCommand, cmCommand); }; diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index 9e76e1b..fcc3da1 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -54,7 +54,7 @@ bool cmGetDirectoryPropertyCommand // lookup the makefile from the directory name cmLocalGenerator *lg = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - FindLocalGenerator(sd.c_str()); + FindLocalGenerator(sd); if (!lg) { this->SetError @@ -79,18 +79,18 @@ bool cmGetDirectoryPropertyCommand "providing the name of the variable to get."); return false; } - output = dir->GetSafeDefinition(i->c_str()); - this->Makefile->AddDefinition(variable.c_str(), output.c_str()); + output = dir->GetSafeDefinition(*i); + this->Makefile->AddDefinition(variable, output.c_str()); return true; } - const char *prop = dir->GetProperty(i->c_str()); + const char *prop = dir->GetProperty(*i); if (prop) { - this->Makefile->AddDefinition(variable.c_str(), prop); + this->Makefile->AddDefinition(variable, prop); return true; } - this->Makefile->AddDefinition(variable.c_str(), ""); + this->Makefile->AddDefinition(variable, ""); return true; } diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h index aea04ad..6c5750a 100644 --- a/Source/cmGetDirectoryPropertyCommand.h +++ b/Source/cmGetDirectoryPropertyCommand.h @@ -37,7 +37,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_directory_property";} + virtual std::string GetName() const { return "get_directory_property";} cmTypeMacro(cmGetDirectoryPropertyCommand, cmCommand); }; diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 1d7fefc..10406d2 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -26,7 +26,7 @@ bool cmGetFilenameComponentCommand // already, if so use that value if(args.size() == 4 && args[3] == "CACHE") { - const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str()); + const char* cacheValue = this->Makefile->GetDefinition(args[0]); if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) { return true; @@ -107,7 +107,7 @@ bool cmGetFilenameComponentCommand else { std::string err = "unknown component " + args[2]; - this->SetError(err.c_str()); + this->SetError(err); return false; } @@ -116,12 +116,12 @@ bool cmGetFilenameComponentCommand if(programArgs.size() && storeArgs.size()) { this->Makefile->AddCacheDefinition - (storeArgs.c_str(), programArgs.c_str(), + (storeArgs, programArgs.c_str(), "", args[2] == "PATH" ? cmCacheManager::FILEPATH : cmCacheManager::STRING); } this->Makefile->AddCacheDefinition - (args[0].c_str(), result.c_str(), "", + (args[0], result.c_str(), "", args[2] == "PATH" ? cmCacheManager::FILEPATH : cmCacheManager::STRING); } @@ -129,9 +129,9 @@ bool cmGetFilenameComponentCommand { if(programArgs.size() && storeArgs.size()) { - this->Makefile->AddDefinition(storeArgs.c_str(), programArgs.c_str()); + this->Makefile->AddDefinition(storeArgs, programArgs.c_str()); } - this->Makefile->AddDefinition(args[0].c_str(), result.c_str()); + this->Makefile->AddDefinition(args[0], result.c_str()); } return true; diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h index e2cd219..534de53 100644 --- a/Source/cmGetFilenameComponentCommand.h +++ b/Source/cmGetFilenameComponentCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_filename_component";} + virtual std::string GetName() const { return "get_filename_component";} cmTypeMacro(cmGetFilenameComponentCommand, cmCommand); }; diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 33c43ca..6dd40c9 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -73,7 +73,7 @@ bool cmGetPropertyCommand e << "given invalid scope " << args[1] << ". " << "Valid scopes are " << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -120,7 +120,7 @@ bool cmGetPropertyCommand { cmOStringStream e; e << "given invalid argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -139,7 +139,7 @@ bool cmGetPropertyCommand std::string output; if(cmPropertyDefinition* def = this->Makefile->GetCMakeInstance()-> - GetPropertyDefinition(this->PropertyName.c_str(), scope)) + GetPropertyDefinition(this->PropertyName, scope)) { output = def->GetShortDescription(); } @@ -147,7 +147,7 @@ bool cmGetPropertyCommand { output = "NOTFOUND"; } - this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(this->Variable, output.c_str()); } else if(this->InfoType == OutFullDoc) { @@ -155,7 +155,7 @@ bool cmGetPropertyCommand std::string output; if(cmPropertyDefinition* def = this->Makefile->GetCMakeInstance()-> - GetPropertyDefinition(this->PropertyName.c_str(), scope)) + GetPropertyDefinition(this->PropertyName, scope)) { output = def->GetFullDescription(); } @@ -163,19 +163,19 @@ bool cmGetPropertyCommand { output = "NOTFOUND"; } - this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str()); + this->Makefile->AddDefinition(this->Variable, output.c_str()); } else if(this->InfoType == OutDefined) { // Lookup if the property is defined if(this->Makefile->GetCMakeInstance()-> - GetPropertyDefinition(this->PropertyName.c_str(), scope)) + GetPropertyDefinition(this->PropertyName, scope)) { - this->Makefile->AddDefinition(this->Variable.c_str(), "1"); + this->Makefile->AddDefinition(this->Variable, "1"); } else { - this->Makefile->AddDefinition(this->Variable.c_str(), "0"); + this->Makefile->AddDefinition(this->Variable, "0"); } } else @@ -204,17 +204,17 @@ bool cmGetPropertyCommand::StoreResult(const char* value) { if(this->InfoType == OutSet) { - this->Makefile->AddDefinition(this->Variable.c_str(), value? "1":"0"); + this->Makefile->AddDefinition(this->Variable, value? "1":"0"); } else // if(this->InfoType == OutValue) { if(value) { - this->Makefile->AddDefinition(this->Variable.c_str(), value); + this->Makefile->AddDefinition(this->Variable, value); } else { - this->Makefile->RemoveDefinition(this->Variable.c_str()); + this->Makefile->RemoveDefinition(this->Variable); } } return true; @@ -231,7 +231,7 @@ bool cmGetPropertyCommand::HandleGlobalMode() // Get the property. cmake* cm = this->Makefile->GetCMakeInstance(); - return this->StoreResult(cm->GetProperty(this->PropertyName.c_str())); + return this->StoreResult(cm->GetProperty(this->PropertyName)); } //---------------------------------------------------------------------------- @@ -259,7 +259,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode() // Lookup the generator. if(cmLocalGenerator* lg = (this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str()))) + ->GetGlobalGenerator()->FindLocalGenerator(dir))) { // Use the makefile for the directory found. mf = lg->GetMakefile(); @@ -276,7 +276,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode() } // Get the property. - return this->StoreResult(mf->GetProperty(this->PropertyName.c_str())); + return this->StoreResult(mf->GetProperty(this->PropertyName)); } //---------------------------------------------------------------------------- @@ -295,21 +295,21 @@ bool cmGetPropertyCommand::HandleTargetMode() if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) { - return this->StoreResult(target->GetName()); + return this->StoreResult(target->GetName().c_str()); } } return this->StoreResult((this->Variable + "-NOTFOUND").c_str()); } if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) { - return this->StoreResult(target->GetProperty(this->PropertyName.c_str())); + return this->StoreResult(target->GetProperty(this->PropertyName)); } else { cmOStringStream e; e << "could not find TARGET " << this->Name << ". Perhaps it has not yet been created."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -325,17 +325,17 @@ bool cmGetPropertyCommand::HandleSourceMode() // Get the source file. if(cmSourceFile* sf = - this->Makefile->GetOrCreateSource(this->Name.c_str())) + this->Makefile->GetOrCreateSource(this->Name)) { return - this->StoreResult(sf->GetPropertyForUser(this->PropertyName.c_str())); + this->StoreResult(sf->GetPropertyForUser(this->PropertyName)); } else { cmOStringStream e; e << "given SOURCE name that could not be found or created: " << this->Name; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -350,15 +350,15 @@ bool cmGetPropertyCommand::HandleTestMode() } // Loop over all tests looking for matching names. - if(cmTest* test = this->Makefile->GetTest(this->Name.c_str())) + if(cmTest* test = this->Makefile->GetTest(this->Name)) { - return this->StoreResult(test->GetProperty(this->PropertyName.c_str())); + return this->StoreResult(test->GetProperty(this->PropertyName)); } // If not found it is an error. cmOStringStream e; e << "given TEST name that does not exist: " << this->Name; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -372,7 +372,7 @@ bool cmGetPropertyCommand::HandleVariableMode() } return this->StoreResult - (this->Makefile->GetDefinition(this->PropertyName.c_str())); + (this->Makefile->GetDefinition(this->PropertyName)); } //---------------------------------------------------------------------------- @@ -389,7 +389,7 @@ bool cmGetPropertyCommand::HandleCacheMode() this->Makefile->GetCacheManager()->GetCacheIterator(this->Name.c_str()); if(!it.IsAtEnd()) { - value = it.GetProperty(this->PropertyName.c_str()); + value = it.GetProperty(this->PropertyName); } this->StoreResult(value); return true; diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h index e1630ff..8c3738f 100644 --- a/Source/cmGetPropertyCommand.h +++ b/Source/cmGetPropertyCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_property";} + virtual std::string GetName() const { return "get_property";} cmTypeMacro(cmGetPropertyCommand, cmCommand); private: diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx index 3d85e6d..8a96289 100644 --- a/Source/cmGetSourceFilePropertyCommand.cxx +++ b/Source/cmGetSourceFilePropertyCommand.cxx @@ -35,10 +35,10 @@ bool cmGetSourceFilePropertyCommand { if(args[2] == "LANGUAGE") { - this->Makefile->AddDefinition(var, sf->GetLanguage()); + this->Makefile->AddDefinition(var, sf->GetLanguage().c_str()); return true; } - const char *prop = sf->GetPropertyForUser(args[2].c_str()); + const char *prop = sf->GetPropertyForUser(args[2]); if (prop) { this->Makefile->AddDefinition(var, prop); diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h index 338318e..ab8ce36 100644 --- a/Source/cmGetSourceFilePropertyCommand.h +++ b/Source/cmGetSourceFilePropertyCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_source_file_property";} + virtual std::string GetName() const { return "get_source_file_property";} cmTypeMacro(cmGetSourceFilePropertyCommand, cmCommand); }; diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 4aa49fe..e3ec0bc 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -20,9 +20,9 @@ bool cmGetTargetPropertyCommand this->SetError("called with incorrect number of arguments"); return false; } - std::string var = args[0].c_str(); + std::string var = args[0]; const std::string& targetName = args[1]; - const char *prop = 0; + std::string prop; if(args[2] == "ALIASED_TARGET") { @@ -38,7 +38,11 @@ bool cmGetTargetPropertyCommand else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) { cmTarget& target = *tgt; - prop = target.GetProperty(args[2].c_str()); + const char* prop_cstr = target.GetProperty(args[2]); + if(prop_cstr) + { + prop = prop_cstr; + } } else { @@ -63,19 +67,19 @@ bool cmGetTargetPropertyCommand { e << "get_target_property() called with non-existent target \"" << targetName << "\"."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return false; } } } - if (prop) + if (!prop.empty()) { - this->Makefile->AddDefinition(var.c_str(), prop); + this->Makefile->AddDefinition(var, prop.c_str()); return true; } - this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str()); + this->Makefile->AddDefinition(var, (var+"-NOTFOUND").c_str()); return true; } diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h index 4985b3c..a35c6fe 100644 --- a/Source/cmGetTargetPropertyCommand.h +++ b/Source/cmGetTargetPropertyCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_target_property";} + virtual std::string GetName() const { return "get_target_property";} cmTypeMacro(cmGetTargetPropertyCommand, cmCommand); }; diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx index 0e0e2c0..b3df4c3 100644 --- a/Source/cmGetTestPropertyCommand.cxx +++ b/Source/cmGetTestPropertyCommand.cxx @@ -26,17 +26,17 @@ bool cmGetTestPropertyCommand std::string testName = args[0]; std::string var = args[2]; - cmTest *test = this->Makefile->GetTest(testName.c_str()); + cmTest *test = this->Makefile->GetTest(testName); if (test) { - const char *prop = test->GetProperty(args[1].c_str()); + const char *prop = test->GetProperty(args[1]); if (prop) { - this->Makefile->AddDefinition(var.c_str(), prop); + this->Makefile->AddDefinition(var, prop); return true; } } - this->Makefile->AddDefinition(var.c_str(), "NOTFOUND"); + this->Makefile->AddDefinition(var, "NOTFOUND"); return true; } diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h index 2dccabe..2819492 100644 --- a/Source/cmGetTestPropertyCommand.h +++ b/Source/cmGetTestPropertyCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "get_test_property";} + virtual std::string GetName() const { return "get_test_property";} cmTypeMacro(cmGetTestPropertyCommand, cmCommand); }; diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 70004ea..470dea4 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -28,9 +28,9 @@ public: <cmGlobalBorlandMakefileGenerator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalBorlandMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "Borland Makefiles";} + static std::string GetActualName() {return "Borland Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4f3328d..5b6d729 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -89,19 +89,25 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) return false; } -std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, - std::string makeDefault) const +std::string cmGlobalGenerator::SelectMakeProgram( + const std::string& inMakeProgram, + const std::string& makeDefault) const { - if(cmSystemTools::IsOff(makeProgram)) + std::string makeProgram = inMakeProgram; + if(cmSystemTools::IsOff(makeProgram.c_str())) { - makeProgram = + const char* makeProgramCSTR = this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); - if(cmSystemTools::IsOff(makeProgram)) + if(cmSystemTools::IsOff(makeProgramCSTR)) { - makeProgram = makeDefault.c_str(); + makeProgram = makeDefault; } - if(cmSystemTools::IsOff(makeProgram) && - !(makeProgram && *makeProgram)) + else + { + makeProgram = makeProgramCSTR; + } + if(cmSystemTools::IsOff(makeProgram.c_str()) && + !makeProgram.empty()) { makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND"; } @@ -117,7 +123,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, langComp += lang; langComp += "_COMPILER"; - if(!mf->GetDefinition(langComp.c_str())) + if(!mf->GetDefinition(langComp)) { if(!optional) { @@ -126,7 +132,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, } return; } - const char* name = mf->GetRequiredDefinition(langComp.c_str()); + const char* name = mf->GetRequiredDefinition(langComp); std::string path; if(!cmSystemTools::FileIsFullPath(name)) { @@ -144,7 +150,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, std::string doc = lang; doc += " compiler."; const char* cname = this->GetCMakeInstance()-> - GetCacheManager()->GetCacheValue(langComp.c_str()); + GetCacheManager()->GetCacheValue(langComp); std::string changeVars; if(cname && !optional) { @@ -179,7 +185,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, changeVars.c_str()); } } - mf->AddCacheDefinition(langComp.c_str(), path.c_str(), + mf->AddCacheDefinition(langComp, path.c_str(), doc.c_str(), cmCacheManager::FILEPATH); } @@ -432,8 +438,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, fpath += "/CMakeSystem.cmake"; mf->ReadListFile(0,fpath.c_str()); } - std::map<cmStdString, bool> needTestLanguage; - std::map<cmStdString, bool> needSetLanguageEnabledMaps; + std::map<std::string, bool> needTestLanguage; + std::map<std::string, bool> needSetLanguageEnabledMaps; // foreach language // load the CMakeDetermine(LANG)Compiler.cmake file to find // the compiler @@ -451,7 +457,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, std::string loadedLang = "CMAKE_"; loadedLang += lang; loadedLang += "_COMPILER_LOADED"; - if(!mf->GetDefinition(loadedLang.c_str())) + if(!mf->GetDefinition(loadedLang)) { fpath = rootBin; fpath += "/CMake"; @@ -512,9 +518,9 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, std::string compilerEnv = "CMAKE_"; compilerEnv += lang; compilerEnv += "_COMPILER_ENV_VAR"; - std::string envVar = mf->GetRequiredDefinition(compilerEnv.c_str()); + std::string envVar = mf->GetRequiredDefinition(compilerEnv); std::string envVarValue = - mf->GetRequiredDefinition(compilerName.c_str()); + mf->GetRequiredDefinition(compilerName); std::string env = envVar; env += "="; env += envVarValue; @@ -572,7 +578,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, compilerEnv += lang; compilerEnv += "_COMPILER_ENV_VAR"; cmOStringStream noCompiler; - const char* compilerFile = mf->GetDefinition(compilerName.c_str()); + const char* compilerFile = mf->GetDefinition(compilerName); if(!compilerFile || !*compilerFile || cmSystemTools::IsNOTFOUND(compilerFile)) { @@ -615,7 +621,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, if(!this->CMakeInstance->GetIsInTryCompile()) { this->PrintCompilerAdvice(noCompiler, lang, - mf->GetDefinition(compilerEnv.c_str())); + mf->GetDefinition(compilerEnv)); mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str()); fatalError = true; } @@ -625,7 +631,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, std::string langLoadedVar = "CMAKE_"; langLoadedVar += lang; langLoadedVar += "_INFORMATION_LOADED"; - if (!mf->GetDefinition(langLoadedVar.c_str())) + if (!mf->GetDefinition(langLoadedVar)) { fpath = "CMake"; fpath += lang; @@ -672,7 +678,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, // if the compiler did not work, then remove the // CMake(LANG)Compiler.cmake file so that it will get tested the // next time cmake is run - if(!mf->IsOn(compilerWorks.c_str())) + if(!mf->IsOn(compilerWorks)) { std::string compilerLangFile = rootBin; compilerLangFile += "/CMake"; @@ -687,7 +693,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, sharedLibFlagsVar += lang; sharedLibFlagsVar += "_FLAGS"; const char* sharedLibFlags = - mf->GetSafeDefinition(sharedLibFlagsVar.c_str()); + mf->GetSafeDefinition(sharedLibFlagsVar); if (sharedLibFlags) { this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags; @@ -722,7 +728,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, //---------------------------------------------------------------------------- void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, - std::string lang, + std::string const& lang, const char* envVar) const { // Subclasses override this method if they do not support this advice. @@ -744,10 +750,10 @@ void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, //---------------------------------------------------------------------------- void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, - std::string lang) const + std::string const& lang) const { std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; - const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); + const char* compilerId = mf->GetDefinition(compilerIdVar); if(!compilerId) { return; @@ -770,7 +776,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, } case cmPolicies::OLD: // OLD behavior is to convert AppleClang to Clang. - mf->AddDefinition(compilerIdVar.c_str(), "Clang"); + mf->AddDefinition(compilerIdVar, "Clang"); break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: @@ -801,7 +807,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, } case cmPolicies::OLD: // OLD behavior is to convert QCC to GNU. - mf->AddDefinition(compilerIdVar.c_str(), "GNU"); + mf->AddDefinition(compilerIdVar, "GNU"); break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: @@ -817,17 +823,18 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, } //---------------------------------------------------------------------------- -const char* +std::string cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const { - if(const char* lang = source.GetLanguage()) + const std::string& lang = source.GetLanguage(); + if(!lang.empty()) { - std::map<cmStdString, cmStdString>::const_iterator it = + std::map<std::string, std::string>::const_iterator it = this->LanguageToOutputExtension.find(lang); if(it != this->LanguageToOutputExtension.end()) { - return it->second.c_str(); + return it->second; } } else @@ -840,7 +847,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const { if(this->OutputExtensions.count(ext)) { - return ext.c_str(); + return ext; } } } @@ -848,7 +855,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const } -const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const +std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const { // if there is an extension and it starts with . then move past the // . because the extensions are not stored with a . in the map @@ -856,13 +863,13 @@ const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const { ++ext; } - std::map<cmStdString, cmStdString>::const_iterator it + std::map<std::string, std::string>::const_iterator it = this->ExtensionToLanguage.find(ext); if(it != this->ExtensionToLanguage.end()) { - return it->second.c_str(); + return it->second; } - return 0; + return ""; } /* SetLanguageEnabled() is now split in two parts: @@ -877,13 +884,15 @@ files could change the object file extension (CMAKE_<LANG>_OUTPUT_EXTENSION) before the CMake variables were copied to the C++ maps. */ -void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf) +void cmGlobalGenerator::SetLanguageEnabled(const std::string& l, + cmMakefile* mf) { this->SetLanguageEnabledFlag(l, mf); this->SetLanguageEnabledMaps(l, mf); } -void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf) +void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l, + cmMakefile* mf) { this->LanguageEnabled[l] = true; @@ -895,7 +904,8 @@ void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf) this->FillExtensionToLanguageMap(l, mf); } -void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) +void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, + cmMakefile* mf) { // use LanguageToLinkerPreference to detect whether this functions has // run before @@ -907,7 +917,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) std::string linkerPrefVar = std::string("CMAKE_") + std::string(l) + std::string("_LINKER_PREFERENCE"); - const char* linkerPref = mf->GetDefinition(linkerPrefVar.c_str()); + const char* linkerPref = mf->GetDefinition(linkerPrefVar); int preference = 0; if(linkerPref) { @@ -940,7 +950,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) std::string outputExtensionVar = std::string("CMAKE_") + std::string(l) + std::string("_OUTPUT_EXTENSION"); - const char* outputExtension = mf->GetDefinition(outputExtensionVar.c_str()); + const char* outputExtension = mf->GetDefinition(outputExtensionVar); if(outputExtension) { this->LanguageToOutputExtension[l] = outputExtension; @@ -958,7 +968,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) std::string ignoreExtensionsVar = std::string("CMAKE_") + std::string(l) + std::string("_IGNORE_EXTENSIONS"); - std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar.c_str()); + std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar); std::vector<std::string> extensionList; cmSystemTools::ExpandListArgument(ignoreExts, extensionList); for(std::vector<std::string>::iterator i = extensionList.begin(); @@ -969,12 +979,12 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) } -void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l, +void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf) { std::string extensionsVar = std::string("CMAKE_") + std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS"); - std::string exts = mf->GetSafeDefinition(extensionsVar.c_str()); + std::string exts = mf->GetSafeDefinition(extensionsVar); std::vector<std::string> extensionList; cmSystemTools::ExpandListArgument(exts, extensionList); for(std::vector<std::string>::iterator i = extensionList.begin(); @@ -984,16 +994,16 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l, } } -bool cmGlobalGenerator::IgnoreFile(const char* l) const +bool cmGlobalGenerator::IgnoreFile(const char* ext) const { - if(this->GetLanguageFromExtension(l)) + if(!this->GetLanguageFromExtension(ext).empty()) { return false; } - return (this->IgnoreExtensions.count(l) > 0); + return (this->IgnoreExtensions.count(ext) > 0); } -bool cmGlobalGenerator::GetLanguageEnabled(const char* l) const +bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const { return (this->LanguageEnabled.find(l)!= this->LanguageEnabled.end()); } @@ -1003,11 +1013,11 @@ void cmGlobalGenerator::ClearEnabledLanguages() this->LanguageEnabled.clear(); } -bool cmGlobalGenerator::IsDependedOn(const char* project, +bool cmGlobalGenerator::IsDependedOn(const std::string& project, cmTarget const* targetIn) { // Get all local gens for this project - std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator it = + std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->ProjectMap.find(project); if (it == this->ProjectMap.end()) { @@ -1148,12 +1158,6 @@ void cmGlobalGenerator::Generate() return; } - // Check that all targets are valid. - if(!this->CheckTargets()) - { - return; - } - this->FinalizeTargetCompileInfo(); #ifdef CMAKE_BUILD_WITH_CMAKE @@ -1306,35 +1310,6 @@ bool cmGlobalGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::CheckTargets() -{ - // Make sure all targets can find their source files. - for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) - { - cmTargets& targets = - this->LocalGenerators[i]->GetMakefile()->GetTargets(); - for(cmTargets::iterator ti = targets.begin(); - ti != targets.end(); ++ti) - { - cmTarget& target = ti->second; - if(target.GetType() == cmTarget::EXECUTABLE || - target.GetType() == cmTarget::STATIC_LIBRARY || - target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY || - target.GetType() == cmTarget::OBJECT_LIBRARY || - target.GetType() == cmTarget::UTILITY) - { - if(!target.FindSourceFiles()) - { - return false; - } - } - } - } - return true; -} - -//---------------------------------------------------------------------------- void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) { #ifdef CMAKE_BUILD_WITH_CMAKE @@ -1414,8 +1389,8 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(*ci); - t->AppendProperty(defPropName.c_str(), - mf->GetProperty(defPropName.c_str())); + t->AppendProperty(defPropName, + mf->GetProperty(defPropName)); } } } @@ -1474,7 +1449,7 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() continue; } cmGeneratorTarget* gt = ti->second; - gt->ClassifySources(); + this->ComputeTargetObjectDirectory(gt); gt->LookupObjectLibraries(); this->ComputeTargetObjects(gt); } @@ -1541,15 +1516,37 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const } //---------------------------------------------------------------------------- -void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const +void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const +{ + std::vector<cmSourceFile const*> objectSources; + gt->GetObjectSources(objectSources); + + std::map<cmSourceFile const*, std::string> mapping; + for(std::vector<cmSourceFile const*>::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); + + for(std::map<cmSourceFile const*, std::string>::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) + { + assert(!it->second.empty()); + gt->AddObject(it->first, it->second); + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const { - // Implemented in generator subclasses that need this. } void cmGlobalGenerator::CheckLocalGenerators() { - std::map<cmStdString, cmStdString> notFoundMap; -// std::set<cmStdString> notFoundMap; + std::map<std::string, std::string> notFoundMap; +// std::set<std::string> notFoundMap; // after it is all done do a ConfigureFinalPass cmCacheManager* manager = 0; for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) @@ -1598,7 +1595,7 @@ void cmGlobalGenerator::CheckLocalGenerators() std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions); - cmSystemTools::ExpandListArgument(incDirs.c_str(), incs); + cmSystemTools::ExpandListArgument(incDirs, incs); for( std::vector<std::string>::const_iterator incDir = incs.begin(); incDir != incs.end(); ++incDir) @@ -1629,7 +1626,7 @@ void cmGlobalGenerator::CheckLocalGenerators() if(notFoundMap.size()) { std::string notFoundVars; - for(std::map<cmStdString, cmStdString>::const_iterator + for(std::map<std::string, std::string>::const_iterator ii = notFoundMap.begin(); ii != notFoundMap.end(); ++ii) @@ -1646,9 +1643,10 @@ void cmGlobalGenerator::CheckLocalGenerators() } } -int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, - const char *projectName, - const char *target, bool fast, +int cmGlobalGenerator::TryCompile(const std::string& srcdir, + const std::string& bindir, + const std::string& projectName, + const std::string& target, bool fast, std::string *output, cmMakefile *mf) { // if this is not set, then this is a first time configure @@ -1672,7 +1670,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, } std::string newTarget; - if (target && strlen(target)) + if (!target.empty()) { newTarget += target; #if 0 @@ -1687,27 +1685,30 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, #endif // WIN32 #endif } - const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); + std::string config = + mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); return this->Build(srcdir,bindir,projectName, - newTarget.c_str(), - output,0,config,false,fast, + newTarget, + output,"",config,false,fast, this->TryCompileTimeout); } void cmGlobalGenerator::GenerateBuildCommand( - std::vector<std::string>& makeCommand, const char*, const char*, const char*, - const char*, const char*, bool, std::vector<std::string> const&) + std::vector<std::string>& makeCommand, const std::string&, + const std::string&, const std::string&, const std::string&, + const std::string&, bool, + std::vector<std::string> const&) { makeCommand.push_back( "cmGlobalGenerator::GenerateBuildCommand not implemented"); } int cmGlobalGenerator::Build( - const char *, const char *bindir, - const char *projectName, const char *target, + const std::string&, const std::string& bindir, + const std::string& projectName, const std::string& target, std::string *output, - const char *makeCommandCSTR, - const char *config, + const std::string& makeCommandCSTR, + const std::string& config, bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag, @@ -1717,7 +1718,7 @@ int cmGlobalGenerator::Build( * Run an executable command and put the stdout in output. */ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(bindir); + cmSystemTools::ChangeDirectory(bindir.c_str()); if(output) { *output += "Change Dir: "; @@ -1819,19 +1820,20 @@ int cmGlobalGenerator::Build( //---------------------------------------------------------------------------- std::string cmGlobalGenerator::GenerateCMakeBuildCommand( - const char* target, const char* config, const char* native, + const std::string& target, const std::string& config, + const std::string& native, bool ignoreErrors) { std::string makeCommand = cmSystemTools::GetCMakeCommand(); makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); makeCommand += " --build ."; - if(config && *config) + if(!config.empty()) { makeCommand += " --config \""; makeCommand += config; makeCommand += "\""; } - if(target && *target) + if(!target.empty()) { makeCommand += " --target \""; makeCommand += target; @@ -1848,7 +1850,7 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand( sep = " "; } } - if(native && *native) + if(!native.empty()) { makeCommand += sep; makeCommand += native; @@ -1987,16 +1989,16 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, void cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const { - for(std::map<cmStdString, bool>::const_iterator i = + for(std::map<std::string, bool>::const_iterator i = this->LanguageEnabled.begin(); i != this->LanguageEnabled.end(); ++i) { lang.push_back(i->first); } } -int cmGlobalGenerator::GetLinkerPreference(const char* lang) const +int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const { - std::map<cmStdString, int>::const_iterator it = + std::map<std::string, int>::const_iterator it = this->LanguageToLinkerPreference.find(lang); if (it != this->LanguageToLinkerPreference.end()) { @@ -2073,7 +2075,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() ///! Find a local generator by its startdirectory cmLocalGenerator* -cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const +cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const { for(std::vector<cmLocalGenerator*>::const_iterator it = this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it) @@ -2088,60 +2090,41 @@ cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt) +void cmGlobalGenerator::AddAlias(const std::string& name, cmTarget *tgt) { this->AliasTargets[name] = tgt; } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsAlias(const char *name) const +bool cmGlobalGenerator::IsAlias(const std::string& name) const { return this->AliasTargets.find(name) != this->AliasTargets.end(); } //---------------------------------------------------------------------------- cmTarget* -cmGlobalGenerator::FindTarget(const char* project, const char* name, +cmGlobalGenerator::FindTarget(const std::string& name, bool excludeAliases) const { - // if project specific - if(project) + if (!excludeAliases) { - std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator - gens = this->ProjectMap.find(project); - for(unsigned int i = 0; i < gens->second.size(); ++i) + std::map<std::string, cmTarget*>::const_iterator ai + = this->AliasTargets.find(name); + if (ai != this->AliasTargets.end()) { - cmTarget* ret = (gens->second)[i]->GetMakefile()->FindTarget(name, - excludeAliases); - if(ret) - { - return ret; - } + return ai->second; } } - // if all projects/directories - else + std::map<std::string,cmTarget *>::const_iterator i = + this->TotalTargets.find ( name ); + if ( i != this->TotalTargets.end() ) { - if (!excludeAliases) - { - std::map<cmStdString, cmTarget*>::const_iterator ai - = this->AliasTargets.find(name); - if (ai != this->AliasTargets.end()) - { - return ai->second; - } - } - std::map<cmStdString,cmTarget *>::const_iterator i = - this->TotalTargets.find ( name ); - if ( i != this->TotalTargets.end() ) - { - return i->second; - } - i = this->ImportedTargets.find(name); - if ( i != this->ImportedTargets.end() ) - { - return i->second; - } + return i->second; + } + i = this->ImportedTargets.find(name); + if ( i != this->ImportedTargets.end() ) + { + return i->second; } return 0; } @@ -2155,7 +2138,7 @@ cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const return true; } - if(cmTarget* tgt = this->FindTarget(0, libname.c_str())) + if(cmTarget* tgt = this->FindTarget(libname)) { if(tgt->IsFrameworkOnApple()) { @@ -2344,7 +2327,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { if(!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') { - std::set<cmStdString>* componentsSet = &this->InstallComponents; + std::set<std::string>* componentsSet = &this->InstallComponents; cpackCommandLines.erase(cpackCommandLines.begin(), cpackCommandLines.end()); depends.erase(depends.begin(), depends.end()); @@ -2352,20 +2335,20 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) if ( componentsSet->size() > 0 ) { ostr << "Available install components are:"; - std::set<cmStdString>::iterator it; + std::set<std::string>::iterator it; for ( it = componentsSet->begin(); it != componentsSet->end(); ++ it ) { - ostr << " \"" << it->c_str() << "\""; + ostr << " \"" << *it << "\""; } } else { ostr << "Only default component available"; } - singleLine.push_back(ostr.str().c_str()); + singleLine.push_back(ostr.str()); (*targets)["list_install_components"] = this->CreateGlobalTarget("list_install_components", ostr.str().c_str(), @@ -2396,7 +2379,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) // automatically convert this name to the build-time location. cmd = "cmake"; } - singleLine.push_back(cmd.c_str()); + singleLine.push_back(cmd); if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) { std::string cfgArg = "-DBUILD_TYPE="; @@ -2513,7 +2496,7 @@ void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf) //---------------------------------------------------------------------------- cmTarget cmGlobalGenerator::CreateGlobalTarget( - const char* name, const char* message, + const std::string& name, const char* message, const cmCustomCommandLines* commandLines, std::vector<std::string> depends, const char* workingDirectory) @@ -2534,7 +2517,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( std::vector<std::string>::iterator dit; for ( dit = depends.begin(); dit != depends.end(); ++ dit ) { - target.AddUtility(dit->c_str()); + target.AddUtility(*dit); } // Organize in the "predefined targets" folder: @@ -2566,7 +2549,7 @@ cmGlobalGenerator::GenerateRuleFile(std::string const& output) const std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( std::string const& l) const { - std::map<cmStdString, cmStdString>::const_iterator it = + std::map<std::string, std::string>::const_iterator it = this->LanguageToOriginalSharedLibFlags.find(l); if(it != this->LanguageToOriginalSharedLibFlags.end()) { @@ -2576,8 +2559,10 @@ std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, - const char*, std::string&) +void cmGlobalGenerator::AppendDirectoryForConfig(const std::string&, + const std::string&, + const std::string&, + std::string&) { // Subclasses that support multiple configurations should implement // this method to append the subdirectory for the given build @@ -2644,9 +2629,9 @@ void cmGlobalGenerator::SetExternalMakefileProjectGenerator( } } -const char* cmGlobalGenerator::GetExtraGeneratorName() const +std::string cmGlobalGenerator::GetExtraGeneratorName() const { - return this->ExtraGenerator==0 ? 0 : this->ExtraGenerator->GetName(); + return this->ExtraGenerator? this->ExtraGenerator->GetName() : std::string(); } void cmGlobalGenerator::FileReplacedDuringGenerate(const std::string& filename) @@ -2704,7 +2689,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const { return (target->GetType() == cmTarget::GLOBAL_TARGET || - strcmp(target->GetName(), this->GetAllTargetName()) == 0); + target->GetName() == this->GetAllTargetName()); } //---------------------------------------------------------------------------- @@ -2727,7 +2712,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget const* target, //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddToManifest(const char* config, +void cmGlobalGenerator::AddToManifest(const std::string& config, std::string const& f) { // Add to the main manifest for this configuration. @@ -2740,7 +2725,7 @@ void cmGlobalGenerator::AddToManifest(const char* config, } //---------------------------------------------------------------------------- -std::set<cmStdString> const& +std::set<std::string> const& cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk) { DirectoryContent& dc = this->DirectoryContentMap[dir]; @@ -2792,7 +2777,7 @@ cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs, // Shorten the output name (in expected use case). cmLocalGenerator* lg = this->GetLocalGenerators()[0]; - std::string fname = lg->Convert(outputs[0].c_str(), + std::string fname = lg->Convert(outputs[0], cmLocalGenerator::HOME_OUTPUT); // Associate the hash with this output. @@ -2846,7 +2831,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, fname = line.substr(33, line.npos); // Look for a hash for this file's rule. - std::map<cmStdString, RuleHash>::const_iterator rhi = + std::map<std::string, RuleHash>::const_iterator rhi = this->RuleHashes.find(fname); if(rhi != this->RuleHashes.end()) { @@ -2891,7 +2876,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile) { cmGeneratedFileStream fout(pfile.c_str()); fout << "# Hashes of file build rules.\n"; - for(std::map<cmStdString, RuleHash>::const_iterator + for(std::map<std::string, RuleHash>::const_iterator rhi = this->RuleHashes.begin(); rhi != this->RuleHashes.end(); ++rhi) { fout.write(rhi->second.Data, 32); @@ -2912,7 +2897,7 @@ void cmGlobalGenerator::WriteSummary() cmGeneratedFileStream fout(fname.c_str()); // Generate summary information files for each target. - for(std::map<cmStdString,cmTarget *>::const_iterator ti = + for(std::map<std::string,cmTarget *>::const_iterator ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti) { if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 753eebf..49a418d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -51,11 +51,11 @@ public: virtual cmLocalGenerator *CreateLocalGenerator(); ///! Get the name for this generator - virtual const char *GetName() const { return "Generic"; }; + virtual std::string GetName() const { return "Generic"; }; /** Check whether the given name matches the current generator. */ - virtual bool MatchesGeneratorName(const char* name) const - { return strcmp(this->GetName(), name) == 0; } + virtual bool MatchesGeneratorName(const std::string& name) const + { return this->GetName() == name; } /** Set the generator-specific toolset name. Returns true if toolset is supported and false otherwise. */ @@ -77,8 +77,8 @@ public: /** * Set/Get and Clear the enabled languages. */ - void SetLanguageEnabled(const char*, cmMakefile* mf); - bool GetLanguageEnabled(const char*) const; + void SetLanguageEnabled(const std::string&, cmMakefile* mf); + bool GetLanguageEnabled(const std::string&) const; void ClearEnabledLanguages(); void GetEnabledLanguages(std::vector<std::string>& lang) const; /** @@ -105,8 +105,9 @@ public: * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ - virtual int TryCompile(const char *srcdir, const char *bindir, - const char *projectName, const char *targetName, + virtual int TryCompile(const std::string& srcdir, const std::string& bindir, + const std::string& projectName, + const std::string& targetName, bool fast, std::string *output, cmMakefile* mf); @@ -116,10 +117,10 @@ public: * empty then all is assumed. clean indicates if a "make clean" should be * done first. */ - int Build(const char *srcdir, const char *bindir, - const char *projectName, const char *targetName, + int Build(const std::string& srcdir, const std::string& bindir, + const std::string& projectName, const std::string& targetName, std::string *output, - const char *makeProgram, const char *config, + const std::string& makeProgram, const std::string& config, bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE, @@ -128,16 +129,16 @@ public: virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char *projectName, const char *projectDir, - const char *targetName, const char* config, bool fast, + const std::string& makeProgram, + const std::string& projectName, const std::string& projectDir, + const std::string& targetName, const std::string& config, bool fast, std::vector<std::string> const& makeOptions = std::vector<std::string>() ); /** Generate a "cmake --build" call for a given target and config. */ - std::string GenerateCMakeBuildCommand(const char* target, - const char* config, - const char* native, + std::string GenerateCMakeBuildCommand(const std::string& target, + const std::string& config, + const std::string& native, bool ignoreErrors); ///! Set the CMake instance @@ -162,17 +163,17 @@ public: void SetExternalMakefileProjectGenerator( cmExternalMakefileProjectGenerator *extraGenerator); - const char* GetExtraGeneratorName() const; + std::string GetExtraGeneratorName() const; void AddInstallComponent(const char* component); - const std::set<cmStdString>* GetInstallComponents() const + const std::set<std::string>* GetInstallComponents() const { return &this->InstallComponents; } cmExportSetMap& GetExportSets() {return this->ExportSets;} /** Add a file to the manifest of generated targets for a configuration. */ - void AddToManifest(const char* config, std::string const& f); + void AddToManifest(const std::string& config, std::string const& f); void EnableInstallTarget(); @@ -182,13 +183,13 @@ public: bool GetToolSupportsColor() const { return this->ToolSupportsColor; } ///! return the language for the given extension - const char* GetLanguageFromExtension(const char* ext) const; + std::string GetLanguageFromExtension(const char* ext) const; ///! is an extension to be ignored bool IgnoreFile(const char* ext) const; ///! What is the preference for linkers and this language (None or Prefered) - int GetLinkerPreference(const char* lang) const; + int GetLinkerPreference(const std::string& lang) const; ///! What is the object file extension for a given source file? - const char* GetLanguageOutputExtension(cmSourceFile const&) const; + std::string GetLanguageOutputExtension(cmSourceFile const&) const; ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const { return "."; } @@ -210,11 +211,11 @@ public: virtual void FindMakeProgram(cmMakefile*); ///! Find a target by name by searching the local generators. - cmTarget* FindTarget(const char* project, const char* name, + cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; - void AddAlias(const char *name, cmTarget *tgt); - bool IsAlias(const char *name) const; + void AddAlias(const std::string& name, cmTarget *tgt); + bool IsAlias(const std::string& name) const; /** Determine if a name resolves to a framework on disk or a built target that is a framework. */ @@ -222,16 +223,16 @@ public: /** If check to see if the target is linked to by any other target in the project */ - bool IsDependedOn(const char* project, cmTarget const* target); + bool IsDependedOn(const std::string& project, cmTarget const* target); ///! Find a local generator by its startdirectory - cmLocalGenerator* FindLocalGenerator(const char* start_dir) const; + cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const; /** Append the subdirectory for the given configuration. If anything is appended the given prefix and suffix will be appended around it, which is useful for leading or trailing slashes. */ - virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, + virtual void AppendDirectoryForConfig(const std::string& prefix, + const std::string& config, + const std::string& suffix, std::string& dir); /** Get the manifest of all targets that will be built for each @@ -243,7 +244,7 @@ public: from disk at most once and cached. During the generation step the content will include the target files to be built even if they do not yet exist. */ - std::set<cmStdString> const& GetDirectoryContent(std::string const& dir, + std::set<std::string> const& GetDirectoryContent(std::string const& dir, bool needDisk = true); void AddTarget(cmTarget* t); @@ -275,7 +276,7 @@ public: /** Get per-target generator information. */ cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; - const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap() + const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap() const {return this->ProjectMap;} // track files replaced during a Generate @@ -286,12 +287,12 @@ public: std::string const& content); /** Return whether the given binary directory is unused. */ - bool BinaryDirectoryIsNew(const char* dir) + bool BinaryDirectoryIsNew(const std::string& dir) { return this->BinaryDirectories.insert(dir).second; } /** Supported systems creates a GUID for the given name */ - virtual void CreateGUID(const char*) {} + virtual void CreateGUID(const std::string&) {} /** Return true if the generated build tree may contain multiple builds. i.e. "Can I build Debug and Release in the same tree?" */ @@ -322,6 +323,8 @@ public: GetExportedTargetsFile(const std::string &filename) const; void AddCMP0042WarnTarget(const std::string& target); + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend @@ -332,21 +335,20 @@ protected: bool IsRootOnlyTarget(cmTarget* target) const; void AddTargetDepends(cmTarget const* target, TargetDependSet& projectTargets); - void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); - void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); - void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); + void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); + void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf); + void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf); virtual bool ComputeTargetDepends(); virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; - bool CheckTargets(); typedef std::vector<std::pair<cmQtAutoGenerators, cmTarget const*> > AutogensType; void CreateQtAutoGeneratorsTargets(AutogensType& autogens); - std::string SelectMakeProgram(const char* makeProgram, - std::string makeDefault = "") const; + std::string SelectMakeProgram(const std::string& makeProgram, + const std::string& makeDefault = "") const; // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. @@ -356,7 +358,7 @@ protected: bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); - cmTarget CreateGlobalTarget(const char* name, const char* message, + cmTarget CreateGlobalTarget(const std::string& name, const char* message, const cmCustomCommandLines* commandLines, std::vector<std::string> depends, const char* workingDir); @@ -364,18 +366,18 @@ protected: bool UseLinkScript; bool ForceUnixPaths; bool ToolSupportsColor; - cmStdString FindMakeProgramFile; - cmStdString ConfiguredFilesPath; + std::string FindMakeProgramFile; + std::string ConfiguredFilesPath; cmake *CMakeInstance; std::vector<cmLocalGenerator *> LocalGenerators; cmLocalGenerator* CurrentLocalGenerator; // map from project name to vector of local generators in that project - std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap; + std::map<std::string, std::vector<cmLocalGenerator*> > ProjectMap; std::map<cmLocalGenerator*, std::set<cmTarget const*> > LocalGeneratorToTargetMap; // Set of named installation components requested by the project. - std::set<cmStdString> InstallComponents; + std::set<std::string> InstallComponents; bool InstallTargetEnabled; // Sets of named target exports cmExportSetMap ExportSets; @@ -387,9 +389,9 @@ protected: cmTargetManifest TargetManifest; // All targets in the entire project. - std::map<cmStdString,cmTarget *> TotalTargets; - std::map<cmStdString,cmTarget *> AliasTargets; - std::map<cmStdString,cmTarget *> ImportedTargets; + std::map<std::string,cmTarget *> TotalTargets; + std::map<std::string,cmTarget *> AliasTargets; + std::map<std::string,cmTarget *> ImportedTargets; std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles; virtual const char* GetPredefinedTargetsFolder(); @@ -401,18 +403,18 @@ private: float FirstTimeProgress; // If you add a new map here, make sure it is copied // in EnableLanguagesFromGenerator - std::map<cmStdString, bool> IgnoreExtensions; - std::map<cmStdString, bool> LanguageEnabled; - std::set<cmStdString> LanguagesReady; // Ready for try_compile - std::map<cmStdString, cmStdString> OutputExtensions; - std::map<cmStdString, cmStdString> LanguageToOutputExtension; - std::map<cmStdString, cmStdString> ExtensionToLanguage; - std::map<cmStdString, int> LanguageToLinkerPreference; - std::map<cmStdString, cmStdString> LanguageToOriginalSharedLibFlags; + std::map<std::string, bool> IgnoreExtensions; + std::map<std::string, bool> LanguageEnabled; + std::set<std::string> LanguagesReady; // Ready for try_compile + std::map<std::string, std::string> OutputExtensions; + std::map<std::string, std::string> LanguageToOutputExtension; + std::map<std::string, std::string> ExtensionToLanguage; + std::map<std::string, int> LanguageToLinkerPreference; + std::map<std::string, std::string> LanguageToOriginalSharedLibFlags; // Record hashes for rules and outputs. struct RuleHash { char Data[32]; }; - std::map<cmStdString, RuleHash> RuleHashes; + std::map<std::string, RuleHash> RuleHashes; void CheckRuleHashes(); void CheckRuleHashes(std::string const& pfile, std::string const& home); void WriteRuleHashes(std::string const& pfile); @@ -421,9 +423,10 @@ private: void WriteSummary(cmTarget* target); void FinalizeTargetCompileInfo(); - virtual void PrintCompilerAdvice(std::ostream& os, std::string lang, + virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, const char* envVar) const; - void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang) const; + void CheckCompilerIdCompatibility(cmMakefile* mf, + std::string const& lang) const; cmExternalMakefileProjectGenerator* ExtraGenerator; @@ -440,25 +443,25 @@ private: void CreateGeneratorTargets(cmMakefile* mf); void CreateGeneratorTargets(); void ComputeGeneratorTargetObjects(); - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; + void ComputeTargetObjects(cmGeneratorTarget* gt) const; void ClearGeneratorMembers(); virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; } // Cache directory content and target files to be built. - struct DirectoryContent: public std::set<cmStdString> + struct DirectoryContent: public std::set<std::string> { - typedef std::set<cmStdString> derived; + typedef std::set<std::string> derived; bool LoadedFromDisk; DirectoryContent(): LoadedFromDisk(false) {} DirectoryContent(DirectoryContent const& dc): derived(dc), LoadedFromDisk(dc.LoadedFromDisk) {} }; - std::map<cmStdString, DirectoryContent> DirectoryContentMap; + std::map<std::string, DirectoryContent> DirectoryContentMap; // Set of binary directories on disk. - std::set<cmStdString> BinaryDirectories; + std::set<std::string> BinaryDirectories; // track targets to issue CMP0042 warning for. std::set<std::string> CMP0042WarnTargets; diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h index fd1d65f..3c2cd60 100644 --- a/Source/cmGlobalGeneratorFactory.h +++ b/Source/cmGlobalGeneratorFactory.h @@ -29,7 +29,8 @@ public: virtual ~cmGlobalGeneratorFactory() {} /** Create a GlobalGenerator */ - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* n) const = 0; + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& n) const = 0; /** Get the documentation entry for this factory */ virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0; @@ -43,8 +44,9 @@ class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory { public: /** Create a GlobalGenerator */ - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if (strcmp(name, T::GetActualName())) return 0; + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { + if (name != T::GetActualName()) return 0; return new T; } /** Get the documentation entry for this factory */ diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 28893bf..344e013 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -27,11 +27,11 @@ public: return new cmGlobalGeneratorSimpleFactory <cmGlobalJOMMakefileGenerator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalJOMMakefileGenerator::GetActualName();} // use NMake Makefiles in the name so that scripts/tests that depend on the // name NMake Makefiles will work - static const char* GetActualName() {return "NMake Makefiles JOM";} + static std::string GetActualName() {return "NMake Makefiles JOM";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index ed0e15b..df3ce10 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -25,7 +25,7 @@ //---------------------------------------------------------------------------- void cmGlobalKdevelopGenerator -::GetDocumentation(cmDocumentationEntry& entry, const char*) const +::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const { entry.Name = this->GetName(); entry.Brief = "Generates KDevelop 3 project files."; @@ -44,7 +44,7 @@ void cmGlobalKdevelopGenerator::Generate() { // for each sub project in the project create // a kdevelop project - for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); it!= this->GlobalGenerator->GetProjectMap().end(); ++it) @@ -76,7 +76,7 @@ void cmGlobalKdevelopGenerator::Generate() { if (ti->second.GetType()==cmTarget::EXECUTABLE) { - executable = ti->second.GetLocation(0); + executable = ti->second.GetLocation(""); break; } } @@ -103,7 +103,7 @@ bool cmGlobalKdevelopGenerator std::string projectDir = projectDirIn + "/"; std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist"; - std::set<cmStdString> files; + std::set<std::string> files; std::string tmp; for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin(); @@ -183,7 +183,7 @@ bool cmGlobalKdevelopGenerator (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash())==0)) { - files.insert(tmp.c_str()); + files.insert(tmp); } } } @@ -217,7 +217,7 @@ bool cmGlobalKdevelopGenerator } fileToOpen=""; - for (std::set<cmStdString>::const_iterator it=files.begin(); + for (std::set<std::string>::const_iterator it=files.begin(); it!=files.end(); it++) { // get the full path to the file @@ -360,7 +360,7 @@ void cmGlobalKdevelopGenerator if (strstr(line, "<general>")) { fout<< " <projectmanagement>KDevCustomProject</projectmanagement>\n"; - fout<< " <projectdirectory>" <<projectDir.c_str() + fout<< " <projectdirectory>" <<projectDir << "</projectdirectory>\n"; //this one is important fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one @@ -368,14 +368,14 @@ void cmGlobalKdevelopGenerator // inside kdevcustomproject the <filelistdirectory> must be put if (strstr(line, "<kdevcustomproject>")) { - fout<<" <filelistdirectory>"<<outputDir.c_str() + fout<<" <filelistdirectory>"<<outputDir <<"</filelistdirectory>\n"; } // buildtool and builddir go inside <build> if (strstr(line, "<build>")) { fout<<" <buildtool>make</buildtool>\n"; - fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; + fout<<" <builddir>"<<outputDir<<"</builddir>\n"; } } } @@ -417,7 +417,7 @@ void cmGlobalKdevelopGenerator " <projectmanagement>KDevCustomProject</projectmanagement>\n" " <primarylanguage>" << primaryLanguage << "</primarylanguage>\n" " <ignoreparts/>\n" - " <projectdirectory>" << projectDir.c_str() << + " <projectdirectory>" << projectDir << "</projectdirectory>\n"; //this one is important fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one @@ -444,12 +444,12 @@ void cmGlobalKdevelopGenerator fout<<" </general>\n" " <kdevcustomproject>\n" - " <filelistdirectory>" << outputDir.c_str() << + " <filelistdirectory>" << outputDir << "</filelistdirectory>\n" " <run>\n" - " <mainprogram>" << executable.c_str() << "</mainprogram>\n" + " <mainprogram>" << executable << "</mainprogram>\n" " <directoryradio>custom</directoryradio>\n" - " <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n" + " <customdirectory>"<<outputDir<<"</customdirectory>\n" " <programargs></programargs>\n" " <terminal>false</terminal>\n" " <autocompile>true</autocompile>\n" @@ -457,7 +457,7 @@ void cmGlobalKdevelopGenerator " </run>\n" " <build>\n" " <buildtool>make</buildtool>\n"; //this one is important - fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; //and this one + fout<<" <builddir>"<<outputDir<<"</builddir>\n"; //and this one fout<<" </build>\n" " <make>\n" " <abortonerror>false</abortonerror>\n" @@ -480,7 +480,7 @@ void cmGlobalKdevelopGenerator dirIt != this->Blacklist.end(); ++dirIt) { - fout<<" <path>" << dirIt->c_str() << "</path>\n"; + fout<<" <path>" << *dirIt << "</path>\n"; } fout<<" </blacklist>\n"; @@ -558,7 +558,7 @@ void cmGlobalKdevelopGenerator // command fout<<" <kdevfileview>\n" " <groups>\n" - " <group pattern=\"" << cmakeFilePattern.c_str() << + " <group pattern=\"" << cmakeFilePattern << "\" name=\"CMake\" />\n"; if (enableCxx) @@ -601,7 +601,7 @@ void cmGlobalKdevelopGenerator "<!DOCTYPE KDevPrjSession>\n" "<KDevPrjSession>\n" " <DocsAndViews NumberOfDocuments=\"1\" >\n" - " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen.c_str() << + " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen << "\" >\n" " <View0 line=\"0\" Type=\"Source\" />\n" " </Doc0>\n" diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h index a1ad39d..0d59fc5 100644 --- a/Source/cmGlobalKdevelopGenerator.h +++ b/Source/cmGlobalKdevelopGenerator.h @@ -33,14 +33,14 @@ class cmGlobalKdevelopGenerator : public cmExternalMakefileProjectGenerator public: cmGlobalKdevelopGenerator(); - virtual const char* GetName() const + virtual std::string GetName() const { return cmGlobalKdevelopGenerator::GetActualName();} - static const char* GetActualName() { return "KDevelop3";} + static std::string GetActualName() { return "KDevelop3";} static cmExternalMakefileProjectGenerator* New() { return new cmGlobalKdevelopGenerator; } /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, - const char* fullName) const; + const std::string& fullName) const; virtual void Generate(); private: diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index 659de11..c4825bd 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -28,9 +28,9 @@ public: <cmGlobalMSYSMakefileGenerator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalMSYSMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "MSYS Makefiles";} + static std::string GetActualName() {return "MSYS Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index 7951e98..4289422 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory <cmGlobalMinGWMakefileGenerator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalMinGWMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "MinGW Makefiles";} + static std::string GetActualName() {return "MinGW Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 5756fbd..2ff44e3 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory <cmGlobalNMakeMakefileGenerator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalNMakeMakefileGenerator::GetActualName();} - static const char* GetActualName() {return "NMake Makefiles";} + static std::string GetActualName() {return "NMake Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 731bc00..88f1b08 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -19,6 +19,7 @@ #include "cmVersion.h" #include <algorithm> +#include <assert.h> const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja"; const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja"; @@ -551,11 +552,11 @@ bool cmGlobalNinjaGenerator::UsingMinGW = false; // cmGlobalGenerator::Build() void cmGlobalNinjaGenerator ::GenerateBuildCommand(std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* /*projectName*/, - const char* /*projectDir*/, - const char* targetName, - const char* /*config*/, + const std::string& makeProgram, + const std::string& /*projectName*/, + const std::string& /*projectDir*/, + const std::string& targetName, + const std::string& /*config*/, bool /*fast*/, std::vector<std::string> const& makeOptions) { @@ -565,9 +566,9 @@ void cmGlobalNinjaGenerator makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); - if(targetName && *targetName) + if(!targetName.empty()) { - if(strcmp(targetName, "clean") == 0) + if(targetName == "clean") { makeCommand.push_back("-t"); makeCommand.push_back("clean"); @@ -631,31 +632,19 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const return cmSystemTools::GetCMakeGUICommand(); } -// TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. -void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const +//---------------------------------------------------------------------------- +void cmGlobalNinjaGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += gt->LocalGenerator->GetTargetDirectory(*target); - dir_max += "/"; - gt->ObjectDirectory = dir_max; - - std::vector<cmSourceFile*> objectSources; - gt->GetObjectSources(objectSources); - // Compute the name of each object file. - for(std::vector<cmSourceFile*>::iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max); - gt->AddObject(sf, objectName); - } + std::string dir; + dir += gt->Makefile->GetCurrentOutputDirectory(); + dir += "/"; + dir += gt->LocalGenerator->GetTargetDirectory(*target); + dir += "/"; + gt->ObjectDirectory = dir; } //---------------------------------------------------------------------------- @@ -834,8 +823,8 @@ void cmGlobalNinjaGenerator ::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs) { - const char* configName = - target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); + std::string configName = + target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); @@ -886,7 +875,7 @@ cmGlobalNinjaGenerator if (target->GetType() == cmTarget::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in // the TargetDepends set (e.g. "all"). - std::set<cmStdString> const& utils = target->GetUtilities(); + std::set<std::string> const& utils = target->GetUtilities(); std::copy(utils.begin(), utils.end(), std::back_inserter(outputs)); } else { cmTargetDependSet const& targetDeps = @@ -1159,7 +1148,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) { WriteRule(*this->RulesFileStream, "CLEAN", - (ninjaCmd() + " -t clean").c_str(), + ninjaCmd() + " -t clean", "Cleaning all built files...", "Rule for cleaning all built files.", /*depfile=*/ "", @@ -1182,7 +1171,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) { WriteRule(*this->RulesFileStream, "HELP", - (ninjaCmd() + " -t targets").c_str(), + ninjaCmd() + " -t targets", "All primary targets available:", "Rule for printing all primary targets available.", /*depfile=*/ "", diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 0d5fb44..f2643af 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -173,11 +173,11 @@ public: virtual cmLocalGenerator* CreateLocalGenerator(); /// Overloaded methods. @see cmGlobalGenerator::GetName(). - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } /// @return the name of this generator. - static const char* GetActualName() { return "Ninja"; } + static std::string GetActualName() { return "Ninja"; } /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() static void GetDocumentation(cmDocumentationEntry& entry); @@ -193,11 +193,11 @@ public: /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, std::vector<std::string> const& makeOptions = std::vector<std::string>() ); @@ -299,7 +299,7 @@ public: void AddTargetAlias(const std::string& alias, cmTarget* target); - + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: /// Overloaded methods. @@ -310,8 +310,6 @@ protected: private: virtual std::string GetEditCacheCommand() const; - /// @see cmGlobalGenerator::ComputeTargetObjects - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; void OpenBuildFileStream(); void CloseBuildFileStream(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0b37a07..3aa293e 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -72,7 +72,7 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const { // If generating for an extra IDE, the edit_cache target cannot // launch a terminal-interactive tool, so always use cmake-gui. - if(this->GetExtraGeneratorName()) + if(!this->GetExtraGeneratorName().empty()) { return cmSystemTools::GetCMakeGUICommand(); } @@ -106,35 +106,17 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 -::ComputeTargetObjects(cmGeneratorTarget* gt) const +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; - cmLocalUnixMakefileGenerator3* lg = - static_cast<cmLocalUnixMakefileGenerator3*>(gt->LocalGenerator); // Compute full path to object file directory for this target. - std::string dir_max; - dir_max += gt->Makefile->GetCurrentOutputDirectory(); - dir_max += "/"; - dir_max += gt->LocalGenerator->GetTargetDirectory(*target); - dir_max += "/"; - gt->ObjectDirectory = dir_max; - - std::vector<cmSourceFile*> objectSources; - gt->GetObjectSources(objectSources); - // Compute the name of each object file. - for(std::vector<cmSourceFile*>::iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - bool hasSourceExtension = true; - std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max, - &hasSourceExtension); - gt->AddObject(sf, objectName); - lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension); - } + std::string dir; + dir += gt->Makefile->GetCurrentOutputDirectory(); + dir += "/"; + dir += gt->LocalGenerator->GetTargetDirectory(*target); + dir += "/"; + gt->ObjectDirectory = dir; } void cmGlobalUnixMakefileGenerator3::Configure() @@ -356,14 +338,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() << "# The top level Makefile was generated from the following files:\n" << "set(CMAKE_MAKEFILE_DEPENDS\n" << " \"" - << lg->Convert(cache.c_str(), - cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"; + << lg->Convert(cache, + cmLocalGenerator::START_OUTPUT) << "\"\n"; for(std::vector<std::string>::const_iterator i = lfiles.begin(); i != lfiles.end(); ++i) { cmakefileStream << " \"" - << lg->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT).c_str() + << lg->Convert(*i, cmLocalGenerator::START_OUTPUT) << "\"\n"; } cmakefileStream @@ -379,11 +361,11 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() << "# The corresponding makefile is:\n" << "set(CMAKE_MAKEFILE_OUTPUTS\n" << " \"" - << lg->Convert(makefileName.c_str(), - cmLocalGenerator::START_OUTPUT).c_str() << "\"\n" + << lg->Convert(makefileName, + cmLocalGenerator::START_OUTPUT) << "\"\n" << " \"" - << lg->Convert(check.c_str(), - cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"; + << lg->Convert(check, + cmLocalGenerator::START_OUTPUT) << "\"\n"; cmakefileStream << " )\n\n"; // CMake must rerun if a byproduct is missing. @@ -397,7 +379,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() k != outfiles.end(); ++k) { cmakefileStream << " \"" << - lg->Convert(k->c_str(),cmLocalGenerator::HOME_OUTPUT).c_str() + lg->Convert(*k,cmLocalGenerator::HOME_OUTPUT) << "\"\n"; } @@ -411,7 +393,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() tmpStr += cmake::GetCMakeFilesDirectory(); tmpStr += "/CMakeDirectoryInformation.cmake"; cmakefileStream << " \"" << - lg->Convert(tmpStr.c_str(),cmLocalGenerator::HOME_OUTPUT).c_str() + lg->Convert(tmpStr,cmLocalGenerator::HOME_OUTPUT) << "\"\n"; } cmakefileStream << " )\n\n"; @@ -450,7 +432,7 @@ void cmGlobalUnixMakefileGenerator3 std::string tname = lg->GetRelativeTargetDirectory(l->second); tname += "/DependInfo.cmake"; cmSystemTools::ConvertToUnixSlashes(tname); - cmakefileStream << " \"" << tname.c_str() << "\"\n"; + cmakefileStream << " \"" << tname << "\"\n"; } } } @@ -477,24 +459,26 @@ cmGlobalUnixMakefileGenerator3 for(cmGeneratorTargetsType::iterator l = targets.begin(); l != targets.end(); ++l) { - if((l->second->GetType() == cmTarget::EXECUTABLE) || - (l->second->GetType() == cmTarget::STATIC_LIBRARY) || - (l->second->GetType() == cmTarget::SHARED_LIBRARY) || - (l->second->GetType() == cmTarget::MODULE_LIBRARY) || - (l->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (l->second->GetType() == cmTarget::UTILITY)) + cmGeneratorTarget* gtarget = l->second; + int type = gtarget->GetType(); + if((type == cmTarget::EXECUTABLE) || + (type == cmTarget::STATIC_LIBRARY) || + (type == cmTarget::SHARED_LIBRARY) || + (type == cmTarget::MODULE_LIBRARY) || + (type == cmTarget::OBJECT_LIBRARY) || + (type == cmTarget::UTILITY)) { - if(l->second->Target->IsImported()) + if(gtarget->Target->IsImported()) { continue; } // Add this to the list of depends rules in this directory. - if((!check_all || !l->second->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && + if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - l->second->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))) + gtarget->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName))) { - std::string tname = lg->GetRelativeTargetDirectory(*l->second->Target); + std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); tname += "/"; tname += pass; depends.push_back(tname); @@ -528,7 +512,7 @@ cmGlobalUnixMakefileGenerator3 doc += "\" pass in the directory."; std::vector<std::string> no_commands; lg->WriteMakeRule(ruleFileStream, doc.c_str(), - makeTarget.c_str(), depends, no_commands, true); + makeTarget, depends, no_commands, true); } //---------------------------------------------------------------------------- @@ -545,7 +529,7 @@ cmGlobalUnixMakefileGenerator3 // Begin the directory-level rules section. std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); - dir = lg->Convert(dir.c_str(), cmLocalGenerator::HOME_OUTPUT, + dir = lg->Convert(dir, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); lg->WriteDivider(ruleFileStream); ruleFileStream @@ -565,11 +549,11 @@ cmGlobalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 ::GenerateBuildCommand(std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* /*projectName*/, - const char* /*projectDir*/, - const char* targetName, - const char* /*config*/, + const std::string& makeProgram, + const std::string& /*projectName*/, + const std::string& /*projectDir*/, + const std::string& targetName, + const std::string& /*config*/, bool fast, std::vector<std::string> const& makeOptions) { @@ -579,13 +563,13 @@ void cmGlobalUnixMakefileGenerator3 // Since we have full control over the invocation of nmake, let us // make it quiet. - if ( strcmp(this->GetName(), "NMake Makefiles") == 0 ) + if ( this->GetName() == "NMake Makefiles" ) { makeCommand.push_back("/NOLOGO"); } makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); - if ( targetName && strlen(targetName)) + if (!targetName.empty()) { cmLocalUnixMakefileGenerator3 *lg; if (this->LocalGenerators.size()) @@ -610,7 +594,7 @@ void cmGlobalUnixMakefileGenerator3 { tname += "/fast"; } - tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT); + tname = lg->Convert(tname,cmLocalGenerator::HOME_OUTPUT); cmSystemTools::ConvertToOutputSlashes(tname); makeCommand.push_back(tname); if (!this->LocalGenerators.size()) @@ -624,7 +608,7 @@ void cmGlobalUnixMakefileGenerator3 void cmGlobalUnixMakefileGenerator3 ::WriteConvenienceRules(std::ostream& ruleFileStream, - std::set<cmStdString> &emitted) + std::set<std::string> &emitted) { std::vector<std::string> depends; std::vector<std::string> commands; @@ -643,46 +627,48 @@ cmGlobalUnixMakefileGenerator3 for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if(t->second->Target->IsImported()) + cmGeneratorTarget* gtarget = t->second; + if(gtarget->Target->IsImported()) { continue; } // Don't emit the same rule twice (e.g. two targets with the same // simple name) - if(t->second->GetName() && - strlen(t->second->GetName()) && - emitted.insert(t->second->GetName()).second && + int type = gtarget->GetType(); + std::string name = gtarget->GetName(); + if(!name.empty() && + emitted.insert(name).second && // Handle user targets here. Global targets are handled in // the local generator on a per-directory basis. - ((t->second->GetType() == cmTarget::EXECUTABLE) || - (t->second->GetType() == cmTarget::STATIC_LIBRARY) || - (t->second->GetType() == cmTarget::SHARED_LIBRARY) || - (t->second->GetType() == cmTarget::MODULE_LIBRARY) || - (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::UTILITY))) + ((type == cmTarget::EXECUTABLE) || + (type == cmTarget::STATIC_LIBRARY) || + (type == cmTarget::SHARED_LIBRARY) || + (type == cmTarget::MODULE_LIBRARY) || + (type == cmTarget::OBJECT_LIBRARY) || + (type == cmTarget::UTILITY))) { // Add a rule to build the target by name. lg->WriteDivider(ruleFileStream); ruleFileStream << "# Target rules for targets named " - << t->second->GetName() << "\n\n"; + << name << "\n\n"; // Write the rule. commands.clear(); std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); tmp += "Makefile2"; commands.push_back(lg->GetRecursiveMakeCall - (tmp.c_str(),t->second->GetName())); + (tmp.c_str(),name)); depends.clear(); depends.push_back("cmake_check_build_system"); lg->WriteMakeRule(ruleFileStream, "Build rule for target.", - t->second->GetName(), depends, commands, + name, depends, commands, true); // Add a fast rule to build the target std::string localName = - lg->GetRelativeTargetDirectory(*t->second->Target); + lg->GetRelativeTargetDirectory(*gtarget->Target); std::string makefileName; makefileName = localName; makefileName += "/build.make"; @@ -690,29 +676,29 @@ cmGlobalUnixMakefileGenerator3 commands.clear(); std::string makeTargetName = localName; makeTargetName += "/build"; - localName = t->second->GetName(); + localName = name; localName += "/fast"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(), makeTargetName.c_str())); + (makefileName.c_str(), makeTargetName)); lg->WriteMakeRule(ruleFileStream, "fast build rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) + if(gtarget->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName)) { - makeTargetName = lg->GetRelativeTargetDirectory(*t->second->Target); + makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); makeTargetName += "/preinstall"; - localName = t->second->GetName(); + localName = name; localName += "/preinstall"; depends.clear(); commands.clear(); commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(), makeTargetName.c_str())); + (makefileName.c_str(), makeTargetName)); lg->WriteMakeRule(ruleFileStream, "Manual pre-install relink rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); } } } @@ -742,26 +728,28 @@ cmGlobalUnixMakefileGenerator3 for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if(t->second->Target->IsImported()) + cmGeneratorTarget* gtarget = t->second; + if(gtarget->Target->IsImported()) { continue; } - if (t->second->GetName() - && strlen(t->second->GetName()) - && ((t->second->GetType() == cmTarget::EXECUTABLE) - || (t->second->GetType() == cmTarget::STATIC_LIBRARY) - || (t->second->GetType() == cmTarget::SHARED_LIBRARY) - || (t->second->GetType() == cmTarget::MODULE_LIBRARY) - || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) - || (t->second->GetType() == cmTarget::UTILITY))) + int type = gtarget->GetType(); + std::string name = gtarget->GetName(); + if (!name.empty() + && ( (type == cmTarget::EXECUTABLE) + || (type == cmTarget::STATIC_LIBRARY) + || (type == cmTarget::SHARED_LIBRARY) + || (type == cmTarget::MODULE_LIBRARY) + || (type == cmTarget::OBJECT_LIBRARY) + || (type == cmTarget::UTILITY))) { std::string makefileName; // Add a rule to build the target by name. - localName = lg->GetRelativeTargetDirectory(*t->second->Target); + localName = lg->GetRelativeTargetDirectory(*gtarget->Target); makefileName = localName; makefileName += "/build.make"; - bool needRequiresStep = this->NeedRequiresStep(*t->second->Target); + bool needRequiresStep = this->NeedRequiresStep(*gtarget->Target); lg->WriteDivider(ruleFileStream); ruleFileStream @@ -772,7 +760,7 @@ cmGlobalUnixMakefileGenerator3 makeTargetName = localName; makeTargetName += "/depend"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); + (makefileName.c_str(),makeTargetName)); // add requires if we need it for this generator if (needRequiresStep) @@ -780,12 +768,12 @@ cmGlobalUnixMakefileGenerator3 makeTargetName = localName; makeTargetName += "/requires"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); + (makefileName.c_str(),makeTargetName)); } makeTargetName = localName; makeTargetName += "/build"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); + (makefileName.c_str(),makeTargetName)); // Write the rule. localName += "/all"; @@ -798,12 +786,12 @@ cmGlobalUnixMakefileGenerator3 cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; // all target counts - progCmd << lg->Convert(progressDir.c_str(), + progCmd << lg->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " "; std::vector<unsigned long>& progFiles = - this->ProgressMap[t->second->Target].Marks; + this->ProgressMap[gtarget->Target].Marks; for (std::vector<unsigned long>::iterator i = progFiles.begin(); i != progFiles.end(); ++i) { @@ -812,15 +800,15 @@ cmGlobalUnixMakefileGenerator3 commands.push_back(progCmd.str()); } progressDir = "Built target "; - progressDir += t->second->GetName(); + progressDir += name; lg->AppendEcho(commands,progressDir.c_str()); - this->AppendGlobalTargetDepends(depends,*t->second->Target); + this->AppendGlobalTargetDepends(depends,*gtarget->Target); lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) { depends.clear(); depends.push_back(localName); @@ -839,23 +827,23 @@ cmGlobalUnixMakefileGenerator3 cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # in target - progCmd << lg->Convert(progressDir.c_str(), + progCmd << lg->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); // std::set<cmTarget const*> emitted; progCmd << " " - << this->CountProgressMarksInTarget(t->second->Target, emitted); + << this->CountProgressMarksInTarget(gtarget->Target, emitted); commands.push_back(progCmd.str()); } std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); tmp += "Makefile2"; commands.push_back(lg->GetRecursiveMakeCall - (tmp.c_str(),localName.c_str())); + (tmp.c_str(),localName)); { cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 - progCmd << lg->Convert(progressDir.c_str(), + progCmd << lg->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " 0"; @@ -863,34 +851,34 @@ cmGlobalUnixMakefileGenerator3 } depends.clear(); depends.push_back("cmake_check_build_system"); - localName = lg->GetRelativeTargetDirectory(*t->second->Target); + localName = lg->GetRelativeTargetDirectory(*gtarget->Target); localName += "/rule"; lg->WriteMakeRule(ruleFileStream, "Build rule for subdir invocation for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // Add a target with the canonical name (no prefix, suffix or path). commands.clear(); depends.clear(); depends.push_back(localName); lg->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second->GetName(), depends, commands, true); + name, depends, commands, true); // Add rules to prepare the target for installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) + if(gtarget->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName)) { - localName = lg->GetRelativeTargetDirectory(*t->second->Target); + localName = lg->GetRelativeTargetDirectory(*gtarget->Target); localName += "/preinstall"; depends.clear(); commands.clear(); commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(), localName.c_str())); + (makefileName.c_str(), localName)); lg->WriteMakeRule(ruleFileStream, "Pre-install relink rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target)) + if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target)) { depends.clear(); depends.push_back(localName); @@ -901,15 +889,15 @@ cmGlobalUnixMakefileGenerator3 } // add the clean rule - localName = lg->GetRelativeTargetDirectory(*t->second->Target); + localName = lg->GetRelativeTargetDirectory(*gtarget->Target); makeTargetName = localName; makeTargetName += "/clean"; depends.clear(); commands.clear(); commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(), makeTargetName.c_str())); + (makefileName.c_str(), makeTargetName)); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", - makeTargetName.c_str(), depends, commands, true); + makeTargetName, depends, commands, true); commands.clear(); depends.push_back(makeTargetName); lg->WriteMakeRule(ruleFileStream, "clean rule for target.", @@ -970,21 +958,6 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress( } //---------------------------------------------------------------------------- -bool -cmGlobalUnixMakefileGenerator3::ProgressMapCompare -::operator()(cmTarget const* l, cmTarget const* r) const -{ - // Order by target name. - if(int c = strcmp(l->GetName(), r->GetName())) - { - return c < 0; - } - // Order duplicate targets by binary directory. - return strcmp(l->GetMakefile()->GetCurrentOutputDirectory(), - r->GetMakefile()->GetCurrentOutputDirectory()) < 0; -} - -//---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3::TargetProgress ::WriteProgressVariables(unsigned long total, unsigned long ¤t) @@ -1051,7 +1024,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule lg->AppendEcho(commands,"... depend"); // Keep track of targets already listed. - std::set<cmStdString> emittedTargets; + std::set<std::string> emittedTargets; // for each local generator unsigned int i; @@ -1068,26 +1041,29 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule cmTargets& targets = lg2->GetMakefile()->GetTargets(); for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY) || - (t->second.GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second.GetType() == cmTarget::GLOBAL_TARGET) || - (t->second.GetType() == cmTarget::UTILITY)) + cmTarget const& target = t->second; + cmTarget::TargetType type = target.GetType(); + if((type == cmTarget::EXECUTABLE) || + (type == cmTarget::STATIC_LIBRARY) || + (type == cmTarget::SHARED_LIBRARY) || + (type == cmTarget::MODULE_LIBRARY) || + (type == cmTarget::OBJECT_LIBRARY) || + (type == cmTarget::GLOBAL_TARGET) || + (type == cmTarget::UTILITY)) { - if(emittedTargets.insert(t->second.GetName()).second) + std::string name = target.GetName(); + if(emittedTargets.insert(name).second) { path = "... "; - path += t->second.GetName(); + path += name; lg->AppendEcho(commands,path.c_str()); } } } } } - std::vector<cmStdString> const& localHelp = lg->GetLocalHelp(); - for(std::vector<cmStdString>::const_iterator o = localHelp.begin(); + std::vector<std::string> const& localHelp = lg->GetLocalHelp(); + for(std::vector<std::string>::const_iterator o = localHelp.begin(); o != localHelp.end(); ++o) { path = "... "; @@ -1104,15 +1080,15 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule bool cmGlobalUnixMakefileGenerator3 ::NeedRequiresStep(cmTarget const& target) { - std::set<cmStdString> languages; + std::set<std::string> languages; target.GetLanguages(languages); - for(std::set<cmStdString>::const_iterator l = languages.begin(); + for(std::set<std::string>::const_iterator l = languages.begin(); l != languages.end(); ++l) { std::string var = "CMAKE_NEEDS_REQUIRES_STEP_"; var += *l; var += "_FLAG"; - if(target.GetMakefile()->GetDefinition(var.c_str())) + if(target.GetMakefile()->GetDefinition(var)) { return true; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 9173751..f44dd12 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -60,9 +60,9 @@ public: <cmGlobalUnixMakefileGenerator3>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalUnixMakefileGenerator3::GetActualName();} - static const char* GetActualName() {return "Unix Makefiles";} + static std::string GetActualName() {return "Unix Makefiles";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -96,7 +96,7 @@ public: // write the top level target rules void WriteConvenienceRules(std::ostream& ruleFileStream, - std::set<cmStdString> &emitted); + std::set<std::string> &emitted); /** Get the command to use for a target that has no rule. This is used for multiple output dependencies and for cmake_force. */ @@ -109,11 +109,11 @@ public: // change the build command for speed virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, std::vector<std::string> const& makeOptions = std::vector<std::string>() ); @@ -128,6 +128,7 @@ public: /** Does the make tool tolerate .NOTPARALLEL? */ virtual bool AllowNotParallel() const { return true; } + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: void WriteMainMakefile2(); void WriteMainCMakefile(); @@ -184,10 +185,8 @@ protected: std::vector<unsigned long> Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; - struct ProgressMapCompare { bool operator()(cmTarget const*, - cmTarget const*) const; }; typedef std::map<cmTarget const*, TargetProgress, - ProgressMapCompare> ProgressMapType; + cmStrictTargetComparison> ProgressMapType; ProgressMapType ProgressMap; size_t CountProgressMarksInTarget(cmTarget const* target, @@ -198,7 +197,6 @@ protected: private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; }; #endif diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 6983ef9..37a416b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -21,13 +21,14 @@ static const char vs10generatorName[] = "Visual Studio 10 2010"; // Map generator name without year to name with year. -static const char* cmVS10GenName(const char* name, std::string& genName) +static const char* cmVS10GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0) + if(strncmp(name.c_str(), vs10generatorName, + sizeof(vs10generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs10generatorName) - 6; + const char* p = name.c_str() + sizeof(vs10generatorName) - 6; if(cmHasLiteralPrefix(p, " 2010")) { p += 5; @@ -40,27 +41,27 @@ class cmGlobalVisualStudio10Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS10GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio10Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio10Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " IA64") == 0) { return new cmGlobalVisualStudio10Generator( - name, "Itanium", "CMAKE_FORCE_IA64"); + genName, "Itanium", "CMAKE_FORCE_IA64"); } return 0; } @@ -87,8 +88,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { @@ -102,7 +103,8 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio10Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS10GenName(name, genName)) @@ -310,11 +312,11 @@ std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand() //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, std::vector<std::string> const& makeOptions) { @@ -334,7 +336,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( cmSlnData slnData; { std::string slnFile; - if(projectDir && *projectDir) + if(!projectDir.empty()) { slnFile = projectDir; slnFile += "/"; @@ -369,25 +371,26 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( makeCommand.push_back(makeProgramSelected); + std::string realTarget = targetName; // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD - if(!targetName || strlen(targetName) == 0) + if(realTarget.empty()) { - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } - if ( targetName && strcmp(targetName, "clean") == 0 ) + if ( realTarget == "clean" ) { makeCommand.push_back(std::string(projectName)+".sln"); makeCommand.push_back("/t:Clean"); } else { - std::string targetProject(targetName); + std::string targetProject(realTarget); targetProject += ".vcxproj"; if (targetProject.find('/') == std::string::npos) { // it might be in a subdir if (cmSlnProjectEntry const* proj = - slnData.GetProjectByName(targetName)) + slnData.GetProjectByName(realTarget)) { targetProject = proj->GetRelativePath(); cmSystemTools::ConvertToUnixSlashes(targetProject); @@ -396,7 +399,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( makeCommand.push_back(targetProject); } std::string configArg = "/p:Configuration="; - if(config && strlen(config)) + if(!config.empty()) { configArg += config; } @@ -467,7 +470,7 @@ cmGlobalVisualStudio10Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::PathTooLong( - cmTarget* target, cmSourceFile* sf, std::string const& sfRel) + cmTarget* target, cmSourceFile const* sf, std::string const& sfRel) { size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) + 1 + sfRel.length()); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 976d41f..ede6b1b 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -24,21 +24,22 @@ class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio10Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio10Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual bool SetGeneratorToolset(std::string const& ts); virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, std::vector<std::string> const& makeOptions = std::vector<std::string>() ); @@ -86,7 +87,7 @@ public: /** Generate an <output>.rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; - void PathTooLong(cmTarget* target, cmSourceFile* sf, + void PathTooLong(cmTarget* target, cmSourceFile const* sf, std::string const& sfRel); virtual const char* GetToolsVersion() { return "4.0"; } @@ -111,7 +112,7 @@ private: LongestSourcePath(): Length(0), Target(0), SourceFile(0) {} size_t Length; cmTarget* Target; - cmSourceFile* SourceFile; + cmSourceFile const* SourceFile; std::string SourceRel; }; LongestSourcePath LongestSource; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 1f0c47a..4caa7f2 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -16,13 +16,14 @@ static const char vs11generatorName[] = "Visual Studio 11 2012"; // Map generator name without year to name with year. -static const char* cmVS11GenName(const char* name, std::string& genName) +static const char* cmVS11GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs11generatorName, sizeof(vs11generatorName)-6) != 0) + if(strncmp(name.c_str(), vs11generatorName, + sizeof(vs11generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs11generatorName) - 6; + const char* p = name.c_str() + sizeof(vs11generatorName) - 6; if(cmHasLiteralPrefix(p, " 2012")) { p += 5; @@ -35,27 +36,27 @@ class cmGlobalVisualStudio11Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS11GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio11Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio11Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio11Generator( - name, "ARM", NULL); + genName, "ARM", ""); } if(*p++ != ' ') @@ -107,8 +108,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio10Generator(name, platformName, additionalPlatformDefinition) { @@ -121,7 +122,8 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio11Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio11Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS11GenName(name, genName)) diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 7ef77e7..48ea489 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -20,11 +20,12 @@ class cmGlobalVisualStudio11Generator: public cmGlobalVisualStudio10Generator { public: - cmGlobalVisualStudio11Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio11Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 3074794..6cd9f12 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -16,13 +16,14 @@ static const char vs12generatorName[] = "Visual Studio 12 2013"; // Map generator name without year to name with year. -static const char* cmVS12GenName(const char* name, std::string& genName) +static const char* cmVS12GenName(const std::string& name, std::string& genName) { - if(strncmp(name, vs12generatorName, sizeof(vs12generatorName)-6) != 0) + if(strncmp(name.c_str(), vs12generatorName, + sizeof(vs12generatorName)-6) != 0) { return 0; } - const char* p = name + sizeof(vs12generatorName) - 6; + const char* p = name.c_str() + sizeof(vs12generatorName) - 6; if(cmHasLiteralPrefix(p, " 2013")) { p += 5; @@ -35,27 +36,27 @@ class cmGlobalVisualStudio12Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { std::string genName; const char* p = cmVS12GenName(name, genName); if(!p) { return 0; } - name = genName.c_str(); if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio12Generator( - name, NULL, NULL); + genName, "", ""); } if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio12Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + genName, "x64", "CMAKE_FORCE_WIN64"); } if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio12Generator( - name, "ARM", NULL); + genName, "ARM", ""); } return 0; } @@ -82,8 +83,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio11Generator(name, platformName, additionalPlatformDefinition) { @@ -96,7 +97,8 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( //---------------------------------------------------------------------------- bool -cmGlobalVisualStudio12Generator::MatchesGeneratorName(const char* name) const +cmGlobalVisualStudio12Generator::MatchesGeneratorName( + const std::string& name) const { std::string genName; if(cmVS12GenName(name, genName)) diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 5a4a78d..4557f28 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -20,11 +20,12 @@ class cmGlobalVisualStudio12Generator: public cmGlobalVisualStudio11Generator { public: - cmGlobalVisualStudio12Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio12Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); - virtual bool MatchesGeneratorName(const char* name) const; + virtual bool MatchesGeneratorName(const std::string& name) const; virtual void WriteSLNHeader(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 6c458c3..7397bbb 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -116,11 +116,11 @@ std::string cmGlobalVisualStudio6Generator::FindMSDevCommand() void cmGlobalVisualStudio6Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* /*projectDir*/, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& /*projectDir*/, + const std::string& targetName, + const std::string& config, bool /*fast*/, std::vector<std::string> const& makeOptions ) @@ -134,21 +134,22 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( makeCommand.push_back("/MAKE"); std::string targetArg; bool clean = false; - if ( targetName && strcmp(targetName, "clean") == 0 ) + std::string realTarget = targetName; + if ( realTarget == "clean" ) { clean = true; - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } - if (targetName && strlen(targetName)) + if (!realTarget.empty()) { - targetArg += targetName; + targetArg += realTarget; } else { targetArg += "ALL_BUILD"; } targetArg += " - "; - if(config && strlen(config)) + if(!config.empty()) { targetArg += config; } @@ -259,7 +260,7 @@ void cmGlobalVisualStudio6Generator // output the DSW file void cmGlobalVisualStudio6Generator::OutputDSWFile() { - std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; + std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { this->OutputDSWFile(it->second[0], it->second); @@ -270,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile() // Note, that dependencies from executables to // the libraries it uses are also done here void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, - const char* dspname, + const std::string& dspname, const char* dir, cmTarget const& target) { @@ -315,9 +316,9 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, // Note, that dependencies from executables to // the libraries it uses are also done here void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* location, - const std::set<cmStdString>& dependencies) + const std::set<std::string>& dependencies) { fout << "#########################################################" "######################\n\n"; @@ -328,7 +329,7 @@ void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout, fout << "{{{\n"; - std::set<cmStdString>::const_iterator i, end; + std::set<std::string>::const_iterator i, end; // write dependencies. i = dependencies.begin(); end = dependencies.end(); @@ -417,12 +418,12 @@ void cmGlobalVisualStudio6Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio6Generator -::AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, +::AppendDirectoryForConfig(const std::string& prefix, + const std::string& config, + const std::string& suffix, std::string& dir) { - if(config) + if(!config.empty()) { dir += prefix; dir += config; diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 5521410..2797e11 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -31,9 +31,9 @@ public: <cmGlobalVisualStudio6Generator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio6Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 6";} + static std::string GetActualName() {return "Visual Studio 6";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -54,11 +54,11 @@ public: */ virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, std::vector<std::string> const& makeOptions = std::vector<std::string>() ); @@ -81,9 +81,9 @@ public: std::vector<cmLocalGenerator*>& generators); /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, + virtual void AppendDirectoryForConfig(const std::string& prefix, + const std::string& config, + const std::string& suffix, std::string& dir); ///! What is the configurations directory variable called? @@ -99,10 +99,11 @@ private: void WriteDSWFile(std::ostream& fout); void WriteDSWHeader(std::ostream& fout); void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget const& t); + const std::string& name, const char* path, + cmTarget const& t); void WriteExternalProject(std::ostream& fout, - const char* name, const char* path, - const std::set<cmStdString>& dependencies); + const std::string& name, const char* path, + const std::set<std::string>& dependencies); void WriteDSWFooter(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget const* target); std::string MSDevCommand; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 22e4f08..4bea5ac 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -17,7 +17,8 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator( - const char* platformName) : cmGlobalVisualStudio7Generator(platformName) + const std::string& platformName) + : cmGlobalVisualStudio7Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfiguration"; } @@ -155,7 +156,7 @@ cmGlobalVisualStudio71Generator // the libraries it uses are also done here void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, - const char* dspname, + const std::string& dspname, const char* dir, cmTarget const& t) { @@ -208,7 +209,7 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio71Generator ::WriteProjectDepends(std::ostream& fout, - const char*, + const std::string&, const char*, cmTarget const& target) { VSDependSet const& depends = this->VSTargetDepends[&target]; @@ -234,10 +235,10 @@ cmGlobalVisualStudio71Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator ::WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* location, const char* typeGuid, - const std::set<cmStdString>& depends) + const std::set<std::string>& depends) { fout << "Project(\"{" << (typeGuid ? typeGuid : this->ExternalProjectType(location)) @@ -252,7 +253,7 @@ void cmGlobalVisualStudio71Generator if(!depends.empty()) { fout << "\tProjectSection(ProjectDependencies) = postProject\n"; - std::set<cmStdString>::const_iterator it; + std::set<std::string>::const_iterator it; for(it = depends.begin(); it != depends.end(); ++it) { if(it->size() > 0) @@ -277,12 +278,12 @@ void cmGlobalVisualStudio71Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator ::WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType, + std::ostream& fout, const std::string& name, cmTarget::TargetType, const std::set<std::string>& configsPartOfDefaultBuild, - const char* platformMapping) + std::string const& platformMapping) { - const char* platformName = - platformMapping ? platformMapping : this->GetPlatformName(); + const std::string& platformName = + !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 04e3a55..2b5259a 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -23,15 +23,15 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator { public: - cmGlobalVisualStudio71Generator(const char* platformName = NULL); + cmGlobalVisualStudio71Generator(const std::string& platformName = ""); static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory <cmGlobalVisualStudio71Generator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio71Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 7 .NET 2003";} + static std::string GetActualName() {return "Visual Studio 7 .NET 2003";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -59,20 +59,20 @@ protected: std::vector<cmLocalGenerator*>& generators); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, cmTarget const& t); virtual void WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual void WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* path, const char* typeGuid, - const std::set<cmStdString>& depends); + const std::set<std::string>& depends); virtual void WriteSLNHeader(std::ostream& fout); std::string ProjectConfigurationSectionName; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index bb63289..42033c5 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -19,16 +19,19 @@ #include <cmsys/Encoding.hxx> cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( - const char* platformName) + const std::string& platformName) { this->IntelProjectVersion = 0; this->DevEnvCommandInitialized = false; - if (!platformName) + if (platformName.empty()) { - platformName = "Win32"; + this->PlatformName = "Win32"; + } + else + { + this->PlatformName = platformName; } - this->PlatformName = platformName; } cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator() @@ -183,11 +186,11 @@ const char* cmGlobalVisualStudio7Generator::ExternalProjectType( //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* /*projectDir*/, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& /*projectDir*/, + const std::string& targetName, + const std::string& config, bool /*fast*/, std::vector<std::string> const& makeOptions) { @@ -208,11 +211,12 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( makeCommand.push_back(makeProgramSelected); makeCommand.push_back(std::string(projectName) + ".sln"); + std::string realTarget = targetName; bool clean = false; - if ( targetName && strcmp(targetName, "clean") == 0 ) + if ( realTarget == "clean" ) { clean = true; - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } if(clean) { @@ -223,7 +227,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( makeCommand.push_back("/build"); } - if(config && strlen(config)) + if(!config.empty()) { makeCommand.push_back(config); } @@ -233,9 +237,9 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( } makeCommand.push_back("/project"); - if (targetName && strlen(targetName)) + if (!realTarget.empty()) { - makeCommand.push_back(targetName); + makeCommand.push_back(realTarget); } else { @@ -259,7 +263,7 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) { cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName()); + mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str()); mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", this->GetIntelProjectVersion()); } @@ -352,7 +356,7 @@ void cmGlobalVisualStudio7Generator // output the SLN file void cmGlobalVisualStudio7Generator::OutputSLNFile() { - std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; + std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { this->OutputSLNFile(it->second[0], it->second); @@ -380,9 +384,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( { std::set<std::string> allConfigurations(this->Configurations.begin(), this->Configurations.end()); + const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING"); this->WriteProjectConfigurations( - fout, target->GetName(), target->GetType(), - allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING")); + fout, target->GetName().c_str(), target->GetType(), + allConfigurations, mapping ? mapping : ""); } else { @@ -653,7 +658,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) // Note, that dependencies from executables to // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, - const char* dspname, + const std::string& dspname, const char* dir, cmTarget const& target) { // check to see if this is a fortran build @@ -693,7 +698,7 @@ void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio7Generator ::WriteProjectDepends(std::ostream& fout, - const char* dspname, + const std::string& dspname, const char*, cmTarget const& target) { int depcount = 0; @@ -729,12 +734,12 @@ cmGlobalVisualStudio7Generator // executables to the libraries it uses are also done here void cmGlobalVisualStudio7Generator ::WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType, + std::ostream& fout, const std::string& name, cmTarget::TargetType, const std::set<std::string>& configsPartOfDefaultBuild, - const char* platformMapping) + const std::string& platformMapping) { - const char* platformName = - platformMapping ? platformMapping : this->GetPlatformName(); + const std::string& platformName = + !platformMapping.empty() ? platformMapping : this->GetPlatformName(); std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) @@ -757,10 +762,10 @@ void cmGlobalVisualStudio7Generator // Note, that dependencies from executables to // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* location, const char* typeGuid, - const std::set<cmStdString>&) + const std::set<std::string>&) { std::string d = cmSystemTools::ConvertToOutputPath(location); fout << "Project(" @@ -868,7 +873,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) std::string guid = this->GetGUID(pname.c_str()); fout << - "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" + "<?xml version=\"1.0\" encoding = \"" + << this->Encoding() << "\"?>\n" "<VisualStudioProject\n" "\tProjectType=\"Visual C++\"\n" "\tVersion=\"" << this->GetIDEVersion() << "0\"\n" @@ -907,7 +913,7 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) return pname; } -std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name) +std::string cmGlobalVisualStudio7Generator::GetGUID(const std::string& name) { std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; @@ -918,12 +924,12 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name) return std::string(storedGUID); } cmSystemTools::Error("Unknown Target referenced : ", - name); + name.c_str()); return ""; } -void cmGlobalVisualStudio7Generator::CreateGUID(const char* name) +void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name) { std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; @@ -960,12 +966,12 @@ void cmGlobalVisualStudio7Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator -::AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, +::AppendDirectoryForConfig(const std::string& prefix, + const std::string& config, + const std::string& suffix, std::string& dir) { - if(config) + if(!config.empty()) { dir += prefix; dir += config; @@ -974,8 +980,9 @@ cmGlobalVisualStudio7Generator } std::set<std::string> -cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, - cmTarget const* target) +cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( + const std::string& project, + cmTarget const* target) { std::set<std::string> activeConfigs; // if it is a utilitiy target then only make it part of the @@ -1032,3 +1039,14 @@ cmIDEFlagTable const* cmGlobalVisualStudio7Generator::GetExtraFlagTableVS7() { return cmVS7ExtraFlagTable; } + +std::string cmGlobalVisualStudio7Generator::Encoding() +{ + std::ostringstream encoding; +#ifdef CMAKE_ENCODING_UTF8 + encoding << "UTF-8"; +#else + encoding << "Windows-1252"; +#endif + return encoding.str(); +} diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index f69bd84..1dc709d 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -26,7 +26,7 @@ struct cmIDEFlagTable; class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: - cmGlobalVisualStudio7Generator(const char* platformName = NULL); + cmGlobalVisualStudio7Generator(const std::string& platformName = ""); ~cmGlobalVisualStudio7Generator(); static cmGlobalGeneratorFactory* NewFactory() { @@ -34,12 +34,12 @@ public: <cmGlobalVisualStudio7Generator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalVisualStudio7Generator::GetActualName();} - static const char* GetActualName() {return "Visual Studio 7";} + static std::string GetActualName() {return "Visual Studio 7";} ///! Get the name for the platform. - const char* GetPlatformName() const { return this->PlatformName.c_str(); } + const std::string& GetPlatformName() const { return this->PlatformName; } ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); @@ -62,11 +62,11 @@ public: */ virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, std::vector<std::string> const& makeOptions = std::vector<std::string>() ); @@ -89,13 +89,13 @@ public: std::vector<std::string> *GetConfigurations(); ///! Create a GUID or get an existing one. - void CreateGUID(const char* name); - std::string GetGUID(const char* name); + void CreateGUID(const std::string& name); + std::string GetGUID(const std::string& name); /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, + virtual void AppendDirectoryForConfig(const std::string& prefix, + const std::string& config, + const std::string& suffix, std::string& dir); ///! What is the configurations directory variable called? @@ -109,6 +109,9 @@ public: virtual void FindMakeProgram(cmMakefile*); + // Encoding for Visual Studio files + virtual std::string Encoding(); + protected: virtual const char* GetIDEVersion() { return "7.0"; } @@ -123,15 +126,15 @@ protected: virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, + const std::string& name, const char* path, cmTarget const&t); virtual void WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual void WriteSLNGlobalSections(std::ostream& fout, cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); @@ -153,18 +156,18 @@ protected: void GenerateConfigurations(cmMakefile* mf); virtual void WriteExternalProject(std::ostream& fout, - const char* name, + const std::string& name, const char* path, const char* typeGuid, - const std::set<cmStdString>& + const std::set<std::string>& dependencies); std::string ConvertToSolutionPath(const char* path); - std::set<std::string> IsPartOfDefaultBuild(const char* project, + std::set<std::string> IsPartOfDefaultBuild(const std::string& project, cmTarget const* target); std::vector<std::string> Configurations; - std::map<cmStdString, cmStdString> GUIDMap; + std::map<std::string, std::string> GUIDMap; virtual void WriteFolders(std::ostream& fout); virtual void WriteFoldersContent(std::ostream& fout); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 12c240b..ab4380c 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -23,17 +23,19 @@ class cmGlobalVisualStudio8Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs8generatorName) != name) + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { + if(strncmp(name.c_str(), vs8generatorName, + sizeof(vs8generatorName) - 1) != 0) { return 0; } - const char* p = name + sizeof(vs8generatorName) - 1; + const char* p = name.c_str() + sizeof(vs8generatorName) - 1; if(p[0] == '\0') { return new cmGlobalVisualStudio8Generator( - name, NULL, NULL); + name, "", ""); } if(p[0] != ' ') @@ -57,7 +59,7 @@ public: } cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator( - name, p, NULL); + name, p, ""); ret->WindowsCEVersion = parser.GetOSVersion(); return ret; } @@ -90,14 +92,14 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio71Generator(platformName) { this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; - if (additionalPlatformDefinition) + if (!additionalPlatformDefinition.empty()) { this->AdditionalPlatformDefinition = additionalPlatformDefinition; } @@ -314,7 +316,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // file as the main dependency because it would get // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; if(cmSourceFile* file = mf->AddCustomCommandToOutput( stamps, listFiles, @@ -338,7 +340,7 @@ void cmGlobalVisualStudio8Generator::Generate() if(this->AddCheckTarget()) { // All targets depend on the build-system check target. - for(std::map<cmStdString,cmTarget *>::const_iterator + for(std::map<std::string,cmTarget *>::const_iterator ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti) { @@ -372,9 +374,9 @@ cmGlobalVisualStudio8Generator void cmGlobalVisualStudio8Generator ::WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, - const char* platformMapping) + std::string const& platformMapping) { std::string guid = this->GetGUID(name); for(std::vector<std::string>::iterator i = this->Configurations.begin(); @@ -382,7 +384,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; std::set<std::string>::const_iterator ci = configsPartOfDefaultBuild.find(*i); @@ -390,7 +393,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; } bool needsDeploy = (type == cmTarget::EXECUTABLE || @@ -399,7 +403,8 @@ cmGlobalVisualStudio8Generator { fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|" - << (platformMapping ? platformMapping : this->GetPlatformName()) + << (!platformMapping.empty()? + platformMapping : this->GetPlatformName()) << "\n"; } } @@ -415,7 +420,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::WriteProjectDepends( - std::ostream& fout, const char*, const char*, cmTarget const& t) + std::ostream& fout, const std::string&, const char*, cmTarget const& t) { TargetDependSet const& unordered = this->GetTargetDirectDepends(t); OrderedTargetDependSet depends(unordered); @@ -426,7 +431,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends( { continue; } - std::string guid = this->GetGUID((*i)->GetName()); + std::string guid = this->GetGUID((*i)->GetName().c_str()); fout << "\t\t{" << guid << "} = {" << guid << "}\n"; } } @@ -436,11 +441,11 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( cmTarget& target) { // Look for utility dependencies that magically link. - for(std::set<cmStdString>::const_iterator ui = + for(std::set<std::string>::const_iterator ui = target.GetUtilities().begin(); ui != target.GetUtilities().end(); ++ui) { - if(cmTarget* depTarget = this->FindTarget(0, ui->c_str())) + if(cmTarget* depTarget = this->FindTarget(ui->c_str())) { if(depTarget->GetType() != cmTarget::INTERFACE_LIBRARY && depTarget->GetProperty("EXTERNAL_MSPROJECT")) diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 5b952c4..2459c05 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -23,12 +23,13 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: - cmGlobalVisualStudio8Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio8Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual const char* GetName() const {return this->Name.c_str();} + virtual std::string GetName() const {return this->Name;} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -79,11 +80,12 @@ protected: virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProjectConfigurations( - std::ostream& fout, const char* name, cmTarget::TargetType type, + std::ostream& fout, const std::string& name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, - const char* platformMapping = NULL); + const std::string& platformMapping = ""); virtual bool ComputeTargetDepends(); - virtual void WriteProjectDepends(std::ostream& fout, const char* name, + virtual void WriteProjectDepends(std::ostream& fout, + const std::string& name, const char* path, cmTarget const& t); std::string Name; diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index ccc27ad..c0051c7 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -22,17 +22,19 @@ class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs9generatorName) != name) + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const { + if(strncmp(name.c_str(), vs9generatorName, + sizeof(vs9generatorName) - 1) != 0) { return 0; } - const char* p = name + sizeof(vs9generatorName) - 1; + const char* p = name.c_str() + sizeof(vs9generatorName) - 1; if(p[0] == '\0') { return new cmGlobalVisualStudio9Generator( - name, NULL, NULL); + name, "", ""); } if(p[0] != ' ') @@ -96,8 +98,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() //---------------------------------------------------------------------------- cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( - const char* name, const char* platformName, - const char* additionalPlatformDefinition) + const std::string& name, const std::string& platformName, + const std::string& additionalPlatformDefinition) : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h index 202aa8d..fb87bbe 100644 --- a/Source/cmGlobalVisualStudio9Generator.h +++ b/Source/cmGlobalVisualStudio9Generator.h @@ -24,8 +24,9 @@ class cmGlobalVisualStudio9Generator : public cmGlobalVisualStudio8Generator { public: - cmGlobalVisualStudio9Generator(const char* name, - const char* platformName, const char* additionalPlatformDefinition); + cmGlobalVisualStudio9Generator(const std::string& name, + const std::string& platformName, + const std::string& additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 0c5f35b..38f709f 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -1,3 +1,4 @@ + /*============================================================================ CMake - Cross Platform Makefile Generator Copyright 2000-2009 Kitware, Inc., Insight Software Consortium @@ -22,7 +23,7 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() { - this->AdditionalPlatformDefinition = NULL; + this->AdditionalPlatformDefinition = ""; } //---------------------------------------------------------------------------- @@ -53,7 +54,7 @@ void cmGlobalVisualStudioGenerator::Generate() const char* no_working_dir = 0; std::vector<std::string> no_depends; cmCustomCommandLines no_commands; - std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; + std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { std::vector<cmLocalGenerator*>& gen = it->second; @@ -118,51 +119,12 @@ void cmGlobalVisualStudioGenerator::Generate() } //---------------------------------------------------------------------------- -void -cmGlobalVisualStudioGenerator -::ComputeTargetObjects(cmGeneratorTarget* gt) const +void cmGlobalVisualStudioGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { - cmLocalVisualStudioGenerator* lg = - static_cast<cmLocalVisualStudioGenerator*>(gt->LocalGenerator); - std::string dir_max = lg->ComputeLongestObjectDirectory(*gt->Target); - - // Count the number of object files with each name. Note that - // windows file names are not case sensitive. - std::map<cmStdString, int> counts; - std::vector<cmSourceFile*> objectSources; - gt->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectNameLower = cmSystemTools::LowerCase( - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); - objectNameLower += ".obj"; - counts[objectNameLower] += 1; - } - - // For all source files producing duplicate names we need unique - // object name computation. - for(std::vector<cmSourceFile*>::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".obj"; - if(counts[cmSystemTools::LowerCase(objectName)] > 1) - { - gt->AddExplicitObjectName(sf); - objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max); - } - gt->AddObject(sf, objectName); - } - std::string dir = gt->Makefile->GetCurrentOutputDirectory(); dir += "/"; - std::string tgtDir = lg->GetTargetDirectory(*gt->Target); + std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target); if(!tgtDir.empty()) { dir += tgtDir; @@ -380,7 +342,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() { return false; } - std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; + std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { std::vector<cmLocalGenerator*>& gen = it->second; @@ -518,7 +480,7 @@ void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { - if(this->AdditionalPlatformDefinition) + if(!this->AdditionalPlatformDefinition.empty()) { mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE"); } @@ -852,7 +814,7 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // check to see if this is a fortran build - std::set<cmStdString> languages; + std::set<std::string> languages; target.GetLanguages(languages); if(languages.size() == 1) { @@ -870,15 +832,15 @@ cmGlobalVisualStudioGenerator::TargetCompare ::operator()(cmTarget const* l, cmTarget const* r) const { // Make sure ALL_BUILD is first so it is the default active project. - if(strcmp(r->GetName(), "ALL_BUILD") == 0) + if(r->GetName() == "ALL_BUILD") { return false; } - if(strcmp(l->GetName(), "ALL_BUILD") == 0) + if(l->GetName() == "ALL_BUILD") { return true; } - return strcmp(l->GetName(), r->GetName()) < 0; + return strcmp(l->GetName().c_str(), r->GetName().c_str()) < 0; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 9186d65..1ab8990 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -88,6 +88,7 @@ public: virtual std::string ExpandCFGIntDir(const std::string& str, const std::string& config) const; + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions @@ -99,23 +100,23 @@ protected: virtual void AddPlatformDefinitions(cmMakefile* mf); virtual bool ComputeTargetDepends(); - class VSDependSet: public std::set<cmStdString> {}; + class VSDependSet: public std::set<std::string> {}; class VSDependMap: public std::map<cmTarget const*, VSDependSet> {}; VSDependMap VSTargetDepends; void ComputeVSTargetDepends(cmTarget&); - bool CheckTargetLinks(cmTarget& target, const char* name); - std::string GetUtilityForTarget(cmTarget& target, const char*); + bool CheckTargetLinks(cmTarget& target, const std::string& name); + std::string GetUtilityForTarget(cmTarget& target, const std::string&); virtual std::string WriteUtilityDepend(cmTarget const*) = 0; std::string GetUtilityDepend(cmTarget const* target); - typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap; + typedef std::map<cmTarget const*, std::string> UtilityDependsMap; UtilityDependsMap UtilityDepends; - const char* AdditionalPlatformDefinition; + std::string AdditionalPlatformDefinition; private: virtual std::string GetVSMakeProgram() = 0; - void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} - void ComputeTargetObjects(cmGeneratorTarget* gt) const; + void PrintCompilerAdvice(std::ostream&, std::string const&, + const char*) const {} void FollowLinkDepends(cmTarget const* target, std::set<cmTarget const*>& linked); diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 98ce685..e44ed79 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -16,7 +16,9 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator() { this->FindMakeProgramFile = "CMakeFindWMake.cmake"; +#ifdef _WIN32 this->ForceUnixPaths = false; +#endif this->ToolSupportsColor = true; this->NeedSymbolicMark = true; this->EmptyRuleHackCommand = "@cd ."; @@ -33,7 +35,6 @@ void cmGlobalWatcomWMakeGenerator mf->AddDefinition("CMAKE_MANGLE_OBJECT_FILE_NAMES", "1"); mf->AddDefinition("CMAKE_MAKE_LINE_CONTINUE", "&"); mf->AddDefinition("CMAKE_MAKE_SYMBOLIC_RULE", ".SYMBOLIC"); - mf->AddDefinition("CMAKE_NO_QUOTED_OBJECTS", "1"); mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl386"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl386"); this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); @@ -43,11 +44,12 @@ void cmGlobalWatcomWMakeGenerator cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator() { cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; - lg->SetSilentNoColon(true); lg->SetDefineWindowsNULL(true); +#ifdef _WIN32 lg->SetWindowsShell(true); +#endif lg->SetWatcomWMake(true); - lg->SetMakeSilentFlag("-s -h -e"); + lg->SetMakeSilentFlag("-h"); lg->SetGlobalGenerator(this); lg->SetIgnoreLibPrefix(true); lg->SetPassMakeflags(false); diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index d5350ef..2057a42 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -27,9 +27,9 @@ public: return new cmGlobalGeneratorSimpleFactory <cmGlobalWatcomWMakeGenerator>(); } ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalWatcomWMakeGenerator::GetActualName();} - static const char* GetActualName() {return "Watcom WMake";} + static std::string GetActualName() {return "Watcom WMake";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 484b28f..d4eb85b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -34,17 +34,17 @@ class cmXcodeVersionParser : public cmXMLParser { public: cmXcodeVersionParser(): Version("1.5") {} - void StartElement(const char* , const char** ) + void StartElement(const std::string&, const char**) { this->Data = ""; } - void EndElement(const char* name) + void EndElement(const std::string& name) { - if(strcmp(name, "key") == 0) + if(name == "key") { this->Key = this->Data; } - else if(strcmp(name, "string") == 0) + else if(name == "string") { if(this->Key == "CFBundleShortVersionString") { @@ -116,7 +116,8 @@ public: class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const; + virtual cmGlobalGenerator* CreateGlobalGenerator( + const std::string& name) const; virtual void GetDocumentation(cmDocumentationEntry& entry) const { cmGlobalXCodeGenerator::GetDocumentation(entry); } @@ -152,9 +153,9 @@ cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory() //---------------------------------------------------------------------------- cmGlobalGenerator* cmGlobalXCodeGenerator::Factory -::CreateGlobalGenerator(const char* name) const +::CreateGlobalGenerator(const std::string& name) const { - if (strcmp(name, GetActualName())) + if (name != GetActualName()) return 0; #if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; @@ -260,11 +261,11 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& void cmGlobalXCodeGenerator::GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* /*projectDir*/, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& /*projectDir*/, + const std::string& targetName, + const std::string& config, bool /*fast*/, std::vector<std::string> const& makeOptions) { @@ -283,10 +284,11 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( makeCommand.push_back(projectArg); bool clean = false; - if ( targetName && strcmp(targetName, "clean") == 0 ) + std::string realTarget = targetName; + if ( realTarget == "clean" ) { clean = true; - targetName = "ALL_BUILD"; + realTarget = "ALL_BUILD"; } if(clean) { @@ -297,14 +299,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( makeCommand.push_back("build"); } makeCommand.push_back("-target"); - // if it is a null string for config don't use it - if(config && *config == 0) + if (!realTarget.empty()) { - config = 0; - } - if (targetName && strlen(targetName)) - { - makeCommand.push_back(targetName); + makeCommand.push_back(realTarget); } else { @@ -318,7 +315,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( else { makeCommand.push_back("-configuration"); - makeCommand.push_back(config?config:"Debug"); + makeCommand.push_back(!config.empty()?config:"Debug"); } makeCommand.insert(makeCommand.end(), makeOptions.begin(), makeOptions.end()); @@ -336,7 +333,7 @@ cmLocalGenerator *cmGlobalXCodeGenerator::CreateLocalGenerator() //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::Generate() { - std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; + std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; // make sure extra targets are added before calling // the parent generate which will call trace depends for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) @@ -569,7 +566,7 @@ void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj) { if(obj->GetType() == cmXCodeObject::OBJECT) { - cmStdString id = obj->GetId(); + std::string id = obj->GetId(); // If this is a duplicate id, it's an error: // @@ -613,7 +610,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) //---------------------------------------------------------------------------- cmXCodeObject* -cmGlobalXCodeGenerator::CreateString(const char* s) +cmGlobalXCodeGenerator::CreateString(const std::string& s) { cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING); obj->SetString(s); @@ -630,17 +627,17 @@ cmXCodeObject* cmGlobalXCodeGenerator } //---------------------------------------------------------------------------- -cmStdString +std::string GetGroupMapKeyFromPath(cmTarget& cmtarget, const std::string& fullpath) { - cmStdString key(cmtarget.GetName()); + std::string key(cmtarget.GetName()); key += "-"; key += fullpath; return key; } //---------------------------------------------------------------------------- -cmStdString +std::string GetGroupMapKey(cmTarget& cmtarget, cmSourceFile* sf) { return GetGroupMapKeyFromPath(cmtarget, sf->GetFullPath()); @@ -696,12 +693,8 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, flags += flagsBuild.GetString(); } - const char* lang = + std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf); - if (!lang) - { - lang = ""; - } cmXCodeObject* buildFile = this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), cmtarget, lang); @@ -713,22 +706,23 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, // Is this a resource file in this target? Add it to the resources group... // - cmTarget::SourceFileFlags tsFlags = cmtarget.GetTargetSourceFileFlags(sf); - bool isResource = (tsFlags.Type == cmTarget::SourceFileTypeResource); + cmGeneratorTarget::SourceFileFlags tsFlags = + this->GetGeneratorTarget(&cmtarget)->GetTargetSourceFileFlags(sf); + bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource; // Is this a "private" or "public" framework header file? // Set the ATTRIBUTES attribute appropriately... // if(cmtarget.IsFrameworkOnApple()) { - if(tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) + if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) { cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST); attrs->AddObject(this->CreateString("Private")); settings->AddAttribute("ATTRIBUTES", attrs); isResource = true; } - else if(tsFlags.Type == cmTarget::SourceFileTypePublicHeader) + else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader) { cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST); attrs->AddObject(this->CreateString("Public")); @@ -846,7 +840,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( fileRef->SetComment(fname.c_str()); this->FileRefs[fname] = fileRef; } - cmStdString key = GetGroupMapKeyFromPath(cmtarget, fullpath); + std::string key = GetGroupMapKeyFromPath(cmtarget, fullpath); cmXCodeObject* group = this->GroupMap[key]; cmXCodeObject* children = group->GetObject("children"); if (!children->HasObject(fileRef)) @@ -905,12 +899,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, cmTarget& cmtarget) { - const char* lang = + std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf); - if (!lang) - { - lang = ""; - } return this->CreateXCodeFileReferenceFromPath( sf->GetFullPath(), cmtarget, lang); @@ -973,6 +963,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& cmtarget = l->second; + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget); // make sure ALL_BUILD, INSTALL, etc are only done once if(this->SpecialTargetEmitted(l->first.c_str())) @@ -1011,21 +1002,21 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, cmXCodeObject* filetype = fr->GetObject()->GetObject("explicitFileType"); - cmTarget::SourceFileFlags tsFlags = - cmtarget.GetTargetSourceFileFlags(*i); + cmGeneratorTarget::SourceFileFlags tsFlags = + gtgt->GetTargetSourceFileFlags(*i); if(filetype && - strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0) + filetype->GetString() == "compiled.mach-o.objfile") { externalObjFiles.push_back(xsf); } else if(this->IsHeaderFile(*i) || - (tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) || - (tsFlags.Type == cmTarget::SourceFileTypePublicHeader)) + (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) || + (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader)) { headerFiles.push_back(xsf); } - else if(tsFlags.Type == cmTarget::SourceFileTypeResource) + else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) { resourceFiles.push_back(xsf); } @@ -1034,7 +1025,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // Include this file in the build if it has a known language // and has not been listed as an ignored extension for this // generator. - if(this->CurrentLocalGenerator->GetSourceFileLanguage(**i) && + if(!this->CurrentLocalGenerator->GetSourceFileLanguage(**i).empty() && !this->IgnoreFile((*i)->GetExtension().c_str())) { sourceFiles.push_back(xsf); @@ -1048,7 +1039,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // the externalObjFiles above, except each one is not a cmSourceFile // within the target.) std::vector<std::string> objs; - this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs); + gtgt->UseObjectLibraries(objs); for(std::vector<std::string>::const_iterator oi = objs.begin(); oi != objs.end(); ++oi) { @@ -1132,15 +1123,15 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, std::vector<cmXCodeObject*> contentBuildPhases; if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { - typedef std::map<cmStdString, std::vector<cmSourceFile*> > + typedef std::map<std::string, std::vector<cmSourceFile*> > mapOfVectorOfSourceFiles; mapOfVectorOfSourceFiles bundleFiles; for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); i != classes.end(); ++i) { - cmTarget::SourceFileFlags tsFlags = - cmtarget.GetTargetSourceFileFlags(*i); - if(tsFlags.Type == cmTarget::SourceFileTypeMacContent) + cmGeneratorTarget::SourceFileFlags tsFlags = + gtgt->GetTargetSourceFileFlags(*i); + if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) { bundleFiles[tsFlags.MacFolder].push_back(*i); } @@ -1221,7 +1212,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, void cmGlobalXCodeGenerator::ForceLinkerLanguages() { // This makes sure all targets link using the proper language. - for(std::map<cmStdString, cmTarget*>::const_iterator + for(std::map<std::string, cmTarget*>::const_iterator ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti) { this->ForceLinkerLanguage(*ti->second); @@ -1239,8 +1230,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - const char* llang = cmtarget.GetLinkerLanguage("NOCONFIG"); - if(!llang) { return; } + std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. cmTarget::LinkImplementation const* impl = @@ -1268,7 +1259,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) } if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str())) { - sf->SetProperty("LANGUAGE", llang); + sf->SetProperty("LANGUAGE", llang.c_str()); cmtarget.AddSourceFile(sf); } } @@ -1479,32 +1470,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, const & commands, const char* name) { - - // collect multiple outputs of custom commands into a set - // which will be used for every configuration - std::map<cmStdString, cmStdString> multipleOutputPairs; - for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); - i != commands.end(); ++i) - { - cmCustomCommand const& cc = *i; - if(!cc.GetCommandLines().empty()) - { - const std::vector<std::string>& outputs = cc.GetOutputs(); - if(!outputs.empty()) - { - // If there are more than one outputs treat the - // first as the primary output and make the rest depend on it. - std::vector<std::string>::const_iterator o = outputs.begin(); - std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str()); - for(++o; o != outputs.end(); ++o) - { - std::string currentOutput=this->ConvertToRelativeForMake(o->c_str()); - multipleOutputPairs[currentOutput] = primaryOutput; - } - } - } - } - + bool haveMultipleOutputPairs = false; std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory(); dir += "/CMakeScripts"; cmSystemTools::MakeDirectory(dir.c_str()); @@ -1524,7 +1490,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, target, commands, currentConfig->c_str(), - multipleOutputPairs); + haveMultipleOutputPairs); } std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory(); @@ -1534,7 +1500,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, makecmd += " -f "; makecmd += this->ConvertToRelativeForMake( (makefile+"$CONFIGURATION").c_str()); - if(!multipleOutputPairs.empty()) + if(haveMultipleOutputPairs) { makecmd += " cmake_check_multiple_outputs"; } @@ -1552,10 +1518,8 @@ void cmGlobalXCodeGenerator cmTarget& target, std::vector<cmCustomCommand> const & commands, - const char* configName, - const std::map<cmStdString, - cmStdString>& multipleOutputPairs - ) + const std::string& configName, + bool& haveMultipleOutputPairs) { std::string makefileName=makefileBasename; if(this->XcodeVersion > 20) @@ -1576,15 +1540,16 @@ void cmGlobalXCodeGenerator // have all depend on all outputs makefileStream << "all: "; - std::map<const cmCustomCommand*, cmStdString> tname; + std::map<const cmCustomCommand*, std::string> tname; int count = 0; + std::map<std::string, std::string> multipleOutputPairs; for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; - if(!cc.GetCommandLines().empty()) + cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile); + if(ccg.GetNumberOfCommands() > 0) { - const std::vector<std::string>& outputs = cc.GetOutputs(); + const std::vector<std::string>& outputs = ccg.GetOutputs(); if(!outputs.empty()) { for(std::vector<std::string>::const_iterator o = outputs.begin(); @@ -1593,13 +1558,23 @@ void cmGlobalXCodeGenerator makefileStream << "\\\n\t" << this->ConvertToRelativeForMake(o->c_str()); } + + // If there is more than one output treat the first as the + // primary output and make the rest depend on it. + std::vector<std::string>::const_iterator o = outputs.begin(); + std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str()); + for(++o; o != outputs.end(); ++o) + { + std::string currentOutput=this->ConvertToRelativeForMake(o->c_str()); + multipleOutputPairs[currentOutput] = primaryOutput; + } } else { cmOStringStream str; str << "_buildpart_" << count++ ; - tname[&cc] = std::string(target.GetName()) + str.str(); - makefileStream << "\\\n\t" << tname[&cc]; + tname[&ccg.GetCC()] = std::string(target.GetName()) + str.str(); + makefileStream << "\\\n\t" << tname[&ccg.GetCC()]; } } } @@ -1607,12 +1582,11 @@ void cmGlobalXCodeGenerator for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; - if(!cc.GetCommandLines().empty()) + cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile); + if(ccg.GetNumberOfCommands() > 0) { - cmCustomCommandGenerator ccg(cc, configName, this->CurrentMakefile); makefileStream << "\n"; - const std::vector<std::string>& outputs = cc.GetOutputs(); + const std::vector<std::string>& outputs = ccg.GetOutputs(); if(!outputs.empty()) { // There is at least one output, start the rule for it @@ -1623,11 +1597,11 @@ void cmGlobalXCodeGenerator else { // There are no outputs. Use the generated force rule name. - makefileStream << tname[&cc] << ": "; + makefileStream << tname[&ccg.GetCC()] << ": "; } for(std::vector<std::string>::const_iterator d = - cc.GetDepends().begin(); - d != cc.GetDepends().end(); ++d) + ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { std::string dep; if(this->CurrentLocalGenerator @@ -1639,11 +1613,11 @@ void cmGlobalXCodeGenerator } makefileStream << "\n"; - if(const char* comment = cc.GetComment()) + if(const char* comment = ccg.GetComment()) { std::string echo_cmd = "echo "; echo_cmd += (this->CurrentLocalGenerator-> - EscapeForShell(comment, cc.GetEscapeAllowMakeVars())); + EscapeForShell(comment, ccg.GetCC().GetEscapeAllowMakeVars())); makefileStream << "\t" << echo_cmd.c_str() << "\n"; } @@ -1655,10 +1629,11 @@ void cmGlobalXCodeGenerator cmSystemTools::ReplaceString(cmd2, "/./", "/"); cmd2 = this->ConvertToRelativeForMake(cmd2.c_str()); std::string cmd; - if(cc.GetWorkingDirectory()) + std::string wd = ccg.GetWorkingDirectory(); + if(!wd.empty()) { cmd += "cd "; - cmd += this->ConvertToRelativeForMake(cc.GetWorkingDirectory()); + cmd += this->ConvertToRelativeForMake(wd.c_str()); cmd += " && "; } cmd += cmd2; @@ -1674,7 +1649,7 @@ void cmGlobalXCodeGenerator makefileStream << "\n# Dependencies of multiple outputs to their primary outputs \n"; - for(std::map<cmStdString, cmStdString>::const_iterator o = + for(std::map<std::string, std::string>::const_iterator o = multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o) { makefileStream << o->first << ": " << o->second << "\n"; @@ -1683,7 +1658,7 @@ void cmGlobalXCodeGenerator makefileStream << "\n" "cmake_check_multiple_outputs:\n"; - for(std::map<cmStdString, cmStdString>::const_iterator o = + for(std::map<std::string, std::string>::const_iterator o = multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o) { makefileStream << "\t@if [ ! -f " @@ -1691,12 +1666,15 @@ void cmGlobalXCodeGenerator << o->second << "; fi\n"; } } + + haveMultipleOutputPairs = + haveMultipleOutputPairs || !multipleOutputPairs.empty(); } //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, - cmXCodeObject* buildSettings, - const char* configName) + cmXCodeObject* buildSettings, + const std::string& configName) { if(target.GetType() == cmTarget::INTERFACE_LIBRARY) { @@ -1712,12 +1690,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, (target.GetType() == cmTarget::EXECUTABLE) || shared); - const char* lang = target.GetLinkerLanguage(configName); + std::string lang = target.GetLinkerLanguage(configName); std::string cflags; - if(lang) + if(!lang.empty()) { // for c++ projects get the c flags as well - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { this->CurrentLocalGenerator->AddLanguageFlags(cflags, "C", configName); this->CurrentLocalGenerator->AddCMP0018Flags(cflags, &target, @@ -1743,7 +1721,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.GetName()); + target.GetName().c_str()); return; } @@ -1809,7 +1787,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CurrentLocalGenerator-> AppendFlags(extraLinkOptions, targetLinkFlags); } - if(configName && *configName) + if(!configName.empty()) { std::string linkFlagsVar = "LINK_FLAGS_"; linkFlagsVar += cmSystemTools::UpperCase(configName); @@ -2093,7 +2071,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::vector<std::string> includes; this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", configName); - std::set<cmStdString> emitted; + std::set<std::string> emitted; emitted.insert("/System/Library/Frameworks"); for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) @@ -2176,7 +2154,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* debugStr = "YES"; // We can't set the Xcode flag differently depending on the language, // so put them back in this case. - if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc ) + if( (lang == "CXX") && gflag != gflagc ) { cflags += " "; cflags += gflagc; @@ -2199,7 +2177,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString("NO")); buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN", this->CreateString("NO")); - if(lang && strcmp(lang, "CXX") == 0) + if(lang == "CXX") { flags += " "; flags += defFlags; @@ -2362,18 +2340,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { if(i->first.find("XCODE_ATTRIBUTE_") == 0) { - cmStdString attribute = i->first.substr(16); + std::string attribute = i->first.substr(16); // Handle [variant=<config>] condition explicitly here. - cmStdString::size_type beginVariant = + std::string::size_type beginVariant = attribute.find("[variant="); - if (beginVariant != cmStdString::npos) + if (beginVariant != std::string::npos) { - cmStdString::size_type endVariant = + std::string::size_type endVariant = attribute.find("]", beginVariant+9); - if (endVariant != cmStdString::npos) + if (endVariant != std::string::npos) { // Compare the variant to the configuration. - cmStdString variant = + std::string variant = attribute.substr(beginVariant+9, endVariant-beginVariant-9); if (variant == configName) { @@ -2426,7 +2404,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXAggregateTarget); - target->SetComment(cmtarget.GetName()); + target->SetComment(cmtarget.GetName().c_str()); cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST); std::vector<cmXCodeObject*> emptyContentVector; @@ -2627,7 +2605,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, fileRef->AddAttribute("refType", this->CreateString("0")); fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); - fileRef->SetComment(cmtarget.GetName()); + fileRef->SetComment(cmtarget.GetName().c_str()); target->AddAttribute("productReference", this->CreateObjectReference(fileRef)); if(const char* productType = this->GetTargetProductType(cmtarget)) @@ -2660,8 +2638,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) } //---------------------------------------------------------------------------- -std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, - const char* id) +std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name, + const std::string& id) { std::string guidStoreName = name; guidStoreName += "_GUID_CMAKE"; @@ -2674,7 +2652,7 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, } this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), - id, "Stored Xcode object GUID", cmCacheManager::INTERNAL); + id.c_str(), "Stored Xcode object GUID", cmCacheManager::INTERNAL); return id; } @@ -2743,7 +2721,7 @@ void cmGlobalXCodeGenerator ::AppendBuildSettingAttribute(cmXCodeObject* target, const char* attribute, const char* value, - const char* configName) + const std::string& configName) { if(this->XcodeVersion < 21) { @@ -2766,9 +2744,9 @@ void cmGlobalXCodeGenerator for(std::vector<cmXCodeObject*>::iterator i = list.begin(); i != list.end(); ++i) { - if(configName) + if(!configName.empty()) { - if(strcmp((*i)->GetObject("name")->GetString(), configName) == 0) + if((*i)->GetObject("name")->GetString() == configName) { cmXCodeObject* settings = (*i)->GetObject("buildSettings"); this->AppendOrAddBuildSetting(settings, attribute, value); @@ -2974,7 +2952,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, mf->FindSourceGroup(source.c_str(), sourceGroups); cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(cmtarget, sourceGroup); - cmStdString key = GetGroupMapKey(cmtarget, sf); + std::string key = GetGroupMapKey(cmtarget, sf); this->GroupMap[key] = pbxgroup; } @@ -2989,7 +2967,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, mf->FindSourceGroup(source.c_str(), sourceGroups); cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(cmtarget, sourceGroup); - cmStdString key = GetGroupMapKeyFromPath(cmtarget, source); + std::string key = GetGroupMapKeyFromPath(cmtarget, source); this->GroupMap[key] = pbxgroup; } } @@ -2997,7 +2975,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } cmXCodeObject *cmGlobalXCodeGenerator -::CreatePBXGroup(cmXCodeObject *parent, cmStdString name) +::CreatePBXGroup(cmXCodeObject *parent, std::string name) { cmXCodeObject* parentChildren = NULL; if(parent) @@ -3021,8 +2999,8 @@ cmXCodeObject *cmGlobalXCodeGenerator cmXCodeObject* cmGlobalXCodeGenerator ::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg) { - cmStdString s; - cmStdString target; + std::string s; + std::string target; const char *targetFolder= cmtarget.GetProperty("FOLDER"); if(targetFolder) { target = targetFolder; @@ -3031,7 +3009,7 @@ cmXCodeObject* cmGlobalXCodeGenerator target += cmtarget.GetName(); s = target + "/"; s += sg->GetFullName(); - std::map<cmStdString, cmXCodeObject* >::iterator it = + std::map<std::string, cmXCodeObject* >::iterator it = this->GroupNameMap.find(s); if(it != this->GroupNameMap.end()) { @@ -3048,7 +3026,7 @@ cmXCodeObject* cmGlobalXCodeGenerator { std::vector<std::string> tgt_folders = cmSystemTools::tokenize(target, "/"); - cmStdString curr_tgt_folder; + std::string curr_tgt_folder; for(std::vector<std::string>::size_type i = 0; i < tgt_folders.size();i++) { if (i != 0) @@ -3075,7 +3053,7 @@ cmXCodeObject* cmGlobalXCodeGenerator // If it's the default source group (empty name) then put the source file // directly in the tgroup... // - if (cmStdString(sg->GetFullName()) == "") + if (std::string(sg->GetFullName()) == "") { this->GroupNameMap[s] = tgroup; return tgroup; @@ -3086,12 +3064,12 @@ cmXCodeObject* cmGlobalXCodeGenerator { std::vector<std::string> folders = cmSystemTools::tokenize(sg->GetFullName(), "\\"); - cmStdString curr_folder = target; + std::string curr_folder = target; curr_folder += "/"; for(std::vector<std::string>::size_type i = 0; i < folders.size();i++) { curr_folder += folders[i]; - std::map<cmStdString, cmXCodeObject* >::iterator i_folder = + std::map<std::string, cmXCodeObject* >::iterator i_folder = this->GroupNameMap.find(curr_folder); //Create new folder if(i_folder == this->GroupNameMap.end()) @@ -3471,14 +3449,14 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( makefileStream << "# For each target create a dummy rule " "so the target does not have to exist\n"; - std::set<cmStdString> emitted; + std::set<std::string> emitted; for(std::vector<cmXCodeObject*>::iterator i = targets.begin(); i != targets.end(); ++i) { cmXCodeObject* target = *i; - std::map<cmStdString, cmXCodeObject::StringVec> const& deplibs = + std::map<std::string, cmXCodeObject::StringVec> const& deplibs = target->GetDependLibraries(); - for(std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator ci + for(std::map<std::string, cmXCodeObject::StringVec>::const_iterator ci = deplibs.begin(); ci != deplibs.end(); ++ci) { for(cmXCodeObject::StringVec::const_iterator d = ci->second.begin(); @@ -3534,12 +3512,12 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string trel = this->ConvertToRelativeForMake(tfull.c_str()); // Add this target to the post-build phases of its dependencies. - std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator + std::map<std::string, cmXCodeObject::StringVec>::const_iterator y = target->GetDependTargets().find(*ct); if(y != target->GetDependTargets().end()) { - std::vector<cmStdString> const& deptgts = y->second; - for(std::vector<cmStdString>::const_iterator d = deptgts.begin(); + std::vector<std::string> const& deptgts = y->second; + for(std::vector<std::string>::const_iterator d = deptgts.begin(); d != deptgts.end(); ++d) { makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": " @@ -3551,12 +3529,12 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( makefileStream << trel << ":"; // List dependencies if any exist. - std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator + std::map<std::string, cmXCodeObject::StringVec>::const_iterator x = target->GetDependLibraries().find(*ct); if(x != target->GetDependLibraries().end()) { - std::vector<cmStdString> const& deplibs = x->second; - for(std::vector<cmStdString>::const_iterator d = deplibs.begin(); + std::vector<std::string> const& deplibs = x->second; + for(std::vector<std::string>::const_iterator d = deplibs.begin(); d != deplibs.end(); ++d) { makefileStream << "\\\n\t" << @@ -3781,14 +3759,14 @@ std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p) //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator -::AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, +::AppendDirectoryForConfig(const std::string& prefix, + const std::string& config, + const std::string& suffix, std::string& dir) { if(this->XcodeVersion > 20) { - if(config) + if(!config.empty()) { dir += prefix; dir += config; @@ -3798,12 +3776,13 @@ cmGlobalXCodeGenerator } //---------------------------------------------------------------------------- -std::string cmGlobalXCodeGenerator::LookupFlags(const char* varNamePrefix, - const char* varNameLang, - const char* varNameSuffix, - const char* default_flags) +std::string cmGlobalXCodeGenerator::LookupFlags( + const std::string& varNamePrefix, + const std::string& varNameLang, + const std::string& varNameSuffix, + const std::string& default_flags) { - if(varNameLang) + if(!varNameLang.empty()) { std::string varName = varNamePrefix; varName += varNameLang; @@ -3955,37 +3934,10 @@ bool cmGlobalXCodeGenerator::IsMultiConfig() return true; } - //---------------------------------------------------------------------------- -void -cmGlobalXCodeGenerator -::ComputeTargetObjects(cmGeneratorTarget* gt) const +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { - // Count the number of object files with each name. Warn about duplicate - // names since Xcode names them uniquely automatically with a numeric suffix - // to avoid exact duplicate file names. Note that Mac file names are not - // typically case sensitive, hence the LowerCase. - std::map<cmStdString, int> counts; - std::vector<cmSourceFile*> objectSources; - gt->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".o"; - - std::string objectNameLower = cmSystemTools::LowerCase(objectName); - counts[objectNameLower] += 1; - if (2 == counts[objectNameLower]) - { - // TODO: emit warning about duplicate name? - } - - gt->AddObject(sf, objectName); - } - const char* configName = this->GetCMakeCFGIntDir(); std::string dir = this->GetObjectsNormalDirectory( "$(PROJECT_NAME)", configName, gt->Target); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index c9d20c2..23616b4 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -33,9 +33,9 @@ public: static cmGlobalGeneratorFactory* NewFactory(); ///! Get the name for the generator. - virtual const char* GetName() const { + virtual std::string GetName() const { return cmGlobalXCodeGenerator::GetActualName();} - static const char* GetActualName() {return "Xcode";} + static std::string GetActualName() {return "Xcode";} /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); @@ -55,11 +55,11 @@ public: */ virtual void GenerateBuildCommand( std::vector<std::string>& makeCommand, - const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* targetName, - const char* config, + const std::string& makeProgram, + const std::string& projectName, + const std::string& projectDir, + const std::string& targetName, + const std::string& config, bool fast, std::vector<std::string> const& makeOptions = std::vector<std::string>() ); @@ -72,9 +72,9 @@ public: virtual void Generate(); /** Append the subdirectory for the given configuration. */ - virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, + virtual void AppendDirectoryForConfig(const std::string& prefix, + const std::string& config, + const std::string& suffix, std::string& dir); ///! What is the configurations directory variable called? @@ -95,7 +95,7 @@ private: cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg); cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent, - cmStdString name); + std::string name); void CreateGroups(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); @@ -123,19 +123,17 @@ private: void CreateCustomRulesMakefile(const char* makefileBasename, cmTarget& target, std::vector<cmCustomCommand> const & commands, - const char* configName, - const std::map<cmStdString, cmStdString>& - multipleOutputPairs - ); + const std::string& configName, + bool& haveMultipleOutputPairs); cmXCodeObject* FindXCodeTarget(cmTarget const*); - std::string GetOrCreateId(const char* name, const char* id); + std::string GetOrCreateId(const std::string& name, const std::string& id); // create cmXCodeObject from these functions so that memory can be managed // correctly. All objects created are stored in this->XCodeObjects. cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype); cmXCodeObject* CreateObject(cmXCodeObject::Type type); - cmXCodeObject* CreateString(const char* s); + cmXCodeObject* CreateString(const std::string& s); cmXCodeObject* CreateObjectReference(cmXCodeObject*); cmXCodeObject* CreateXCodeTarget(cmTarget& target, cmXCodeObject* buildPhases); @@ -147,12 +145,13 @@ private: void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr, const char* value); void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr, - const char* value, const char* configName); + const char* value, + const std::string& configName); cmXCodeObject* CreateUtilityTarget(cmTarget& target); void AddDependAndLinkInformation(cmXCodeObject* target); void CreateBuildSettings(cmTarget& target, cmXCodeObject* buildSettings, - const char* buildType); + const std::string& buildType); std::string ExtractFlag(const char* flag, std::string& flags); // delete all objects in the this->XCodeObjects vector. void ClearXCodeObjects(); @@ -190,10 +189,10 @@ private: void CreateReRunCMakeFile(cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens); - std::string LookupFlags(const char* varNamePrefix, - const char* varNameLang, - const char* varNameSuffix, - const char* default_flags); + std::string LookupFlags(const std::string& varNamePrefix, + const std::string& varNameLang, + const std::string& varNameSuffix, + const std::string& default_flags); class Factory; class BuildObjectListOrString; @@ -205,18 +204,19 @@ private: std::vector<std::string> const& defines, bool dflag = false); + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: virtual const char* GetInstallTargetName() const { return "install"; } virtual const char* GetPackageTargetName() const { return "package"; } unsigned int XcodeVersion; std::string VersionString; - std::set<cmStdString> XCodeObjectIDs; + std::set<std::string> XCodeObjectIDs; std::vector<cmXCodeObject*> XCodeObjects; cmXCodeObject* RootObject; private: - void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} - void ComputeTargetObjects(cmGeneratorTarget* gt) const; + void PrintCompilerAdvice(std::ostream&, std::string const&, + const char*) const {} std::string GetObjectsNormalDirectory( const std::string &projName, @@ -235,14 +235,14 @@ private: std::string CurrentReRunCMakeMakefile; std::string CurrentXCodeHackMakefile; std::string CurrentProject; - std::set<cmStdString> TargetDoneSet; + std::set<std::string> TargetDoneSet; std::vector<std::string> CurrentOutputDirectoryComponents; std::vector<std::string> ProjectSourceDirectoryComponents; std::vector<std::string> ProjectOutputDirectoryComponents; - std::map<cmStdString, cmXCodeObject* > GroupMap; - std::map<cmStdString, cmXCodeObject* > GroupNameMap; - std::map<cmStdString, cmXCodeObject* > TargetGroup; - std::map<cmStdString, cmXCodeObject* > FileRefs; + std::map<std::string, cmXCodeObject* > GroupMap; + std::map<std::string, cmXCodeObject* > GroupNameMap; + std::map<std::string, cmXCodeObject* > TargetGroup; + std::map<std::string, cmXCodeObject* > FileRefs; std::vector<std::string> Architectures; std::string PlatformToolset; }; diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index db964a9..601993f 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -121,7 +121,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, __set_bool_if_set(this->GeneratePerTarget, "GRAPHVIZ_GENERATE_PER_TARGET"); __set_bool_if_set(this->GenerateDependers, "GRAPHVIZ_GENERATE_DEPENDERS"); - cmStdString ignoreTargetsRegexes; + std::string ignoreTargetsRegexes; __set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS"); this->TargetsToIgnoreRegex.clear(); @@ -135,7 +135,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, itvIt != ignoreTargetsRegExVector.end(); ++ itvIt ) { - cmStdString currentRegexString(*itvIt); + std::string currentRegexString(*itvIt); cmsys::RegularExpression currentRegex; if (!currentRegex.compile(currentRegexString.c_str())) { @@ -160,7 +160,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) this->CollectTargetsAndLibs(); - for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt = + for(std::map<std::string, const cmTarget*>::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -192,7 +192,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) std::cout << "Writing " << currentFilename << "..." << std::endl; this->WriteHeader(str); - this->WriteDependerConnections(ptrIt->first.c_str(), + this->WriteDependerConnections(ptrIt->first, insertedNodes, insertedConnections, str); this->WriteFooter(str); @@ -211,7 +211,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) this->CollectTargetsAndLibs(); - for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt = + for(std::map<std::string, const cmTarget*>::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -241,7 +241,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) std::cout << "Writing " << currentFilename << "..." << std::endl; this->WriteHeader(str); - this->WriteConnections(ptrIt->first.c_str(), + this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections, str); this->WriteFooter(str); } @@ -265,7 +265,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName) std::set<std::string> insertedConnections; std::set<std::string> insertedNodes; - for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt = + for(std::map<std::string, const cmTarget*>::const_iterator ptrIt = this->TargetPtrs.begin(); ptrIt != this->TargetPtrs.end(); ++ptrIt) @@ -280,7 +280,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName) continue; } - this->WriteConnections(ptrIt->first.c_str(), + this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections, str); } this->WriteFooter(str); @@ -300,12 +300,12 @@ void cmGraphVizWriter::WriteFooter(cmGeneratedFileStream& str) const } -void cmGraphVizWriter::WriteConnections(const char* targetName, +void cmGraphVizWriter::WriteConnections(const std::string& targetName, std::set<std::string>& insertedNodes, std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const { - std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt = + std::map<std::string, const cmTarget* >::const_iterator targetPtrIt = this->TargetPtrs.find(targetName); if (targetPtrIt == this->TargetPtrs.end()) // not found at all @@ -331,7 +331,7 @@ void cmGraphVizWriter::WriteConnections(const char* targetName, ++ llit ) { const char* libName = llit->first.c_str(); - std::map<cmStdString, cmStdString>::const_iterator libNameIt = + std::map<std::string, std::string>::const_iterator libNameIt = this->TargetNamesNodes.find(libName); // can happen e.g. if GRAPHVIZ_TARGET_IGNORE_REGEX is used @@ -349,8 +349,8 @@ void cmGraphVizWriter::WriteConnections(const char* targetName, this->WriteNode(libName, this->TargetPtrs.find(libName)->second, insertedNodes, str); - str << " \"" << myNodeName.c_str() << "\" -> \"" - << libNameIt->second.c_str() << "\""; + str << " \"" << myNodeName << "\" -> \"" + << libNameIt->second << "\""; str << " // " << targetName << " -> " << libName << std::endl; this->WriteConnections(libName, insertedNodes, insertedConnections, str); } @@ -359,12 +359,12 @@ void cmGraphVizWriter::WriteConnections(const char* targetName, } -void cmGraphVizWriter::WriteDependerConnections(const char* targetName, +void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName, std::set<std::string>& insertedNodes, std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const { - std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt = + std::map<std::string, const cmTarget* >::const_iterator targetPtrIt = this->TargetPtrs.find(targetName); if (targetPtrIt == this->TargetPtrs.end()) // not found at all @@ -383,7 +383,7 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName, std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; // now search who links against me - for(std::map<cmStdString, const cmTarget*>::const_iterator dependerIt = + for(std::map<std::string, const cmTarget*>::const_iterator dependerIt = this->TargetPtrs.begin(); dependerIt != this->TargetPtrs.end(); ++dependerIt) @@ -407,11 +407,11 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName, llit != ll->end(); ++ llit ) { - std::string libName = llit->first.c_str(); + std::string libName = llit->first; if (libName == targetName) { // So this target links against targetName. - std::map<cmStdString, cmStdString>::const_iterator dependerNodeNameIt = + std::map<std::string, std::string>::const_iterator dependerNodeNameIt = this->TargetNamesNodes.find(dependerIt->first); if(dependerNodeNameIt != this->TargetNamesNodes.end()) @@ -424,13 +424,13 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName, insertedConnections.end()) { insertedConnections.insert(connectionName); - this->WriteNode(dependerIt->first.c_str(), dependerIt->second, + this->WriteNode(dependerIt->first, dependerIt->second, insertedNodes, str); str << " \"" << dependerNodeNameIt->second << "\" -> \"" << myNodeName << "\""; str << " // " <<targetName<< " -> " <<dependerIt->first<<std::endl; - this->WriteDependerConnections(dependerIt->first.c_str(), + this->WriteDependerConnections(dependerIt->first, insertedNodes, insertedConnections, str); } @@ -444,7 +444,7 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName, } -void cmGraphVizWriter::WriteNode(const char* targetName, +void cmGraphVizWriter::WriteNode(const std::string& targetName, const cmTarget* target, std::set<std::string>& insertedNodes, cmGeneratedFileStream& str) const @@ -452,10 +452,10 @@ void cmGraphVizWriter::WriteNode(const char* targetName, if (insertedNodes.find(targetName) == insertedNodes.end()) { insertedNodes.insert(targetName); - std::map<cmStdString, cmStdString>::const_iterator nameIt = + std::map<std::string, std::string>::const_iterator nameIt = this->TargetNamesNodes.find(targetName); - str << " \"" << nameIt->second.c_str() << "\" [ label=\"" + str << " \"" << nameIt->second << "\" [ label=\"" << targetName << "\" shape=\"" << getShapeForTarget(target) << "\"];" << std::endl; } @@ -540,7 +540,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) continue; } - std::map<cmStdString, const cmTarget*>::const_iterator tarIt = + std::map<std::string, const cmTarget*>::const_iterator tarIt = this->TargetPtrs.find(libName); if ( tarIt == this->TargetPtrs.end() ) { @@ -558,7 +558,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) } -bool cmGraphVizWriter::IgnoreThisTarget(const char* name) +bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name) { for(std::vector<cmsys::RegularExpression>::iterator itvIt = this->TargetsToIgnoreRegex.begin(); diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 17b97f8..a7acd0e 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -44,30 +44,30 @@ protected: void WriteHeader(cmGeneratedFileStream& str) const; - void WriteConnections(const char* targetName, + void WriteConnections(const std::string& targetName, std::set<std::string>& insertedNodes, std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const; - void WriteDependerConnections(const char* targetName, + void WriteDependerConnections(const std::string& targetName, std::set<std::string>& insertedNodes, std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const; - void WriteNode(const char* targetName, const cmTarget* target, + void WriteNode(const std::string& targetName, const cmTarget* target, std::set<std::string>& insertedNodes, cmGeneratedFileStream& str) const; void WriteFooter(cmGeneratedFileStream& str) const; - bool IgnoreThisTarget(const char* name); + bool IgnoreThisTarget(const std::string& name); bool GenerateForTargetType(cmTarget::TargetType targetType) const; - cmStdString GraphType; - cmStdString GraphName; - cmStdString GraphHeader; - cmStdString GraphNodePrefix; + std::string GraphType; + std::string GraphName; + std::string GraphHeader; + std::string GraphNodePrefix; bool GenerateForExecutables; bool GenerateForStaticLibs; @@ -81,9 +81,9 @@ protected: const std::vector<cmLocalGenerator*>& LocalGenerators; - std::map<cmStdString, const cmTarget*> TargetPtrs; + std::map<std::string, const cmTarget*> TargetPtrs; // maps from the actual target names to node names in dot: - std::map<cmStdString, cmStdString> TargetNamesNodes; + std::map<std::string, std::string> TargetNamesNodes; bool HaveTargetsAndLibs; }; diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 34a9c7c..e03223f 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -108,7 +108,7 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, { const char *new_value = flag+1+n; - std::map<cmStdString,cmStdString>::iterator itr; + std::map<std::string,std::string>::iterator itr; itr = this->FlagMap.find(entry->IDEName); if(itr != this->FlagMap.end()) { @@ -186,7 +186,7 @@ void cmIDEOptions::RemoveFlag(const char* flag) //---------------------------------------------------------------------------- const char* cmIDEOptions::GetFlag(const char* flag) { - std::map<cmStdString, cmStdString>::iterator i = this->FlagMap.find(flag); + std::map<std::string, std::string>::iterator i = this->FlagMap.find(flag); if(i != this->FlagMap.end()) { return i->second.c_str(); diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index e78af3e..691893f 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -40,13 +40,13 @@ protected: // Then parse the command line flags specified in CMAKE_CXX_FLAGS // and CMAKE_C_FLAGS // and overwrite or add new values to this map - std::map<cmStdString, cmStdString> FlagMap; + std::map<std::string, std::string> FlagMap; // Preprocessor definitions. std::vector<std::string> Defines; // Unrecognized flags that get no special handling. - cmStdString FlagString; + std::string FlagString; bool DoingDefine; bool AllowDefine; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index ee95c05..06c4b89 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -26,7 +26,7 @@ static std::string cmIfCommandError( i != args.end(); ++i) { err += " "; - err += lg->EscapeForCMake(i->c_str()); + err += lg->EscapeForCMake(*i); } err += "\n"; return err; @@ -199,7 +199,7 @@ bool cmIfCommand err += errorString; if (status == cmake::FATAL_ERROR) { - this->SetError(err.c_str()); + this->SetError(err); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -261,7 +261,7 @@ namespace } // Check definition. - const char* def = mf->GetDefinition(arg.c_str()); + const char* def = mf->GetDefinition(arg); return !cmSystemTools::IsOff(def); } @@ -277,12 +277,12 @@ namespace else if(arg == "1") { return true; } else - { return !cmSystemTools::IsOff(mf->GetDefinition(arg.c_str())); } + { return !cmSystemTools::IsOff(mf->GetDefinition(arg)); } } else { // Old GetVariableOrNumber behavior. - const char* def = mf->GetDefinition(arg.c_str()); + const char* def = mf->GetDefinition(arg); if(!def && atoi(arg.c_str())) { def = arg.c_str(); @@ -559,7 +559,7 @@ namespace } else { - bdef = makefile->IsDefinitionSet((argP1)->c_str()); + bdef = makefile->IsDefinitionSet(*(argP1)); } HandlePredicate(bdef, reducible, arg, newArgs, argP1, argP2); } @@ -593,7 +593,7 @@ namespace if (argP1 != newArgs.end() && argP2 != newArgs.end() && *(argP1) == "MATCHES") { - def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); + def = cmIfCommand::GetVariableOrString(*arg, makefile); const char* rex = (argP2)->c_str(); cmStringCommand::ClearMatches(makefile); cmsys::RegularExpression regEntry; @@ -634,8 +634,8 @@ namespace (*(argP1) == "LESS" || *(argP1) == "GREATER" || *(argP1) == "EQUAL")) { - def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); - def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); + def = cmIfCommand::GetVariableOrString(*arg, makefile); + def2 = cmIfCommand::GetVariableOrString(*argP2, makefile); double lhs; double rhs; bool result; @@ -665,8 +665,8 @@ namespace *(argP1) == "STREQUAL" || *(argP1) == "STRGREATER")) { - def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); - def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); + def = cmIfCommand::GetVariableOrString(*arg, makefile); + def2 = cmIfCommand::GetVariableOrString(*argP2, makefile); int val = strcmp(def,def2); bool result; if (*(argP1) == "STRLESS") @@ -689,8 +689,8 @@ namespace (*(argP1) == "VERSION_LESS" || *(argP1) == "VERSION_GREATER" || *(argP1) == "VERSION_EQUAL")) { - def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); - def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); + def = cmIfCommand::GetVariableOrString(*arg, makefile); + def2 = cmIfCommand::GetVariableOrString(*argP2, makefile); cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL; if(*argP1 == "VERSION_LESS") { @@ -907,13 +907,13 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, } //========================================================================= -const char* cmIfCommand::GetVariableOrString(const char* str, +const char* cmIfCommand::GetVariableOrString(const std::string& str, const cmMakefile* mf) { const char* def = mf->GetDefinition(str); if(!def) { - def = str; + def = str.c_str(); } return def; } diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index f2633ad..b9de845 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -63,7 +63,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "if";} + virtual std::string GetName() const { return "if";} /** * This determines if the command is invoked when in script mode. @@ -79,7 +79,7 @@ public: // Get a definition from the makefile. If it doesn't exist, // return the original string. - static const char* GetVariableOrString(const char* str, + static const char* GetVariableOrString(const std::string& str, const cmMakefile* mf); cmTypeMacro(cmIfCommand, cmCommand); diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index fbcbc75..0a4f5c9 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -65,7 +65,7 @@ bool cmIncludeCommand { std::string errorText = "called with invalid argument: "; errorText += args[i]; - this->SetError(errorText.c_str()); + this->SetError(errorText); return false; } } @@ -121,7 +121,7 @@ bool cmIncludeCommand "command. It " << modal << " not be used as the argument to the " "include() command. Use ALIAS targets instead to refer to targets " "by alternative names.\n"; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return false; @@ -139,7 +139,7 @@ bool cmIncludeCommand // add the location of the included file if a result variable was given if (resultVarName.size()) { - this->Makefile->AddDefinition(resultVarName.c_str(), + this->Makefile->AddDefinition(resultVarName, readit?fullFilePath.c_str():"NOTFOUND"); } @@ -149,7 +149,7 @@ bool cmIncludeCommand "could not find load file:\n" " "; m += fname; - this->SetError(m.c_str()); + this->SetError(m); return false; } return true; diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index 267723d..0dcd7de 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "include";} + virtual std::string GetName() const {return "include";} cmTypeMacro(cmIncludeCommand, cmCommand); }; diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index e20fe02..df5508e 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -38,7 +38,7 @@ bool cmIncludeDirectoryCommand std::vector<std::string> beforeIncludes; std::vector<std::string> afterIncludes; - std::set<cmStdString> systemIncludes; + std::set<std::string> systemIncludes; for(; i != args.end(); ++i) { diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index c621dcb..6cc2c83 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "include_directories";} + virtual std::string GetName() const { return "include_directories";} cmTypeMacro(cmIncludeDirectoryCommand, cmCommand); diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h index 8ca674f..081f77a 100644 --- a/Source/cmIncludeExternalMSProjectCommand.h +++ b/Source/cmIncludeExternalMSProjectCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "include_external_msproject";} + virtual std::string GetName() const {return "include_external_msproject";} cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand); }; diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx index ef6e8c6..d6dfdd2 100644 --- a/Source/cmIncludeRegularExpressionCommand.cxx +++ b/Source/cmIncludeRegularExpressionCommand.cxx @@ -24,7 +24,7 @@ bool cmIncludeRegularExpressionCommand if(args.size() > 1) { - this->Makefile->SetComplainRegularExpression(args[1].c_str()); + this->Makefile->SetComplainRegularExpression(args[1]); } return true; diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h index 0c5fa6f..c58f018 100644 --- a/Source/cmIncludeRegularExpressionCommand.h +++ b/Source/cmIncludeRegularExpressionCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "include_regular_expression";} + virtual std::string GetName() const {return "include_regular_expression";} cmTypeMacro(cmIncludeRegularExpressionCommand, cmCommand); }; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 0878aae..0041122 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -97,9 +97,9 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args, } // Unknown mode. - cmStdString e = "called with unknown mode "; + std::string e = "called with unknown mode "; e += args[0]; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -269,7 +269,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // Unknown argument. cmOStringStream e; e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -370,7 +370,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) << "\" which is an alias."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Lookup this target in the current directory. @@ -387,7 +387,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) << "\" which is not an executable, library, or module."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } else if(target->GetType() == cmTarget::OBJECT_LIBRARY) @@ -395,7 +395,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given OBJECT library \"" << (*targetIt) << "\" which may not be installed."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Store the target in the list to be installed. @@ -407,7 +407,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) << "\" which does not exist in this directory."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -499,7 +499,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given no FRAMEWORK DESTINATION for shared library " "FRAMEWORK target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -519,7 +519,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given no LIBRARY DESTINATION for shared library " "target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -539,7 +539,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given no ARCHIVE DESTINATION for static library " "target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -560,7 +560,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given no LIBRARY DESTINATION for module target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -595,7 +595,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE " "executable target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -612,7 +612,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmOStringStream e; e << "TARGETS given no RUNTIME DESTINATION for executable " "target \"" << target.GetName() << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -851,7 +851,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) // Unknown argument. cmOStringStream e; e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -866,7 +866,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) // The rename option works only with one file. cmOStringStream e; e << args[0] << " given RENAME option with more than one file."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -886,7 +886,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) // A destination is required. cmOStringStream e; e << args[0] << " given no DESTINATION!"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -927,7 +927,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -941,7 +941,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -969,7 +969,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" before a PATTERN or REGEX is given."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } literal_args += " EXCLUDE"; @@ -982,7 +982,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" before a PATTERN or REGEX is given."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -997,7 +997,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1011,7 +1011,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1025,7 +1025,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1040,7 +1040,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1055,7 +1055,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1069,7 +1069,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " does not allow \"" << args[i] << "\" after PATTERN or REGEX."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1094,7 +1094,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " given non-directory \"" << args[i] << "\" to install."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1150,7 +1150,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " given invalid file permission \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1162,7 +1162,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " given invalid directory permission \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1174,7 +1174,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " given invalid permission \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1183,7 +1183,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // Unknown argument. cmOStringStream e; e << args[0] << " given unknown argument \"" << args[i] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1204,7 +1204,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // A destination is required. cmOStringStream e; e << args[0] << " given no DESTINATION!"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1247,7 +1247,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) // Unknown argument. cmOStringStream e; e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1262,7 +1262,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) // A destination is required. cmOStringStream e; e << args[0] << " given no DESTINATION!"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1274,7 +1274,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) e << args[0] << " given invalid export file name \"" << fname << "\". " << "The FILE argument may not contain a path. " << "Specify the path in the DESTINATION argument."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1285,7 +1285,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) cmOStringStream e; e << args[0] << " given invalid export file name \"" << fname << "\". " << "The FILE argument must specify a name ending in \".cmake\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -1302,7 +1302,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) << "This name cannot be safely converted to a file name. " << "Specify a different export name or use the FILE option to set " << "a file name explicitly."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1327,7 +1327,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \"" << te->Target->GetName() << "\" does not have policy CMP0022 set to NEW."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -1368,7 +1368,7 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName, { cmOStringStream e; e << modeName << " given directory \"" << (*fileIt) << "\" to install."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } // Store the file for installation. diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 9db2490..8e14a08 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "install";} + virtual std::string GetName() const { return "install";} cmTypeMacro(cmInstallCommand, cmCommand); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 1287ea6..9a17052 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -94,7 +94,7 @@ void cmInstallExportGenerator::ComputeTempDir() { // Replace the destination path with a hash to keep it short. this->TempDir += - cmSystemTools::ComputeStringMD5(this->Destination.c_str()); + cmSystemTools::ComputeStringMD5(this->Destination); } else { @@ -138,11 +138,11 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) // Generate the import file for this export set. this->EFGen->SetExportFile(this->MainImportFile.c_str()); - this->EFGen->SetNamespace(this->Namespace.c_str()); + this->EFGen->SetNamespace(this->Namespace); this->EFGen->SetExportOld(this->ExportOld); if(this->ConfigurationTypes->empty()) { - if(this->ConfigurationName && *this->ConfigurationName) + if(!this->ConfigurationName.empty()) { this->EFGen->AddConfiguration(this->ConfigurationName); } @@ -157,7 +157,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) ci = this->ConfigurationTypes->begin(); ci != this->ConfigurationTypes->end(); ++ci) { - this->EFGen->AddConfiguration(ci->c_str()); + this->EFGen->AddConfiguration(*ci); } } this->EFGen->GenerateImportFile(); @@ -177,12 +177,12 @@ cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os, // Now create a configuration-specific install rule for the import // file of each configuration. std::vector<std::string> files; - for(std::map<cmStdString, cmStdString>::const_iterator + for(std::map<std::string, std::string>::const_iterator i = this->EFGen->GetConfigImportFiles().begin(); i != this->EFGen->GetConfigImportFiles().end(); ++i) { files.push_back(i->second); - std::string config_test = this->CreateConfigTest(i->first.c_str()); + std::string config_test = this->CreateConfigTest(i->first); os << indent << "if(" << config_test << ")\n"; this->AddInstallRule(os, cmInstallType_FILES, files, false, this->FilePermissions.c_str(), 0, 0, 0, diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 488d486..7eabbef 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -100,9 +100,9 @@ void cmInstallFilesCommand::FinalPass() else // reg exp list { std::vector<std::string> files; - std::string regex = this->FinalArgs[0].c_str(); + std::string regex = this->FinalArgs[0]; cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(), - regex.c_str(), files); + regex, files); std::vector<std::string>::iterator s = files.begin(); // for each argument, get the files diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index 5583fe4..4551ab1 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "install_files";} + virtual std::string GetName() const { return "install_files";} /** * This is called at the end after all the information diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index ec15044..6594218 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -80,8 +80,8 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os, //---------------------------------------------------------------------------- void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os, - const char* config, - Indent const& indent) + const std::string& config, + Indent const& indent) { std::vector<std::string> files; cmListFileBacktrace lfbt; diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 9dea296..23bf935 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -35,7 +35,7 @@ public: protected: virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); virtual void GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent); void AddFilesInstallRule(std::ostream& os, Indent const& indent, std::vector<std::string> const& files); diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index d105a0c..9370e48 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -91,7 +91,7 @@ void cmInstallGenerator << "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n"; os << indent << "endif()\n"; } - os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str(); + os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype; if(optional) { os << " OPTIONAL"; @@ -163,7 +163,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) } //---------------------------------------------------------------------------- -bool cmInstallGenerator::InstallsForConfig(const char* config) +bool cmInstallGenerator::InstallsForConfig(const std::string& config) { return this->GeneratesForConfig(config); } diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index c89ab8a..c72e9e9 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -48,7 +48,7 @@ public: std::string GetInstallDestination() const; /** Test if this generator installs something for a given configuration. */ - bool InstallsForConfig(const char*); + bool InstallsForConfig(const std::string& config); protected: virtual void GenerateScript(std::ostream& os); diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 54d903a..597f7ee 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -68,7 +68,7 @@ void cmInstallProgramsCommand::FinalPass() { std::vector<std::string> programs; cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(), - this->FinalArgs[0].c_str(), programs); + this->FinalArgs[0], programs); std::vector<std::string>::iterator s = programs.begin(); // for each argument, get the programs diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h index 95acfa2..90c7ba3 100644 --- a/Source/cmInstallProgramsCommand.h +++ b/Source/cmInstallProgramsCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "install_programs";} + virtual std::string GetName() const { return "install_programs";} /** * This is called at the end after all the information diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a39f45..ec2b518 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -59,8 +59,8 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os) //---------------------------------------------------------------------------- void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, - const char* config, - Indent const& indent) + const std::string& config, + Indent const& indent) { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; @@ -319,7 +319,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, //---------------------------------------------------------------------------- std::string -cmInstallTargetGenerator::GetInstallFilename(const char* config) const +cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const { NameType nameType = this->ImportLibrary? NameImplib : NameNormal; return @@ -330,7 +330,7 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const //---------------------------------------------------------------------------- std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, - const char* config, + const std::string& config, NameType nameType) { std::string fname; @@ -405,7 +405,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, //---------------------------------------------------------------------------- void cmInstallTargetGenerator -::AddTweak(std::ostream& os, Indent const& indent, const char* config, +::AddTweak(std::ostream& os, Indent const& indent, const std::string& config, std::string const& file, TweakMethod tweak) { cmOStringStream tw; @@ -423,7 +423,7 @@ cmInstallTargetGenerator //---------------------------------------------------------------------------- void cmInstallTargetGenerator -::AddTweak(std::ostream& os, Indent const& indent, const char* config, +::AddTweak(std::ostream& os, Indent const& indent, const std::string& config, std::vector<std::string> const& files, TweakMethod tweak) { if(files.size() == 1) @@ -470,7 +470,7 @@ std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file) //---------------------------------------------------------------------------- void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os, Indent const& indent, - const char* config, + const std::string& config, std::string const& file) { this->AddRPathCheckRule(os, indent, config, file); @@ -478,9 +478,9 @@ void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os, //---------------------------------------------------------------------------- void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, - Indent const& indent, - const char* config, - std::string const& file) + Indent const& indent, + const std::string& config, + std::string const& file) { this->AddInstallNamePatchRule(os, indent, config, file); this->AddChrpathPatchRule(os, indent, config, file); @@ -492,7 +492,8 @@ void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os, void cmInstallTargetGenerator ::AddInstallNamePatchRule(std::ostream& os, Indent const& indent, - const char* config, std::string const& toDestDirPath) + const std::string& config, + std::string const& toDestDirPath) { if(this->ImportLibrary || !(this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -513,7 +514,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. - std::map<cmStdString, cmStdString> install_name_remap; + std::map<std::string, std::string> install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set<cmTarget const*> const& sharedLibs @@ -590,7 +591,7 @@ cmInstallTargetGenerator { os << "\n" << indent << " -id \"" << new_id << "\""; } - for(std::map<cmStdString, cmStdString>::const_iterator + for(std::map<std::string, std::string>::const_iterator i = install_name_remap.begin(); i != install_name_remap.end(); ++i) { @@ -605,7 +606,8 @@ cmInstallTargetGenerator void cmInstallTargetGenerator ::AddRPathCheckRule(std::ostream& os, Indent const& indent, - const char* config, std::string const& toDestDirPath) + const std::string& config, + std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) @@ -642,7 +644,8 @@ cmInstallTargetGenerator void cmInstallTargetGenerator ::AddChrpathPatchRule(std::ostream& os, Indent const& indent, - const char* config, std::string const& toDestDirPath) + const std::string& config, + std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 18c3957..0f21da7 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -43,7 +43,7 @@ public: void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; } NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; } - std::string GetInstallFilename(const char* config) const; + std::string GetInstallFilename(const std::string& config) const; enum NameType { @@ -54,7 +54,7 @@ public: }; static std::string GetInstallFilename(cmTarget const* target, - const char* config, + const std::string& config, NameType nameType = NameNormal); cmTarget* GetTarget() const { return this->Target; } @@ -63,30 +63,33 @@ public: protected: virtual void GenerateScript(std::ostream& os); virtual void GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent); typedef void (cmInstallTargetGenerator::*TweakMethod)( - std::ostream&, Indent const&, const char*, std::string const& + std::ostream&, Indent const&, const std::string&, std::string const& ); void AddTweak(std::ostream& os, Indent const& indent, - const char* config, std::string const& file, + const std::string& config, std::string const& file, TweakMethod tweak); void AddTweak(std::ostream& os, Indent const& indent, - const char* config, std::vector<std::string> const& files, + const std::string& config, + std::vector<std::string> const& files, TweakMethod tweak); std::string GetDestDirPath(std::string const& file); void PreReplacementTweaks(std::ostream& os, Indent const& indent, - const char* config, std::string const& file); + const std::string& config, + std::string const& file); void PostReplacementTweaks(std::ostream& os, Indent const& indent, - const char* config, std::string const& file); + const std::string& config, + std::string const& file); void AddInstallNamePatchRule(std::ostream& os, Indent const& indent, - const char* config, + const std::string& config, const std::string& toDestDirPath); void AddChrpathPatchRule(std::ostream& os, Indent const& indent, - const char* config, + const std::string& config, std::string const& toDestDirPath); void AddRPathCheckRule(std::ostream& os, Indent const& indent, - const char* config, + const std::string& config, std::string const& toDestDirPath); void AddStripRule(std::ostream& os, Indent const& indent, diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 277ccea..b738844 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -52,7 +52,7 @@ bool cmInstallTargetsCommand else { std::string str = "Cannot find target: \"" + *s + "\" to install."; - this->SetError(str.c_str()); + this->SetError(str); return false; } } diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h index 2aa34db..e6cbe6e 100644 --- a/Source/cmInstallTargetsCommand.h +++ b/Source/cmInstallTargetsCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "install_targets";} + virtual std::string GetName() const { return "install_targets";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx index 4412414..3644d93 100644 --- a/Source/cmLinkDirectoriesCommand.cxx +++ b/Source/cmLinkDirectoriesCommand.cxx @@ -66,5 +66,5 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir) unixPath = tmp; } } - this->Makefile->AddLinkDirectory(unixPath.c_str()); + this->Makefile->AddLinkDirectory(unixPath); } diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index c6eb40c..8e04baf 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "link_directories";} + virtual std::string GetName() const { return "link_directories";} cmTypeMacro(cmLinkDirectoriesCommand, cmCommand); private: diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index 2f1db2a..996b538 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -33,7 +33,7 @@ bool cmLinkLibrariesCommand "a library"); return false; } - this->Makefile->AddLinkLibrary(i->c_str(), + this->Makefile->AddLinkLibrary(*i, cmTarget::DEBUG); } else if (*i == "optimized") @@ -45,12 +45,12 @@ bool cmLinkLibrariesCommand "a library"); return false; } - this->Makefile->AddLinkLibrary(i->c_str(), + this->Makefile->AddLinkLibrary(*i, cmTarget::OPTIMIZED); } else { - this->Makefile->AddLinkLibrary(i->c_str()); + this->Makefile->AddLinkLibrary(*i); } } diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h index 74de23c..c572439 100644 --- a/Source/cmLinkLibrariesCommand.h +++ b/Source/cmLinkLibrariesCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "link_libraries";} + virtual std::string GetName() const { return "link_libraries";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index df64695..f1ea088 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -69,17 +69,14 @@ bool cmListCommand } std::string e = "does not recognize sub-command "+subCommand; - this->SetError(e.c_str()); + this->SetError(e); return false; } //---------------------------------------------------------------------------- -bool cmListCommand::GetListString(std::string& listString, const char* var) +bool cmListCommand::GetListString(std::string& listString, + const std::string& var) { - if ( !var ) - { - return false; - } // get the old value const char* cacheValue = this->Makefile->GetDefinition(var); @@ -92,7 +89,8 @@ bool cmListCommand::GetListString(std::string& listString, const char* var) } //---------------------------------------------------------------------------- -bool cmListCommand::GetList(std::vector<std::string>& list, const char* var) +bool cmListCommand::GetList(std::vector<std::string>& list, + const std::string& var) { std::string listString; if ( !this->GetListString(listString, var) ) @@ -178,12 +176,12 @@ bool cmListCommand::HandleLengthCommand(std::vector<std::string> const& args) // do not check the return value here // if the list var is not found varArgsExpanded will have size 0 // and we will return 0 - this->GetList(varArgsExpanded, listName.c_str()); + this->GetList(varArgsExpanded, listName); size_t length = varArgsExpanded.size(); char buffer[1024]; sprintf(buffer, "%d", static_cast<int>(length)); - this->Makefile->AddDefinition(variableName.c_str(), buffer); + this->Makefile->AddDefinition(variableName, buffer); return true; } @@ -200,9 +198,9 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) const std::string& variableName = args[args.size() - 1]; // expand the variable std::vector<std::string> varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { - this->Makefile->AddDefinition(variableName.c_str(), "NOTFOUND"); + this->Makefile->AddDefinition(variableName, "NOTFOUND"); return true; } // FIXME: Add policy to make non-existing lists an error like empty lists. @@ -231,13 +229,13 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } value += varArgsExpanded[item]; } - this->Makefile->AddDefinition(variableName.c_str(), value.c_str()); + this->Makefile->AddDefinition(variableName, value.c_str()); return true; } @@ -255,7 +253,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args) const std::string& listName = args[1]; // expand the variable std::string listString; - this->GetListString(listString, listName.c_str()); + this->GetListString(listString, listName); size_t cc; for ( cc = 2; cc < args.size(); ++ cc ) { @@ -266,7 +264,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args) listString += args[cc]; } - this->Makefile->AddDefinition(listName.c_str(), listString.c_str()); + this->Makefile->AddDefinition(listName, listString.c_str()); return true; } @@ -283,9 +281,9 @@ bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args) const std::string& variableName = args[args.size() - 1]; // expand the variable std::vector<std::string> varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { - this->Makefile->AddDefinition(variableName.c_str(), "-1"); + this->Makefile->AddDefinition(variableName, "-1"); return true; } @@ -297,13 +295,13 @@ bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args) { char indexString[32]; sprintf(indexString, "%d", index); - this->Makefile->AddDefinition(variableName.c_str(), indexString); + this->Makefile->AddDefinition(variableName, indexString); return true; } index++; } - this->Makefile->AddDefinition(variableName.c_str(), "-1"); + this->Makefile->AddDefinition(variableName, "-1"); return true; } @@ -321,12 +319,12 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args) // expand the variable int item = atoi(args[2].c_str()); std::vector<std::string> varArgsExpanded; - if((!this->GetList(varArgsExpanded, listName.c_str()) + if((!this->GetList(varArgsExpanded, listName) || varArgsExpanded.empty()) && item != 0) { cmOStringStream str; str << "index: " << item << " out of range (0, 0)"; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } @@ -343,7 +341,7 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args) str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << (varArgsExpanded.size() == 0?0:(varArgsExpanded.size()-1)) << ")"; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } } @@ -364,7 +362,7 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args) sep = ";"; } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -381,7 +379,7 @@ bool cmListCommand const std::string& listName = args[1]; // expand the variable std::vector<std::string> varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError("sub-command REMOVE_ITEM requires list to be present."); return false; @@ -413,7 +411,7 @@ bool cmListCommand sep = ";"; } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -432,7 +430,7 @@ bool cmListCommand const std::string& listName = args[1]; // expand the variable std::vector<std::string> varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError("sub-command REVERSE requires list to be present."); return false; @@ -448,7 +446,7 @@ bool cmListCommand sep = ";"; } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -467,7 +465,7 @@ bool cmListCommand const std::string& listName = args[1]; // expand the variable std::vector<std::string> varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError( "sub-command REMOVE_DUPLICATES requires list to be present."); @@ -493,7 +491,7 @@ bool cmListCommand } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -512,7 +510,7 @@ bool cmListCommand const std::string& listName = args[1]; // expand the variable std::vector<std::string> varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError("sub-command SORT requires list to be present."); return false; @@ -530,7 +528,7 @@ bool cmListCommand sep = ";"; } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } @@ -548,7 +546,7 @@ bool cmListCommand::HandleRemoveAtCommand( const std::string& listName = args[1]; // expand the variable std::vector<std::string> varArgsExpanded; - if ( !this->GetList(varArgsExpanded, listName.c_str()) ) + if ( !this->GetList(varArgsExpanded, listName) ) { this->SetError("sub-command REMOVE_AT requires list to be present."); return false; @@ -576,7 +574,7 @@ bool cmListCommand::HandleRemoveAtCommand( str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; - this->SetError(str.str().c_str()); + this->SetError(str.str()); return false; } removed.push_back(static_cast<size_t>(item)); @@ -604,7 +602,7 @@ bool cmListCommand::HandleRemoveAtCommand( } } - this->Makefile->AddDefinition(listName.c_str(), value.c_str()); + this->Makefile->AddDefinition(listName, value.c_str()); return true; } diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h index 0cb5da2..5ea1d9f 100644 --- a/Source/cmListCommand.h +++ b/Source/cmListCommand.h @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "list";} + virtual std::string GetName() const { return "list";} cmTypeMacro(cmListCommand, cmCommand); protected: @@ -60,8 +60,8 @@ protected: bool HandleReverseCommand(std::vector<std::string> const& args); - bool GetList(std::vector<std::string>& list, const char* var); - bool GetListString(std::string& listString, const char* var); + bool GetList(std::vector<std::string>& list, const std::string& var); + bool GetListString(std::string& listString, const std::string& var); }; diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 7461d37..34781d3 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -397,12 +397,12 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token, << "Argument not separated from preceding token by whitespace."; if(isError) { - this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str()); return false; } else { - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str()); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str()); return true; } } diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index dfd98fa..427e29d 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -33,7 +33,7 @@ bool cmLoadCacheCommand // and they can not be overridden. bool excludeFiles=false; unsigned int i; - std::set<cmStdString> excludes; + std::set<std::string> excludes; for(i=0; i<args.size(); i++) { @@ -55,7 +55,7 @@ bool cmLoadCacheCommand // If this set is empty, no internal cache entries are // brought in. bool includeFiles=false; - std::set<cmStdString> includes; + std::set<std::string> includes; for(i=0; i<args.size(); i++) { @@ -81,7 +81,7 @@ bool cmLoadCacheCommand { break; } - this->Makefile->GetCacheManager()->LoadCache(args[i].c_str(), false, + this->Makefile->GetCacheManager()->LoadCache(args[i], false, excludes, includes); } @@ -104,7 +104,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args) if(!cmSystemTools::FileExists(cacheFile.c_str())) { std::string e = "Cannot load cache file from " + cacheFile; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -186,11 +186,11 @@ void cmLoadCacheCommand::CheckLine(const char* line) var = this->Prefix + var; if(value.length()) { - this->Makefile->AddDefinition(var.c_str(), value.c_str()); + this->Makefile->AddDefinition(var, value.c_str()); } else { - this->Makefile->RemoveDefinition(var.c_str()); + this->Makefile->RemoveDefinition(var); } } } diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index c8f7236..04207d0 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -40,12 +40,12 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "load_cache";} + virtual std::string GetName() const { return "load_cache";} cmTypeMacro(cmLoadCacheCommand, cmCommand); protected: - std::set<cmStdString> VariablesToRead; + std::set<std::string> VariablesToRead; std::string Prefix; bool ReadWithPrefix(std::vector<std::string> const& args); diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 21ee0fe..a4063a6 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -69,7 +69,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return info.Name; } + virtual std::string GetName() const { return info.Name; } static const char* LastName; static void TrapsForSignals(int sig) @@ -201,7 +201,7 @@ bool cmLoadCommandCommand // Start by removing the definition in case of failure. std::string reportVar = "CMAKE_LOADED_COMMAND_"; reportVar += args[0]; - this->Makefile->RemoveDefinition(reportVar.c_str()); + this->Makefile->RemoveDefinition(reportVar); // the file must exist std::string moduleName = @@ -219,7 +219,7 @@ bool cmLoadCommandCommand cmSystemTools::ExpandRegistryValues(exp); // Glob the entry in case of wildcards. - cmSystemTools::GlobDirs(exp.c_str(), path); + cmSystemTools::GlobDirs(exp, path); } // Try to find the program. @@ -229,7 +229,7 @@ bool cmLoadCommandCommand cmOStringStream e; e << "Attempt to load command failed from file \"" << moduleName << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -246,12 +246,12 @@ bool cmLoadCommandCommand err += " Additional error info is:\n"; err += error; } - this->SetError(err.c_str()); + this->SetError(err); return false; } // Report what file was loaded for this command. - this->Makefile->AddDefinition(reportVar.c_str(), fullPath.c_str()); + this->Makefile->AddDefinition(reportVar, fullPath.c_str()); // find the init function std::string initFuncName = args[0] + "Init"; diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index 11bcf09..4581269 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -20,7 +20,7 @@ public: virtual cmCommand* Clone() { return new cmLoadCommandCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - virtual const char* GetName() const {return "load_command";} + virtual std::string GetName() const {return "load_command";} virtual bool IsDiscouraged() const { return true; } cmTypeMacro(cmLoadCommandCommand, cmCommand); }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7890379..c47147c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -22,6 +22,7 @@ #include "cmSourceFile.h" #include "cmTest.h" #include "cmTestGenerator.h" +#include "cmCustomCommandGenerator.h" #include "cmVersion.h" #include "cmake.h" @@ -281,7 +282,7 @@ void cmLocalGenerator::GenerateTestFiles() // Compute the set of configurations. std::vector<std::string> configurationTypes; - const char* config = + const std::string& config = this->Makefile->GetConfigurations(configurationTypes, false); std::string file = this->Makefile->GetStartOutputDirectory(); @@ -326,7 +327,7 @@ void cmLocalGenerator::GenerateTestFiles() fout << "subdirs("; std::string outP = this->Children[i]->GetMakefile()->GetStartOutputDirectory(); - fout << this->Convert(outP.c_str(),START_OUTPUT); + fout << this->Convert(outP,START_OUTPUT); fout << ")" << std::endl; } } @@ -385,11 +386,11 @@ void cmLocalGenerator::GenerateInstallRules() // Compute the set of configurations. std::vector<std::string> configurationTypes; - const char* config = + const std::string& config = this->Makefile->GetConfigurations(configurationTypes, false); // Choose a default install configuration. - const char* default_config = config; + const char* default_config = config.c_str(); const char* default_order[] = {"RELEASE", "MINSIZEREL", "RELWITHDEBINFO", "DEBUG", 0}; for(const char** c = default_order; *c && !default_config; ++c) @@ -504,7 +505,7 @@ void cmLocalGenerator::GenerateInstallRules() { std::string odir = (*ci)->GetMakefile()->GetStartOutputDirectory(); cmSystemTools::ConvertToUnixSlashes(odir); - fout << " include(\"" << odir.c_str() + fout << " include(\"" << odir << "/cmake_install.cmake\")" << std::endl; } } @@ -524,12 +525,12 @@ void cmLocalGenerator::GenerateInstallRules() "endif()\n\n"; fout << "file(WRITE \"" - << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" " + << homedir << "/${CMAKE_INSTALL_MANIFEST}\" " << "\"\")" << std::endl; fout << "foreach(file ${CMAKE_INSTALL_MANIFEST_FILES})" << std::endl << " file(APPEND \"" - << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" " + << homedir << "/${CMAKE_INSTALL_MANIFEST}\" " << "\"${file}\\n\")" << std::endl << "endforeach()" << std::endl; } @@ -558,7 +559,7 @@ void cmLocalGenerator::GenerateTargetManifest() } if(configNames.empty()) { - target.GenerateTargetManifest(0); + target.GenerateTargetManifest(""); } else { @@ -573,25 +574,25 @@ void cmLocalGenerator::GenerateTargetManifest() } void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const char* lang, + const std::string& lang, cmSourceFile& source, cmGeneratorTarget& target) { std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); - objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); + objectDir = this->Convert(objectDir,START_OUTPUT,SHELL); std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL); std::string sourceFile = - this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true); + this->Convert(source.GetFullPath(),START_OUTPUT,SHELL,true); std::string varString = "CMAKE_"; varString += lang; varString += "_COMPILE_OBJECT"; std::vector<std::string> rules; - rules.push_back(this->Makefile->GetRequiredDefinition(varString.c_str())); + rules.push_back(this->Makefile->GetRequiredDefinition(varString)); varString = "CMAKE_"; varString += lang; varString += "_FLAGS"; std::string flags; - flags += this->Makefile->GetSafeDefinition(varString.c_str()); + flags += this->Makefile->GetSafeDefinition(varString); flags += " "; { std::vector<std::string> includes; @@ -605,7 +606,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, std::vector<std::string> commands; cmSystemTools::ExpandList(rules, commands); cmLocalGenerator::RuleVariables vars; - vars.Language = lang; + vars.Language = lang.c_str(); vars.Source = sourceFile.c_str(); vars.Object = objectFile.c_str(); vars.ObjectDir = objectDir.c_str(); @@ -618,8 +619,8 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, // Parse the string to get the custom command line. cmCustomCommandLine commandLine; - std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str()); - for(std::vector<cmStdString>::iterator a = cmd.begin(); + std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str()); + for(std::vector<std::string>::iterator a = cmd.begin(); a != cmd.end(); ++a) { commandLine.push_back(*a); @@ -647,17 +648,17 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, this->Makefile->AddCustomCommandToOutput( ofname, depends, - source.GetFullPath().c_str(), + source.GetFullPath(), commandLines, comment.c_str(), this->Makefile->GetStartOutputDirectory() ); } -void cmLocalGenerator::AddBuildTargetRule(const char* llang, +void cmLocalGenerator::AddBuildTargetRule(const std::string& llang, cmGeneratorTarget& target) { - cmStdString objs; + std::string objs; std::vector<std::string> objVector; // Add all the sources outputs to the depends of the target std::vector<cmSourceFile*> classes; @@ -682,7 +683,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, objVector.push_back(ofname); this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target); - objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE); + objs += this->Convert(ofname,START_OUTPUT,MAKEFILE); objs += " "; } } @@ -704,7 +705,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, &target); linkLibs = frameworkPath + linkPath + linkLibs; cmLocalGenerator::RuleVariables vars; - vars.Language = llang; + vars.Language = llang.c_str(); vars.Objects = objs.c_str(); vars.ObjectDir = "."; vars.Target = targetName.c_str(); @@ -713,13 +714,13 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, vars.LinkFlags = linkFlags.c_str(); std::string langFlags; - this->AddLanguageFlags(langFlags, llang, 0); - this->AddArchitectureFlags(langFlags, &target, llang, 0); + this->AddLanguageFlags(langFlags, llang, ""); + this->AddArchitectureFlags(langFlags, &target, llang, ""); vars.LanguageCompileFlags = langFlags.c_str(); cmCustomCommandLines commandLines; std::vector<std::string> rules; - rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str())); + rules.push_back(this->Makefile->GetRequiredDefinition(createRule)); std::vector<std::string> commands; cmSystemTools::ExpandList(rules, commands); for(std::vector<std::string>::iterator i = commands.begin(); @@ -729,8 +730,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, this->ExpandRuleVariables(*i, vars); // Parse the string to get the custom command line. cmCustomCommandLine commandLine; - std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str()); - for(std::vector<cmStdString>::iterator a = cmd.begin(); + std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str()); + for(std::vector<std::string>::iterator a = cmd.begin(); a != cmd.end(); ++a) { commandLine.push_back(*a); @@ -744,22 +745,22 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, std::string comment = "Linking "; comment += llang; comment += " target "; - comment += this->Convert(targetFullPath.c_str(), START_OUTPUT); + comment += this->Convert(targetFullPath, START_OUTPUT); this->Makefile->AddCustomCommandToOutput( - targetFullPath.c_str(), + targetFullPath, objVector, - 0, + "", commandLines, comment.c_str(), this->Makefile->GetStartOutputDirectory() ); target.Target->AddSourceFile - (this->Makefile->GetSource(targetFullPath.c_str())); + (this->Makefile->GetSource(targetFullPath)); } void cmLocalGenerator -::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang) +::CreateCustomTargetsAndCommands(std::set<std::string> const& lang) { cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator l = tgts.begin(); @@ -777,12 +778,12 @@ void cmLocalGenerator case cmTarget::MODULE_LIBRARY: case cmTarget::EXECUTABLE: { - const char* llang = target.Target->GetLinkerLanguage(); - if(!llang) + std::string llang = target.Target->GetLinkerLanguage(); + if(llang.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.Target->GetName()); + target.Target->GetName().c_str()); return; } // if the language is not in the set lang then create custom @@ -902,6 +903,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.TargetPDB; } } + if(replaceValues.TargetCompilePDB) + { + if(variable == "TARGET_COMPILE_PDB") + { + return replaceValues.TargetCompilePDB; + } + } if(replaceValues.DependencyFile ) { if(variable == "DEP_FILE") @@ -1075,28 +1083,28 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, { std::string arg1 = actualReplace + "_ARG1"; cmSystemTools::ReplaceString(arg1, "${LANG}", lang); - compilerArg1 = this->Makefile->GetDefinition(arg1.c_str()); + compilerArg1 = this->Makefile->GetDefinition(arg1); compilerTarget = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str()); + std::string("CMAKE_") + lang + "_COMPILER_TARGET"); compilerOptionTarget = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILE_OPTIONS_TARGET").c_str()); + std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_TARGET"); compilerExternalToolchain = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILER_EXTERNAL_TOOLCHAIN").c_str()); + std::string("CMAKE_") + lang + + "_COMPILER_EXTERNAL_TOOLCHAIN"); compilerOptionExternalToolchain = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str()); + std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN"); compilerSysroot = this->Makefile->GetDefinition("CMAKE_SYSROOT"); compilerOptionSysroot = this->Makefile->GetDefinition( - (std::string("CMAKE_") + lang + - "_COMPILE_OPTIONS_SYSROOT").c_str()); + std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_SYSROOT"); } if(actualReplace.find("${LANG}") != actualReplace.npos) { @@ -1105,11 +1113,11 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, if(actualReplace == variable) { std::string replace = - this->Makefile->GetSafeDefinition(variable.c_str()); + this->Makefile->GetSafeDefinition(variable); // if the variable is not a FLAG then treat it like a path if(variable.find("_FLAG") == variable.npos) { - std::string ret = this->ConvertToOutputForExisting(replace.c_str()); + std::string ret = this->ConvertToOutputForExisting(replace); // if there is a required first argument to the compiler add it // to the compiler string if(compilerArg1) @@ -1150,8 +1158,11 @@ void cmLocalGenerator::ExpandRuleVariables(std::string& s, const RuleVariables& replaceValues) { - this->InsertRuleLauncher(s, replaceValues.CMTarget, - replaceValues.RuleLauncher); + if(replaceValues.RuleLauncher) + { + this->InsertRuleLauncher(s, replaceValues.CMTarget, + replaceValues.RuleLauncher); + } std::string::size_type start = s.find('<'); // no variables to expand if(start == s.npos) @@ -1195,7 +1206,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s, //---------------------------------------------------------------------------- const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, - const char* prop) + const std::string& prop) { if(target) { @@ -1209,7 +1220,7 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, //---------------------------------------------------------------------------- void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, - const char* prop) + const std::string& prop) { if(const char* val = this->GetRuleLauncher(target, prop)) { @@ -1221,19 +1232,20 @@ void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, - std::string const& result) +cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote, + std::string const& result, + OutputFormat format) { // If this is a windows shell, the result has a space, and the path // already exists, we can use a short-path to reference it without a // space. if(this->WindowsShell && result.find(' ') != result.npos && - cmSystemTools::FileExists(remote)) + cmSystemTools::FileExists(remote.c_str())) { std::string tmp; - if(cmSystemTools::GetShortPath(remote, tmp)) + if(cmSystemTools::GetShortPath(remote.c_str(), tmp)) { - return this->Convert(tmp.c_str(), NONE, SHELL, true); + return this->Convert(tmp, NONE, format, true); } } @@ -1243,57 +1255,62 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOutputForExisting(const char* remote, - RelativeRoot local) +cmLocalGenerator::ConvertToOutputForExisting(const std::string& remote, + RelativeRoot local, + OutputFormat format) { // Perform standard conversion. - std::string result = this->Convert(remote, local, SHELL, true); + std::string result = this->Convert(remote, local, format, true); // Consider short-path. - return this->ConvertToOutputForExistingCommon(remote, result); + return this->ConvertToOutputForExistingCommon(remote, result, format); } //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, - const char* local) + const std::string& local, + OutputFormat format) { // Perform standard conversion. - std::string result = this->Convert(remote, local, SHELL, true); + std::string result = this->Convert(remote, local, format, true); // Consider short-path. const char* remotePath = this->GetRelativeRootPath(remote); - return this->ConvertToOutputForExistingCommon(remotePath, result); + return this->ConvertToOutputForExistingCommon(remotePath, result, format); } //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToIncludeReference(std::string const& path) +cmLocalGenerator::ConvertToIncludeReference(std::string const& path, + OutputFormat format) { - return this->ConvertToOutputForExisting(path.c_str()); + return this->ConvertToOutputForExisting(path, START_OUTPUT, format); } //---------------------------------------------------------------------------- std::string cmLocalGenerator::GetIncludeFlags( const std::vector<std::string> &includes, cmGeneratorTarget* target, - const char* lang, bool forResponseFile, - const char *config) + const std::string& lang, + bool forResponseFile, + const std::string& config) { - if(!lang) + if(lang.empty()) { return ""; } + OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL; cmOStringStream includeFlags; std::string flagVar = "CMAKE_INCLUDE_FLAG_"; flagVar += lang; const char* includeFlag = - this->Makefile->GetSafeDefinition(flagVar.c_str()); + this->Makefile->GetSafeDefinition(flagVar); flagVar = "CMAKE_INCLUDE_FLAG_SEP_"; flagVar += lang; - const char* sep = this->Makefile->GetDefinition(flagVar.c_str()); + const char* sep = this->Makefile->GetDefinition(flagVar); bool quotePaths = false; if(this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) { @@ -1319,17 +1336,17 @@ std::string cmLocalGenerator::GetIncludeFlags( const char* sysIncludeFlag = 0; if(repeatFlag) { - sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar.c_str()); + sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar); } std::string fwSearchFlagVar = "CMAKE_"; fwSearchFlagVar += lang; fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; const char* fwSearchFlag = - this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + this->Makefile->GetDefinition(fwSearchFlagVar); bool flagUsed = false; - std::set<cmStdString> emitted; + std::set<std::string> emitted; #ifdef __APPLE__ emitted.insert("/System/Library/Frameworks"); #endif @@ -1344,10 +1361,9 @@ std::string cmLocalGenerator::GetIncludeFlags( frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); if(emitted.insert(frameworkDir).second) { - OutputFormat format = forResponseFile? RESPONSE : SHELL; includeFlags - << fwSearchFlag << this->Convert(frameworkDir.c_str(), - START_OUTPUT, format, true) + << fwSearchFlag << this->Convert(frameworkDir, + START_OUTPUT, shellFormat, true) << " "; } continue; @@ -1356,7 +1372,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if(!flagUsed || repeatFlag) { if(sysIncludeFlag && target && - target->IsSystemIncludeDirectory(i->c_str(), config)) + target->IsSystemIncludeDirectory(*i, config)) { includeFlags << sysIncludeFlag; } @@ -1366,16 +1382,8 @@ std::string cmLocalGenerator::GetIncludeFlags( } flagUsed = true; } - std::string includePath; - if(forResponseFile) - { - includePath = this->Convert(i->c_str(), START_OUTPUT, - RESPONSE, true); - } - else - { - includePath = this->ConvertToIncludeReference(*i); - } + std::string includePath = + this->ConvertToIncludeReference(*i, shellFormat); if(quotePaths && includePath.size() && includePath[0] != '\"') { includeFlags << "\""; @@ -1399,7 +1407,7 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, cmTarget const* target, - const char* config) + const std::string& config) { std::vector<std::string> targetDefines; target->GetCompileDefinitions(targetDefines, @@ -1410,12 +1418,12 @@ void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( std::string& flags, cmTarget* target, - const char* lang, const char* config + const std::string& lang, const std::string& config ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; if(const char* langFlagRegexStr = - this->Makefile->GetDefinition(langFlagRegexVar.c_str())) + this->Makefile->GetDefinition(langFlagRegexVar)) { // Filter flags acceptable to this language. cmsys::RegularExpression r(langFlagRegexStr); @@ -1432,7 +1440,7 @@ void cmLocalGenerator::AddCompileOptions( { // (Re-)Escape this flag. COMPILE_FLAGS were already parsed // as a command line above, and COMPILE_OPTIONS are escaped. - this->AppendFlagEscape(flags, i->c_str()); + this->AppendFlagEscape(flags, *i); } } } @@ -1450,7 +1458,7 @@ void cmLocalGenerator::AddCompileOptions( i != opts.end(); ++i) { // COMPILE_OPTIONS are escaped. - this->AppendFlagEscape(flags, i->c_str()); + this->AppendFlagEscape(flags, *i); } } } @@ -1458,8 +1466,8 @@ void cmLocalGenerator::AddCompileOptions( //---------------------------------------------------------------------------- void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget* target, - const char* lang, - const char *config, + const std::string& lang, + const std::string& config, bool stripImplicitInclDirs ) { @@ -1482,7 +1490,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, } // Do not repeat an include path. - std::set<cmStdString> emitted; + std::set<std::string> emitted; // Store the automatic include paths. if(includeBinaryDir) @@ -1515,7 +1523,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, std::string impDirVar = "CMAKE_"; impDirVar += lang; impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES"; - if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str())) + if(const char* value = this->Makefile->GetDefinition(impDirVar)) { std::vector<std::string> impDirVec; cmSystemTools::ExpandListArgument(value, impDirVec); @@ -1590,13 +1598,13 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, if(!config.empty()) { std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config; - this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name.c_str())); + this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name)); } this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS")); if(!config.empty()) { std::string name = "STATIC_LIBRARY_FLAGS_" + config; - this->AppendFlags(flags, target->GetProperty(name.c_str())); + this->AppendFlags(flags, target->GetProperty(name)); } } @@ -1629,7 +1637,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, std::string build = libraryLinkVariable; build += "_"; build += buildType; - linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } if(this->Makefile->IsOn("WIN32") && @@ -1645,7 +1653,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); - linkFlags += this->Convert(sf->GetFullPath().c_str(), + linkFlags += this->Convert(sf->GetFullPath(), FULL, SHELL); linkFlags += " "; } @@ -1661,7 +1669,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; - targetLinkFlags = target->GetProperty(configLinkFlags.c_str()); + targetLinkFlags = target->GetProperty(configLinkFlags); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1669,7 +1677,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *target, false); + *target, false, false); } break; case cmTarget::EXECUTABLE: @@ -1681,26 +1689,26 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string build = "CMAKE_EXE_LINKER_FLAGS_"; build += buildType; - linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - const char* linkLanguage = target->Target->GetLinkerLanguage(); - if(!linkLanguage) + std::string linkLanguage = target->Target->GetLinkerLanguage(); + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target->Target->GetName()); + target->Target->GetName().c_str()); return; } - this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); + this->AddLanguageFlags(flags, linkLanguage, buildType); this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *target, false); + *target, false, false); if(cmSystemTools::IsOn (this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); - linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); + linkFlags += this->Makefile->GetSafeDefinition(sFlagVar); linkFlags += " "; } if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") ) @@ -1722,7 +1730,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, exportFlagVar += "_FLAG"; linkFlags += - this->Makefile->GetSafeDefinition(exportFlagVar.c_str()); + this->Makefile->GetSafeDefinition(exportFlagVar); linkFlags += " "; } const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"); @@ -1735,7 +1743,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; - targetLinkFlags = target->GetProperty(configLinkFlags.c_str()); + targetLinkFlags = target->GetProperty(configLinkFlags); if(targetLinkFlags) { linkFlags += targetLinkFlags; @@ -1749,7 +1757,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } -std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib) +std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib, + OutputFormat format) { #if defined(_WIN32) && !defined(__CYGWIN__) // Work-ardound command line parsing limitations in MSVC 6.0 and @@ -1771,14 +1780,14 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib) sp += lib.substr(pos); // Convert to an output path. - return this->Convert(sp.c_str(), NONE, SHELL); + return this->Convert(sp.c_str(), NONE, format); } } } #endif // Normal behavior. - return this->Convert(lib.c_str(), START_OUTPUT, SHELL); + return this->Convert(lib, START_OUTPUT, format); } /** @@ -1790,8 +1799,11 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget &tgt, - bool relink) + bool relink, + bool forResponseFile) { + OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL; + bool escapeAllowMakeVars = !forResponseFile; cmOStringStream fout; const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); @@ -1804,7 +1816,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, // Collect library linking flags command line options. std::string linkLibs; - const char* linkLanguage = cli.GetLinkLanguage(); + std::string linkLanguage = cli.GetLinkLanguage(); std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); @@ -1817,7 +1829,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, linkFlagsVar += "_FLAGS"; if( tgt.GetType() == cmTarget::EXECUTABLE ) { - linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str()); + linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar); linkLibs += " "; } @@ -1826,7 +1838,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, fwSearchFlagVar += linkLanguage; fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; const char* fwSearchFlag = - this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + this->Makefile->GetDefinition(fwSearchFlagVar); if(fwSearchFlag && *fwSearchFlag) { std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths(); @@ -1834,7 +1846,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, fdi != fwDirs.end(); ++fdi) { frameworkPath += fwSearchFlag; - frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false); + frameworkPath += this->Convert(*fdi, NONE, shellFormat, false); frameworkPath += " "; } } @@ -1844,7 +1856,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, for(std::vector<std::string>::const_iterator libDir = libDirs.begin(); libDir != libDirs.end(); ++libDir) { - std::string libpath = this->ConvertToOutputForExisting(libDir->c_str()); + std::string libpath = this->ConvertToOutputForExisting(*libDir, + START_OUTPUT, + shellFormat); linkPath += " " + libPathFlag; linkPath += libpath; linkPath += libPathTerminator; @@ -1862,7 +1876,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, } if(li->IsPath) { - linkLibs += this->ConvertToLinkReference(li->Value); + linkLibs += this->ConvertToLinkReference(li->Value, shellFormat); } else { @@ -1887,7 +1901,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, ri != runtimeDirs.end(); ++ri) { rpath += cli.GetRuntimeFlag(); - rpath += this->Convert(ri->c_str(), NONE, SHELL, false); + rpath += this->Convert(*ri, NONE, shellFormat, false); rpath += " "; } fout << rpath; @@ -1901,7 +1915,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, if(!rpath.empty()) { fout << cli.GetRuntimeFlag(); - fout << this->EscapeForShell(rpath.c_str(), true); + fout << this->EscapeForShell(rpath, escapeAllowMakeVars); fout << " "; } } @@ -1911,7 +1925,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) { fout << cli.GetRPathLinkFlag(); - fout << this->EscapeForShell(rpath_link.c_str(), true); + fout << this->EscapeForShell(rpath_link, escapeAllowMakeVars); fout << " "; } @@ -1920,7 +1934,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, standardLibsVar += cli.GetLinkLanguage(); standardLibsVar += "_STANDARD_LIBRARIES"; if(const char* stdLibs = - this->Makefile->GetDefinition(standardLibsVar.c_str())) + this->Makefile->GetDefinition(standardLibsVar)) { fout << stdLibs << " "; } @@ -1932,8 +1946,8 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, //---------------------------------------------------------------------------- void cmLocalGenerator::AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, - const char *lang, - const char* config) + const std::string& lang, + const std::string& config) { // Only add Mac OS X specific flags on Darwin platforms (OSX and iphone): if(!this->Makefile->IsOn("APPLE")) @@ -1951,14 +1965,14 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, std::string sysrootFlagVar = std::string("CMAKE_") + lang + "_SYSROOT_FLAG"; const char* sysrootFlag = - this->Makefile->GetDefinition(sysrootFlagVar.c_str()); + this->Makefile->GetDefinition(sysrootFlagVar); const char* deploymentTarget = this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); std::string deploymentTargetFlagVar = std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG"; const char* deploymentTargetFlag = - this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str()); - if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F')) + this->Makefile->GetDefinition(deploymentTargetFlagVar); + if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F')) { for(std::vector<std::string>::iterator i = archs.begin(); i != archs.end(); ++i) @@ -1989,19 +2003,19 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AddLanguageFlags(std::string& flags, - const char* lang, - const char* config) + const std::string& lang, + const std::string& config) { // Add language-specific flags. std::string flagsVar = "CMAKE_"; flagsVar += lang; flagsVar += "_FLAGS"; - this->AddConfigVariableFlags(flags, flagsVar.c_str(), config); + this->AddConfigVariableFlags(flags, flagsVar, config); } //---------------------------------------------------------------------------- -bool cmLocalGenerator::GetRealDependency(const char* inName, - const char* config, +bool cmLocalGenerator::GetRealDependency(const std::string& inName, + const std::string& config, std::string& dep) { // Older CMake code may specify the dependency using the target @@ -2028,7 +2042,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, { // make sure it is not just a coincidence that the target name // found is part of the inName - if(cmSystemTools::FileIsFullPath(inName)) + if(cmSystemTools::FileIsFullPath(inName.c_str())) { std::string tLocation; if(target->GetType() >= cmTarget::EXECUTABLE && @@ -2076,7 +2090,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, } // The name was not that of a CMake target. It must name a file. - if(cmSystemTools::FileIsFullPath(inName)) + if(cmSystemTools::FileIsFullPath(inName.c_str())) { // This is a full path. Return it as given. dep = inName; @@ -2101,7 +2115,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, //---------------------------------------------------------------------------- void cmLocalGenerator::AddSharedFlags(std::string& flags, - const char* lang, + const std::string& lang, bool shared) { std::string flagsVar; @@ -2112,23 +2126,24 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, flagsVar = "CMAKE_SHARED_LIBRARY_"; flagsVar += lang; flagsVar += "_FLAGS"; - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); } } static void AddVisibilityCompileOption(std::string &flags, cmTarget* target, - cmLocalGenerator *lg, const char *lang) + cmLocalGenerator *lg, + const std::string& lang) { std::string l(lang); std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY"; - const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str()); + const char *opt = lg->GetMakefile()->GetDefinition(compileOption); if (!opt) { return; } std::string flagDefine = l + "_VISIBILITY_PRESET"; - const char *prop = target->GetProperty(flagDefine.c_str()); + const char *prop = target->GetProperty(flagDefine); if (!prop) { return; @@ -2154,7 +2169,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags, { std::string compileOption = "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN"; - const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str()); + const char *opt = lg->GetMakefile()->GetDefinition(compileOption); if (!opt) { return; @@ -2171,7 +2186,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags, //---------------------------------------------------------------------------- void cmLocalGenerator ::AddVisibilityPresetFlags(std::string &flags, cmTarget* target, - const char *lang) + const std::string& lang) { int targetType = target->GetType(); bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY) @@ -2183,13 +2198,13 @@ void cmLocalGenerator return; } - if (!lang) + if (lang.empty()) { return; } AddVisibilityCompileOption(flags, target, this, lang); - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { AddInlineVisibilityCompileOption(flags, target, this); } @@ -2198,7 +2213,7 @@ void cmLocalGenerator //---------------------------------------------------------------------------- void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target, std::string const& lang, - const char *config) + const std::string& config) { int targetType = target->GetType(); @@ -2207,7 +2222,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target, if (this->GetShouldUseOldFlags(shared, lang)) { - this->AddSharedFlags(flags, lang.c_str(), shared); + this->AddSharedFlags(flags, lang, shared); } else { @@ -2228,7 +2243,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target, } if (shared) { - this->AppendFeatureOptions(flags, lang.c_str(), "DLL"); + this->AppendFeatureOptions(flags, lang, "DLL"); } } } @@ -2245,7 +2260,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared, flagsVar += lang; flagsVar += "_FLAGS"; const char* flags = - this->Makefile->GetSafeDefinition(flagsVar.c_str()); + this->Makefile->GetSafeDefinition(flagsVar); if (flags && flags != originalFlags) { @@ -2290,14 +2305,14 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, std::string flagsVar = "CMAKE_"; flagsVar += lang; flagsVar += "_COMPILE_OPTIONS_PIE"; - picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str()); + picFlags = this->Makefile->GetSafeDefinition(flagsVar); } if (!picFlags) { std::string flagsVar = "CMAKE_"; flagsVar += lang; flagsVar += "_COMPILE_OPTIONS_PIC"; - picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str()); + picFlags = this->Makefile->GetSafeDefinition(flagsVar); } if (picFlags) { @@ -2306,25 +2321,25 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, for(std::vector<std::string>::const_iterator oi = options.begin(); oi != options.end(); ++oi) { - this->AppendFlagEscape(flags, oi->c_str()); + this->AppendFlagEscape(flags, *oi); } } } //---------------------------------------------------------------------------- void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, - const char* var, - const char* config) + const std::string& var, + const std::string& config) { // Add the flags from the variable itself. std::string flagsVar = var; - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); // Add the flags from the build-type specific variable. - if(config && *config) + if(!config.empty()) { flagsVar += "_"; flagsVar += cmSystemTools::UpperCase(config); - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str())); + this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); } } @@ -2345,7 +2360,7 @@ void cmLocalGenerator::AppendFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator::AppendFlagEscape(std::string& flags, - const char* rawFlag) + const std::string& rawFlag) { this->AppendFlags(flags, this->EscapeForShell(rawFlag).c_str()); } @@ -2385,16 +2400,16 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, std::string &definesString, - const char* lang) + const std::string& lang) { // Lookup the define flag for the current language. std::string dflag = "-D"; - if(lang) + if(!lang.empty()) { std::string defineFlagVar = "CMAKE_"; defineFlagVar += lang; defineFlagVar += "_DEFINE_FLAG"; - const char* df = this->Makefile->GetDefinition(defineFlagVar.c_str()); + const char* df = this->Makefile->GetDefinition(defineFlagVar); if(df && *df) { dflag = df; @@ -2449,46 +2464,46 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, //---------------------------------------------------------------------------- void cmLocalGenerator::AppendFeatureOptions( - std::string& flags, const char* lang, const char* feature) + std::string& flags, const std::string& lang, const char* feature) { std::string optVar = "CMAKE_"; optVar += lang; optVar += "_COMPILE_OPTIONS_"; optVar += feature; - if(const char* optionList = this->Makefile->GetDefinition(optVar.c_str())) + if(const char* optionList = this->Makefile->GetDefinition(optVar)) { std::vector<std::string> options; cmSystemTools::ExpandListArgument(optionList, options); for(std::vector<std::string>::const_iterator oi = options.begin(); oi != options.end(); ++oi) { - this->AppendFlagEscape(flags, oi->c_str()); + this->AppendFlagEscape(flags, *oi); } } } //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, +cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg, const char* default_comment) { // Check for a comment provided with the command. - if(cc.GetComment()) + if(ccg.GetComment()) { - return cc.GetComment(); + return ccg.GetComment(); } // Construct a reasonable default comment if possible. - if(!cc.GetOutputs().empty()) + if(!ccg.GetOutputs().empty()) { std::string comment; comment = "Generating "; const char* sep = ""; - for(std::vector<std::string>::const_iterator o = cc.GetOutputs().begin(); - o != cc.GetOutputs().end(); ++o) + for(std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin(); + o != ccg.GetOutputs().end(); ++o) { comment += sep; - comment += this->Convert(o->c_str(), cmLocalGenerator::START_OUTPUT); + comment += this->Convert(*o, cmLocalGenerator::START_OUTPUT); sep = ", "; } return comment; @@ -2500,7 +2515,8 @@ cmLocalGenerator::ConstructComment(const cmCustomCommand& cc, //---------------------------------------------------------------------------- std::string -cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(const char* remote) +cmLocalGenerator::ConvertToOptionallyRelativeOutputPath( + const std::string& remote) { return this->Convert(remote, START_OUTPUT, SHELL, true); } @@ -2520,7 +2536,7 @@ const char* cmLocalGenerator::GetRelativeRootPath(RelativeRoot relroot) } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::Convert(const char* source, +std::string cmLocalGenerator::Convert(const std::string& source, RelativeRoot relative, OutputFormat output, bool optional) @@ -2542,24 +2558,24 @@ std::string cmLocalGenerator::Convert(const char* source, case HOME: //result = cmSystemTools::CollapseFullPath(result.c_str()); result = this->ConvertToRelativePath(this->HomeDirectoryComponents, - result.c_str()); + result); break; case START: //result = cmSystemTools::CollapseFullPath(result.c_str()); result = this->ConvertToRelativePath(this->StartDirectoryComponents, - result.c_str()); + result); break; case HOME_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); result = this->ConvertToRelativePath(this->HomeOutputDirectoryComponents, - result.c_str()); + result); break; case START_OUTPUT: //result = cmSystemTools::CollapseFullPath(result.c_str()); result = this->ConvertToRelativePath(this->StartOutputDirectoryComponents, - result.c_str()); + result); break; case FULL: result = cmSystemTools::CollapseFullPath(result.c_str()); @@ -2568,11 +2584,11 @@ std::string cmLocalGenerator::Convert(const char* source, break; } } - return this->ConvertToOutputFormat(result.c_str(), output); + return this->ConvertToOutputFormat(result, output); } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::ConvertToOutputFormat(const char* source, +std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source, OutputFormat output) { std::string result = source; @@ -2603,18 +2619,18 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const char* source, pos++; } } - result = this->EscapeForShell(result.c_str(), true, false); + result = this->EscapeForShell(result, true, false); } else if(output == RESPONSE) { - result = this->EscapeForShell(result.c_str(), false, false); + result = this->EscapeForShell(result, false, false); } return result; } //---------------------------------------------------------------------------- std::string cmLocalGenerator::Convert(RelativeRoot remote, - const char* local, + const std::string& local, OutputFormat output, bool optional) { @@ -2623,12 +2639,12 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote, // The relative root must have a path (i.e. not FULL or NONE) assert(remotePath != 0); - if(local && (!optional || this->UseRelativePaths)) + if(!local.empty() && (!optional || this->UseRelativePaths)) { std::vector<std::string> components; - cmSystemTools::SplitPath(local, components); + cmSystemTools::SplitPath(local.c_str(), components); std::string result = this->ConvertToRelativePath(components, remotePath); - return this->ConvertToOutputFormat(result.c_str(), output); + return this->ConvertToOutputFormat(result, output); } else { @@ -2709,7 +2725,8 @@ static bool cmLocalGeneratorNotAbove(const char* a, const char* b) //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, - const char* in_remote, bool force) + const std::string& in_remote, + bool force) { // The path should never be quoted. assert(in_remote[0] != '\"'); @@ -2718,7 +2735,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, assert(local.size() > 0 && !(local[local.size()-1] == "")); // If the path is already relative then just return the path. - if(!cmSystemTools::FileIsFullPath(in_remote)) + if(!cmSystemTools::FileIsFullPath(in_remote.c_str())) { return in_remote; } @@ -2737,11 +2754,11 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, std::string local_path = cmSystemTools::JoinPath(local); if(!((cmLocalGeneratorNotAbove(local_path.c_str(), this->RelativePathTopBinary.c_str()) && - cmLocalGeneratorNotAbove(in_remote, + cmLocalGeneratorNotAbove(in_remote.c_str(), this->RelativePathTopBinary.c_str())) || (cmLocalGeneratorNotAbove(local_path.c_str(), this->RelativePathTopSource.c_str()) && - cmLocalGeneratorNotAbove(in_remote, + cmLocalGeneratorNotAbove(in_remote.c_str(), this->RelativePathTopSource.c_str())))) { return in_remote; @@ -2751,7 +2768,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, // Identify the longest shared path component between the remote // path and the local path. std::vector<std::string> remote; - cmSystemTools::SplitPath(in_remote, remote); + cmSystemTools::SplitPath(in_remote.c_str(), remote); unsigned int common=0; while(common < remote.size() && common < local.size() && @@ -2822,7 +2839,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, void cmLocalGenerator ::GenerateTargetInstallRules( - std::ostream& os, const char* config, + std::ostream& os, const std::string& config, std::vector<std::string> const& configurationTypes) { // Convert the old-style install specification from each target to @@ -2969,11 +2986,11 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName, //---------------------------------------------------------------------------- std::string& cmLocalGenerator -::CreateSafeUniqueObjectFileName(const char* sin, +::CreateSafeUniqueObjectFileName(const std::string& sin, std::string const& dir_max) { // Look for an existing mapped name for this object file. - std::map<cmStdString,cmStdString>::iterator it = + std::map<std::string,std::string>::iterator it = this->UniqueObjectNamesMap.find(sin); // If no entry exists create one. @@ -3056,7 +3073,7 @@ cmLocalGenerator #endif // Insert the newly mapped object file name. - std::map<cmStdString, cmStdString>::value_type e(sin, ssin); + std::map<std::string, std::string>::value_type e(sin, ssin); it = this->UniqueObjectNamesMap.insert(e).first; } @@ -3065,6 +3082,14 @@ cmLocalGenerator } //---------------------------------------------------------------------------- +void cmLocalGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>&, + cmGeneratorTarget const*) +{ + +} + +//---------------------------------------------------------------------------- std::string cmLocalGenerator ::GetObjectFileNameWithoutTarget(const cmSourceFile& source, @@ -3129,12 +3154,13 @@ cmLocalGenerator bool replaceExt = this->NeedBackwardsCompatibility_2_4(); if(!replaceExt) { - if(const char* lang = source.GetLanguage()) + std::string lang = source.GetLanguage(); + if(!lang.empty()) { std::string repVar = "CMAKE_"; repVar += lang; repVar += "_OUTPUT_EXTENSION_REPLACE"; - replaceExt = this->Makefile->IsOn(repVar.c_str()); + replaceExt = this->Makefile->IsOn(repVar); } } @@ -3159,11 +3185,11 @@ cmLocalGenerator } // Convert to a safe name. - return this->CreateSafeUniqueObjectFileName(objectName.c_str(), dir_max); + return this->CreateSafeUniqueObjectFileName(objectName, dir_max); } //---------------------------------------------------------------------------- -const char* +std::string cmLocalGenerator ::GetSourceFileLanguage(const cmSourceFile& source) { @@ -3171,7 +3197,7 @@ cmLocalGenerator } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) +std::string cmLocalGenerator::EscapeForShellOldStyle(const std::string& str) { std::string result; #if defined(_WIN32) && !defined(__CYGWIN__) @@ -3187,7 +3213,7 @@ std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) } return str; #else - for(const char* ch = str; *ch != '\0'; ++ch) + for(const char* ch = str.c_str(); *ch != '\0'; ++ch) { if(*ch == ' ') { @@ -3200,28 +3226,30 @@ std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) } //---------------------------------------------------------------------------- -static bool cmLocalGeneratorIsShellOperator(const char* str) -{ - if(strcmp(str, "<") == 0 || - strcmp(str, ">") == 0 || - strcmp(str, "<<") == 0 || - strcmp(str, ">>") == 0 || - strcmp(str, "|") == 0 || - strcmp(str, "||") == 0 || - strcmp(str, "&&") == 0 || - strcmp(str, "&>") == 0 || - strcmp(str, "1>") == 0 || - strcmp(str, "2>") == 0 || - strcmp(str, "2>&1") == 0 || - strcmp(str, "1>&2") == 0) +static bool cmLocalGeneratorIsShellOperator(const std::string& str) +{ + static std::set<std::string> shellOperators; + if(shellOperators.empty()) { - return true; + shellOperators.insert("<"); + shellOperators.insert(">"); + shellOperators.insert("<<"); + shellOperators.insert(">>"); + shellOperators.insert("|"); + shellOperators.insert("||"); + shellOperators.insert("&&"); + shellOperators.insert("&>"); + shellOperators.insert("1>"); + shellOperators.insert("2>"); + shellOperators.insert("2>&1"); + shellOperators.insert("1>&2"); } - return false; + return shellOperators.count(str) > 0; } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, +std::string cmLocalGenerator::EscapeForShell(const std::string& str, + bool makeVars, bool forEcho) { // Do not escape shell operators. @@ -3263,28 +3291,28 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, // Compute the buffer size needed. int size = (this->WindowsShell ? - cmsysSystem_Shell_GetArgumentSizeForWindows(str, flags) : - cmsysSystem_Shell_GetArgumentSizeForUnix(str, flags)); + cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) : + cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags)); // Compute the shell argument itself. std::vector<char> arg(size); if(this->WindowsShell) { - cmsysSystem_Shell_GetArgumentForWindows(str, &arg[0], flags); + cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags); } else { - cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags); + cmsysSystem_Shell_GetArgumentForUnix(str.c_str(), &arg[0], flags); } return std::string(&arg[0]); } //---------------------------------------------------------------------------- -std::string cmLocalGenerator::EscapeForCMake(const char* str) +std::string cmLocalGenerator::EscapeForCMake(const std::string& str) { // Always double-quote the argument to take care of most escapes. std::string result = "\""; - for(const char* c = str; *c; ++c) + for(const char* c = str.c_str(); *c; ++c) { if(*c == '"') { @@ -3447,7 +3475,8 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const } //---------------------------------------------------------------------------- -static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop) +static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, + const std::string& prop) { if(const char* val = target->GetProperty(prop)) { @@ -3457,7 +3486,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop) //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, - const char* targetName, + const std::string& targetName, const char* fname) { // Find the Info.plist template. @@ -3486,7 +3515,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, // back to the directory-level values set by the user. cmMakefile* mf = this->Makefile; mf->PushScope(); - mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName); + mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName.c_str()); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE"); cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER"); @@ -3501,8 +3530,8 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, //---------------------------------------------------------------------------- void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, - const char* targetName, - const char* fname) + const std::string& targetName, + const char* fname) { // Find the Info.plist template. const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); @@ -3530,7 +3559,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, // back to the directory-level values set by the user. cmMakefile* mf = this->Makefile; mf->PushScope(); - mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName); + mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName.c_str()); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING"); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9764813..61488fe 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -21,6 +21,7 @@ class cmTarget; class cmTargetManifest; class cmSourceFile; class cmCustomCommand; +class cmCustomCommandGenerator; /** \class cmLocalGenerator * \brief Create required build files for a directory. @@ -106,11 +107,12 @@ public: */ enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT }; enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, RESPONSE }; - std::string ConvertToOutputFormat(const char* source, OutputFormat output); - std::string Convert(const char* remote, RelativeRoot local, + std::string ConvertToOutputFormat(const std::string& source, + OutputFormat output); + std::string Convert(const std::string& remote, RelativeRoot local, OutputFormat output = UNCHANGED, bool optional = false); - std::string Convert(RelativeRoot remote, const char* local, + std::string Convert(RelativeRoot remote, const std::string& local, OutputFormat output = UNCHANGED, bool optional = false); @@ -125,7 +127,7 @@ public: * remote path must use forward slashes and not already be escaped * or quoted. */ - std::string ConvertToOptionallyRelativeOutputPath(const char* remote); + std::string ConvertToOptionallyRelativeOutputPath(const std::string& remote); ///! set/get the parent generator cmLocalGenerator* GetParent(){return this->Parent;} @@ -137,24 +139,26 @@ public: void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, - const char *lang, const char* config); + const std::string&lang, const std::string& config); - void AddLanguageFlags(std::string& flags, const char* lang, - const char* config); + void AddLanguageFlags(std::string& flags, const std::string& lang, + const std::string& config); void AddCMP0018Flags(std::string &flags, cmTarget* target, - std::string const& lang, const char *config); + std::string const& lang, const std::string& config); void AddVisibilityPresetFlags(std::string &flags, cmTarget* target, - const char *lang); - void AddConfigVariableFlags(std::string& flags, const char* var, - const char* config); + const std::string& lang); + void AddConfigVariableFlags(std::string& flags, const std::string& var, + const std::string& config); ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const char* newFlags); - virtual void AppendFlagEscape(std::string& flags, const char* rawFlag); + virtual void AppendFlagEscape(std::string& flags, + const std::string& rawFlag); ///! Get the include flags for the current makefile and language std::string GetIncludeFlags(const std::vector<std::string> &includes, cmGeneratorTarget* target, - const char* lang, bool forResponseFile = false, - const char *config = 0); + const std::string& lang, + bool forResponseFile = false, + const std::string& config = ""); /** * Encode a list of preprocessor definitions for the compiler @@ -175,10 +179,10 @@ public: */ void JoinDefines(const std::set<std::string>& defines, std::string &definesString, - const char* lang); + const std::string& lang); /** Lookup and append options associated with a particular feature. */ - void AppendFeatureOptions(std::string& flags, const char* lang, + void AppendFeatureOptions(std::string& flags, const std::string& lang, const char* feature); /** \brief Get absolute path to dependency \a name @@ -193,19 +197,22 @@ public: * the source directory of this generator. This should only be * used for dependencies of custom commands. */ - bool GetRealDependency(const char* name, const char* config, + bool GetRealDependency(const std::string& name, const std::string& config, std::string& dep); ///! for existing files convert to output path and short path if spaces - std::string ConvertToOutputForExisting(const char* remote, - RelativeRoot local = START_OUTPUT); + std::string ConvertToOutputForExisting(const std::string& remote, + RelativeRoot local = START_OUTPUT, + OutputFormat format = SHELL); /** For existing path identified by RelativeRoot convert to output path and short path if spaces. */ std::string ConvertToOutputForExisting(RelativeRoot remote, - const char* local = 0); + const std::string& local = "", + OutputFormat format = SHELL); - virtual std::string ConvertToIncludeReference(std::string const& path); + virtual std::string ConvertToIncludeReference(std::string const& path, + OutputFormat format = SHELL); /** Called from command-line hook to clear dependencies. */ virtual void ClearDependencies(cmMakefile* /* mf */, @@ -220,16 +227,17 @@ public: /** Get the include flags for the current makefile and language. */ void GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget* target, - const char* lang = "C", const char *config = 0, + const std::string& lang = "C", + const std::string& config = "", bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, - const char* lang, const char* config); + const std::string& lang, const std::string& config); void AddCompileDefinitions(std::set<std::string>& defines, cmTarget const* target, - const char* config); + const std::string& config); /** Compute the language used to compile the given source file. */ - const char* GetSourceFileLanguage(const cmSourceFile& source); + std::string GetSourceFileLanguage(const cmSourceFile& source); // Fill the vector with the target names for the object files, // preprocessed files and assembly files. @@ -245,6 +253,7 @@ public: } cmTarget* CMTarget; const char* TargetPDB; + const char* TargetCompilePDB; const char* TargetVersionMajor; const char* TargetVersionMinor; const char* Language; @@ -278,14 +287,14 @@ public: system to replace make variable references. Optionally adjust escapes for the special case of passing to the native echo command. */ - std::string EscapeForShell(const char* str, bool makeVars = false, + std::string EscapeForShell(const std::string& str, bool makeVars = false, bool forEcho = false); /** Backwards-compatibility version of EscapeForShell. */ - std::string EscapeForShellOldStyle(const char* str); + std::string EscapeForShellOldStyle(const std::string& str); /** Escape the given string as an argument in a CMake script. */ - static std::string EscapeForCMake(const char* str); + static std::string EscapeForCMake(const std::string& str); enum FortranFormat { @@ -303,7 +312,8 @@ public: * or quoted. */ std::string ConvertToRelativePath(const std::vector<std::string>& local, - const char* remote, bool force=false); + const std::string& remote, + bool force=false); /** * Get the relative path from the generator output directory to a @@ -331,17 +341,17 @@ public: /** * Generate a Mac OS X application bundle Info.plist file. */ - void GenerateAppleInfoPList(cmTarget* target, const char* targetName, + void GenerateAppleInfoPList(cmTarget* target, const std::string& targetName, const char* fname); /** * Generate a Mac OS X framework Info.plist file. */ void GenerateFrameworkInfoPList(cmTarget* target, - const char* targetName, + const std::string& targetName, const char* fname); /** Construct a comment for a custom command. */ - std::string ConstructComment(const cmCustomCommand& cc, + std::string ConstructComment(cmCustomCommandGenerator const& ccg, const char* default_comment = ""); // Compute object file names. std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source, @@ -362,13 +372,18 @@ public: std::string& linkPath, cmGeneratorTarget* target); + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = 0); + protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::string& linkLibraries, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget &, - bool relink); + bool relink, + bool forResponseFile); // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, @@ -377,17 +392,18 @@ protected: std::string ExpandRuleVariable(std::string const& variable, const RuleVariables& replaceValues); - const char* GetRuleLauncher(cmTarget* target, const char* prop); + const char* GetRuleLauncher(cmTarget* target, const std::string& prop); void InsertRuleLauncher(std::string& s, cmTarget* target, - const char* prop); + const std::string& prop); /** Convert a target to a utility target for unsupported * languages of a generator */ - void AddBuildTargetRule(const char* llang, cmGeneratorTarget& target); + void AddBuildTargetRule(const std::string& llang, + cmGeneratorTarget& target); ///! add a custom command to build a .o file that is part of a target void AddCustomCommandToCreateObject(const char* ofname, - const char* lang, + const std::string& lang, cmSourceFile& source, cmGeneratorTarget& target); // Create Custom Targets and commands for unsupported languages @@ -395,14 +411,14 @@ protected: // generator directly. Any targets containing files that are not // of the types listed will be compiled as custom commands and added // to a custom target. - void CreateCustomTargetsAndCommands(std::set<cmStdString> const&); + void CreateCustomTargetsAndCommands(std::set<std::string> const&); // Handle old-style install rules stored in the targets. void GenerateTargetInstallRules( - std::ostream& os, const char* config, + std::ostream& os, const std::string& config, std::vector<std::string> const& configurationTypes); - std::string& CreateSafeUniqueObjectFileName(const char* sin, + std::string& CreateSafeUniqueObjectFileName(const std::string& sin, std::string const& dir_max); void ComputeObjectMaxPath(); @@ -411,7 +427,8 @@ protected: std::string FindRelativePathTopBinary(); void SetupPathConversions(); - virtual std::string ConvertToLinkReference(std::string const& lib); + virtual std::string ConvertToLinkReference(std::string const& lib, + OutputFormat format = SHELL); /** Check whether the native build system supports the given definition. Issues a warning. */ @@ -431,9 +448,9 @@ protected: std::vector<std::string> StartOutputDirectoryComponents; cmLocalGenerator* Parent; std::vector<cmLocalGenerator*> Children; - std::map<cmStdString, cmStdString> UniqueObjectNamesMap; + std::map<std::string, std::string> UniqueObjectNamesMap; std::string::size_type ObjectPathMax; - std::set<cmStdString> ObjectMaxPathViolations; + std::set<std::string> ObjectMaxPathViolations; bool WindowsShell; bool WindowsVSIDE; bool WatcomWMake; @@ -463,10 +480,12 @@ protected: cmIML_INT_uint64_t BackwardsCompatibility; bool BackwardsCompatibilityFinal; private: - std::string ConvertToOutputForExistingCommon(const char* remote, - std::string const& result); + std::string ConvertToOutputForExistingCommon(const std::string& remote, + std::string const& result, + OutputFormat format); - void AddSharedFlags(std::string& flags, const char* lang, bool shared); + void AddSharedFlags(std::string& flags, const std::string& lang, + bool shared); bool GetShouldUseOldFlags(bool shared, const std::string &lang) const; void AddPositionIndependentFlags(std::string& flags, std::string const& l, int targetType); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index cd12c9d..2f763ce 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -143,15 +143,17 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() // Virtual protected methods. std::string -cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib) +cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib, + OutputFormat format) { - return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL); + return this->Convert(lib, HOME_OUTPUT, format); } std::string -cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path) +cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path, + OutputFormat format) { - return this->Convert(path.c_str(), HOME_OUTPUT, SHELL); + return this->Convert(path, HOME_OUTPUT, format); } //---------------------------------------------------------------------------- @@ -265,6 +267,20 @@ void cmLocalNinjaGenerator::SetConfigName() } } +//---------------------------------------------------------------------------- +void cmLocalNinjaGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt) +{ + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + si->second = this->GetObjectFileNameWithoutTarget(*sf, + gt->ObjectDirectory); + } +} + void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); @@ -301,14 +317,15 @@ cmLocalNinjaGenerator this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs); } -void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, - cmNinjaDeps &ninjaDeps) +void cmLocalNinjaGenerator::AppendCustomCommandDeps( + cmCustomCommandGenerator const& ccg, + cmNinjaDeps &ninjaDeps) { - const std::vector<std::string> &deps = cc->GetDepends(); + const std::vector<std::string> &deps = ccg.GetDepends(); for (std::vector<std::string>::const_iterator i = deps.begin(); i != deps.end(); ++i) { std::string dep; - if (this->GetRealDependency(i->c_str(), this->GetConfigName(), dep)) + if (this->GetRealDependency(*i, this->GetConfigName(), dep)) ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str())); } } @@ -357,13 +374,13 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( return cmd.str(); } -void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, - std::vector<std::string> &cmdLines) +void cmLocalNinjaGenerator::AppendCustomCommandLines( + cmCustomCommandGenerator const& ccg, + std::vector<std::string> &cmdLines) { - cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); if (ccg.GetNumberOfCommands() > 0) { - const char* wd = cc->GetWorkingDirectory(); - if (!wd) + std::string wd = ccg.GetWorkingDirectory(); + if (wd.empty()) wd = this->GetMakefile()->GetStartOutputDirectory(); cmOStringStream cdCmd; @@ -376,11 +393,11 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, cmdLines.push_back(cdCmd.str()); } - std::string launcher = this->MakeCustomLauncher(*cc); + std::string launcher = this->MakeCustomLauncher(ccg); for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { cmdLines.push_back(launcher + - this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), SHELL)); + this->ConvertToOutputFormat(ccg.GetCommand(i), SHELL)); std::string& cmd = cmdLines.back(); ccg.AppendArguments(i, cmd); @@ -394,19 +411,21 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) return; - const std::vector<std::string> &outputs = cc->GetOutputs(); + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); + + const std::vector<std::string> &outputs = ccg.GetOutputs(); cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; std::transform(outputs.begin(), outputs.end(), ninjaOutputs.begin(), MapToNinjaPath()); - this->AppendCustomCommandDeps(cc, ninjaDeps); + this->AppendCustomCommandDeps(ccg, ninjaDeps); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); ++i) this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i); std::vector<std::string> cmdLines; - this->AppendCustomCommandLines(cc, cmdLines); + this->AppendCustomCommandLines(ccg, cmdLines); if (cmdLines.empty()) { this->GetGlobalNinjaGenerator()->WritePhonyBuild( @@ -421,7 +440,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( } else { this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild( this->BuildCommandLine(cmdLines), - this->ConstructComment(*cc), + this->ConstructComment(ccg), "Custom command for " + ninjaOutputs[0], ninjaOutputs, ninjaDeps, @@ -470,7 +489,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() } std::string cmLocalNinjaGenerator::MakeCustomLauncher( - const cmCustomCommand& cc) + cmCustomCommandGenerator const& ccg) { const char* property = "RULE_LAUNCH_CUSTOM"; const char* property_value = this->Makefile->GetProperty(property); @@ -485,13 +504,13 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher( RuleVariables vars; vars.RuleLauncher = property; std::string output; - const std::vector<std::string>& outputs = cc.GetOutputs(); + const std::vector<std::string>& outputs = ccg.GetOutputs(); if(!outputs.empty()) { RelativeRoot relative_root = - cc.GetWorkingDirectory() ? NONE : START_OUTPUT; + ccg.GetWorkingDirectory().empty() ? START_OUTPUT : NONE; - output = this->Convert(outputs[0].c_str(), relative_root, SHELL); + output = this->Convert(outputs[0], relative_root, SHELL); } vars.Output = output.c_str(); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index ea854c6..e91e60b 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -16,6 +16,7 @@ # include "cmLocalGenerator.h" # include "cmNinjaTypes.h" +class cmCustomCommandGenerator; class cmGlobalNinjaGenerator; class cmGeneratedFileStream; class cmake; @@ -55,8 +56,8 @@ public: const cmake* GetCMakeInstance() const; cmake* GetCMakeInstance(); - const char* GetConfigName() const - { return this->ConfigName.c_str(); } + std::string const& GetConfigName() const + { return this->ConfigName; } /// @return whether we are processing the top CMakeLists.txt file. bool isRootMakefile() const; @@ -92,16 +93,22 @@ public: void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target); - void AppendCustomCommandLines(const cmCustomCommand *cc, + void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg, std::vector<std::string> &cmdLines); - void AppendCustomCommandDeps(const cmCustomCommand *cc, + void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg, cmNinjaDeps &ninjaDeps); - virtual std::string ConvertToLinkReference(std::string const& lib); + virtual std::string ConvertToLinkReference(std::string const& lib, + OutputFormat format = SHELL); + + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = 0); protected: - virtual std::string ConvertToIncludeReference(std::string const& path); + virtual std::string ConvertToIncludeReference(std::string const& path, + OutputFormat format = SHELL); private: @@ -122,7 +129,7 @@ private: void WriteCustomCommandBuildStatements(); - std::string MakeCustomLauncher(const cmCustomCommand& cc); + std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg); std::string ConfigName; std::string HomeRelativeOutputPath; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 93722d1..ff173f5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -80,7 +80,6 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3() { - this->SilentNoColon = false; this->WindowsShell = false; this->IncludeDirective = "include"; this->MakefileVariableSize = 0; @@ -173,26 +172,71 @@ void cmLocalUnixMakefileGenerator3::Generate() } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::AddLocalObjectFile( - cmTarget* target, cmSourceFile* sf, std::string objNoTargetDir, - bool hasSourceExtension) +void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt) { - if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str())) + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) { - objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir); + cmSourceFile const* sf = si->first; + si->second = this->GetObjectFileNameWithoutTarget(*sf, + gt->ObjectDirectory); + } +} + +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3:: +GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles) +{ + std::set<std::string> emitted; + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmGeneratorTarget* gt = ti->second; + if (gt->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + std::vector<cmSourceFile const*> objectSources; + gt->GetObjectSources(objectSources); + // Compute full path to object file directory for this target. + std::string dir; + dir += gt->Makefile->GetCurrentOutputDirectory(); + dir += "/"; + dir += this->GetTargetDirectory(*gt->Target); + dir += "/"; + // Compute the name of each object file. + for(std::vector<cmSourceFile const*>::iterator + si = objectSources.begin(); + si != objectSources.end(); ++si) + { + cmSourceFile const* sf = *si; + bool hasSourceExtension = true; + std::string objectName = this->GetObjectFileNameWithoutTarget(*sf, + dir, + &hasSourceExtension); + if(cmSystemTools::FileIsFullPath(objectName.c_str())) + { + objectName = cmSystemTools::GetFilenameName(objectName); + } + LocalObjectInfo& info = localObjectFiles[objectName]; + info.HasSourceExtension = hasSourceExtension; + info.push_back(LocalObjectEntry(gt->Target, sf->GetLanguage())); + } } - LocalObjectInfo& info = this->LocalObjectFiles[objNoTargetDir]; - info.HasSourceExtension = hasSourceExtension; - info.push_back(LocalObjectEntry(target, sf->GetLanguage())); } //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets (std::vector<std::string>& targets) { - for (std::map<cmStdString, LocalObjectInfo>::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + std::map<std::string, LocalObjectInfo> localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); + for (std::map<std::string, LocalObjectInfo>::iterator lo = + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { targets.push_back(lo->first); @@ -235,7 +279,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() // only write local targets unless at the top Keep track of targets already // listed. - std::set<cmStdString> emittedTargets; + std::set<std::string> emittedTargets; if (this->Parent) { // write our targets, and while doing it collect up the object @@ -254,11 +298,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() bool do_assembly_rules = this->GetCreateAssemblySourceRules(); + std::map<std::string, LocalObjectInfo> localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); + // now write out the object rules // for each object file name - for (std::map<cmStdString, LocalObjectInfo>::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + for (std::map<std::string, LocalObjectInfo>::iterator lo = + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { // Add a convenience rule for building the object file. this->WriteObjectConvenienceRule(ruleFileStream, @@ -339,7 +386,7 @@ cmLocalUnixMakefileGenerator3 depends.push_back(output); std::vector<std::string> no_commands; this->WriteMakeRule(ruleFileStream, 0, - outNoExt.c_str(), depends, no_commands, true, true); + outNoExt, depends, no_commands, true, true); inHelp = false; } @@ -355,7 +402,7 @@ cmLocalUnixMakefileGenerator3 targetName += "/"; targetName += output; commands.push_back( - this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName.c_str()) + this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName) ); } this->CreateCDCommand(commands, @@ -371,7 +418,7 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 ::WriteLocalMakefileTargets(std::ostream& ruleFileStream, - std::set<cmStdString> &emitted) + std::set<std::string> &emitted) { std::vector<std::string> depends; std::vector<std::string> commands; @@ -407,12 +454,12 @@ void cmLocalUnixMakefileGenerator3 std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash(); makefile2 += "Makefile2"; commands.push_back(this->GetRecursiveMakeCall - (makefile2.c_str(),localName.c_str())); + (makefile2.c_str(),localName)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // Add a target with the canonical name (no prefix, suffix or path). if(localName != t->second->GetName()) @@ -436,17 +483,17 @@ void cmLocalUnixMakefileGenerator3 depends.clear(); commands.clear(); commands.push_back(this->GetRecursiveMakeCall - (makefileName.c_str(), makeTargetName.c_str())); + (makefileName.c_str(), makeTargetName)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "fast build rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); // Add a local name for the rule to relink the target before // installation. if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigurationName.c_str())) + ->NeedRelinkBeforeInstall(this->ConfigurationName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; @@ -455,13 +502,13 @@ void cmLocalUnixMakefileGenerator3 depends.clear(); commands.clear(); commands.push_back(this->GetRecursiveMakeCall - (makefile2.c_str(), makeTargetName.c_str())); + (makefile2.c_str(), makeTargetName)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Manual pre-install relink rule for target.", - localName.c_str(), depends, commands, true); + localName, depends, commands, true); } } } @@ -550,14 +597,14 @@ void cmLocalUnixMakefileGenerator3 ::WriteMakeRule(std::ostream& os, const char* comment, - const char* target, + const std::string& target, const std::vector<std::string>& depends, const std::vector<std::string>& commands, bool symbolic, bool in_help) { // Make sure there is a target. - if(!target || !*target) + if(target.empty()) { cmSystemTools::Error("No target for WriteMakeRule! called with comment: ", comment); @@ -582,7 +629,7 @@ cmLocalUnixMakefileGenerator3 // Construct the left hand side of the rule. replace = target; - std::string tgt = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); + std::string tgt = this->Convert(replace,HOME_OUTPUT,MAKEFILE); const char* space = ""; if(tgt.size() == 1) { @@ -615,7 +662,7 @@ cmLocalUnixMakefileGenerator3 dep != depends.end(); ++dep) { replace = *dep; - replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); + replace = this->Convert(replace,HOME_OUTPUT,MAKEFILE); os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n"; } } @@ -625,7 +672,7 @@ cmLocalUnixMakefileGenerator3 i != commands.end(); ++i) { replace = *i; - os << "\t" << replace.c_str() << "\n"; + os << "\t" << replace << "\n"; } if(symbolic && !this->WatcomWMake) { @@ -654,10 +701,10 @@ cmLocalUnixMakefileGenerator3 std::string scmd; if(cmSystemTools::GetShortPath(cmd.c_str(), scmd)) { - return this->Convert(scmd.c_str(), NONE, SHELL); + return this->Convert(scmd, NONE, SHELL); } } - return this->Convert(cmd.c_str(), root, SHELL); + return this->Convert(cmd, root, SHELL); } //---------------------------------------------------------------------------- @@ -758,15 +805,17 @@ cmLocalUnixMakefileGenerator3 depends.push_back(".hpux_make_needs_suffix_list"); this->WriteMakeRule(makefileStream, 0, ".SUFFIXES", depends, no_commands, false); - - cmGlobalUnixMakefileGenerator3* gg = - static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); - // Write special target to silence make output. This must be after - // the default target in case VERBOSE is set (which changes the - // name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a - // "VERBOSE=1" to be added as a make variable which will change the - // name of this special target. This gives a make-time choice to - // the user. + if(this->WatcomWMake) + { + // Switch on WMake feature, if an error or interrupt occurs during + // makefile processing, the current target being made may be deleted + // without prompting (the same as command line -e option). + makefileStream << + "\n" + ".ERASE\n" + "\n" + ; + } if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) { makefileStream @@ -774,12 +823,23 @@ cmLocalUnixMakefileGenerator3 << "VERBOSE = 1\n" << "\n"; } - if(this->SilentNoColon) + if(this->WatcomWMake) { - makefileStream << "$(VERBOSE).SILENT\n"; + makefileStream << + "!ifndef VERBOSE\n" + ".SILENT\n" + "!endif\n" + "\n" + ; } else { + // Write special target to silence make output. This must be after + // the default target in case VERBOSE is set (which changes the + // name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a + // "VERBOSE=1" to be added as a make variable which will change the + // name of this special target. This gives a make-time choice to + // the user. this->WriteMakeRule(makefileStream, "Suppress display of executed commands.", "$(VERBOSE).SILENT", @@ -789,6 +849,8 @@ cmLocalUnixMakefileGenerator3 // Work-around for makes that drop rules that have no dependencies // or commands. + cmGlobalUnixMakefileGenerator3* gg = + static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); std::string hack = gg->GetEmptyRuleHackDepends(); if(!hack.empty()) { @@ -829,7 +891,7 @@ void cmLocalUnixMakefileGenerator3 std::string runRule = "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; runRule += " --check-build-system "; - runRule += this->Convert(cmakefileName.c_str(),NONE,SHELL); + runRule += this->Convert(cmakefileName,NONE,SHELL); runRule += " 0"; std::vector<std::string> no_depends; @@ -859,11 +921,11 @@ void cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3 ::WriteConvenienceRule(std::ostream& ruleFileStream, - const char* realTarget, - const char* helpTarget) + const std::string& realTarget, + const std::string& helpTarget) { // A rule is only needed if the names are different. - if(strcmp(realTarget, helpTarget) != 0) + if(realTarget != helpTarget) { // The helper target depends on the real target. std::vector<std::string> depends; @@ -886,7 +948,7 @@ cmLocalUnixMakefileGenerator3 { std::string dir = this->HomeRelativeOutputPath; dir += this->GetTargetDirectory(target); - return this->Convert(dir.c_str(),NONE,UNCHANGED); + return this->Convert(dir,NONE,UNCHANGED); } @@ -947,7 +1009,9 @@ cmLocalUnixMakefileGenerator3 for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin(); i != ccs.end(); ++i) { - this->AppendCustomDepend(depends, *i); + cmCustomCommandGenerator ccg(*i, this->ConfigurationName, + this->Makefile); + this->AppendCustomDepend(depends, ccg); } } @@ -955,14 +1019,14 @@ cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3 ::AppendCustomDepend(std::vector<std::string>& depends, - const cmCustomCommand& cc) + cmCustomCommandGenerator const& ccg) { - for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin(); - d != cc.GetDepends().end(); ++d) + for(std::vector<std::string>::const_iterator d = ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { // Lookup the real name of the dependency in case it is a CMake target. std::string dep; - if(this->GetRealDependency(d->c_str(), this->ConfigurationName.c_str(), + if(this->GetRealDependency(*d, this->ConfigurationName, dep)) { depends.push_back(dep); @@ -981,7 +1045,9 @@ cmLocalUnixMakefileGenerator3 for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin(); i != ccs.end(); ++i) { - this->AppendCustomCommand(commands, *i, target, true, relative); + cmCustomCommandGenerator ccg(*i, this->ConfigurationName, + this->Makefile); + this->AppendCustomCommand(commands, ccg, target, true, relative); } } @@ -989,7 +1055,7 @@ cmLocalUnixMakefileGenerator3 void cmLocalUnixMakefileGenerator3 ::AppendCustomCommand(std::vector<std::string>& commands, - const cmCustomCommand& cc, + cmCustomCommandGenerator const& ccg, cmTarget* target, bool echo_comment, cmLocalGenerator::RelativeRoot relative, @@ -1001,8 +1067,8 @@ cmLocalUnixMakefileGenerator3 // their comments generated elsewhere. if(echo_comment) { - const char* comment = cc.GetComment(); - if(comment && *comment) + const char* comment = ccg.GetComment(); + if(comment && !*comment) { this->AppendEcho(commands, comment, cmLocalUnixMakefileGenerator3::EchoGenerate); @@ -1010,9 +1076,9 @@ cmLocalUnixMakefileGenerator3 } // if the command specified a working directory use it. - const char* dir = this->Makefile->GetStartOutputDirectory(); - const char* workingDir = cc.GetWorkingDirectory(); - if(workingDir) + std::string dir = this->Makefile->GetStartOutputDirectory(); + std::string workingDir = ccg.GetWorkingDirectory(); + if(!workingDir.empty()) { dir = workingDir; } @@ -1020,8 +1086,6 @@ cmLocalUnixMakefileGenerator3 { *content << dir; } - cmCustomCommandGenerator ccg(cc, this->ConfigurationName.c_str(), - this->Makefile); // Add each command line to the set of commands. std::vector<std::string> commands1; @@ -1053,9 +1117,9 @@ cmLocalUnixMakefileGenerator3 // Convert the command to a relative path only if the current // working directory will be the start-output directory. bool had_slash = cmd.find("/") != cmd.npos; - if(!workingDir) + if(workingDir.empty()) { - cmd = this->Convert(cmd.c_str(),START_OUTPUT); + cmd = this->Convert(cmd,START_OUTPUT); } bool has_slash = cmd.find("/") != cmd.npos; if(had_slash && !has_slash) @@ -1066,7 +1130,8 @@ cmLocalUnixMakefileGenerator3 cmd = "./" + cmd; } std::string launcher = - this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT); + this->MakeLauncher(ccg, target, + workingDir.empty()? START_OUTPUT : NONE); cmd = launcher + this->ConvertShellCommand(cmd, NONE); ccg.AppendArguments(c, cmd); @@ -1112,7 +1177,7 @@ cmLocalUnixMakefileGenerator3 } // Setup the proper working directory for the commands. - this->CreateCDCommand(commands1, dir, relative); + this->CreateCDCommand(commands1, dir.c_str(), relative); // push back the custom commands commands.insert(commands.end(), commands1.begin(), commands1.end()); @@ -1120,9 +1185,9 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- std::string -cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc, - cmTarget* target, - RelativeRoot relative) +cmLocalUnixMakefileGenerator3::MakeLauncher( + cmCustomCommandGenerator const& ccg, + cmTarget* target, RelativeRoot relative) { // Short-circuit if there is no launcher. const char* prop = "RULE_LAUNCH_CUSTOM"; @@ -1138,10 +1203,10 @@ cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc, vars.RuleLauncher = prop; vars.CMTarget = target; std::string output; - const std::vector<std::string>& outputs = cc.GetOutputs(); + const std::vector<std::string>& outputs = ccg.GetOutputs(); if(!outputs.empty()) { - output = this->Convert(outputs[0].c_str(), relative, SHELL); + output = this->Convert(outputs[0], relative, SHELL); } vars.Output = output.c_str(); @@ -1171,7 +1236,7 @@ cmLocalUnixMakefileGenerator3 cleanfile += filename; } cleanfile += ".cmake"; - std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); + std::string cleanfilePath = this->Convert(cleanfile, FULL); cmsys::ofstream fout(cleanfilePath.c_str()); if(!fout) { @@ -1183,25 +1248,25 @@ cmLocalUnixMakefileGenerator3 for(std::vector<std::string>::const_iterator f = files.begin(); f != files.end(); ++f) { - std::string fc = this->Convert(f->c_str(),START_OUTPUT,UNCHANGED); - fout << " " << this->EscapeForCMake(fc.c_str()) << "\n"; + std::string fc = this->Convert(*f,START_OUTPUT,UNCHANGED); + fout << " " << this->EscapeForCMake(fc) << "\n"; } fout << ")\n"; } std::string remove = "$(CMAKE_COMMAND) -P "; - remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL); + remove += this->Convert(cleanfile, START_OUTPUT, SHELL); commands.push_back(remove); // For the main clean rule add per-language cleaning. if(!filename) { // Get the set of source languages in the target. - std::set<cmStdString> languages; + std::set<std::string> languages; target.GetLanguages(languages); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" << "foreach(lang"; - for(std::set<cmStdString>::const_iterator l = languages.begin(); + for(std::set<std::string>::const_iterator l = languages.begin(); l != languages.end(); ++l) { fout << " " << *l; @@ -1267,14 +1332,14 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands, { // Use the native echo command. cmd = "@echo "; - cmd += this->EscapeForShell(line.c_str(), false, true); + cmd += this->EscapeForShell(line, false, true); } else { // Use cmake to echo the text in color. cmd = "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) "; cmd += color_name; - cmd += this->EscapeForShell(line.c_str()); + cmd += this->EscapeForShell(line); } commands.push_back(cmd); } @@ -1299,7 +1364,7 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands, //---------------------------------------------------------------------------- std::string cmLocalUnixMakefileGenerator3 -::CreateMakeVariable(const char* sin, const char* s2in) +::CreateMakeVariable(const std::string& sin, const std::string& s2in) { std::string s = sin; std::string s2 = s2in; @@ -1317,7 +1382,7 @@ cmLocalUnixMakefileGenerator3 // see if the variable has been defined before and return // the modified version of the variable - std::map<cmStdString, cmStdString>::iterator i = + std::map<std::string, std::string>::iterator i = this->MakeVariableMap.find(unmodified); if(i != this->MakeVariableMap.end()) { @@ -1588,14 +1653,14 @@ cmLocalUnixMakefileGenerator3 langs.begin(); li != langs.end(); ++li) { // construct the checker - std::string lang = li->c_str(); + std::string lang = *li; // Create the scanner for this language cmDepends *scanner = 0; if(lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM") { // TODO: Handle RC (resource files) dependencies correctly. - scanner = new cmDependsC(this, targetDir, lang.c_str(), &validDeps); + scanner = new cmDependsC(this, targetDir, lang, &validDeps); } #ifdef CMAKE_BUILD_WITH_CMAKE else if(lang == "Fortran") @@ -1613,7 +1678,7 @@ cmLocalUnixMakefileGenerator3 scanner->SetLocalGenerator(this); scanner->SetFileComparison (this->GlobalGenerator->GetCMakeInstance()->GetFileComparison()); - scanner->SetLanguage(lang.c_str()); + scanner->SetLanguage(lang); scanner->SetTargetDirectory(dir.c_str()); scanner->Write(ruleFileStream, internalRuleFileStream); @@ -1721,12 +1786,12 @@ void cmLocalUnixMakefileGenerator3 { text = "Running external command ..."; } - std::set<cmStdString>::const_iterator dit; + std::set<std::string>::const_iterator dit; for ( dit = glIt->second.GetUtilities().begin(); dit != glIt->second.GetUtilities().end(); ++ dit ) { - depends.push_back(dit->c_str()); + depends.push_back(*dit); } this->AppendEcho(commands, text, cmLocalUnixMakefileGenerator3::EchoGlobal); @@ -1746,7 +1811,7 @@ void cmLocalUnixMakefileGenerator3 cmLocalGenerator::START_OUTPUT); std::string targetName = glIt->second.GetName(); this->WriteMakeRule(ruleFileStream, targetString.c_str(), - targetName.c_str(), depends, commands, true); + targetName, depends, commands, true); // Provide a "/fast" version of the target. depends.clear(); @@ -1766,7 +1831,7 @@ void cmLocalUnixMakefileGenerator3 } targetName += "/fast"; this->WriteMakeRule(ruleFileStream, targetString.c_str(), - targetName.c_str(), depends, commands, true); + targetName, depends, commands, true); } } @@ -1786,15 +1851,15 @@ void cmLocalUnixMakefileGenerator3 cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; - progCmd << this->Convert(progressDir.c_str(), + progCmd << this->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); std::string progressFile = cmake::GetCMakeFilesDirectory(); progressFile += "/progress.marks"; std::string progressFileNameFull = - this->ConvertToFullPath(progressFile.c_str()); - progCmd << " " << this->Convert(progressFileNameFull.c_str(), + this->ConvertToFullPath(progressFile); + progCmd << " " << this->Convert(progressFileNameFull, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); commands.push_back(progCmd.str()); @@ -1802,14 +1867,14 @@ void cmLocalUnixMakefileGenerator3 std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash(); mf2Dir += "Makefile2"; commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), - recursiveTarget.c_str())); + recursiveTarget)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); { cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 - progCmd << this->Convert(progressDir.c_str(), + progCmd << this->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " 0"; @@ -1824,7 +1889,7 @@ void cmLocalUnixMakefileGenerator3 commands.clear(); depends.clear(); commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), - recursiveTarget.c_str())); + recursiveTarget)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); @@ -1854,7 +1919,7 @@ void cmLocalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); } commands.push_back - (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget.c_str())); + (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), cmLocalGenerator::START_OUTPUT); @@ -1872,7 +1937,7 @@ void cmLocalUnixMakefileGenerator3 std::string runRule = "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"; runRule += " --check-build-system "; - runRule += this->Convert(cmakefileName.c_str(),cmLocalGenerator::NONE, + runRule += this->Convert(cmakefileName,cmLocalGenerator::NONE, cmLocalGenerator::SHELL); runRule += " 1"; commands.push_back(runRule); @@ -1905,7 +1970,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, for(std::vector<std::string>::iterator l = files.begin(); l != files.end(); ++l) { - std::string dir = cmSystemTools::GetFilenamePath(l->c_str()); + std::string dir = cmSystemTools::GetFilenamePath(*l); // Clear the implicit dependency makefile. std::string dependFile = dir + "/depend.make"; @@ -1933,7 +1998,7 @@ void cmLocalUnixMakefileGenerator3 for(ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin(); l != implicitLangs.end(); ++l) { - cmakefileStream << " \"" << l->first.c_str() << "\"\n"; + cmakefileStream << " \"" << l->first << "\"\n"; } cmakefileStream << " )\n"; @@ -1944,7 +2009,7 @@ void cmLocalUnixMakefileGenerator3 l = implicitLangs.begin(); l != implicitLangs.end(); ++l) { cmakefileStream - << "set(CMAKE_DEPENDS_CHECK_" << l->first.c_str() << "\n"; + << "set(CMAKE_DEPENDS_CHECK_" << l->first << "\n"; ImplicitDependFileMap const& implicitPairs = l->second; // for each file pair @@ -1964,11 +2029,11 @@ void cmLocalUnixMakefileGenerator3 std::string cidVar = "CMAKE_"; cidVar += l->first; cidVar += "_COMPILER_ID"; - const char* cid = this->Makefile->GetDefinition(cidVar.c_str()); + const char* cid = this->Makefile->GetDefinition(cidVar); if(cid && *cid) { cmakefileStream - << "set(CMAKE_" << l->first.c_str() << "_COMPILER_ID \"" + << "set(CMAKE_" << l->first << "_COMPILER_ID \"" << cid << "\")\n"; } } @@ -1976,7 +2041,7 @@ void cmLocalUnixMakefileGenerator3 // Build a list of preprocessor definitions for the target. std::set<std::string> defines; this->AddCompileDefinitions(defines, &target, - this->ConfigurationName.c_str()); + this->ConfigurationName); if(!defines.empty()) { cmakefileStream @@ -1987,7 +2052,7 @@ void cmLocalUnixMakefileGenerator3 di != defines.end(); ++di) { cmakefileStream - << " " << this->EscapeForCMake(di->c_str()) << "\n"; + << " " << this->EscapeForCMake(*di) << "\n"; } cmakefileStream << " )\n"; @@ -2013,7 +2078,7 @@ void cmLocalUnixMakefileGenerator3 for(std::vector<std::string>::const_iterator tri = transformRules.begin(); tri != transformRules.end(); ++tri) { - cmakefileStream << " " << this->EscapeForCMake(tri->c_str()) << "\n"; + cmakefileStream << " " << this->EscapeForCMake(*tri) << "\n"; } cmakefileStream << " )\n"; @@ -2034,7 +2099,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os) //---------------------------------------------------------------------------- std::string cmLocalUnixMakefileGenerator3 -::GetRecursiveMakeCall(const char *makefile, const char* tgt) +::GetRecursiveMakeCall(const char *makefile, const std::string& tgt) { // Call make on the given file. std::string cmd; @@ -2059,7 +2124,7 @@ cmLocalUnixMakefileGenerator3 } // Add the target. - if (tgt && tgt[0] != '\0') + if (!tgt.empty()) { // The make target is always relative to the top of the build tree. std::string tgt2 = this->Convert(tgt, HOME_OUTPUT); @@ -2070,12 +2135,12 @@ cmLocalUnixMakefileGenerator3 // Escape one extra time if the make tool requires it. if(this->MakeCommandEscapeTargetTwice) { - tgt2 = this->EscapeForShell(tgt2.c_str(), true, false); + tgt2 = this->EscapeForShell(tgt2, true, false); } // The target name is now a string that should be passed verbatim // on the command line. - cmd += this->EscapeForShell(tgt2.c_str(), true, false); + cmd += this->EscapeForShell(tgt2, true, false); } return cmd; } @@ -2116,59 +2181,82 @@ cmLocalUnixMakefileGenerator3 //---------------------------------------------------------------------------- std::string -cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p) +cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p, + bool useWatcomQuote) { - // Split the path into its components. std::vector<std::string> components; cmSystemTools::SplitPath(p, components); - // Return an empty path if there are no components. - if(components.empty()) + // Open the quoted result. + std::string result; + if(useWatcomQuote) { - return "\"\""; +#if defined(_WIN32) && !defined(__CYGWIN__) + result = "'"; +#else + result = "\"'"; +#endif + } + else + { + result = "\""; } - // Choose a slash direction and fix root component. - const char* slash = "/"; + // Return an empty path if there are no components. + if(!components.empty()) + { + // Choose a slash direction and fix root component. + const char* slash = "/"; #if defined(_WIN32) && !defined(__CYGWIN__) - if(!cmSystemTools::GetForceUnixPaths()) - { - slash = "\\"; - for(std::string::iterator i = components[0].begin(); - i != components[0].end(); ++i) - { - if(*i == '/') - { - *i = '\\'; - } - } - } + if(!cmSystemTools::GetForceUnixPaths()) + { + slash = "\\"; + for(std::string::iterator i = components[0].begin(); + i != components[0].end(); ++i) + { + if(*i == '/') + { + *i = '\\'; + } + } + } #endif - // Begin the quoted result with the root component. - std::string result = "\""; - result += components[0]; + // Begin the quoted result with the root component. + result += components[0]; - // Now add the rest of the components separated by the proper slash - // direction for this platform. - bool first = true; - for(unsigned int i=1; i < components.size(); ++i) - { - // Only the last component can be empty to avoid double slashes. - if(components[i].length() > 0 || (i == (components.size()-1))) + // Now add the rest of the components separated by the proper slash + // direction for this platform. + bool first = true; + for(unsigned int i=1; i < components.size(); ++i) { - if(!first) + // Only the last component can be empty to avoid double slashes. + if(components[i].length() > 0 || (i == (components.size()-1))) { - result += slash; + if(!first) + { + result += slash; + } + result += components[i]; + first = false; } - result += components[i]; - first = false; } } // Close the quoted result. - result += "\""; + if(useWatcomQuote) + { +#if defined(_WIN32) && !defined(__CYGWIN__) + result += "'"; +#else + result += "'\""; +#endif + } + else + { + result += "\""; + } return result; } @@ -2198,7 +2286,7 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(cmTarget const& tgt) //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt, - const char* lang, + const std::string& lang, const char* obj, const char* src) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 703369e..99974ee 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -18,6 +18,7 @@ #include "cmDepends.h" class cmCustomCommand; +class cmCustomCommandGenerator; class cmDependInformation; class cmDepends; class cmMakefileTargetGenerator; @@ -55,7 +56,7 @@ public: // Write out a make rule void WriteMakeRule(std::ostream& os, const char* comment, - const char* target, + const std::string& target, const std::vector<std::string>& depends, const std::vector<std::string>& commands, bool symbolic, @@ -75,7 +76,7 @@ public: /** * Set the flag used to keep the make program silent. */ - void SetMakeSilentFlag(const char* s) { this->MakeSilentFlag = s; } + void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; } std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; } /** @@ -121,17 +122,12 @@ public: void SetUnixCD(bool v) {this->UnixCD = v;} /** - * Set Support Verbose Variable. If true, then .SILENT will - * be not end with : i.e. .SILENT: or .SILENT - */ - void SetSilentNoColon(bool v) {this->SilentNoColon = v;} - - /** * Set the string used to include one makefile into another default * is include. */ - void SetIncludeDirective(const char* s) { this->IncludeDirective = s; } - const char *GetIncludeDirective() { return this->IncludeDirective.c_str(); } + void SetIncludeDirective(const std::string& s) + { this->IncludeDirective = s; } + const std::string& GetIncludeDirective() { return this->IncludeDirective; } /** * Set max makefile variable size, default is 0 which means unlimited. @@ -168,7 +164,8 @@ public: void WriteDivider(std::ostream& os); /** used to create a recursive make call */ - std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); + std::string GetRecursiveMakeCall(const char *makefile, + const std::string& tgt); // append flags to a string virtual void AppendFlags(std::string& flags, const char* newFlags); @@ -189,9 +186,11 @@ public: const char *targetDir, cmLocalGenerator::RelativeRoot returnDir); - static std::string ConvertToQuotedOutputPath(const char* p); + static std::string ConvertToQuotedOutputPath(const char* p, + bool useWatcomQuote); - std::string CreateMakeVariable(const char* sin, const char* s2in); + std::string CreateMakeVariable(const std::string& sin, + const std::string& s2in); /** Called from command-line hook to bring dependencies up to date for a target. */ @@ -210,14 +209,14 @@ public: // File pairs for implicit dependency scanning. The key of the map // is the depender and the value is the explicit dependee. struct ImplicitDependFileMap: - public std::map<cmStdString, cmDepends::DependencyVector> {}; + public std::map<std::string, cmDepends::DependencyVector> {}; struct ImplicitDependLanguageMap: - public std::map<cmStdString, ImplicitDependFileMap> {}; + public std::map<std::string, ImplicitDependFileMap> {}; struct ImplicitDependTargetMap: - public std::map<cmStdString, ImplicitDependLanguageMap> {}; + public std::map<std::string, ImplicitDependLanguageMap> {}; ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt); - void AddImplicitDepends(cmTarget const& tgt, const char* lang, + void AddImplicitDepends(cmTarget const& tgt, const std::string& lang, const char* obj, const char* src); void AppendGlobalTargetDepends(std::vector<std::string>& depends, @@ -226,11 +225,7 @@ public: // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); - void AddLocalObjectFile(cmTarget* target, cmSourceFile* sf, - std::string objNoTargetDir, - bool hasSourceExtension); - - std::vector<cmStdString> const& GetLocalHelp() { return this->LocalHelp; } + std::vector<std::string> const& GetLocalHelp() { return this->LocalHelp; } /** Get whether to create rules to generate preprocessed and assembly sources. This could be converted to a variable lookup @@ -255,7 +250,7 @@ protected: // write the target rules for the local Makefile into the stream void WriteLocalMakefileTargets(std::ostream& ruleFileStream, - std::set<cmStdString> &emitted); + std::set<std::string> &emitted); // this method Writes the Directory information files void WriteDirectoryInformationFile(); @@ -273,8 +268,8 @@ protected: void WriteConvenienceRule(std::ostream& ruleFileStream, - const char* realTarget, - const char* helpTarget); + const std::string& realTarget, + const std::string& helpTarget); void WriteTargetDependRule(std::ostream& ruleFileStream, cmTarget& target); @@ -292,14 +287,14 @@ protected: void AppendCustomDepends(std::vector<std::string>& depends, const std::vector<cmCustomCommand>& ccs); void AppendCustomDepend(std::vector<std::string>& depends, - const cmCustomCommand& cc); + cmCustomCommandGenerator const& cc); void AppendCustomCommands(std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs, cmTarget* target, cmLocalGenerator::RelativeRoot relative = cmLocalGenerator::HOME_OUTPUT); void AppendCustomCommand(std::vector<std::string>& commands, - const cmCustomCommand& cc, + cmCustomCommandGenerator const& ccg, cmTarget* target, bool echo_comment=false, cmLocalGenerator::RelativeRoot relative = @@ -316,8 +311,12 @@ protected: private: std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root); - std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target, - RelativeRoot relative); + std::string MakeLauncher(cmCustomCommandGenerator const& ccg, + cmTarget* target, RelativeRoot relative); + + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = 0); friend class cmMakefileTargetGenerator; friend class cmMakefileExecutableTargetGenerator; @@ -336,7 +335,6 @@ private: bool DefineWindowsNULL; bool UnixCD; bool PassMakeflags; - bool SilentNoColon; bool MakeCommandEscapeTargetTwice; bool BorlandMakeCurlyHack; //========================================================================== @@ -358,7 +356,7 @@ private: cmTarget* Target; std::string Language; LocalObjectEntry(): Target(0), Language() {} - LocalObjectEntry(cmTarget* t, const char* lang): + LocalObjectEntry(cmTarget* t, const std::string& lang): Target(t), Language(lang) {} }; struct LocalObjectInfo: public std::vector<LocalObjectEntry> @@ -369,16 +367,18 @@ private: LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), HasAssembleRule(false) {} }; - std::map<cmStdString, LocalObjectInfo> LocalObjectFiles; + void GetLocalObjectFiles( + std::map<std::string, LocalObjectInfo> &localObjectFiles); + void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, LocalObjectInfo const& info); - std::vector<cmStdString> LocalHelp; + std::vector<std::string> LocalHelp; /* does the work for each target */ - std::map<cmStdString, cmStdString> MakeVariableMap; - std::map<cmStdString, cmStdString> ShortMakeVariableMap; + std::map<std::string, std::string> MakeVariableMap; + std::map<std::string, std::string> ShortMakeVariableMap; }; #endif diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index aedd6ed..aa70ab9 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -19,7 +19,7 @@ class cmVS10XMLParser : public cmXMLParser { public: - virtual void EndElement(const char* /* name */) + virtual void EndElement(const std::string& /* name */) { } virtual void CharacterDataHandler(const char* data, int length) @@ -30,14 +30,14 @@ class cmVS10XMLParser : public cmXMLParser this->DoGUID = false; } } - virtual void StartElement(const char* name, const char**) + virtual void StartElement(const std::string& name, const char**) { // once the GUID is found do nothing if(this->GUID.size()) { return; } - if(strcmp("ProjectGUID", name) == 0 || strcmp("ProjectGuid", name) == 0) + if("ProjectGUID" == name || "ProjectGuid" == name) { this->DoGUID = true; } @@ -98,7 +98,7 @@ void cmLocalVisualStudio10Generator::Generate() void cmLocalVisualStudio10Generator -::ReadAndStoreExternalGUID(const char* name, +::ReadAndStoreExternalGUID(const std::string& name, const char* path) { cmVS10XMLParser parser; diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 41db735..b50e345 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -34,7 +34,7 @@ public: * Generate the makefile for this directory. */ virtual void Generate(); - virtual void ReadAndStoreExternalGUID(const char* name, + virtual void ReadAndStoreExternalGUID(const std::string& name, const char* path); protected: diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index a5e8294..2ab25cc 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -16,6 +16,7 @@ #include "cmSourceFile.h" #include "cmCacheManager.h" #include "cmGeneratorTarget.h" +#include "cmCustomCommandGenerator.h" #include "cmake.h" #include "cmComputeLinkInformation.h" @@ -38,7 +39,7 @@ class cmLocalVisualStudio6Generator::EventWriter { public: EventWriter(cmLocalVisualStudio6Generator* lg, - const char* config, std::string& code): + const std::string& config, std::string& code): LG(lg), Config(config), Code(code), First(true) {} void Start(const char* event) { @@ -59,6 +60,7 @@ public: } void Write(cmCustomCommand const& cc) { + cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile()); if(this->First) { this->Code += this->Event + "_Cmds="; @@ -68,11 +70,11 @@ public: { this->Code += "\\\n\t"; } - this->Code += this->LG->ConstructScript(cc, this->Config, "\\\n\t"); + this->Code += this->LG->ConstructScript(ccg, "\\\n\t"); } private: cmLocalVisualStudio6Generator* LG; - const char* Config; + std::string Config; std::string& Code; bool First; std::string Event; @@ -80,7 +82,7 @@ private: void cmLocalVisualStudio6Generator::AddHelperCommands() { - std::set<cmStdString> lang; + std::set<std::string> lang; lang.insert("C"); lang.insert("CXX"); this->CreateCustomTargetsAndCommands(lang); @@ -186,7 +188,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() // extern std::string GetVS6TargetName(const std::string& targetName); -void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname, +void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname, cmTarget &target) { // add to the list of projects @@ -263,7 +265,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, - const char *libName, + const std::string& libName, cmTarget &target) { // For utility targets need custom command since pre- and post- @@ -372,7 +374,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, void cmLocalVisualStudio6Generator ::WriteGroup(const cmSourceGroup *sg, cmTarget& target, - std::ostream &fout, const char *libName) + std::ostream &fout, const std::string& libName) { cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); @@ -413,23 +415,20 @@ void cmLocalVisualStudio6Generator compileFlags += cflags; } - const char* lang = this->GetSourceFileLanguage(*(*sf)); - if(lang) + const std::string& lang = this->GetSourceFileLanguage(*(*sf)); + if(lang == "CXX") { - if(strcmp(lang, "CXX") == 0) - { - // force a C++ file type - compileFlags += " /TP "; - } - else if(strcmp(lang, "C") == 0) - { - // force to c file type - compileFlags += " /TC "; - } + // force a C++ file type + compileFlags += " /TP "; + } + else if(lang == "C") + { + // force to c file type + compileFlags += " /TC "; } // Add per-source and per-configuration preprocessor definitions. - std::map<cmStdString, cmStdString> cdmap; + std::map<std::string, std::string> cdmap; { std::set<std::string> targetCompileDefinitions; @@ -469,7 +468,7 @@ void cmLocalVisualStudio6Generator } bool excludedFromBuild = - (lang && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY")); + (!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY")); // Check for extra object-file dependencies. const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS"); @@ -529,7 +528,7 @@ void cmLocalVisualStudio6Generator { fout << "\n# ADD CPP " << compileFlags << "\n\n"; } - std::map<cmStdString, cmStdString>::iterator cdi = + std::map<std::string, std::string>::iterator cdi = cdmap.find(cmSystemTools::UpperCase(config)); if(cdi != cdmap.end() && !cdi->second.empty()) { @@ -575,18 +574,22 @@ cmLocalVisualStudio6Generator { // Create a fake output that forces the rule to run. char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) + - strlen(target.GetName()) + 30)]; + target.GetName().size() + 30)]; sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(), - target.GetName(), count); - std::string comment = this->ConstructComment(origCommand, "<hack>"); + target.GetName().c_str(), count); + const char* comment = origCommand.GetComment(); + if(!comment && origCommand.GetOutputs().empty()) + { + comment = "<hack>"; + } // Add the rule with the given dependencies and commands. - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; if(cmSourceFile* outsf = this->Makefile->AddCustomCommandToOutput( output, depends, no_main_dependency, - origCommand.GetCommandLines(), comment.c_str(), - origCommand.GetWorkingDirectory())) + origCommand.GetCommandLines(), comment, + origCommand.GetWorkingDirectory().c_str())) { target.AddSourceFile(outsf); } @@ -607,20 +610,21 @@ cmLocalVisualStudio6Generator const cmCustomCommand& command, const char* flags) { - std::string comment = - this->ConstructComment(command, "Building Custom Rule $(InputPath)"); - if(comment == "<hack>") - { - comment = ""; - } - // Write the rule for each configuration. std::vector<std::string>::iterator i; for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { std::string config = this->GetConfigName(*i); + cmCustomCommandGenerator ccg(command, config, this->Makefile); + std::string comment = + this->ConstructComment(ccg, "Building Custom Rule $(InputPath)"); + if(comment == "<hack>") + { + comment = ""; + } + std::string script = - this->ConstructScript(command, config.c_str(), "\\\n\t"); + this->ConstructScript(ccg, "\\\n\t"); if (i == this->Configurations.begin()) { @@ -637,8 +641,8 @@ cmLocalVisualStudio6Generator // Write out the dependencies for the rule. fout << "USERDEP__HACK="; for(std::vector<std::string>::const_iterator d = - command.GetDepends().begin(); - d != command.GetDepends().end(); + ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { // Lookup the real name of the dependency in case it is a CMake target. @@ -658,7 +662,7 @@ cmLocalVisualStudio6Generator fout << " " << comment.c_str(); } fout << "\n\n"; - if(command.GetOutputs().empty()) + if(ccg.GetOutputs().empty()) { fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; @@ -667,8 +671,8 @@ cmLocalVisualStudio6Generator else { for(std::vector<std::string>::const_iterator o = - command.GetOutputs().begin(); - o != command.GetOutputs().end(); + ccg.GetOutputs().begin(); + o != ccg.GetOutputs().end(); ++o) { // Write a rule for every output generated by this command. @@ -702,7 +706,7 @@ void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout) void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, - const char* libName, + const std::string& libName, cmTarget& target) { std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); @@ -788,7 +792,7 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, //---------------------------------------------------------------------------- cmsys::auto_ptr<cmCustomCommand> cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, - const char* config) + const std::string& config) { cmsys::auto_ptr<cmCustomCommand> pcc; @@ -816,8 +820,8 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, // look for custom rules on a target and collect them together std::string cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, - const char* configName, - const char * /* libName */) + const std::string& configName, + const std::string& /* libName */) { if (target.GetType() >= cmTarget::UTILITY ) { @@ -866,7 +870,7 @@ inline std::string removeQuotes(const std::string& s) std::string cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target, - const char *config) + const std::string& config) { std::string includeOptions; @@ -929,7 +933,7 @@ cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target, void cmLocalVisualStudio6Generator ::WriteDSPHeader(std::ostream& fout, - const char *libName, cmTarget &target, + const std::string& libName, cmTarget &target, std::vector<cmSourceGroup> &) { bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE && @@ -1102,7 +1106,7 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str()); + cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { lib = cmSystemTools::GetFilenameWithoutExtension @@ -1255,12 +1259,12 @@ void cmLocalVisualStudio6Generator if(targetBuilds) { // Get the language to use for linking. - const char* linkLanguage = target.GetLinkerLanguage(); - if(!linkLanguage) + const std::string& linkLanguage = target.GetLinkerLanguage(); + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.GetName()); + target.GetName().c_str()); return; } @@ -1677,12 +1681,12 @@ void cmLocalVisualStudio6Generator if(target.GetType() >= cmTarget::EXECUTABLE && target.GetType() <= cmTarget::OBJECT_LIBRARY) { - const char* linkLanguage = target.GetLinkerLanguage(); - if(!linkLanguage) + const std::string& linkLanguage = target.GetLinkerLanguage(); + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.GetName()); + target.GetName().c_str()); return; } // if CXX is on and the target contains cxx code then add the cxx flags @@ -1707,7 +1711,7 @@ void cmLocalVisualStudio6Generator flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; - this->AddCompileOptions(flags, &target, linkLanguage, 0); + this->AddCompileOptions(flags, &target, linkLanguage, ""); this->AddCompileOptions(flagsDebug, &target, linkLanguage, "Debug"); this->AddCompileOptions(flagsRelease, &target, linkLanguage, "Release"); this->AddCompileOptions(flagsMinSizeRel, &target, linkLanguage, @@ -1733,7 +1737,7 @@ void cmLocalVisualStudio6Generator std::set<std::string> minsizeDefinesSet; std::set<std::string> debugrelDefinesSet; - this->AddCompileDefinitions(definesSet, &target, 0); + this->AddCompileDefinitions(definesSet, &target, ""); this->AddCompileDefinitions(debugDefinesSet, &target, "DEBUG"); this->AddCompileDefinitions(releaseDefinesSet, &target, "RELEASE"); this->AddCompileDefinitions(minsizeDefinesSet, &target, "MINSIZEREL"); @@ -1745,11 +1749,11 @@ void cmLocalVisualStudio6Generator std::string minsizeDefines = " "; std::string debugrelDefines = " "; - this->JoinDefines(definesSet, defines, 0); - this->JoinDefines(debugDefinesSet, debugDefines, 0); - this->JoinDefines(releaseDefinesSet, releaseDefines, 0); - this->JoinDefines(minsizeDefinesSet, minsizeDefines, 0); - this->JoinDefines(debugrelDefinesSet, debugrelDefines, 0); + this->JoinDefines(definesSet, defines, ""); + this->JoinDefines(debugDefinesSet, debugDefines, ""); + this->JoinDefines(releaseDefinesSet, releaseDefines, ""); + this->JoinDefines(minsizeDefinesSet, minsizeDefines, ""); + this->JoinDefines(debugrelDefinesSet, debugrelDefines, ""); flags += defines; flagsDebug += debugDefines; @@ -1803,7 +1807,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout) //---------------------------------------------------------------------------- void cmLocalVisualStudio6Generator ::ComputeLinkOptions(cmTarget& target, - const char* configName, + const std::string& configName, const std::string extraOptions, std::string& options) { diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index f45bc17..4771833 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -48,7 +48,7 @@ public: /** * Specify the type of the build: static, dll, or executable. */ - void SetBuildType(BuildType, const char* libName, cmTarget&); + void SetBuildType(BuildType, const std::string& libName, cmTarget&); virtual std::string GetTargetDirectory(cmTarget const& target) const; virtual std::string ComputeLongestObjectDirectory(cmTarget&) const; @@ -56,15 +56,15 @@ private: std::string DSPHeaderTemplate; std::string DSPFooterTemplate; - void CreateSingleDSP(const char *lname, cmTarget &tgt); - void WriteDSPFile(std::ostream& fout, const char *libName, + void CreateSingleDSP(const std::string& lname, cmTarget &tgt); + void WriteDSPFile(std::ostream& fout, const std::string& libName, cmTarget &tgt); void WriteDSPBeginGroup(std::ostream& fout, const char* group, const char* filter); void WriteDSPEndGroup(std::ostream& fout); - void WriteDSPHeader(std::ostream& fout, const char *libName, + void WriteDSPHeader(std::ostream& fout, const std::string& libName, cmTarget &tgt, std::vector<cmSourceGroup> &sgs); void WriteDSPFooter(std::ostream& fout); @@ -77,20 +77,21 @@ private: std::vector<std::string>& depends, const cmCustomCommand& origCommand); void WriteGroup(const cmSourceGroup *sg, cmTarget& target, - std::ostream &fout, const char *libName); + std::ostream &fout, const std::string& libName); class EventWriter; friend class EventWriter; cmsys::auto_ptr<cmCustomCommand> - MaybeCreateOutputDir(cmTarget& target, const char* config); + MaybeCreateOutputDir(cmTarget& target, const std::string& config); std::string CreateTargetRules(cmTarget &target, - const char* configName, - const char *libName); - void ComputeLinkOptions(cmTarget& target, const char* configName, + const std::string& configName, + const std::string& libName); + void ComputeLinkOptions(cmTarget& target, const std::string& configName, const std::string extraOptions, std::string& options); void OutputObjects(cmTarget& target, const char* tool, std::string& options); - std::string GetTargetIncludeOptions(cmTarget &target, const char *config); + std::string GetTargetIncludeOptions(cmTarget &target, + const std::string& config); std::vector<std::string> Configurations; std::string GetConfigName(std::string const& configuration) const; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 212b06b..52524aa 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -18,6 +18,7 @@ #include "cmSourceFile.h" #include "cmCacheManager.h" #include "cmGeneratorTarget.h" +#include "cmCustomCommandGenerator.h" #include "cmake.h" #include "cmComputeLinkInformation.h" @@ -59,7 +60,7 @@ cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator() void cmLocalVisualStudio7Generator::AddHelperCommands() { - std::set<cmStdString> lang; + std::set<std::string> lang; lang.insert("C"); lang.insert("CXX"); lang.insert("RC"); @@ -83,7 +84,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() if(path) { this->ReadAndStoreExternalGUID( - l->second.GetName(), path); + l->second.GetName().c_str(), path); } else { @@ -141,7 +142,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force_command.push_back("."); cmCustomCommandLines force_commands; force_commands.push_back(force_command); - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; std::string force = this->Makefile->GetStartOutputDirectory(); force += cmake::GetCMakeFilesDirectory(); force += "/"; @@ -228,7 +229,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() //---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator -::CreateSingleVCProj(const char *lname, cmTarget &target) +::CreateSingleVCProj(const std::string& lname, cmTarget &target) { this->FortranProject = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) @@ -245,8 +246,7 @@ void cmLocalVisualStudio7Generator } // add to the list of projects - std::string pname = lname; - target.SetProperty("GENERATOR_FILE_NAME",lname); + target.SetProperty("GENERATOR_FILE_NAME",lname.c_str()); // create the dsp.cmake file std::string fname; fname = this->Makefile->GetStartOutputDirectory(); @@ -334,8 +334,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() } void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout, - const char *libName, - cmTarget &target) + const std::string& libName, + cmTarget &target) { std::vector<std::string> *configs = static_cast<cmGlobalVisualStudio7Generator *> @@ -589,7 +589,7 @@ class cmLocalVisualStudio7Generator::EventWriter { public: EventWriter(cmLocalVisualStudio7Generator* lg, - const char* config, std::ostream& os): + const std::string& config, std::ostream& os): LG(lg), Config(config), Stream(os), First(true) {} void Start(const char* tool) { @@ -610,9 +610,10 @@ public: } void Write(cmCustomCommand const& cc) { + cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile()); if(this->First) { - const char* comment = cc.GetComment(); + const char* comment = ccg.GetComment(); if(comment && *comment) { this->Stream << "\nDescription=\"" @@ -625,21 +626,21 @@ public: { this->Stream << this->LG->EscapeForXML("\n"); } - std::string script = this->LG->ConstructScript(cc, this->Config); + std::string script = this->LG->ConstructScript(ccg); this->Stream << this->LG->EscapeForXML(script.c_str()); } private: cmLocalVisualStudio7Generator* LG; - const char* Config; + std::string Config; std::ostream& Stream; bool First; }; //---------------------------------------------------------------------------- void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, - const char* configName, - const char *libName, - cmTarget &target) + const std::string& configName, + const std::string& libName, + cmTarget &target) { const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG"); if(!mfcFlag) @@ -660,7 +661,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: - targetBuilds = false; // TODO: PDB for object library? + targetBuilds = false; // no manifest tool for object library case cmTarget::STATIC_LIBRARY: projectType = "typeStaticLibrary"; configType = "4"; @@ -687,17 +688,18 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, std::string flags; if(strcmp(configType, "10") != 0) { - const char* linkLanguage = (this->FortranProject? "Fortran": + const std::string& linkLanguage = (this->FortranProject? + std::string("Fortran"): target.GetLinkerLanguage(configName)); - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target.GetName()); + target.GetName().c_str()); return; } - if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0 - || strcmp(linkLanguage, "Fortran") == 0) + if(linkLanguage == "C" || linkLanguage == "CXX" + || linkLanguage == "Fortran") { std::string baseFlagVar = "CMAKE_"; baseFlagVar += linkLanguage; @@ -709,11 +711,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, flags += this->Makefile->GetRequiredDefinition(flagVar.c_str()); } // set the correct language - if(strcmp(linkLanguage, "C") == 0) + if(linkLanguage == "C") { flags += " /TC "; } - if(strcmp(linkLanguage, "CXX") == 0) + if(linkLanguage == "CXX") { flags += " /TP "; } @@ -745,7 +747,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, table, this->ExtraFlagTable); targetOptions.FixExceptionHandlingDefault(); - std::string asmLocation = std::string(configName) + "/"; + std::string asmLocation = configName + "/"; targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); @@ -846,6 +848,17 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.OutputFlagMap(fout, "\t\t\t\t"); targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX"); fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; + if(target.GetType() <= cmTarget::OBJECT_LIBRARY) + { + // Specify the compiler program database file if configured. + std::string pdb = target.GetCompilePDBPath(configName); + if(!pdb.empty()) + { + fout << "\t\t\t\tProgramDataBaseFileName=\"" + << this->ConvertToXMLOutputPathSingle(pdb.c_str()) + << "\"\n"; + } + } fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool tool = "VCCustomBuildTool"; if(this->FortranProject) @@ -933,7 +946,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, //---------------------------------------------------------------------------- std::string cmLocalVisualStudio7Generator -::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName) +::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, + const std::string& configName) { std::string configTypeUpper = cmSystemTools::UpperCase(configName); std::string extraLinkOptionsBuildTypeDef = @@ -947,7 +961,8 @@ cmLocalVisualStudio7Generator } void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, - const char* configName, cmTarget &target, const Options& targetOptions) + const std::string& configName, cmTarget &target, + const Options& targetOptions) { cmGlobalVisualStudio7Generator* gg = static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator); @@ -1033,7 +1048,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, fout << "\t\t\t<Tool\n" << "\t\t\t\tName=\"" << tool << "\"\n"; - if(this->GetVersion() < VS8) + if(this->GetVersion() < VS8 || this->FortranProject) { cmOStringStream libdeps; this->Internal->OutputObjects(libdeps, &target); @@ -1070,7 +1085,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, return; } cmComputeLinkInformation& cli = *pcli; - const char* linkLanguage = cli.GetLinkLanguage(); + std::string linkLanguage = cli.GetLinkLanguage(); // Compute the variable name to lookup standard libraries for this // language. @@ -1093,7 +1108,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - if(this->GetVersion() < VS8) + if(this->GetVersion() < VS8 || this->FortranProject) { this->Internal->OutputObjects(fout, &target, " "); } @@ -1166,7 +1181,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, return; } cmComputeLinkInformation& cli = *pcli; - const char* linkLanguage = cli.GetLinkLanguage(); + std::string linkLanguage = cli.GetLinkLanguage(); bool isWin32Executable = target.GetPropertyAsBool("WIN32_EXECUTABLE"); @@ -1191,7 +1206,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, // libraries which may be set by the user to something bad. fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) " << this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); - if(this->GetVersion() < VS8) + if(this->GetVersion() < VS8 || this->FortranProject) { this->Internal->OutputObjects(fout, &target, " "); } @@ -1368,7 +1383,7 @@ cmLocalVisualStudio7Generator } void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, - const char *libName, + const std::string& libName, cmTarget &target) { // get the configurations @@ -1412,7 +1427,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, this->WriteGroup(&sg, target, fout, libName, configs); } - if(this->GetVersion() >= VS8) + if(this->GetVersion() >= VS8 && !this->FortranProject) { // VS >= 8 support per-config source locations so we // list object library content as external objects. @@ -1457,7 +1472,7 @@ public: cmTarget& target, cmSourceFile const& sf, std::vector<std::string>* configs); - std::map<cmStdString, cmLVS7GFileConfig> FileConfigMap; + std::map<std::string, cmLVS7GFileConfig> FileConfigMap; }; cmLocalVisualStudio7GeneratorFCInfo @@ -1535,14 +1550,14 @@ cmLocalVisualStudio7GeneratorFCInfo } } - const char* lang = + std::string lang = lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); - const char* sourceLang = lg->GetSourceFileLanguage(sf); - const char* linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& sourceLang = lg->GetSourceFileLanguage(sf); + const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language - if(lang && sourceLang && strcmp(lang, sourceLang) != 0) + if(lang != sourceLang) { needForceLang = true; lang = sourceLang; @@ -1558,16 +1573,15 @@ cmLocalVisualStudio7GeneratorFCInfo // if the source file does not match the linker language // then force c or c++ - if(needForceLang || (linkLanguage && lang - && strcmp(lang, linkLanguage) != 0)) + if(needForceLang || (linkLanguage != lang)) { - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { // force a C++ file type fc.CompileFlags += " /TP "; needfc = true; } - else if(strcmp(lang, "C") == 0) + else if(lang == "C") { // force to c fc.CompileFlags += " /TC "; @@ -1616,7 +1630,7 @@ cmLocalVisualStudio7Generator bool cmLocalVisualStudio7Generator ::WriteGroup(const cmSourceGroup *sg, cmTarget& target, - std::ostream &fout, const char *libName, + std::ostream &fout, const std::string& libName, std::vector<std::string> *configs) { const std::vector<const cmSourceFile *> &sourceFiles = @@ -1702,7 +1716,7 @@ bool cmLocalVisualStudio7Generator aCompilerTool = "VFCustomBuildTool"; } } - for(std::map<cmStdString, cmLVS7GFileConfig>::const_iterator + for(std::map<std::string, cmLVS7GFileConfig>::const_iterator fci = fcinfo.FileConfigMap.begin(); fci != fcinfo.FileConfigMap.end(); ++fci) { @@ -1779,8 +1793,6 @@ WriteCustomRule(std::ostream& fout, const cmCustomCommand& command, FCInfo& fcinfo) { - std::string comment = this->ConstructComment(command); - // Write the rule for each configuration. std::vector<std::string>::iterator i; std::vector<std::string> *configs = @@ -1798,6 +1810,7 @@ WriteCustomRule(std::ostream& fout, } for(i = configs->begin(); i != configs->end(); ++i) { + cmCustomCommandGenerator ccg(command, *i, this->Makefile); cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i]; fout << "\t\t\t\t<FileConfiguration\n"; fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n"; @@ -1809,7 +1822,8 @@ WriteCustomRule(std::ostream& fout, << this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n"; } - std::string script = this->ConstructScript(command, i->c_str()); + std::string comment = this->ConstructComment(ccg); + std::string script = this->ConstructScript(ccg); if(this->FortranProject) { cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str()); @@ -1821,7 +1835,7 @@ WriteCustomRule(std::ostream& fout, << "\t\t\t\t\tCommandLine=\"" << this->EscapeForXML(script.c_str()) << "\"\n" << "\t\t\t\t\tAdditionalDependencies=\""; - if(command.GetDepends().empty()) + if(ccg.GetDepends().empty()) { // There are no real dependencies. Produce an artificial one to // make sure the rule runs reliably. @@ -1836,8 +1850,8 @@ WriteCustomRule(std::ostream& fout, { // Write out the dependencies for the rule. for(std::vector<std::string>::const_iterator d = - command.GetDepends().begin(); - d != command.GetDepends().end(); + ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { // Get the real name of the dependency in case it is a CMake target. @@ -1851,7 +1865,7 @@ WriteCustomRule(std::ostream& fout, } fout << "\"\n"; fout << "\t\t\t\t\tOutputs=\""; - if(command.GetOutputs().empty()) + if(ccg.GetOutputs().empty()) { fout << source << "_force"; } @@ -1860,8 +1874,8 @@ WriteCustomRule(std::ostream& fout, // Write a rule for the output generated by this command. const char* sep = ""; for(std::vector<std::string>::const_iterator o = - command.GetOutputs().begin(); - o != command.GetOutputs().end(); + ccg.GetOutputs().begin(); + o != ccg.GetOutputs().end(); ++o) { fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str()); @@ -1893,9 +1907,9 @@ void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout) // look for custom rules on a target and collect them together void cmLocalVisualStudio7Generator ::OutputTargetRules(std::ostream& fout, - const char* configName, + const std::string& configName, cmTarget &target, - const char * /*libName*/) + const std::string& /*libName*/) { if (target.GetType() > cmTarget::GLOBAL_TARGET) { @@ -1955,13 +1969,14 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout, void cmLocalVisualStudio7Generator ::WriteProjectStartFortran(std::ostream& fout, - const char *libName, + const std::string& libName, cmTarget & target) { cmGlobalVisualStudio7Generator* gg = static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); - fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" + fout << "<?xml version=\"1.0\" encoding = \"" + << gg->Encoding() << "\"?>\n" << "<VisualStudioProject\n" << "\tProjectCreator=\"Intel Fortran\"\n" << "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n"; @@ -2006,7 +2021,7 @@ cmLocalVisualStudio7Generator } this->WriteProjectSCC(fout, target); fout<< "\tKeyword=\"" << keyword << "\">\n" - << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n" + << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n" << "\t<Platforms>\n" << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n" << "\t</Platforms>\n"; @@ -2015,7 +2030,7 @@ cmLocalVisualStudio7Generator void cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, - const char *libName, + const std::string& libName, cmTarget & target, std::vector<cmSourceGroup> &) { @@ -2024,7 +2039,12 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, this->WriteProjectStartFortran(fout, libName, target); return; } - fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" + + cmGlobalVisualStudio7Generator* gg = + static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); + + fout << "<?xml version=\"1.0\" encoding = \"" + << gg->Encoding() << "\"?>\n" << "<VisualStudioProject\n" << "\tProjectType=\"Visual C++\"\n"; if(this->Version == VS71) @@ -2038,19 +2058,17 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, const char* projLabel = target.GetProperty("PROJECT_LABEL"); if(!projLabel) { - projLabel = libName; + projLabel = libName.c_str(); } const char* keyword = target.GetProperty("VS_KEYWORD"); if(!keyword) { keyword = "Win32Proj"; } - cmGlobalVisualStudio7Generator* gg = - static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); fout << "\tName=\"" << projLabel << "\"\n"; if(this->Version >= VS8) { - fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n"; + fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n"; } this->WriteProjectSCC(fout, target); if(const char* targetFrameworkVersion = @@ -2090,7 +2108,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout, << "</VisualStudioProject>\n"; } -std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s) +std::string cmLocalVisualStudio7GeneratorEscapeForXML(const std::string& s) { std::string ret = s; cmSystemTools::ReplaceString(ret, "&", "&"); @@ -2101,7 +2119,7 @@ std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s) return ret; } -std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s) +std::string cmLocalVisualStudio7Generator::EscapeForXML(const std::string& s) { return cmLocalVisualStudio7GeneratorEscapeForXML(s); } @@ -2134,10 +2152,10 @@ std::string cmLocalVisualStudio7Generator class cmVS7XMLParser : public cmXMLParser { public: - virtual void EndElement(const char* /* name */) + virtual void EndElement(const std::string& /* name */) { } - virtual void StartElement(const char* name, const char** atts) + virtual void StartElement(const std::string& name, const char** atts) { // once the GUID is found do nothing if(this->GUID.size()) @@ -2145,7 +2163,7 @@ public: return; } int i =0; - if(strcmp("VisualStudioProject", name) == 0) + if("VisualStudioProject" == name) { while(atts[i]) { @@ -2182,7 +2200,7 @@ public: }; void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID( - const char* name, + const std::string& name, const char* path) { cmVS7XMLParser parser; diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 92e4d3c..6c04559 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -51,9 +51,9 @@ public: /** * Specify the type of the build: static, dll, or executable. */ - void SetBuildType(BuildType,const char *name); + void SetBuildType(BuildType,const std::string& name); - void SetPlatformName(const char* n) { this->PlatformName = n;} + void SetPlatformName(const std::string& n) { this->PlatformName = n;} void SetExtraFlagTable(cmVS7FlagTable const* table) { this->ExtraFlagTable = table; } @@ -62,41 +62,41 @@ public: void WriteStampFiles(); virtual std::string ComputeLongestObjectDirectory(cmTarget&) const; - virtual void ReadAndStoreExternalGUID(const char* name, + virtual void ReadAndStoreExternalGUID(const std::string& name, const char* path); virtual void AddCMakeListsRules(); protected: - void CreateSingleVCProj(const char *lname, cmTarget &tgt); + void CreateSingleVCProj(const std::string& lname, cmTarget &tgt); private: typedef cmVisualStudioGeneratorOptions Options; typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo; std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags, - const char* configName); + const std::string& configName); void FixGlobalTargets(); void WriteProjectFiles(); - void WriteVCProjHeader(std::ostream& fout, const char *libName, + void WriteVCProjHeader(std::ostream& fout, const std::string& libName, cmTarget &tgt, std::vector<cmSourceGroup> &sgs); void WriteVCProjFooter(std::ostream& fout, cmTarget &target); - void WriteVCProjFile(std::ostream& fout, const char *libName, + void WriteVCProjFile(std::ostream& fout, const std::string& libName, cmTarget &tgt); void WriteConfigurations(std::ostream& fout, - const char *libName, cmTarget &tgt); + const std::string& libName, cmTarget &tgt); void WriteConfiguration(std::ostream& fout, - const char* configName, - const char* libName, cmTarget &tgt); - std::string EscapeForXML(const char* s); + const std::string& configName, + const std::string& libName, cmTarget &tgt); + std::string EscapeForXML(const std::string& s); std::string ConvertToXMLOutputPath(const char* path); std::string ConvertToXMLOutputPathSingle(const char* path); - void OutputTargetRules(std::ostream& fout, const char* configName, - cmTarget &target, const char *libName); - void OutputBuildTool(std::ostream& fout, const char* configName, + void OutputTargetRules(std::ostream& fout, const std::string& configName, + cmTarget &target, const std::string& libName); + void OutputBuildTool(std::ostream& fout, const std::string& configName, cmTarget& t, const Options& targetOptions); void OutputLibraryDirectories(std::ostream& fout, std::vector<std::string> const& dirs); void WriteProjectSCC(std::ostream& fout, cmTarget& target); - void WriteProjectStart(std::ostream& fout, const char *libName, + void WriteProjectStart(std::ostream& fout, const std::string& libName, cmTarget &tgt, std::vector<cmSourceGroup> &sgs); - void WriteProjectStartFortran(std::ostream& fout, const char *libName, + void WriteProjectStartFortran(std::ostream& fout, const std::string& libName, cmTarget &tgt); void WriteVCProjBeginGroup(std::ostream& fout, const char* group, @@ -111,7 +111,8 @@ private: bool WriteGroup(const cmSourceGroup *sg, cmTarget& target, std::ostream &fout, - const char *libName, std::vector<std::string> *configs); + const std::string& libName, + std::vector<std::string> *configs); friend class cmLocalVisualStudio7GeneratorFCInfo; friend class cmLocalVisualStudio7GeneratorInternals; diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index ef2bb1d..9680d43 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -31,9 +31,49 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator() } //---------------------------------------------------------------------------- +void cmLocalVisualStudioGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt) +{ + std::string dir_max = this->ComputeLongestObjectDirectory(*gt->Target); + + // Count the number of object files with each name. Note that + // windows file names are not case sensitive. + std::map<std::string, int> counts; + + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectNameLower = cmSystemTools::LowerCase( + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); + objectNameLower += ".obj"; + counts[objectNameLower] += 1; + } + + // For all source files producing duplicate names we need unique + // object name computation. + + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += ".obj"; + if(counts[cmSystemTools::LowerCase(objectName)] > 1) + { + const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf); + objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max); + } + si->second = objectName; + } +} + +//---------------------------------------------------------------------------- cmsys::auto_ptr<cmCustomCommand> cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, - const char* config, + const std::string& config, bool isFortran) { cmsys::auto_ptr<cmCustomCommand> pcc; @@ -79,17 +119,15 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const //---------------------------------------------------------------------------- std::string cmLocalVisualStudioGenerator -::ConstructScript(cmCustomCommand const& cc, - const char* configName, - const char* newline_text) +::ConstructScript(cmCustomCommandGenerator const& ccg, + const std::string& newline_text) { bool useLocal = this->CustomCommandUseLocal(); - const char* workingDirectory = cc.GetWorkingDirectory(); - cmCustomCommandGenerator ccg(cc, configName, this->Makefile); - RelativeRoot relativeRoot = workingDirectory? NONE : START_OUTPUT; + std::string workingDirectory = ccg.GetWorkingDirectory(); + RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE; // Avoid leading or trailing newlines. - const char* newline = ""; + std::string newline = ""; // Line to check for error between commands. std::string check_error = newline_text; @@ -114,7 +152,7 @@ cmLocalVisualStudioGenerator script += "setlocal"; } - if(workingDirectory) + if(!workingDirectory.empty()) { // Change the working directory. script += newline; @@ -124,7 +162,7 @@ cmLocalVisualStudioGenerator script += check_error; // Change the working drive. - if(workingDirectory[0] && workingDirectory[1] == ':') + if(workingDirectory.size() > 1 && workingDirectory[1] == ':') { script += newline; newline = newline_text; diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 1a3499a..3bf4f43 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -19,6 +19,7 @@ class cmSourceFile; class cmSourceGroup; class cmCustomCommand; +class cmCustomCommandGenerator; /** \class cmLocalVisualStudioGenerator * \brief Base class for Visual Studio generators. @@ -46,9 +47,8 @@ public: virtual ~cmLocalVisualStudioGenerator(); /** Construct a script from the given list of command lines. */ - std::string ConstructScript(cmCustomCommand const& cc, - const char* configName, - const char* newline = "\n"); + std::string ConstructScript(cmCustomCommandGenerator const& ccg, + const std::string& newline = "\n"); /** Label to which to jump in a batch file after a failed step in a sequence of custom commands. */ @@ -61,13 +61,18 @@ public: virtual void AddCMakeListsRules() = 0; + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* = 0); + protected: virtual const char* ReportErrorLabel() const; virtual bool CustomCommandUseLocal() const { return false; } /** Construct a custom command to make exe import lib dir. */ cmsys::auto_ptr<cmCustomCommand> - MaybeCreateImplibDir(cmTarget& target, const char* config, bool isFortran); + MaybeCreateImplibDir(cmTarget& target, const std::string& config, + bool isFortran); VSVersion Version; }; diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index a9a27b9..8ff6c87 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -37,7 +37,7 @@ cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const //---------------------------------------------------------------------------- void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags, - const char* rawFlag) + const std::string& rawFlag) { cmGlobalXCodeGenerator* gg = static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator); @@ -54,7 +54,7 @@ void cmLocalXCodeGenerator::Generate() iter != targets.end(); ++iter) { cmTarget* t = &iter->second; - t->HasMacOSXRpathInstallNameDir(NULL); + t->HasMacOSXRpathInstallNameDir(""); } } @@ -68,6 +68,34 @@ void cmLocalXCodeGenerator::GenerateInstallRules() iter != targets.end(); ++iter) { cmTarget* t = &iter->second; - t->HasMacOSXRpathInstallNameDir(NULL); + t->HasMacOSXRpathInstallNameDir(""); + } +} + +//---------------------------------------------------------------------------- +void cmLocalXCodeGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const*) +{ + // Count the number of object files with each name. Warn about duplicate + // names since Xcode names them uniquely automatically with a numeric suffix + // to avoid exact duplicate file names. Note that Mac file names are not + // typically case sensitive, hence the LowerCase. + std::map<std::string, int> counts; + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += ".o"; + + std::string objectNameLower = cmSystemTools::LowerCase(objectName); + counts[objectNameLower] += 1; + if (2 == counts[objectNameLower]) + { + // TODO: emit warning about duplicate name? + } + si->second = objectName; } } diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index edd2f5b..f553a17 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -28,9 +28,13 @@ public: virtual ~cmLocalXCodeGenerator(); virtual std::string GetTargetDirectory(cmTarget const& target) const; - virtual void AppendFlagEscape(std::string& flags, const char* rawFlag); + virtual void AppendFlagEscape(std::string& flags, + const std::string& rawFlag); virtual void Generate(); virtual void GenerateInstallRules(); + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = 0); private: }; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 499d3c6..9f569e1 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -65,7 +65,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return this->Args[0].c_str(); } + virtual std::string GetName() const { return this->Args[0]; } cmTypeMacro(cmMacroHelperCommand, cmCommand); @@ -95,7 +95,7 @@ bool cmMacroHelperCommand::InvokeInitialPass std::string errorMsg = "Macro invoked with incorrect arguments for macro named: "; errorMsg += this->Args[0]; - this->SetError(errorMsg.c_str()); + this->SetError(errorMsg); return false; } @@ -276,8 +276,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, f->Functions = this->Functions; mf.RecordPolicies(f->Policies); std::string newName = "_" + this->Args[0]; - mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(), - newName.c_str()); + mf.GetCMakeInstance()->RenameCommand(this->Args[0], + newName); mf.AddCommand(f); // remove the function blocker now that the macro is defined diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index 4c585d8..5c1cc00 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -57,7 +57,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "macro";} + virtual std::string GetName() const { return "macro";} cmTypeMacro(cmMacroCommand, cmCommand); }; diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index 615e6f2..52832db 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -74,7 +74,7 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile) cmGeneratorExpression::StripAllGeneratorExpressions); std::vector<std::string> includes; - cmSystemTools::ExpandListArgument(incDirs.c_str(), includes); + cmSystemTools::ExpandListArgument(incDirs, includes); for(std::vector<std::string>::const_iterator j = includes.begin(); j != includes.end(); ++j) @@ -93,7 +93,7 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile) it != orderedAndUniqueIncludes.end(); ++it) { - this->AddSearchPath(it->c_str()); + this->AddSearchPath(*it); } } @@ -165,7 +165,7 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info) { // Try to find the file amongst the sources cmSourceFile *srcFile = this->Makefile->GetSource - (cmSystemTools::GetFilenameWithoutExtension(path).c_str()); + (cmSystemTools::GetFilenameWithoutExtension(path)); if (srcFile) { if (srcFile->GetFullPath() == path) @@ -281,7 +281,7 @@ cmDependInformation* cmMakeDepend::GetDependInformation(const char* file, // Didn't find an instance. Create a new one and save it. cmDependInformation* info = new cmDependInformation; info->FullPath = fullPath; - info->PathOnly = cmSystemTools::GetFilenamePath(fullPath.c_str()); + info->PathOnly = cmSystemTools::GetFilenamePath(fullPath); info->IncludeName = file; this->DependInformationMap[fullPath] = info; return info; @@ -359,7 +359,7 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) } // Add a directory to the search path -void cmMakeDepend::AddSearchPath(const char* path) +void cmMakeDepend::AddSearchPath(const std::string& path) { this->IncludeDirectories.push_back(path); } diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h index b6e3928..2c9d515 100644 --- a/Source/cmMakeDepend.h +++ b/Source/cmMakeDepend.h @@ -94,7 +94,7 @@ public: /** * Add a directory to the search path for include files. */ - virtual void AddSearchPath(const char*); + virtual void AddSearchPath(const std::string&); /** * Generate dependencies for the file given. Returns a pointer to @@ -138,10 +138,10 @@ protected: cmsys::RegularExpression IncludeFileRegularExpression; cmsys::RegularExpression ComplainFileRegularExpression; std::vector<std::string> IncludeDirectories; - typedef std::map<cmStdString, cmStdString> FileToPathMapType; - typedef std::map<cmStdString, FileToPathMapType> + typedef std::map<std::string, std::string> FileToPathMapType; + typedef std::map<std::string, FileToPathMapType> DirectoryToFileToPathMapType; - typedef std::map<cmStdString, cmDependInformation*> + typedef std::map<std::string, cmDependInformation*> DependInformationMapType; DependInformationMapType DependInformationMap; DirectoryToFileToPathMapType DirectoryToFileToPathMap; diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx index 63be627..cc871c9 100644 --- a/Source/cmMakeDirectoryCommand.cxx +++ b/Source/cmMakeDirectoryCommand.cxx @@ -24,7 +24,7 @@ bool cmMakeDirectoryCommand { std::string e = "attempted to create a directory: " + args[0] + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h index 49a4009..71b97eb 100644 --- a/Source/cmMakeDirectoryCommand.h +++ b/Source/cmMakeDirectoryCommand.h @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "make_directory";} + virtual std::string GetName() const { return "make_directory";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 11559d9..2757564 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -45,8 +45,8 @@ class cmMakefile::Internals { public: std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack; - std::stack<std::set<cmStdString> > VarInitStack; - std::stack<std::set<cmStdString> > VarUsageStack; + std::stack<std::set<std::string> > VarInitStack; + std::stack<std::set<std::string> > VarUsageStack; bool IsSourceFileTryCompile; }; @@ -54,7 +54,7 @@ public: cmMakefile::cmMakefile(): Internal(new Internals) { const cmDefinitions& defs = cmDefinitions(); - const std::set<cmStdString> globalKeys = defs.LocalKeys(); + const std::set<std::string> globalKeys = defs.LocalKeys(); this->Internal->VarStack.push(defs); this->Internal->VarInitStack.push(globalKeys); this->Internal->VarUsageStack.push(globalKeys); @@ -203,7 +203,7 @@ cmMakefile::~cmMakefile() { delete *i; } - for(std::map<cmStdString, cmTest*>::iterator i = this->Tests.begin(); + for(std::map<std::string, cmTest*>::iterator i = this->Tests.begin(); i != this->Tests.end(); ++i) { delete i->second; @@ -240,20 +240,20 @@ void cmMakefile::PrintStringVector(const char* s, for(std::vector<std::string>::const_iterator i = v.begin(); i != v.end(); ++i) { - std::cout << (*i).c_str() << " "; + std::cout << *i << " "; } std::cout << " )\n"; } void cmMakefile ::PrintStringVector(const char* s, - const std::vector<std::pair<cmStdString, bool> >& v) const + const std::vector<std::pair<std::string, bool> >& v) const { std::cout << s << ": ( \n"; - for(std::vector<std::pair<cmStdString, bool> >::const_iterator i + for(std::vector<std::pair<std::string, bool> >::const_iterator i = v.begin(); i != v.end(); ++i) { - std::cout << i->first.c_str() << " " << i->second; + std::cout << i->first << " " << i->second; } std::cout << " )\n"; } @@ -273,15 +273,15 @@ void cmMakefile::Print() const } std::cout << " this->StartOutputDirectory; " << - this->StartOutputDirectory.c_str() << std::endl; + this->StartOutputDirectory << std::endl; std::cout << " this->HomeOutputDirectory; " << - this->HomeOutputDirectory.c_str() << std::endl; + this->HomeOutputDirectory << std::endl; std::cout << " this->cmStartDirectory; " << - this->cmStartDirectory.c_str() << std::endl; + this->cmStartDirectory << std::endl; std::cout << " this->cmHomeDirectory; " << - this->cmHomeDirectory.c_str() << std::endl; + this->cmHomeDirectory << std::endl; std::cout << " this->ProjectName; " - << this->ProjectName.c_str() << std::endl; + << this->ProjectName << std::endl; this->PrintStringVector("this->LinkDirectories", this->LinkDirectories); #if defined(CMAKE_BUILD_WITH_CMAKE) for( std::vector<cmSourceGroup>::const_iterator i = @@ -330,7 +330,7 @@ void cmMakefile::IssueMessage(cmake::MessageType t, lfc.Line = 0; if(!this->GetCMakeInstance()->GetIsInTryCompile()) { - lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath.c_str(), + lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, cmLocalGenerator::HOME); } backtrace.push_back(lfc); @@ -351,7 +351,7 @@ bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const i != this->CallStack.rend(); ++i) { cmListFileContext lfc = *(*i).Context; - lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath.c_str(), + lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath, cmLocalGenerator::HOME); backtrace.push_back(lfc); } @@ -394,7 +394,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, static_cast<void>(stack_manager); // Lookup the command prototype. - if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name.c_str())) + if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name)) { // Clone the prototype. cmsys::auto_ptr<cmCommand> pcmd(proto->Clone()); @@ -756,7 +756,7 @@ void cmMakefile::EnforceDirectoryLevelRules() const case cmPolicies::WARN: // Warn because the user did not provide a mimimum required // version. - this->IssueMessage(cmake::AUTHOR_WARNING, msg.str().c_str()); + this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); case cmPolicies::OLD: // OLD behavior is to use policy version 2.4 set in // cmListFileCache. @@ -765,7 +765,7 @@ void cmMakefile::EnforceDirectoryLevelRules() const case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::NEW: // NEW behavior is to issue an error. - this->IssueMessage(cmake::FATAL_ERROR, msg.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, msg.str()); cmSystemTools::SetFatalErrorOccured(); return; } @@ -878,7 +878,7 @@ void cmMakefile::ConfigureFinalPass() //---------------------------------------------------------------------------- void -cmMakefile::AddCustomCommandToTarget(const char* target, +cmMakefile::AddCustomCommandToTarget(const std::string& target, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, @@ -912,7 +912,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target, if(issueMessage) { e << "The target name \"" << target << "\" is unknown in this context."; - IssueMessage(messageType, e.str().c_str()); + IssueMessage(messageType, e.str()); } return; @@ -958,7 +958,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target, cmSourceFile* cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, const std::vector<std::string>& depends, - const char* main_dependency, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, @@ -988,7 +988,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, // Choose a source file on which to store the custom command. cmSourceFile* file = 0; - if(main_dependency && main_dependency[0]) + if(!main_dependency.empty()) { // The main dependency was specified. Use it unless a different // custom command already used it. @@ -1026,7 +1026,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, std::string outName = gg->GenerateRuleFile(outputs[0]); // Check if the rule file already exists. - file = this->GetSource(outName.c_str()); + file = this->GetSource(outName); if(file && file->GetCustomCommand() && !replace) { // The rule file already exists. @@ -1040,7 +1040,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, } // Create a cmSourceFile for the rule file. - file = this->GetOrCreateSource(outName.c_str(), true); + file = this->GetOrCreateSource(outName, true); file->SetProperty("__CMAKE_RULE", "1"); } @@ -1048,7 +1048,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, for(std::vector<std::string>::const_iterator o = outputs.begin(); o != outputs.end(); ++o) { - if(cmSourceFile* out = this->GetOrCreateSource(o->c_str(), true)) + if(cmSourceFile* out = this->GetOrCreateSource(*o, true)) { out->SetProperty("GENERATED", "1"); } @@ -1056,7 +1056,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, // Construct a complete list of dependencies. std::vector<std::string> depends2(depends); - if(main_dependency && main_dependency[0]) + if(!main_dependency.empty()) { depends2.push_back(main_dependency); } @@ -1110,9 +1110,9 @@ cmMakefile::UpdateOutputToSourceMap(std::string const& output, //---------------------------------------------------------------------------- cmSourceFile* -cmMakefile::AddCustomCommandToOutput(const char* output, +cmMakefile::AddCustomCommandToOutput(const std::string& output, const std::vector<std::string>& depends, - const char* main_dependency, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, @@ -1128,16 +1128,16 @@ cmMakefile::AddCustomCommandToOutput(const char* output, //---------------------------------------------------------------------------- void -cmMakefile::AddCustomCommandOldStyle(const char* target, +cmMakefile::AddCustomCommandOldStyle(const std::string& target, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, - const char* source, + const std::string& source, const cmCustomCommandLines& commandLines, const char* comment) { // Translate the old-style signature to one of the new-style // signatures. - if(strcmp(source, target) == 0) + if(source == target) { // In the old-style signature if the source and target were the // same then it added a post-build rule to the target. Preserve @@ -1168,7 +1168,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target, else { // The source may not be a real file. Do not use a main dependency. - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; std::vector<std::string> depends2 = depends; depends2.push_back(source); sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency, @@ -1187,7 +1187,8 @@ cmMakefile::AddCustomCommandOldStyle(const char* target, else { cmSystemTools::Error("Attempt to add a custom rule to a target " - "that does not exist yet for target ", target); + "that does not exist yet for target ", + target.c_str()); return; } } @@ -1195,7 +1196,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target, } //---------------------------------------------------------------------------- -void cmMakefile::AddUtilityCommand(const char* utilityName, +void cmMakefile::AddUtilityCommand(const std::string& utilityName, bool excludeFromAll, const std::vector<std::string>& depends, const char* workingDirectory, @@ -1234,7 +1235,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, //---------------------------------------------------------------------------- cmTarget* -cmMakefile::AddUtilityCommand(const char* utilityName, +cmMakefile::AddUtilityCommand(const std::string& utilityName, bool excludeFromAll, const char* workingDirectory, const std::vector<std::string>& depends, @@ -1258,14 +1259,14 @@ cmMakefile::AddUtilityCommand(const char* utilityName, force += cmake::GetCMakeFilesDirectory(); force += "/"; force += utilityName; - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; bool no_replace = false; - this->AddCustomCommandToOutput(force.c_str(), depends, + this->AddCustomCommandToOutput(force, depends, no_main_dependency, commandLines, comment, workingDirectory, no_replace, escapeOldStyle); - cmSourceFile* sf = target->AddSource(force.c_str()); + cmSourceFile* sf = target->AddSource(force); // The output is not actually created so mark it symbolic. if(sf) @@ -1385,8 +1386,8 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) // VS6 IDE does not support definition values with spaces in // combination with '"', '$', or ';'. - if((strcmp(this->LocalGenerator->GetGlobalGenerator()->GetName(), - "Visual Studio 6") == 0) && + if((this->LocalGenerator->GetGlobalGenerator()->GetName() == + "Visual Studio 6") && (def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos)) { return false; @@ -1461,7 +1462,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) return true; } -void cmMakefile::AddLinkLibrary(const char* lib, +void cmMakefile::AddLinkLibrary(const std::string& lib, cmTarget::LinkLibraryType llt) { cmTarget::LibraryID tmp; @@ -1470,15 +1471,15 @@ void cmMakefile::AddLinkLibrary(const char* lib, this->LinkLibraries.push_back(tmp); } -void cmMakefile::AddLinkLibraryForTarget(const char *target, - const char* lib, +void cmMakefile::AddLinkLibraryForTarget(const std::string& target, + const std::string& lib, cmTarget::LinkLibraryType llt) { cmTargets::iterator i = this->Targets.find(target); if ( i != this->Targets.end()) { cmTarget* tgt = - this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0,lib); + this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(lib); if(tgt) { // if it is not a static or shared library then you can not link to it @@ -1493,7 +1494,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, << " may not be linked into another target. " << "One may link only to STATIC or SHARED libraries, or " << "to executables with the ENABLE_EXPORTS property set."; - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str()); } } i->second.AddLinkLibrary( *this, target, lib, llt ); @@ -1504,12 +1505,12 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, e << "Attempt to add link library \"" << lib << "\" to target \"" << target << "\" which is not built in this directory."; - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str()); } } -void cmMakefile::AddLinkDirectoryForTarget(const char *target, - const char* d) +void cmMakefile::AddLinkDirectoryForTarget(const std::string& target, + const std::string& d) { cmTargets::iterator i = this->Targets.find(target); if ( i != this->Targets.end()) @@ -1519,7 +1520,7 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target, cmOStringStream e; e << "ALIAS target \"" << target << "\" " << "may not be linked into another target."; - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } i->second.AddLinkDirectory( d ); @@ -1528,46 +1529,37 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target, { cmSystemTools::Error ("Attempt to add link directories to non-existent target: ", - target, " for directory ", d); + target.c_str(), " for directory ", d.c_str()); } } -void cmMakefile::AddLinkLibrary(const char* lib) +void cmMakefile::AddLinkLibrary(const std::string& lib) { this->AddLinkLibrary(lib,cmTarget::GENERAL); } -void cmMakefile::AddLinkDirectory(const char* dir) +void cmMakefile::AddLinkDirectory(const std::string& dir) { // Don't add a link directory that is already present. Yes, this // linear search results in n^2 behavior, but n won't be getting // much bigger than 20. We cannot use a set because of order // dependency of the link search path. - if(!dir) + if(dir.empty()) { return; } + std::string newdir = dir; // remove trailing slashes - if(dir[strlen(dir)-1] == '/') + if(*dir.rbegin() == '/') { - std::string newdir = dir; - newdir = newdir.substr(0, newdir.size()-1); - if(std::find(this->LinkDirectories.begin(), - this->LinkDirectories.end(), - newdir.c_str()) == this->LinkDirectories.end()) - { - this->LinkDirectories.push_back(newdir); - } + newdir = dir.substr(0, dir.size()-1); } - else + if(std::find(this->LinkDirectories.begin(), + this->LinkDirectories.end(), newdir) + == this->LinkDirectories.end()) { - if(std::find(this->LinkDirectories.begin(), - this->LinkDirectories.end(), dir) - == this->LinkDirectories.end()) - { - this->LinkDirectories.push_back(dir); - } + this->LinkDirectories.push_back(dir); } } @@ -1621,8 +1613,8 @@ void cmMakefile::InitializeFromParent() { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(*ci); - const char* prop = parent->GetProperty(defPropName.c_str()); - this->SetProperty(defPropName.c_str(), prop); + const char* prop = parent->GetProperty(defPropName); + this->SetProperty(defPropName, prop); } } @@ -1664,7 +1656,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) } } -void cmMakefile::AddSubDirectory(const char* sub, +void cmMakefile::AddSubDirectory(const std::string& sub, bool excludeFromAll, bool preorder) { // the source path must be made full if it isn't already @@ -1686,12 +1678,13 @@ void cmMakefile::AddSubDirectory(const char* sub, } - this->AddSubDirectory(srcPath.c_str(), binPath.c_str(), + this->AddSubDirectory(srcPath, binPath, excludeFromAll, preorder, false); } -void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath, +void cmMakefile::AddSubDirectory(const std::string& srcPath, + const std::string& binPath, bool excludeFromAll, bool preorder, bool immediate) { @@ -1761,9 +1754,9 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs, //---------------------------------------------------------------------------- void -cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs) +cmMakefile::AddSystemIncludeDirectories(const std::set<std::string> &incs) { - for(std::set<cmStdString>::const_iterator li = incs.begin(); + for(std::set<std::string>::const_iterator li = incs.begin(); li != incs.end(); ++li) { this->SystemIncludeDirectories.insert(*li); @@ -1777,7 +1770,7 @@ cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs) } } -void cmMakefile::AddDefinition(const char* name, const char* value) +void cmMakefile::AddDefinition(const std::string& name, const char* value) { if (!value ) { @@ -1806,14 +1799,15 @@ void cmMakefile::AddDefinition(const char* name, const char* value) } -void cmMakefile::AddCacheDefinition(const char* name, const char* value, +void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, const char* doc, cmCacheManager::CacheEntryType type, bool force) { - const char* val = value; + bool haveVal = value ? true : false; + std::string val = haveVal ? value : ""; cmCacheManager::CacheIterator it = - this->GetCacheManager()->GetCacheIterator(name); + this->GetCacheManager()->GetCacheIterator(name.c_str()); if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) && it.Initialized()) { @@ -1822,6 +1816,7 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value, if(!force) { val = it.GetValue(); + haveVal = true; } if ( type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH ) { @@ -1844,16 +1839,18 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value, this->GetCacheManager()->AddCacheEntry(name, nvalue.c_str(), doc, type); val = it.GetValue(); + haveVal = true; } } - this->GetCacheManager()->AddCacheEntry(name, val, doc, type); + this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, + type); // if there was a definition then remove it this->Internal->VarStack.top().Set(name, 0); } -void cmMakefile::AddDefinition(const char* name, bool value) +void cmMakefile::AddDefinition(const std::string& name, bool value) { this->Internal->VarStack.top().Set(name, value? "ON" : "OFF"); if (this->Internal->VarUsageStack.size() && @@ -1880,20 +1877,20 @@ void cmMakefile::CheckForUnusedVariables() const return; } const cmDefinitions& defs = this->Internal->VarStack.top(); - const std::set<cmStdString>& locals = defs.LocalKeys(); - std::set<cmStdString>::const_iterator it = locals.begin(); + const std::set<std::string>& locals = defs.LocalKeys(); + std::set<std::string>::const_iterator it = locals.begin(); for (; it != locals.end(); ++it) { - this->CheckForUnused("out of scope", it->c_str()); + this->CheckForUnused("out of scope", *it); } } -void cmMakefile::MarkVariableAsUsed(const char* var) +void cmMakefile::MarkVariableAsUsed(const std::string& var) { this->Internal->VarUsageStack.top().insert(var); } -bool cmMakefile::VariableInitialized(const char* var) const +bool cmMakefile::VariableInitialized(const std::string& var) const { if(this->Internal->VarInitStack.top().find(var) != this->Internal->VarInitStack.top().end()) @@ -1903,7 +1900,7 @@ bool cmMakefile::VariableInitialized(const char* var) const return false; } -bool cmMakefile::VariableUsed(const char* var) const +bool cmMakefile::VariableUsed(const std::string& var) const { if(this->Internal->VarUsageStack.top().find(var) != this->Internal->VarUsageStack.top().end()) @@ -1913,11 +1910,12 @@ bool cmMakefile::VariableUsed(const char* var) const return false; } -void cmMakefile::CheckForUnused(const char* reason, const char* name) const +void cmMakefile::CheckForUnused(const char* reason, + const std::string& name) const { if (this->WarnUnused && !this->VariableUsed(name)) { - cmStdString path; + std::string path; cmListFileBacktrace bt; if (this->CallStack.size()) { @@ -1945,13 +1943,13 @@ void cmMakefile::CheckForUnused(const char* reason, const char* name) const cmOStringStream msg; msg << "unused variable (" << reason << ") \'" << name << "\'"; this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str().c_str(), + msg.str(), bt); } } } -void cmMakefile::RemoveDefinition(const char* name) +void cmMakefile::RemoveDefinition(const std::string& name) { this->Internal->VarStack.top().Set(name, 0); if (this->Internal->VarUsageStack.size() && @@ -1971,7 +1969,7 @@ void cmMakefile::RemoveDefinition(const char* name) #endif } -void cmMakefile::RemoveCacheDefinition(const char* name) +void cmMakefile::RemoveCacheDefinition(const std::string& name) { this->GetCacheManager()->RemoveCacheEntry(name); } @@ -1982,7 +1980,8 @@ void cmMakefile::SetProjectName(const char* p) } -void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) +void cmMakefile::AddGlobalLinkInformation(const std::string& name, + cmTarget& target) { // for these targets do not add anything switch(target.GetType()) @@ -1997,19 +1996,20 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) for(j = this->LinkDirectories.begin(); j != this->LinkDirectories.end(); ++j) { - target.AddLinkDirectory(j->c_str()); + target.AddLinkDirectory(*j); } target.MergeLinkLibraries( *this, name, this->LinkLibraries ); } -void cmMakefile::AddAlias(const char* lname, cmTarget *tgt) +void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt) { this->AliasTargets[lname] = tgt; this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt); } -cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, +cmTarget* cmMakefile::AddLibrary(const std::string& lname, + cmTarget::TargetType type, const std::vector<std::string> &srcs, bool excludeFromAll) { @@ -2055,7 +2055,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName, //---------------------------------------------------------------------------- cmTarget* -cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) +cmMakefile::AddNewTarget(cmTarget::TargetType type, const std::string& name) { cmTargets::iterator it = this->Targets.insert(cmTargets::value_type(name, cmTarget())).first; @@ -2067,9 +2067,8 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) } cmSourceFile* -cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const +cmMakefile::LinearGetSourceFileWithOutput(const std::string& name) const { - std::string name = cname; std::string out; // look through all the source files that have custom commands @@ -2080,7 +2079,7 @@ cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const // does this source file have a custom command? if ((*i)->GetCustomCommand()) { - // is the output of the custom command match the source files name + // Does the output of the custom command match the source file name? const std::vector<std::string>& outputs = (*i)->GetCustomCommand()->GetOutputs(); for(std::vector<std::string>::const_iterator o = outputs.begin(); @@ -2103,15 +2102,14 @@ cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const return 0; } -cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) const +cmSourceFile *cmMakefile::GetSourceFileWithOutput( + const std::string& name) const { - std::string name = cname; - // If the queried path is not absolute we use the backward compatible // linear-time search for an output with a matching suffix. - if(!cmSystemTools::FileIsFullPath(cname)) + if(!cmSystemTools::FileIsFullPath(name.c_str())) { - return LinearGetSourceFileWithOutput(cname); + return this->LinearGetSourceFileWithOutput(name); } // Otherwise we use an efficient lookup map. OutputToSourceMap::const_iterator o = this->OutputToSource.find(name); @@ -2156,15 +2154,12 @@ cmMakefile::GetSourceGroup(const std::vector<std::string>&name) const return sg; } - void cmMakefile::AddSourceGroup(const char* name, +void cmMakefile::AddSourceGroup(const std::string& name, const char* regex) { - if (name) - { - std::vector<std::string> nameVector; - nameVector.push_back(name); - AddSourceGroup(nameVector, regex); - } + std::vector<std::string> nameVector; + nameVector.push_back(name); + AddSourceGroup(nameVector, regex); } void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, @@ -2212,7 +2207,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, { std::string guidName = "SG_Filter_"; guidName += fullname; - gg->CreateGUID(guidName.c_str()); + gg->CreateGUID(guidName); } for(++i; i<=lastElement; ++i) { @@ -2223,7 +2218,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name, { std::string guidName = "SG_Filter_"; guidName += fullname; - gg->CreateGUID(guidName.c_str()); + gg->CreateGUID(guidName); } } @@ -2337,13 +2332,13 @@ void cmMakefile::ExpandVariablesCMP0019() } } -bool cmMakefile::IsOn(const char* name) const +bool cmMakefile::IsOn(const std::string& name) const { const char* value = this->GetDefinition(name); return cmSystemTools::IsOn(value); } -bool cmMakefile::IsSet(const char* name) const +bool cmMakefile::IsSet(const std::string& name) const { const char* value = this->GetDefinition(name); if ( !value ) @@ -2373,16 +2368,16 @@ bool cmMakefile::PlatformIs64Bit() const return false; } -const char* cmMakefile::GetSONameFlag(const char* language) const +const char* cmMakefile::GetSONameFlag(const std::string& language) const { std::string name = "CMAKE_SHARED_LIBRARY_SONAME"; - if(language) + if(!language.empty()) { name += "_"; name += language; } name += "_FLAG"; - return GetDefinition(name.c_str()); + return GetDefinition(name); } bool cmMakefile::CanIWriteThisFile(const char* fileName) const @@ -2414,7 +2409,7 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) const return true; } -const char* cmMakefile::GetRequiredDefinition(const char* name) const +const char* cmMakefile::GetRequiredDefinition(const std::string& name) const { const char* ret = this->GetDefinition(name); if(!ret) @@ -2422,13 +2417,13 @@ const char* cmMakefile::GetRequiredDefinition(const char* name) const cmSystemTools::Error("Error required internal CMake variable not " "set, cmake may be not be built correctly.\n", "Missing variable is:\n", - name); + name.c_str()); return ""; } return ret; } -bool cmMakefile::IsDefinitionSet(const char* name) const +bool cmMakefile::IsDefinitionSet(const std::string& name) const { const char* def = this->Internal->VarStack.top().Get(name); this->Internal->VarUsageStack.top().insert(name); @@ -2450,7 +2445,7 @@ bool cmMakefile::IsDefinitionSet(const char* name) const return def?true:false; } -const char* cmMakefile::GetDefinition(const char* name) const +const char* cmMakefile::GetDefinition(const std::string& name) const { if (this->WarnUnused) { @@ -2491,7 +2486,7 @@ const char* cmMakefile::GetDefinition(const char* name) const return def; } -const char* cmMakefile::GetSafeDefinition(const char* def) const +const char* cmMakefile::GetSafeDefinition(const std::string& def) const { const char* ret = this->GetDefinition(def); if(!ret) @@ -2504,7 +2499,7 @@ const char* cmMakefile::GetSafeDefinition(const char* def) const std::vector<std::string> cmMakefile ::GetDefinitions(int cacheonly /* = 0 */) const { - std::set<cmStdString> definitions; + std::set<std::string> definitions; if ( !cacheonly ) { definitions = this->Internal->VarStack.top().ClosureKeys(); @@ -2518,7 +2513,7 @@ std::vector<std::string> cmMakefile std::vector<std::string> res; - std::set<cmStdString>::iterator fit; + std::set<std::string>::iterator fit; for ( fit = definitions.begin(); fit != definitions.end(); fit ++ ) { res.push_back(*fit); @@ -2577,7 +2572,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source, // Lookup the definition of VAR. std::string var(first+1, last-first-2); - if(const char* val = this->GetDefinition(var.c_str())) + if(const char* val = this->GetDefinition(var)) { // Store the value in the output escaping as requested. if(escapeQuotes) @@ -2632,7 +2627,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source, << " " << filename << ":" << line << "\n"; } error << "when parsing string\n" - << " " << source.c_str() << "\n"; + << " " << source << "\n"; error << emsg; // If the parser failed ("res" is false) then this is a real @@ -2751,7 +2746,7 @@ void cmMakefile::AddDefaultDefinitions() } //---------------------------------------------------------------------------- -const char* +std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs, bool single) const { @@ -2762,12 +2757,12 @@ cmMakefile::GetConfigurations(std::vector<std::string>& configs, { cmSystemTools::ExpandListArgument(configTypes, configs); } - return 0; + return ""; } else { - const char* buildType = this->GetDefinition("CMAKE_BUILD_TYPE"); - if(single && buildType && *buildType) + const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); + if(single && !buildType.empty()) { configs.push_back(buildType); } @@ -2973,7 +2968,7 @@ cmMakefile::LexicalPushPop::~LexicalPushPop() this->Makefile->PopFunctionBlockerBarrier(this->ReportError); } -void cmMakefile::SetHomeDirectory(const char* dir) +void cmMakefile::SetHomeDirectory(const std::string& dir) { this->cmHomeDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory); @@ -2984,7 +2979,7 @@ void cmMakefile::SetHomeDirectory(const char* dir) } } -void cmMakefile::SetHomeOutputDirectory(const char* lib) +void cmMakefile::SetHomeOutputDirectory(const std::string& lib) { this->HomeOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory); @@ -3012,13 +3007,13 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args) { cmOStringStream tmpStream; tmpStream << "CMAKE_ARGV" << t; - this->AddDefinition(tmpStream.str().c_str(), args[t].c_str()); + this->AddDefinition(tmpStream.str(), args[t].c_str()); //this->MarkVariableAsUsed(tmpStream.str().c_str()); } } //---------------------------------------------------------------------------- -cmSourceFile* cmMakefile::GetSource(const char* sourceName) const +cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const { cmSourceFileLocation sfl(this, sourceName); for(std::vector<cmSourceFile*>::const_iterator @@ -3035,7 +3030,7 @@ cmSourceFile* cmMakefile::GetSource(const char* sourceName) const } //---------------------------------------------------------------------------- -cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, +cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, bool generated) { if(cmSourceFile* esf = this->GetSource(sourceName)) @@ -3077,23 +3072,25 @@ void cmMakefile::ExpandSourceListArguments( } } -int cmMakefile::TryCompile(const char *srcdir, const char *bindir, - const char *projectName, const char *targetName, +int cmMakefile::TryCompile(const std::string& srcdir, + const std::string& bindir, + const std::string& projectName, + const std::string& targetName, bool fast, const std::vector<std::string> *cmakeArgs, std::string *output) { this->Internal->IsSourceFileTryCompile = fast; // does the binary directory exist ? If not create it... - if (!cmSystemTools::FileIsDirectory(bindir)) + if (!cmSystemTools::FileIsDirectory(bindir.c_str())) { - cmSystemTools::MakeDirectory(bindir); + cmSystemTools::MakeDirectory(bindir.c_str()); } // change to the tests directory and run cmake // use the cmake object instead of calling cmake std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(bindir); + cmSystemTools::ChangeDirectory(bindir.c_str()); // make sure the same generator is used // use this program as the cmake to be run, it should not @@ -3345,7 +3342,8 @@ std::string cmMakefile::GetModulesFile(const char* filename) const if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0)) { const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE"); - if (currentFile && (strstr(currentFile, cmakeRoot) == currentFile)) + std::string mods = cmakeRoot + std::string("/Modules/"); + if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0) { switch (this->GetPolicyStatus(cmPolicies::CMP0017)) { @@ -3406,7 +3404,7 @@ void cmMakefile::ConfigureString(const std::string& input, if(this->cmDefineRegex.find(line)) { const char* def = - this->GetDefinition(this->cmDefineRegex.match(1).c_str()); + this->GetDefinition(this->cmDefineRegex.match(1)); if(!cmSystemTools::IsOff(def)) { cmSystemTools::ReplaceString(line, "#cmakedefine", "#define"); @@ -3422,7 +3420,7 @@ void cmMakefile::ConfigureString(const std::string& input, else if(this->cmDefine01Regex.find(line)) { const char* def = - this->GetDefinition(this->cmDefine01Regex.match(1).c_str()); + this->GetDefinition(this->cmDefine01Regex.match(1)); cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define"); output += line; if(!cmSystemTools::IsOff(def)) @@ -3528,6 +3526,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, return 0; } + cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin); + if(bom != cmsys::FStream::BOM_None && + bom != cmsys::FStream::BOM_UTF8) + { + cmOStringStream e; + e << "File starts with a Byte-Order-Mark that is not UTF-8:\n " + << sinfile; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return 0; + } + // rewind to copy BOM to output file + fin.seekg(0); + + // now copy input to output and expand variables in the // input file at the same time std::string inLine; @@ -3555,17 +3567,9 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, return res; } -void cmMakefile::SetProperty(const char* prop, const char* value) +void cmMakefile::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } - - // handle special props - std::string propname = prop; - - if ( propname == "LINK_DIRECTORIES" ) + if ( prop == "LINK_DIRECTORIES" ) { std::vector<std::string> varArgsExpanded; if(value) @@ -3575,7 +3579,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->SetLinkDirectories(varArgsExpanded); return; } - if (propname == "INCLUDE_DIRECTORIES") + if (prop == "INCLUDE_DIRECTORIES") { this->IncludeDirectoriesEntries.clear(); if (!value) @@ -3588,7 +3592,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) cmValueWithOrigin(value, lfbt)); return; } - if (propname == "COMPILE_OPTIONS") + if (prop == "COMPILE_OPTIONS") { this->CompileOptionsEntries.clear(); if (!value) @@ -3600,7 +3604,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); return; } - if (propname == "COMPILE_DEFINITIONS") + if (prop == "COMPILE_DEFINITIONS") { this->CompileDefinitionsEntries.clear(); if (!value) @@ -3614,13 +3618,13 @@ void cmMakefile::SetProperty(const char* prop, const char* value) return; } - if ( propname == "INCLUDE_REGULAR_EXPRESSION" ) + if ( prop == "INCLUDE_REGULAR_EXPRESSION" ) { this->SetIncludeRegularExpression(value); return; } - if ( propname == "ADDITIONAL_MAKE_CLEAN_FILES" ) + if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" ) { // This property is not inherrited if ( strcmp(this->GetCurrentDirectory(), @@ -3633,18 +3637,11 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY); } -void cmMakefile::AppendProperty(const char* prop, const char* value, +void cmMakefile::AppendProperty(const std::string& prop, + const char* value, bool asString) { - if (!prop) - { - return; - } - - // handle special props - std::string propname = prop; - - if (propname == "INCLUDE_DIRECTORIES") + if (prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); @@ -3652,7 +3649,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmValueWithOrigin(value, lfbt)); return; } - if (propname == "COMPILE_OPTIONS") + if (prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); @@ -3660,7 +3657,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmValueWithOrigin(value, lfbt)); return; } - if (propname == "COMPILE_DEFINITIONS") + if (prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); @@ -3668,14 +3665,14 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmValueWithOrigin(value, lfbt)); return; } - if ( propname == "LINK_DIRECTORIES" ) + if ( prop == "LINK_DIRECTORIES" ) { std::vector<std::string> varArgsExpanded; cmSystemTools::ExpandListArgument(value, varArgsExpanded); for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin(); vi != varArgsExpanded.end(); ++vi) { - this->AddLinkDirectory(vi->c_str()); + this->AddLinkDirectory(*vi); } return; } @@ -3683,32 +3680,18 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString); } -const char *cmMakefile::GetPropertyOrDefinition(const char* prop) const -{ - const char *ret = this->GetProperty(prop, cmProperty::DIRECTORY); - if (!ret) - { - ret = this->GetDefinition(prop); - } - return ret; -} - -const char *cmMakefile::GetProperty(const char* prop) const +const char *cmMakefile::GetProperty(const std::string& prop) const { return this->GetProperty(prop, cmProperty::DIRECTORY); } -const char *cmMakefile::GetProperty(const char* prop, +const char *cmMakefile::GetProperty(const std::string& prop, cmProperty::ScopeType scope) const { - if(!prop) - { - return 0; - } // watch for specific properties static std::string output; output = ""; - if (!strcmp("PARENT_DIRECTORY",prop)) + if (prop == "PARENT_DIRECTORY") { if(cmLocalGenerator* plg = this->LocalGenerator->GetParent()) { @@ -3716,14 +3699,14 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("INCLUDE_REGULAR_EXPRESSION",prop) ) + else if (prop == "INCLUDE_REGULAR_EXPRESSION" ) { output = this->GetIncludeRegularExpression(); return output.c_str(); } - else if (!strcmp("LISTFILE_STACK",prop)) + else if (prop == "LISTFILE_STACK") { - for (std::deque<cmStdString>::const_iterator + for (std::deque<std::string>::const_iterator i = this->ListFileStack.begin(); i != this->ListFileStack.end(); ++i) { @@ -3735,10 +3718,10 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("VARIABLES",prop) || !strcmp("CACHE_VARIABLES",prop)) + else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES") { int cacheonly = 0; - if ( !strcmp("CACHE_VARIABLES",prop) ) + if ( prop == "CACHE_VARIABLES" ) { cacheonly = 1; } @@ -3753,17 +3736,17 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("MACROS",prop)) + else if (prop == "MACROS") { this->GetListOfMacros(output); return output.c_str(); } - else if (!strcmp("DEFINITIONS",prop)) + else if (prop == "DEFINITIONS") { output += this->DefineFlagsOrig; return output.c_str(); } - else if (!strcmp("LINK_DIRECTORIES",prop)) + else if (prop == "LINK_DIRECTORIES") { cmOStringStream str; for (std::vector<std::string>::const_iterator @@ -3780,7 +3763,7 @@ const char *cmMakefile::GetProperty(const char* prop, output = str.str(); return output.c_str(); } - else if (!strcmp("INCLUDE_DIRECTORIES",prop)) + else if (prop == "INCLUDE_DIRECTORIES") { std::string sep; for (std::vector<cmValueWithOrigin>::const_iterator @@ -3794,7 +3777,7 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("COMPILE_OPTIONS",prop)) + else if (prop == "COMPILE_OPTIONS") { std::string sep; for (std::vector<cmValueWithOrigin>::const_iterator @@ -3808,7 +3791,7 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } - else if (!strcmp("COMPILE_DEFINITIONS",prop)) + else if (prop == "COMPILE_DEFINITIONS") { std::string sep; for (std::vector<cmValueWithOrigin>::const_iterator @@ -3839,22 +3822,23 @@ const char *cmMakefile::GetProperty(const char* prop, return retVal; } -bool cmMakefile::GetPropertyAsBool(const char* prop) const +bool cmMakefile::GetPropertyAsBool(const std::string& prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } //---------------------------------------------------------------------------- -const char* cmMakefile::GetFeature(const char* feature, const char* config) +const char* cmMakefile::GetFeature(const std::string& feature, + const std::string& config) { // TODO: Define accumulation policy for features (prepend, append, replace). // Currently we always replace. - if(config && *config) + if(!config.empty()) { std::string featureConfig = feature; featureConfig += "_"; featureConfig += cmSystemTools::UpperCase(config); - if(const char* value = this->GetProperty(featureConfig.c_str())) + if(const char* value = this->GetProperty(featureConfig)) { return value; } @@ -3892,12 +3876,8 @@ cmTarget* cmMakefile::FindTarget(const std::string& name, } //---------------------------------------------------------------------------- -cmTest* cmMakefile::CreateTest(const char* testName) +cmTest* cmMakefile::CreateTest(const std::string& testName) { - if ( !testName ) - { - return 0; - } cmTest* test = this->GetTest(testName); if ( test ) { @@ -3910,16 +3890,13 @@ cmTest* cmMakefile::CreateTest(const char* testName) } //---------------------------------------------------------------------------- -cmTest* cmMakefile::GetTest(const char* testName) const +cmTest* cmMakefile::GetTest(const std::string& testName) const { - if(testName) + std::map<std::string, cmTest*>::const_iterator + mi = this->Tests.find(testName); + if(mi != this->Tests.end()) { - std::map<cmStdString, cmTest*>::const_iterator - mi = this->Tests.find(testName); - if(mi != this->Tests.end()) - { - return mi->second; - } + return mi->second; } return 0; } @@ -3954,7 +3931,7 @@ std::string cmMakefile::GetListFileStack() const size_t depth = this->ListFileStack.size(); if (depth > 0) { - std::deque<cmStdString>::const_iterator it = this->ListFileStack.end(); + std::deque<std::string>::const_iterator it = this->ListFileStack.end(); do { if (depth != this->ListFileStack.size()) @@ -3977,8 +3954,8 @@ std::string cmMakefile::GetListFileStack() const void cmMakefile::PushScope() { cmDefinitions* parent = &this->Internal->VarStack.top(); - const std::set<cmStdString>& init = this->Internal->VarInitStack.top(); - const std::set<cmStdString>& usage = this->Internal->VarUsageStack.top(); + const std::set<std::string>& init = this->Internal->VarInitStack.top(); + const std::set<std::string>& usage = this->Internal->VarUsageStack.top(); this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); @@ -3987,18 +3964,18 @@ void cmMakefile::PushScope() void cmMakefile::PopScope() { cmDefinitions* current = &this->Internal->VarStack.top(); - std::set<cmStdString> init = this->Internal->VarInitStack.top(); - std::set<cmStdString> usage = this->Internal->VarUsageStack.top(); - const std::set<cmStdString>& locals = current->LocalKeys(); + std::set<std::string> init = this->Internal->VarInitStack.top(); + std::set<std::string> usage = this->Internal->VarUsageStack.top(); + const std::set<std::string>& locals = current->LocalKeys(); // Remove initialization and usage information for variables in the local // scope. - std::set<cmStdString>::const_iterator it = locals.begin(); + std::set<std::string>::const_iterator it = locals.begin(); for (; it != locals.end(); ++it) { init.erase(*it); - if (!this->VariableUsed(it->c_str())) + if (!this->VariableUsed(*it)) { - this->CheckForUnused("out of scope", it->c_str()); + this->CheckForUnused("out of scope", *it); } else { @@ -4021,9 +3998,9 @@ void cmMakefile::PopScope() } } -void cmMakefile::RaiseScope(const char *var, const char *varDef) +void cmMakefile::RaiseScope(const std::string& var, const char *varDef) { - if (!var || !strlen(var)) + if (var.empty()) { return; } @@ -4077,7 +4054,8 @@ void cmMakefile::DefineProperties(cmake *cm) //---------------------------------------------------------------------------- cmTarget* -cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, +cmMakefile::AddImportedTarget(const std::string& name, + cmTarget::TargetType type, bool global) { // Create the target. @@ -4104,7 +4082,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, { // Look for an imported target. These take priority because they // are more local in scope and do not have to be globally unique. - std::map<cmStdString, cmTarget*>::const_iterator + std::map<std::string, cmTarget*>::const_iterator imported = this->ImportedTargets.find(name); if(imported != this->ImportedTargets.end()) { @@ -4118,8 +4096,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, } // Look for a target built in this project. - return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, - name.c_str(), + return this->LocalGenerator->GetGlobalGenerator()->FindTarget(name, excludeAliases); } @@ -4129,12 +4106,12 @@ bool cmMakefile::IsAlias(const std::string& name) const if (this->AliasTargets.find(name) != this->AliasTargets.end()) return true; return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias( - name.c_str()); + name); } //---------------------------------------------------------------------------- cmGeneratorTarget* -cmMakefile::FindGeneratorTargetToUse(const char* name) const +cmMakefile::FindGeneratorTargetToUse(const std::string& name) const { if (cmTarget *t = this->FindTargetToUse(name)) { @@ -4223,6 +4200,9 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, case cmTarget::UTILITY: e << "a custom target "; break; + case cmTarget::INTERFACE_LIBRARY: + e << "an interface library "; + break; default: break; } e << "created in source directory \"" @@ -4236,8 +4216,8 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, } //---------------------------------------------------------------------------- -bool cmMakefile::EnforceUniqueDir(const char* srcPath, - const char* binPath) const +bool cmMakefile::EnforceUniqueDir(const std::string& srcPath, + const std::string& binPath) const { // Make sure the binary directory is unique. cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); @@ -4375,7 +4355,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, { std::string msg = this->GetPolicies()->GetRequiredAlwaysPolicyError(id); - this->IssueMessage(cmake::FATAL_ERROR, msg.c_str()); + this->IssueMessage(cmake::FATAL_ERROR, msg); return false; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 45f3b9f..460a85c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -69,11 +69,11 @@ public: /* Check for unused variables in this scope */ void CheckForUnusedVariables() const; /* Mark a variable as used */ - void MarkVariableAsUsed(const char* var); + void MarkVariableAsUsed(const std::string& var); /* return true if a variable has been initialized */ - bool VariableInitialized(const char* ) const; + bool VariableInitialized(const std::string& ) const; /* return true if a variable has been used */ - bool VariableUsed(const char* ) const; + bool VariableUsed(const std::string& ) const; /** Return whether compatibility features needed for a version of the cache or lower should be enabled. */ bool NeedCacheCompatibility(int major, int minor) const; @@ -126,8 +126,8 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - int TryCompile(const char *srcdir, const char *bindir, - const char *projectName, const char *targetName, + int TryCompile(const std::string& srcdir, const std::string& bindir, + const std::string& projectName, const std::string& targetName, bool fast, const std::vector<std::string> *cmakeArgs, std::string *output); @@ -168,7 +168,7 @@ public: void Print() const; /** Add a custom command to the build. */ - void AddCustomCommandToTarget(const char* target, + void AddCustomCommandToTarget(const std::string& target, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, @@ -177,23 +177,23 @@ public: cmSourceFile* AddCustomCommandToOutput( const std::vector<std::string>& outputs, const std::vector<std::string>& depends, - const char* main_dependency, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true); cmSourceFile* AddCustomCommandToOutput( - const char* output, + const std::string& output, const std::vector<std::string>& depends, - const char* main_dependency, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true); - void AddCustomCommandOldStyle(const char* target, + void AddCustomCommandOldStyle(const std::string& target, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, - const char* source, + const std::string& source, const cmCustomCommandLines& commandLines, const char* comment); @@ -205,10 +205,11 @@ public: void AddCompileOption(const char* option); /** Create a new imported target with the name and type given. */ - cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type, + cmTarget* AddImportedTarget(const std::string& name, + cmTarget::TargetType type, bool global); - cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name); + cmTarget* AddNewTarget(cmTarget::TargetType type, const std::string& name); /** * Add an executable to the build. @@ -221,7 +222,7 @@ public: * Add a utility to the build. A utiltity target is a command that * is run every time the target is built. */ - void AddUtilityCommand(const char* utilityName, bool excludeFromAll, + void AddUtilityCommand(const std::string& utilityName, bool excludeFromAll, const std::vector<std::string>& depends, const char* workingDirectory, const char* command, @@ -229,7 +230,8 @@ public: const char* arg2=0, const char* arg3=0, const char* arg4=0); - cmTarget* AddUtilityCommand(const char* utilityName, bool excludeFromAll, + cmTarget* AddUtilityCommand(const std::string& utilityName, + bool excludeFromAll, const char* workingDirectory, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, @@ -239,16 +241,16 @@ public: /** * Add a link library to the build. */ - void AddLinkLibrary(const char*); - void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type); - void AddLinkLibraryForTarget(const char *tgt, const char*, + void AddLinkLibrary(const std::string&); + void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type); + void AddLinkLibraryForTarget(const std::string& tgt, const std::string&, cmTarget::LinkLibraryType type); - void AddLinkDirectoryForTarget(const char *tgt, const char* d); + void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d); /** * Add a link directory to the build. */ - void AddLinkDirectory(const char*); + void AddLinkDirectory(const std::string&); const std::vector<std::string>& GetLinkDirectories() const { @@ -262,9 +264,10 @@ public: /** * Add a subdirectory to the build. */ - void AddSubDirectory(const char*, bool excludeFromAll=false, + void AddSubDirectory(const std::string&, bool excludeFromAll=false, bool preorder = false); - void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir, + void AddSubDirectory(const std::string& fullSrcDir, + const std::string& fullBinDir, bool excludeFromAll, bool preorder, bool immediate); @@ -283,9 +286,9 @@ public: * Add a variable definition to the build. This variable * can be used in CMake to refer to lists, directories, etc. */ - void AddDefinition(const char* name, const char* value); + void AddDefinition(const std::string& name, const char* value); ///! Add a definition to this makefile and the global cmake cache. - void AddCacheDefinition(const char* name, const char* value, + void AddCacheDefinition(const std::string& name, const char* value, const char* doc, cmCacheManager::CacheEntryType type, bool force = false); @@ -293,15 +296,15 @@ public: /** * Add bool variable definition to the build. */ - void AddDefinition(const char* name, bool); + void AddDefinition(const std::string& name, bool); /** * Remove a variable definition from the build. This is not valid * for cache entries, and will only affect the current makefile. */ - void RemoveDefinition(const char* name); + void RemoveDefinition(const std::string& name); ///! Remove a definition from the cache. - void RemoveCacheDefinition(const char* name); + void RemoveCacheDefinition(const std::string& name); /** * Specify the name of the project for this build. @@ -317,22 +320,22 @@ public: } /** Get the configurations to be generated. */ - const char* GetConfigurations(std::vector<std::string>& configs, + std::string GetConfigurations(std::vector<std::string>& configs, bool single = true) const; /** * Set the name of the library. */ - cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type, + cmTarget* AddLibrary(const std::string& libname, cmTarget::TargetType type, const std::vector<std::string> &srcs, bool excludeFromAll = false); - void AddAlias(const char *libname, cmTarget *tgt); + void AddAlias(const std::string& libname, cmTarget *tgt); #if defined(CMAKE_BUILD_WITH_CMAKE) /** * Add a root source group for consideration when adding a new source. */ - void AddSourceGroup(const char* name, const char* regex=0); + void AddSourceGroup(const std::string& name, const char* regex=0); /** * Add a source group for consideration when adding a new source. @@ -399,12 +402,12 @@ public: * CMakeLists files by recursing up the tree starting at the StartDirectory * and going up until it reaches the HomeDirectory. */ - void SetHomeDirectory(const char* dir); + void SetHomeDirectory(const std::string& dir); const char* GetHomeDirectory() const { return this->cmHomeDirectory.c_str(); } - void SetHomeOutputDirectory(const char* lib); + void SetHomeOutputDirectory(const std::string& lib); const char* GetHomeOutputDirectory() const { return this->HomeOutputDirectory.c_str(); @@ -429,7 +432,7 @@ public: * recursing up the tree starting at the StartDirectory and going up until * it reaches the HomeDirectory. */ - void SetStartDirectory(const char* dir) + void SetStartDirectory(const std::string& dir) { this->cmStartDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); @@ -442,7 +445,7 @@ public: { return this->cmStartDirectory.c_str(); } - void SetStartOutputDirectory(const char* lib) + void SetStartOutputDirectory(const std::string& lib) { this->StartOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); @@ -494,7 +497,7 @@ public: * Set a regular expression that include files that are not found * must match in order to be considered a problem. */ - void SetComplainRegularExpression(const char* regex) + void SetComplainRegularExpression(const std::string& regex) { this->ComplainFileRegularExpression = regex; } @@ -534,12 +537,12 @@ public: cmTarget* FindTargetToUse(const std::string& name, bool excludeAliases = false) const; bool IsAlias(const std::string& name) const; - cmGeneratorTarget* FindGeneratorTargetToUse(const char* name) const; + cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; /** * Mark include directories as system directories. */ - void AddSystemIncludeDirectories(const std::set<cmStdString> &incs); + void AddSystemIncludeDirectories(const std::set<std::string> &incs); /** Expand out any arguements in the vector that have ; separated * strings into multiple arguements. A new vector is created @@ -555,14 +558,14 @@ public: /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then a null pointer is returned. */ - cmSourceFile* GetSource(const char* sourceName) const; + cmSourceFile* GetSource(const std::string& sourceName) const; /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then create the source file and return it. generated * indicates if it is a generated file, this is used in determining * how to create the source file instance e.g. name */ - cmSourceFile* GetOrCreateSource(const char* sourceName, + cmSourceFile* GetOrCreateSource(const std::string& sourceName, bool generated = false); /** @@ -587,10 +590,10 @@ public: * If the variable is not found in this makefile instance, the * cache is then queried. */ - const char* GetDefinition(const char*) const; - const char* GetSafeDefinition(const char*) const; - const char* GetRequiredDefinition(const char* name) const; - bool IsDefinitionSet(const char*) const; + const char* GetDefinition(const std::string&) const; + const char* GetSafeDefinition(const std::string&) const; + const char* GetRequiredDefinition(const std::string& name) const; + bool IsDefinitionSet(const std::string&) const; /** * Get the list of all variables in the current space. If argument * cacheonly is specified and is greater than 0, then only cache @@ -601,14 +604,14 @@ public: /** Test a boolean cache entry to see if it is true or false, * returns false if no entry defined. */ - bool IsOn(const char* name) const; - bool IsSet(const char* name) const; + bool IsOn(const std::string& name) const; + bool IsSet(const std::string& name) const; /** Return whether the target platform is 64-bit. */ bool PlatformIs64Bit() const; /** Retrieve soname flag for the specified language if supported */ - const char* GetSONameFlag(const char* language) const; + const char* GetSONameFlag(const std::string& language) const; /** * Get a list of preprocessor define flags. @@ -773,7 +776,7 @@ public: * Is there a source file that has the provided source file as an output? * if so then return it */ - cmSourceFile *GetSourceFileWithOutput(const char *outName) const; + cmSourceFile *GetSourceFileWithOutput(const std::string& outName) const; /** * Add a macro to the list of macros. The arguments should be name of the @@ -782,12 +785,12 @@ public: void AddMacro(const char* name, const char* signature); ///! Add a new cmTest to the list of tests for this makefile. - cmTest* CreateTest(const char* testName); + cmTest* CreateTest(const std::string& testName); /** Get a cmTest pointer for a given test name, if the name is * not found, then a null pointer is returned. */ - cmTest* GetTest(const char* testName) const; + cmTest* GetTest(const std::string& testName) const; /** * Get a list of macros as a ; separated string @@ -800,14 +803,16 @@ public: std::string GetModulesFile(const char* name) const; ///! Set/Get a property of this directory - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char *prop, const char *value,bool asString=false); - const char *GetProperty(const char *prop) const; - const char *GetPropertyOrDefinition(const char *prop) const; - const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; - bool GetPropertyAsBool(const char *prop) const; + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, const char *value, + bool asString=false); + const char *GetProperty(const std::string& prop) const; + const char *GetProperty(const std::string& prop, + cmProperty::ScopeType scope) const; + bool GetPropertyAsBool(const std::string& prop) const; - const char* GetFeature(const char* feature, const char* config); + const char* GetFeature(const std::string& feature, + const std::string& config); // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; @@ -835,7 +840,7 @@ public: // push and pop variable scopes void PushScope(); void PopScope(); - void RaiseScope(const char *var, const char *value); + void RaiseScope(const std::string& var, const char *value); /** Helper class to push and pop scopes automatically. */ class ScopePushPop @@ -872,15 +877,15 @@ public: void AddQtUiFileWithOptions(cmSourceFile *sf); std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const; - std::set<cmStdString> const & GetSystemIncludeDirectories() const + std::set<std::string> const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } protected: // add link libraries and directories to the target - void AddGlobalLinkInformation(const char* name, cmTarget& target); + void AddGlobalLinkInformation(const std::string& name, cmTarget& target); // Check for a an unused variable - void CheckForUnused(const char* reason, const char* name) const; + void CheckForUnused(const char* reason, const std::string& name) const; std::string Prefix; std::vector<std::string> AuxSourceDirectories; // @@ -900,14 +905,14 @@ protected: std::vector<cmSourceFile*> SourceFiles; // Tests - std::map<cmStdString, cmTest*> Tests; + std::map<std::string, cmTest*> Tests; // The link-library paths. Order matters, use std::vector (not std::set). std::vector<std::string> LinkDirectories; // The set of include directories that are marked as system include // directories. - std::set<cmStdString> SystemIncludeDirectories; + std::set<std::string> SystemIncludeDirectories; std::vector<std::string> ListFiles; // list of command files loaded std::vector<std::string> OutputFiles; // list of command files loaded @@ -947,12 +952,13 @@ private: bool ParseDefineFlag(std::string const& definition, bool remove); - bool EnforceUniqueDir(const char* srcPath, const char* binPath) const; + bool EnforceUniqueDir(const std::string& srcPath, + const std::string& binPath) const; friend class cmMakeDepend; // make depend needs direct access // to the Sources array void PrintStringVector(const char* s, const - std::vector<std::pair<cmStdString, bool> >& v) const; + std::vector<std::pair<std::string, bool> >& v) const; void PrintStringVector(const char* s, const std::vector<std::string>& v) const; @@ -963,10 +969,10 @@ private: void PushFunctionBlockerBarrier(); void PopFunctionBlockerBarrier(bool reportError = true); - typedef std::map<cmStdString, cmStdString> StringStringMap; + typedef std::map<std::string, std::string> StringStringMap; StringStringMap MacrosMap; - std::map<cmStdString, bool> SubDirectoryOrder; + std::map<std::string, bool> SubDirectoryOrder; mutable cmsys::RegularExpression cmDefineRegex; mutable cmsys::RegularExpression cmDefine01Regex; @@ -982,7 +988,7 @@ private: bool CheckSystemVars; // stack of list files being read - std::deque<cmStdString> ListFileStack; + std::deque<std::string> ListFileStack; // stack of commands being invoked. struct CallStackEntry @@ -995,7 +1001,7 @@ private: friend class cmMakefileCall; std::vector<cmTarget*> ImportedTargetsOwned; - std::map<cmStdString, cmTarget*> ImportedTargets; + std::map<std::string, cmTarget*> ImportedTargets; // Internal policy stack management. void PushPolicy(bool weak = false, @@ -1029,12 +1035,12 @@ private: bool GeneratingBuildSystem; /** - * Old version of GetSourceFileWithOutput(const char*) kept for + * Old version of GetSourceFileWithOutput(const std::string&) kept for * backward-compatibility. It implements a linear search and support * relative file paths. It is used as a fall back by - * GetSourceFileWithOutput(const char*). + * GetSourceFileWithOutput(const std::string&). */ - cmSourceFile *LinearGetSourceFileWithOutput(const char *cname) const; + cmSourceFile *LinearGetSourceFileWithOutput(const std::string& cname) const; // A map for fast output to input look up. #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 69b8092..701d5a0 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -129,7 +129,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } } - std::string pdbOutputPath = this->Target->GetPDBDirectory(); + std::string compilePdbOutputPath = + this->Target->GetCompilePDBDirectory(this->ConfigName); + cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); + + std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; @@ -138,32 +142,32 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetFullPathPDB = pdbOutputPath + targetNamePDB; std::string targetFullPathImport = outpathImp + targetNameImport; std::string targetOutPathPDB = - this->Convert(targetFullPathPDB.c_str(), + this->Convert(targetFullPathPDB, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); // Convert to the output path to use in constructing commands. std::string targetOutPath = - this->Convert(targetFullPath.c_str(), + this->Convert(targetFullPath, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathReal = - this->Convert(targetFullPathReal.c_str(), + this->Convert(targetFullPathReal, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathImport = - this->Convert(targetFullPathImport.c_str(), + this->Convert(targetFullPathImport, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); // Get the language to use for linking this executable. - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", - this->Target->GetName(), "\"."); + this->Target->GetName().c_str(), "\"."); return; } @@ -206,7 +210,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) export_flag_var += linkLanguage; export_flag_var += "_FLAG"; this->LocalGenerator->AppendFlags - (linkFlags, this->Makefile->GetDefinition(export_flag_var.c_str())); + (linkFlags, this->Makefile->GetDefinition(export_flag_var)); } // Add language feature flags. @@ -221,14 +225,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (linkFlags, this->Target->GetProperty(linkFlagsConfig.c_str())); + (linkFlags, this->Target->GetProperty(linkFlagsConfig)); this->AddModuleDefinitionFlag(linkFlags); // Construct a list of files associated with this executable that // may need to be cleaned. std::vector<std::string> exeCleanFiles; - exeCleanFiles.push_back(this->Convert(targetFullPath.c_str(), + exeCleanFiles.push_back(this->Convert(targetFullPath, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); #ifdef _WIN32 @@ -240,19 +244,19 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) #endif if(targetNameReal != targetName) { - exeCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(), + exeCleanFiles.push_back(this->Convert(targetFullPathReal, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } if(!targetNameImport.empty()) { - exeCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(), + exeCleanFiles.push_back(this->Convert(targetFullPathImport, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) { - exeCleanFiles.push_back(this->Convert(implib.c_str(), + exeCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } @@ -262,7 +266,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // cleaned. We do not want to delete the .pdb file just before // linking the target. this->CleanFiles.push_back - (this->Convert(targetFullPathPDB.c_str(), + (this->Convert(targetFullPathPDB, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); @@ -285,7 +289,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_LINK_EXECUTABLE"; - std::string linkRule = this->GetLinkRule(linkRuleVar.c_str()); + std::string linkRule = this->GetLinkRule(linkRuleVar); + bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); std::vector<std::string> commands1; cmSystemTools::ExpandListArgument(linkRule, real_link_commands); if(this->Target->IsExecutableWithExports()) @@ -296,21 +301,33 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) implibRuleVar += linkLanguage; implibRuleVar += "_CREATE_IMPORT_LIBRARY"; if(const char* rule = - this->Makefile->GetDefinition(implibRuleVar.c_str())) + this->Makefile->GetDefinition(implibRuleVar)) { cmSystemTools::ExpandListArgument(rule, real_link_commands); } } // Select whether to use a response file for objects. - bool useResponseFile = false; + bool useResponseFileForObjects = false; { std::string responseVar = "CMAKE_"; responseVar += linkLanguage; responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS"; - if(this->Makefile->IsOn(responseVar.c_str())) + if(this->Makefile->IsOn(responseVar)) { - useResponseFile = true; + useResponseFileForObjects = true; + } + } + + // Select whether to use a response file for libraries. + bool useResponseFileForLibs = false; + { + std::string responseVar = "CMAKE_"; + responseVar += linkLanguage; + responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES"; + if(this->Makefile->IsOn(responseVar)) + { + useResponseFileForLibs = true; } } @@ -321,25 +338,22 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Collect up flags to link in needed libraries. std::string linkLibs; - std::string frameworkPath; - std::string linkPath; - this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *this->GeneratorTarget, - relink); - linkLibs = frameworkPath + linkPath + linkLibs; + this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends); + // Construct object file lists that may be needed to expand the // rule. std::string buildObjs; - this->CreateObjectLists(useLinkScript, false, useResponseFile, - buildObjs, depends); + this->CreateObjectLists(useLinkScript, false, + useResponseFileForObjects, buildObjs, depends, + useWatcomQuote); cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.CMTarget = this->Target; - vars.Language = linkLanguage; + vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->Target->GetSupportDirectory(); - objectDir = this->Convert(objectDir.c_str(), + objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); @@ -425,7 +439,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Write the build rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - targetFullPathReal.c_str(), + targetFullPathReal, depends, commands, false); // The symlink name for the target should depend on the real target @@ -435,14 +449,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) { depends.clear(); commands.clear(); - depends.push_back(targetFullPathReal.c_str()); + depends.push_back(targetFullPathReal); this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - targetFullPath.c_str(), + targetFullPath, depends, commands, false); } // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(targetFullPath.c_str(), relink); + this->WriteTargetDriverRule(targetFullPath, relink); // Clean all the possible executable names and symlinks. this->CleanFiles.insert(this->CleanFiles.end(), diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index d6a0cd4..754f62f 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -131,17 +131,14 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } + linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") && - this->Makefile->GetDefinition((linkRuleVar+"_IPO").c_str())) + this->Makefile->GetDefinition(linkRuleVar+"_IPO")) { linkRuleVar += "_IPO"; } @@ -149,7 +146,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() std::string extraFlags; this->LocalGenerator->GetStaticLibraryFlags(extraFlags, cmSystemTools::UpperCase(this->ConfigName), this->Target); - this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false); + this->WriteLibraryRules(linkRuleVar, extraFlags, false); } //---------------------------------------------------------------------------- @@ -160,13 +157,10 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) this->WriteFrameworkRules(relink); return; } - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } + linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; std::string extraFlags; @@ -175,25 +169,22 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str())); + (extraFlags, this->Target->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName); this->AddModuleDefinitionFlag(extraFlags); - this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink); + this->WriteLibraryRules(linkRuleVar, extraFlags, relink); } //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } + linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; std::string extraFlags; @@ -202,24 +193,21 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str())); + (extraFlags, this->Target->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName); this->AddModuleDefinitionFlag(extraFlags); - this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink); + this->WriteLibraryRules(linkRuleVar, extraFlags, relink); } //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; - if (linkLanguage) - { - linkRuleVar += linkLanguage; - } + linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; std::string extraFlags; @@ -228,16 +216,16 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) std::string linkFlagsConfig = "LINK_FLAGS_"; linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName); this->LocalGenerator->AppendFlags - (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str())); + (extraFlags, this->Target->GetProperty(linkFlagsConfig)); this->LocalGenerator->AddConfigVariableFlags (extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName); - this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink); + this->WriteLibraryRules(linkRuleVar, extraFlags, relink); } //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteLibraryRules -(const char* linkRuleVar, const char* extraFlags, bool relink) +(const std::string& linkRuleVar, const std::string& extraFlags, bool relink) { // TODO: Merge the methods that call this method to avoid // code duplication. @@ -248,20 +236,20 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->AppendLinkDepends(depends); // Get the language to use for linking this library. - const char* linkLanguage = + std::string linkLanguage = this->Target->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error("Cannot determine link language for target \"", - this->Target->GetName(), "\"."); + this->Target->GetName().c_str(), "\"."); return; } // Create set of linking flags. std::string linkFlags; - this->LocalGenerator->AppendFlags(linkFlags, extraFlags); + this->LocalGenerator->AppendFlags(linkFlags, extraFlags.c_str()); // Add OSX version flags, if any. if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -321,7 +309,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } } - std::string pdbOutputPath = this->Target->GetPDBDirectory(); + std::string compilePdbOutputPath = + this->Target->GetCompilePDBDirectory(this->ConfigName); + cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); + + std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath.c_str()); pdbOutputPath += "/"; @@ -334,19 +326,19 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Construct the output path version of the names for use in command // arguments. std::string targetOutPathPDB = - this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE, + this->Convert(targetFullPathPDB,cmLocalGenerator::NONE, cmLocalGenerator::SHELL); std::string targetOutPath = - this->Convert(targetFullPath.c_str(),cmLocalGenerator::START_OUTPUT, + this->Convert(targetFullPath,cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathSO = - this->Convert(targetFullPathSO.c_str(),cmLocalGenerator::START_OUTPUT, + this->Convert(targetFullPathSO,cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathReal = - this->Convert(targetFullPathReal.c_str(),cmLocalGenerator::START_OUTPUT, + this->Convert(targetFullPathReal,cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); std::string targetOutPathImport = - this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT, + this->Convert(targetFullPathImport,cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); if(!this->NoRuleMessages) @@ -390,31 +382,31 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Clean files associated with this library. std::vector<std::string> libCleanFiles; - libCleanFiles.push_back(this->Convert(targetFullPath.c_str(), + libCleanFiles.push_back(this->Convert(targetFullPath, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); if(targetNameReal != targetName) { - libCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(), + libCleanFiles.push_back(this->Convert(targetFullPathReal, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } if(targetNameSO != targetName && targetNameSO != targetNameReal) { - libCleanFiles.push_back(this->Convert(targetFullPathSO.c_str(), + libCleanFiles.push_back(this->Convert(targetFullPathSO, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } if(!targetNameImport.empty()) { - libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(), + libCleanFiles.push_back(this->Convert(targetFullPathImport, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) { - libCleanFiles.push_back(this->Convert(implib.c_str(), + libCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } @@ -424,7 +416,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // cleaned. We do not want to delete the .pdb file just before // linking the target. this->CleanFiles.push_back - (this->Convert(targetFullPathPDB.c_str(), + (this->Convert(targetFullPathPDB, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); @@ -466,18 +458,32 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->Target); } + bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE"); + // Determine whether a link script will be used. bool useLinkScript = this->GlobalGenerator->GetUseLinkScript(); // Select whether to use a response file for objects. - bool useResponseFile = false; + bool useResponseFileForObjects = false; { std::string responseVar = "CMAKE_"; responseVar += linkLanguage; responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS"; - if(this->Makefile->IsOn(responseVar.c_str())) + if(this->Makefile->IsOn(responseVar)) { - useResponseFile = true; + useResponseFileForObjects = true; + } + } + + // Select whether to use a response file for libraries. + bool useResponseFileForLibs = false; + { + std::string responseVar = "CMAKE_"; + responseVar += linkLanguage; + responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES"; + if(this->Makefile->IsOn(responseVar)) + { + useResponseFileForLibs = true; } } @@ -494,21 +500,21 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string arCreateVar = "CMAKE_"; arCreateVar += linkLanguage; arCreateVar += "_ARCHIVE_CREATE"; - if(const char* rule = this->Makefile->GetDefinition(arCreateVar.c_str())) + if(const char* rule = this->Makefile->GetDefinition(arCreateVar)) { cmSystemTools::ExpandListArgument(rule, archiveCreateCommands); } std::string arAppendVar = "CMAKE_"; arAppendVar += linkLanguage; arAppendVar += "_ARCHIVE_APPEND"; - if(const char* rule = this->Makefile->GetDefinition(arAppendVar.c_str())) + if(const char* rule = this->Makefile->GetDefinition(arAppendVar)) { cmSystemTools::ExpandListArgument(rule, archiveAppendCommands); } std::string arFinishVar = "CMAKE_"; arFinishVar += linkLanguage; arFinishVar += "_ARCHIVE_FINISH"; - if(const char* rule = this->Makefile->GetDefinition(arFinishVar.c_str())) + if(const char* rule = this->Makefile->GetDefinition(arFinishVar)) { cmSystemTools::ExpandListArgument(rule, archiveFinishCommands); } @@ -524,7 +530,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules useLinkScript = true; // Archiving rules never use a response file. - useResponseFile = false; + useResponseFileForObjects = false; // Limit the length of individual object lists to less than the // 32K command line length limit on Windows. We could make this a @@ -542,19 +548,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string linkLibs; if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) { - std::string frameworkPath; - std::string linkPath; - this->LocalGenerator - ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, - *this->GeneratorTarget, relink); - linkLibs = frameworkPath + linkPath + linkLibs; + this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends); } // Construct object file lists that may be needed to expand the // rule. std::string buildObjs; - this->CreateObjectLists(useLinkScript, useArchiveRules, useResponseFile, - buildObjs, depends); + this->CreateObjectLists(useLinkScript, useArchiveRules, + useResponseFileForObjects, buildObjs, depends, + useWatcomQuote); cmLocalGenerator::RuleVariables vars; vars.TargetPDB = targetOutPathPDB.c_str(); @@ -578,10 +580,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.CMTarget = this->Target; - vars.Language = linkLanguage; + vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->Target->GetSupportDirectory(); - objectDir = this->Convert(objectDir.c_str(), + objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); @@ -612,7 +614,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Convert to a path for the native build tool. install_name_dir = - this->LocalGenerator->Convert(install_name_dir.c_str(), + this->LocalGenerator->Convert(install_name_dir, cmLocalGenerator::NONE, cmLocalGenerator::SHELL, false); vars.TargetInstallNameDir = install_name_dir.c_str(); @@ -746,7 +748,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Write the build rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - targetFullPathReal.c_str(), + targetFullPathReal, depends, commands, false); // Some targets have more than one output file. Create rules to @@ -765,7 +767,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } // Write the main driver rule to build everything in this target. - this->WriteTargetDriverRule(targetFullPath.c_str(), relink); + this->WriteTargetDriverRule(targetFullPath, relink); // Clean all the possible library names and symlinks. this->CleanFiles.insert(this->CleanFiles.end(), @@ -775,7 +777,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator -::AppendOSXVerFlag(std::string& flags, const char* lang, +::AppendOSXVerFlag(std::string& flags, const std::string& lang, const char* name, bool so) { // Lookup the flag to specify the version. @@ -784,7 +786,7 @@ cmMakefileLibraryTargetGenerator fvar += "_OSX_"; fvar += name; fvar += "_VERSION_FLAG"; - const char* flag = this->Makefile->GetDefinition(fvar.c_str()); + const char* flag = this->Makefile->GetDefinition(fvar); // Skip if no such flag. if(!flag) diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 1487b56..68980c3 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -30,7 +30,8 @@ protected: void WriteStaticLibraryRules(); void WriteSharedLibraryRules(bool relink); void WriteModuleLibraryRules(bool relink); - void WriteLibraryRules(const char *linkRule, const char *extraFlags, + void WriteLibraryRules(const std::string& linkRule, + const std::string& extraFlags, bool relink); // MacOSX Framework support methods void WriteFrameworkRules(bool relink); @@ -38,7 +39,7 @@ protected: // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; - void AppendOSXVerFlag(std::string& flags, const char* lang, + void AppendOSXVerFlag(std::string& flags, const std::string& lang, const char* name, bool so); }; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index c3ca85d..b3d3f71 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -21,6 +21,7 @@ #include "cmTarget.h" #include "cmake.h" #include "cmComputeLinkInformation.h" +#include "cmCustomCommandGenerator.h" #include "cmGeneratorExpression.h" #include "cmMakefileExecutableTargetGenerator.h" @@ -133,7 +134,8 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->Makefile->GetProperty ("ADDITIONAL_MAKE_CLEAN_FILES")) { - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = @@ -151,48 +153,50 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. - std::vector<cmSourceFile*> customCommands; + std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { - cmCustomCommand const* cc = (*si)->GetCustomCommand(); - this->GenerateCustomRuleFile(*cc); + cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(), + this->ConfigName, + this->Makefile); + this->GenerateCustomRuleFile(ccg); if (clean) { - const std::vector<std::string>& outputs = cc->GetOutputs(); + const std::vector<std::string>& outputs = ccg.GetOutputs(); for(std::vector<std::string>::const_iterator o = outputs.begin(); o != outputs.end(); ++o) { this->CleanFiles.push_back - (this->Convert(o->c_str(), + (this->Convert(*o, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); } } } - std::vector<cmSourceFile*> headerSources; + std::vector<cmSourceFile const*> headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector<cmSourceFile*> extraSources; + std::vector<cmSourceFile const*> extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector<cmSourceFile*> externalObjects; + std::vector<cmSourceFile const*> externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->ExternalObjects.push_back((*si)->GetFullPath()); } - std::vector<cmSourceFile*> objectSources; + std::vector<cmSourceFile const*> objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { // Generate this object file's rule file. @@ -215,7 +219,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() *this->BuildFileStream << "# Include any dependencies generated for this target.\n" << this->LocalGenerator->IncludeDirective << " " << root - << this->Convert(dependFileNameFull.c_str(), + << this->Convert(dependFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; @@ -226,7 +230,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() *this->BuildFileStream << "# Include the progress variables for this target.\n" << this->LocalGenerator->IncludeDirective << " " << root - << this->Convert(this->ProgressFileNameFull.c_str(), + << this->Convert(this->ProgressFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; @@ -259,7 +263,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() *this->BuildFileStream << "# Include the compile flags for this target's objects.\n" << this->LocalGenerator->IncludeDirective << " " << root - << this->Convert(this->FlagFileNameFull.c_str(), + << this->Convert(this->FlagFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; @@ -328,7 +332,7 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AddCompileDefinitions(defines, this->Target, - this->LocalGenerator->ConfigurationName.c_str()); + this->LocalGenerator->ConfigurationName); std::string definesString; this->LocalGenerator->JoinDefines(defines, definesString, lang); @@ -342,21 +346,21 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target - std::set<cmStdString> languages; + std::set<std::string> languages; this->Target->GetLanguages(languages); // put the compiler in the rules.make file so that if it changes // things rebuild - for(std::set<cmStdString>::const_iterator l = languages.begin(); + for(std::set<std::string>::const_iterator l = languages.begin(); l != languages.end(); ++l) { - cmStdString compiler = "CMAKE_"; + std::string compiler = "CMAKE_"; compiler += *l; compiler += "_COMPILER"; - *this->FlagFileStream << "# compile " << l->c_str() << " with " << - this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n"; + *this->FlagFileStream << "# compile " << *l << " with " << + this->Makefile->GetSafeDefinition(compiler) << "\n"; } - for(std::set<cmStdString>::const_iterator l = languages.begin(); + for(std::set<std::string>::const_iterator l = languages.begin(); l != languages.end(); ++l) { *this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n"; @@ -369,7 +373,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() - (cmSourceFile& source, const char* pkgloc) + (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. if(!this->Generator->GetTarget()->IsBundleOnApple()) @@ -388,9 +392,9 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() output += "/"; output += cmSystemTools::GetFilenameName(input); this->Generator->CleanFiles.push_back( - this->Generator->Convert(output.c_str(), + this->Generator->Convert(output, cmLocalGenerator::START_OUTPUT)); - output = this->Generator->Convert(output.c_str(), + output = this->Generator->Convert(output, cmLocalGenerator::HOME_OUTPUT); // Create a rule to copy the content into the bundle. @@ -403,27 +407,29 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() commands, copyEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild); std::string copyCommand = "$(CMAKE_COMMAND) -E copy "; - copyCommand += this->Generator->Convert(input.c_str(), + copyCommand += this->Generator->Convert(input, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); copyCommand += " "; - copyCommand += this->Generator->Convert(output.c_str(), + copyCommand += this->Generator->Convert(output, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); commands.push_back(copyCommand); this->Generator->LocalGenerator->WriteMakeRule( *this->Generator->BuildFileStream, 0, - output.c_str(), + output, depends, commands, false); this->Generator->ExtraFiles.insert(output); } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) +void cmMakefileTargetGenerator +::WriteObjectRuleFiles(cmSourceFile const& source) { // Identify the language of the source file. - const char* lang = this->LocalGenerator->GetSourceFileLanguage(source); - if(!lang) + const std::string& lang = + this->LocalGenerator->GetSourceFileLanguage(source); + if(lang.empty()) { // don't know anything about this file so skip it return; @@ -455,7 +461,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) // Create the directory containing the object file. This may be a // subdirectory under the target's directory. - std::string dir = cmSystemTools::GetFilenamePath(obj.c_str()); + std::string dir = cmSystemTools::GetFilenamePath(obj); cmSystemTools::MakeDirectory (this->LocalGenerator->ConvertToFullPath(dir).c_str()); @@ -481,9 +487,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) objFullPath += "/"; objFullPath += obj; objFullPath = - this->Convert(objFullPath.c_str(), cmLocalGenerator::FULL); + this->Convert(objFullPath, cmLocalGenerator::FULL); std::string srcFullPath = - this->Convert(source.GetFullPath().c_str(), cmLocalGenerator::FULL); + this->Convert(source.GetFullPath(), cmLocalGenerator::FULL); this->LocalGenerator-> AddImplicitDepends(*this->Target, lang, objFullPath.c_str(), @@ -493,7 +499,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) +::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source) { const char* srcfmt = source.GetProperty("Fortran_FORMAT"); cmLocalGenerator::FortranFormat format = @@ -523,8 +529,8 @@ cmMakefileTargetGenerator void cmMakefileTargetGenerator ::WriteObjectBuildFile(std::string &obj, - const char *lang, - cmSourceFile& source, + const std::string& lang, + cmSourceFile const& source, std::vector<std::string>& depends) { this->LocalGenerator->AppendRuleDepend(depends, @@ -552,7 +558,7 @@ cmMakefileTargetGenerator cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName); // Add Fortran format flags. - if(strcmp(lang, "Fortran") == 0) + if(lang == "Fortran") { this->AppendFortranFormatFlags(flags, source); } @@ -584,7 +590,7 @@ cmMakefileTargetGenerator std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += configUpper; if(const char* config_compile_defs = - source.GetProperty(defPropName.c_str())) + source.GetProperty(defPropName)) { this->LocalGenerator->AppendDefines(defines, config_compile_defs); *this->FlagFileStream @@ -598,10 +604,10 @@ cmMakefileTargetGenerator std::string sourceFile = source.GetFullPath(); if(this->LocalGenerator->UseRelativePaths) { - sourceFile = this->Convert(sourceFile.c_str(), + sourceFile = this->Convert(sourceFile, cmLocalGenerator::START_OUTPUT); } - sourceFile = this->Convert(sourceFile.c_str(), + sourceFile = this->Convert(sourceFile, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); @@ -624,9 +630,11 @@ cmMakefileTargetGenerator std::string targetOutPathReal; std::string targetOutPathPDB; + std::string targetOutPathCompilePDB; { std::string targetFullPathReal; std::string targetFullPathPDB; + std::string targetFullPathCompilePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE || this->Target->GetType() == cmTarget::STATIC_LIBRARY || this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -638,27 +646,42 @@ cmMakefileTargetGenerator targetFullPathPDB += "/"; targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); } - targetOutPathReal = this->Convert(targetFullPathReal.c_str(), + if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + { + targetFullPathCompilePDB = + this->Target->GetCompilePDBPath(this->ConfigName); + if(targetFullPathCompilePDB.empty()) + { + targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; + } + } + + targetOutPathReal = this->Convert(targetFullPathReal, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); targetOutPathPDB = - this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE, + this->Convert(targetFullPathPDB,cmLocalGenerator::NONE, + cmLocalGenerator::SHELL); + targetOutPathCompilePDB = + this->Convert(targetFullPathCompilePDB, + cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); } cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; vars.CMTarget = this->Target; - vars.Language = lang; + vars.Language = lang.c_str(); vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); + vars.TargetCompilePDB = targetOutPathCompilePDB.c_str(); vars.Source = sourceFile.c_str(); std::string shellObj = - this->Convert(obj.c_str(), + this->Convert(obj, cmLocalGenerator::NONE, - cmLocalGenerator::SHELL).c_str(); + cmLocalGenerator::SHELL); vars.Object = shellObj.c_str(); std::string objectDir = this->Target->GetSupportDirectory(); - objectDir = this->Convert(objectDir.c_str(), + objectDir = this->Convert(objectDir, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); @@ -672,8 +695,7 @@ cmMakefileTargetGenerator vars.Defines = definesString.c_str(); - bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) || - (strcmp(lang, "CXX") == 0)); + bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX")); // Construct the compile rules. { @@ -681,7 +703,7 @@ cmMakefileTargetGenerator compileRuleVar += lang; compileRuleVar += "_COMPILE_OBJECT"; std::string compileRule = - this->Makefile->GetRequiredDefinition(compileRuleVar.c_str()); + this->Makefile->GetRequiredDefinition(compileRuleVar); std::vector<std::string> compileCommands; cmSystemTools::ExpandListArgument(compileRule, compileCommands); @@ -720,7 +742,7 @@ cmMakefileTargetGenerator // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - relativeObj.c_str(), + relativeObj, depends, commands, false); // Check for extra outputs created by the compilation. @@ -738,7 +760,7 @@ cmMakefileTargetGenerator this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false); // Register this as an extra file to clean. - this->CleanFiles.push_back(eoi->c_str()); + this->CleanFiles.push_back(*eoi); } } @@ -774,15 +796,15 @@ cmMakefileTargetGenerator preprocessRuleVar += lang; preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE"; if(const char* preprocessRule = - this->Makefile->GetDefinition(preprocessRuleVar.c_str())) + this->Makefile->GetDefinition(preprocessRuleVar)) { std::vector<std::string> preprocessCommands; cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands); std::string shellObjI = - this->Convert(objI.c_str(), + this->Convert(objI, cmLocalGenerator::NONE, - cmLocalGenerator::SHELL).c_str(); + cmLocalGenerator::SHELL); vars.PreprocessedSource = shellObjI.c_str(); // Expand placeholders in the commands. @@ -808,7 +830,7 @@ cmMakefileTargetGenerator } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - relativeObjI.c_str(), + relativeObjI, force_depends, commands, false); } @@ -831,15 +853,15 @@ cmMakefileTargetGenerator assemblyRuleVar += lang; assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE"; if(const char* assemblyRule = - this->Makefile->GetDefinition(assemblyRuleVar.c_str())) + this->Makefile->GetDefinition(assemblyRuleVar)) { std::vector<std::string> assemblyCommands; cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands); std::string shellObjS = - this->Convert(objS.c_str(), + this->Convert(objS, cmLocalGenerator::NONE, - cmLocalGenerator::SHELL).c_str(); + cmLocalGenerator::SHELL); vars.AssemblySource = shellObjS.c_str(); // Expand placeholders in the commands. @@ -865,7 +887,7 @@ cmMakefileTargetGenerator } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - relativeObjS.c_str(), + relativeObjS, force_depends, commands, false); } } @@ -877,7 +899,7 @@ cmMakefileTargetGenerator std::vector<std::string> p_depends; // always provide an empty requires target this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - objectRequires.c_str(), p_depends, + objectRequires, p_depends, no_commands, true); // write a build rule to recursively build what this obj provides @@ -891,19 +913,19 @@ cmMakefileTargetGenerator tgtMakefileName += "/build.make"; r_commands.push_back (this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(), - temp.c_str())); + temp)); p_depends.clear(); p_depends.push_back(objectRequires); this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - objectProvides.c_str(), p_depends, + objectProvides, p_depends, r_commands, true); // write the provides.build rule dependency on the obj file p_depends.clear(); p_depends.push_back(relativeObj); this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - temp.c_str(), p_depends, no_commands, + temp, p_depends, no_commands, false); } @@ -932,7 +954,7 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules() // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - depTarget.c_str(), + depTarget, depends, no_commands, true); } @@ -957,7 +979,7 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules() // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - cleanTarget.c_str(), + cleanTarget, depends, commands, true); } @@ -993,8 +1015,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() pi != this->MultipleOutputPairs.end(); ++pi) { *this->InfoFileStream - << " " << this->LocalGenerator->EscapeForCMake(pi->first.c_str()) - << " " << this->LocalGenerator->EscapeForCMake(pi->second.c_str()) + << " " << this->LocalGenerator->EscapeForCMake(pi->first) + << " " << this->LocalGenerator->EscapeForCMake(pi->second) << "\n"; } *this->InfoFileStream << " )\n\n"; @@ -1053,7 +1075,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << "set(CMAKE_C_TARGET_INCLUDE_PATH\n"; std::vector<std::string> includes; - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", config); @@ -1062,7 +1085,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() { *this->InfoFileStream << " \"" - << this->LocalGenerator->Convert(i->c_str(), + << this->LocalGenerator->Convert(*i, cmLocalGenerator::HOME_OUTPUT) << "\"\n"; } @@ -1126,7 +1149,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << this->Convert(this->Makefile->GetStartOutputDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " - << this->Convert(this->InfoFileNameFull.c_str(), + << this->Convert(this->InfoFileNameFull, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); if(this->LocalGenerator->GetColorMakefile()) { @@ -1142,7 +1165,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - depTarget.c_str(), + depTarget, depends, commands, true); } @@ -1159,7 +1182,8 @@ cmMakefileTargetGenerator { if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { - const std::vector<std::string>& outputs = cc->GetOutputs(); + cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile); + const std::vector<std::string>& outputs = ccg.GetOutputs(); for(std::vector<std::string>::const_iterator o = outputs.begin(); o != outputs.end(); ++o) { @@ -1171,7 +1195,7 @@ cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::WriteObjectDependRules(cmSourceFile& source, +::WriteObjectDependRules(cmSourceFile const& source, std::vector<std::string>& depends) { // Create the list of dependencies known at cmake time. These are @@ -1184,18 +1208,18 @@ void cmMakefileTargetGenerator for(std::vector<std::string>::iterator i = deps.begin(); i != deps.end(); ++i) { - depends.push_back(i->c_str()); + depends.push_back(*i); } } } //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::GenerateCustomRuleFile(const cmCustomCommand& cc) +::GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg) { // Collect the commands. std::vector<std::string> commands; - std::string comment = this->LocalGenerator->ConstructComment(cc); + std::string comment = this->LocalGenerator->ConstructComment(ccg); if(!comment.empty()) { // add in a progress call if needed @@ -1210,37 +1234,37 @@ void cmMakefileTargetGenerator // Now append the actual user-specified commands. cmOStringStream content; - this->LocalGenerator->AppendCustomCommand(commands, cc, this->Target, false, + this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false, cmLocalGenerator::HOME_OUTPUT, &content); // Collect the dependencies. std::vector<std::string> depends; - this->LocalGenerator->AppendCustomDepend(depends, cc); + this->LocalGenerator->AppendCustomDepend(depends, ccg); // Check whether we need to bother checking for a symbolic output. bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark(); // Write the rule. - const std::vector<std::string>& outputs = cc.GetOutputs(); + const std::vector<std::string>& outputs = ccg.GetOutputs(); std::vector<std::string>::const_iterator o = outputs.begin(); { bool symbolic = false; if(need_symbolic) { - if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str())) + if(cmSourceFile* sf = this->Makefile->GetSource(*o)) { symbolic = sf->GetPropertyAsBool("SYMBOLIC"); } } this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, - o->c_str(), depends, commands, + *o, depends, commands, symbolic); // If the rule has changed make sure the output is rebuilt. if(!symbolic) { - this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), content.str()); + this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str()); } } @@ -1251,7 +1275,7 @@ void cmMakefileTargetGenerator bool symbolic = false; if(need_symbolic) { - if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str())) + if(cmSourceFile* sf = this->Makefile->GetSource(*o)) { symbolic = sf->GetPropertyAsBool("SYMBOLIC"); } @@ -1261,15 +1285,15 @@ void cmMakefileTargetGenerator // Setup implicit dependency scanning. for(cmCustomCommand::ImplicitDependsList::const_iterator - idi = cc.GetImplicitDepends().begin(); - idi != cc.GetImplicitDepends().end(); ++idi) + idi = ccg.GetCC().GetImplicitDepends().begin(); + idi != ccg.GetCC().GetImplicitDepends().end(); ++idi) { std::string objFullPath = - this->Convert(outputs[0].c_str(), cmLocalGenerator::FULL); + this->Convert(outputs[0], cmLocalGenerator::FULL); std::string srcFullPath = - this->Convert(idi->second.c_str(), cmLocalGenerator::FULL); + this->Convert(idi->second, cmLocalGenerator::FULL); this->LocalGenerator-> - AddImplicitDepends(*this->Target, idi->first.c_str(), + AddImplicitDepends(*this->Target, idi->first, objFullPath.c_str(), srcFullPath.c_str()); } @@ -1314,7 +1338,7 @@ cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands) progressDir += cmake::GetCMakeFilesDirectory(); cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; - progCmd << this->LocalGenerator->Convert(progressDir.c_str(), + progCmd << this->LocalGenerator->Convert(progressDir, cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " $(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")"; @@ -1325,7 +1349,8 @@ cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands) void cmMakefileTargetGenerator ::WriteObjectsVariable(std::string& variableName, - std::string& variableNameExternal) + std::string& variableNameExternal, + bool useWatcomQuote) { // Write a make variable assignment that lists all objects for the // target. @@ -1334,10 +1359,8 @@ cmMakefileTargetGenerator "_OBJECTS"); *this->BuildFileStream << "# Object files for target " << this->Target->GetName() << "\n" - << variableName.c_str() << " ="; + << variableName << " ="; std::string object; - const char* objName = - this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS"); const char* lineContinue = this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE"); if(!lineContinue) @@ -1348,17 +1371,9 @@ cmMakefileTargetGenerator i != this->Objects.end(); ++i) { *this->BuildFileStream << " " << lineContinue << "\n"; - if(objName) - { - *this->BuildFileStream << - this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::MAKEFILE); - } - else - { - *this->BuildFileStream << - this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str()); - } + *this->BuildFileStream << + this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(), + useWatcomQuote); } *this->BuildFileStream << "\n"; @@ -1371,26 +1386,18 @@ cmMakefileTargetGenerator << "\n" << "# External object files for target " << this->Target->GetName() << "\n" - << variableNameExternal.c_str() << " ="; + << variableNameExternal << " ="; for(std::vector<std::string>::const_iterator i = this->ExternalObjects.begin(); i != this->ExternalObjects.end(); ++i) { - object = this->Convert(i->c_str(),cmLocalGenerator::START_OUTPUT); + object = this->Convert(*i,cmLocalGenerator::START_OUTPUT); *this->BuildFileStream << " " << lineContinue << "\n" << this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME"); - if(objName) - { - *this->BuildFileStream << - this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::MAKEFILE); - } - else - { - *this->BuildFileStream << - this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str()); - } + *this->BuildFileStream << + this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(), + useWatcomQuote); } *this->BuildFileStream << "\n" << "\n"; } @@ -1420,7 +1427,7 @@ public: { // Construct the name of the next object. this->NextObject = - this->LocalGenerator->Convert(obj.c_str(), + this->LocalGenerator->Convert(obj, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::RESPONSE); @@ -1477,24 +1484,22 @@ cmMakefileTargetGenerator } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, - bool relink) +void cmMakefileTargetGenerator::WriteTargetDriverRule( + const std::string& main_output, + bool relink) { // Compute the name of the driver target. std::string dir = this->LocalGenerator->GetRelativeTargetDirectory(*this->Target); std::string buildTargetRuleName = dir; buildTargetRuleName += relink?"/preinstall":"/build"; - buildTargetRuleName = this->Convert(buildTargetRuleName.c_str(), + buildTargetRuleName = this->Convert(buildTargetRuleName, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::UNCHANGED); // Build the list of target outputs to drive. std::vector<std::string> depends; - if(main_output) - { - depends.push_back(main_output); - } + depends.push_back(main_output); const char* comment = 0; if(relink) @@ -1514,7 +1519,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, } // Make sure the extra files are built. - for(std::set<cmStdString>::const_iterator i = this->ExtraFiles.begin(); + for(std::set<std::string>::const_iterator i = this->ExtraFiles.begin(); i != this->ExtraFiles.end(); ++i) { depends.push_back(*i); @@ -1524,7 +1529,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, // Write the driver rule. std::vector<std::string> no_commands; this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment, - buildTargetRuleName.c_str(), + buildTargetRuleName, depends, no_commands, true); } @@ -1538,19 +1543,20 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG"; const char* fwSearchFlag = - this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + this->Makefile->GetDefinition(fwSearchFlagVar); if(!(fwSearchFlag && *fwSearchFlag)) { return std::string(); } - std::set<cmStdString> emitted; + std::set<std::string> emitted; #ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */ emitted.insert("/System/Library/Frameworks"); #endif std::vector<std::string> includes; - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", config); @@ -1559,7 +1565,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) { - if(this->Target->NameResolvesToFramework(i->c_str())) + if(this->Target->NameResolvesToFramework(*i)) { std::string frameworkDir = *i; frameworkDir += "/../"; @@ -1579,7 +1585,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) if(emitted.insert(*i).second) { flags += fwSearchFlag; - flags += this->Convert(i->c_str(), + flags += this->Convert(*i, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL, true); flags += " "; @@ -1650,9 +1656,10 @@ void cmMakefileTargetGenerator this->AppendTargetDepends(depends); // Add a dependency on the link definitions file, if any. - if(!this->GeneratorTarget->ModuleDefinitionFile.empty()) + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + if(!def.empty()) { - depends.push_back(this->GeneratorTarget->ModuleDefinitionFile); + depends.push_back(def); } // Add user-specified dependencies. @@ -1664,7 +1671,8 @@ void cmMakefileTargetGenerator } //---------------------------------------------------------------------------- -std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar) +std::string cmMakefileTargetGenerator::GetLinkRule( + const std::string& linkRuleVar) { std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); if(this->Target->HasImplibGNUtoMS()) @@ -1672,7 +1680,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar) std::string ruleVar = "CMAKE_"; ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; - if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str())) + if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { linkRule += rule; } @@ -1690,8 +1698,8 @@ void cmMakefileTargetGenerator } void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, - const char* linkLang, - std::string& linkFlags) + const std::string& linkLang, + std::string& linkFlags) { // check for language flags that are not allowed at link time, and // remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool @@ -1701,7 +1709,7 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, removeFlags += linkLang; removeFlags += flagVar; std::string removeflags = - this->Makefile->GetSafeDefinition(removeFlags.c_str()); + this->Makefile->GetSafeDefinition(removeFlags); std::vector<std::string> removeList; cmSystemTools::ExpandListArgument(removeflags, removeList); @@ -1779,7 +1787,7 @@ cmMakefileTargetGenerator // Create the makefile command to invoke the link script. std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script "; - link_command += this->Convert(linkScriptName.c_str(), + link_command += this->Convert(linkScriptName, cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); link_command += " --verbose=$(VERBOSE)"; @@ -1815,13 +1823,55 @@ cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator +::CreateLinkLibs(std::string& linkLibs, bool relink, + bool useResponseFile, + std::vector<std::string>& makefile_depends) +{ + std::string frameworkPath; + std::string linkPath; + this->LocalGenerator + ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath, + *this->GeneratorTarget, relink, + useResponseFile); + linkLibs = frameworkPath + linkPath + linkLibs; + + if(useResponseFile) + { + // Lookup the response file reference flag. + std::string responseFlagVar = "CMAKE_"; + responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; + const char* responseFlag = + this->Makefile->GetDefinition(responseFlagVar); + if(!responseFlag) + { + responseFlag = "@"; + } + + // Create this response file. + std::string link_rsp = + this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends); + + // Reference the response file. + linkLibs = responseFlag; + linkLibs += this->Convert(link_rsp, + cmLocalGenerator::NONE, + cmLocalGenerator::SHELL); + } +} + +//---------------------------------------------------------------------------- +void +cmMakefileTargetGenerator ::CreateObjectLists(bool useLinkScript, bool useArchiveRules, bool useResponseFile, std::string& buildObjs, - std::vector<std::string>& makefile_depends) + std::vector<std::string>& makefile_depends, + bool useWatcomQuote) { std::string variableName; std::string variableNameExternal; - this->WriteObjectsVariable(variableName, variableNameExternal); + this->WriteObjectsVariable(variableName, variableNameExternal, + useWatcomQuote); if(useResponseFile) { // MSVC response files cannot exceed 128K. @@ -1836,7 +1886,7 @@ cmMakefileTargetGenerator responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = - this->Makefile->GetDefinition(responseFlagVar.c_str()); + this->Makefile->GetDefinition(responseFlagVar); if(!responseFlag) { responseFlag = "@"; @@ -1860,7 +1910,7 @@ cmMakefileTargetGenerator // Reference the response file. buildObjs += responseFlag; - buildObjs += this->Convert(objects_rsp.c_str(), + buildObjs += this->Convert(objects_rsp, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); } @@ -1884,16 +1934,17 @@ cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, - const char* lang) + const std::string& lang) { std::string responseVar = "CMAKE_"; responseVar += lang; responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES"; - bool useResponseFile = this->Makefile->IsOn(responseVar.c_str()); + bool useResponseFile = this->Makefile->IsOn(responseVar); std::vector<std::string> includes; - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, lang, config); @@ -2000,7 +2051,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) { std::vector<std::string> includes; - const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + const std::string& config = + this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, "C", config); @@ -2008,7 +2060,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) idi != includes.end(); ++idi) { std::string flg = modpath_flag; - flg += this->Convert(idi->c_str(), + flg += this->Convert(*idi, cmLocalGenerator::NONE, cmLocalGenerator::SHELL); this->LocalGenerator->AppendFlags(flags, flg.c_str()); @@ -2019,7 +2071,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) { - if(this->GeneratorTarget->ModuleDefinitionFile.empty()) + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + if(def.empty()) { return; } @@ -2035,26 +2088,25 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) // Append the flag and value. Use ConvertToLinkReference to help // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; - flag += (this->LocalGenerator->ConvertToLinkReference( - this->GeneratorTarget->ModuleDefinitionFile.c_str())); + flag += (this->LocalGenerator->ConvertToLinkReference(def)); this->LocalGenerator->AppendFlags(flags, flag.c_str()); } //---------------------------------------------------------------------------- -const char* cmMakefileTargetGenerator::GetFeature(const char* feature) +const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature) { return this->Target->GetFeature(feature, this->ConfigName); } //---------------------------------------------------------------------------- -bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature) +bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature) { return cmSystemTools::IsOn(this->GetFeature(feature)); } //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::AddFeatureFlags( - std::string& flags, const char* lang + std::string& flags, const std::string& lang ) { // Add language-specific flags. diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 4f8fafa..ff94660 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -15,7 +15,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmOSXBundleGenerator.h" -class cmCustomCommand; +class cmCustomCommandGenerator; class cmDependInformation; class cmDepends; class cmGeneratorTarget; @@ -81,7 +81,7 @@ protected: MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen) : Generator(gen) {} - void operator()(cmSourceFile& source, const char* pkgloc); + void operator()(cmSourceFile const& source, const char* pkgloc); private: cmMakefileTargetGenerator* Generator; @@ -89,20 +89,20 @@ protected: friend struct MacOSXContentGeneratorType; // write the rules for an object - void WriteObjectRuleFiles(cmSourceFile& source); + void WriteObjectRuleFiles(cmSourceFile const& source); // write the build rule for an object void WriteObjectBuildFile(std::string &obj, - const char *lang, - cmSourceFile& source, + const std::string& lang, + cmSourceFile const& source, std::vector<std::string>& depends); // write the depend.make file for an object - void WriteObjectDependRules(cmSourceFile& source, + void WriteObjectDependRules(cmSourceFile const& source, std::vector<std::string>& depends); // write the build rule for a custom command - void GenerateCustomRuleFile(const cmCustomCommand& cc); + void GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg); // write a rule to drive building of more than one output from // another rule @@ -113,20 +113,22 @@ protected: // write out the variable that lists the objects for this target void WriteObjectsVariable(std::string& variableName, - std::string& variableNameExternal); + std::string& variableNameExternal, + bool useWatcomQuote); void WriteObjectsString(std::string& buildObjs); void WriteObjectsStrings(std::vector<std::string>& objStrings, std::string::size_type limit = std::string::npos); // write the driver rule to build target outputs - void WriteTargetDriverRule(const char* main_output, bool relink); + void WriteTargetDriverRule(const std::string& main_output, bool relink); void DriveCustomCommands(std::vector<std::string>& depends); // Return the a string with -F flags on apple std::string GetFrameworkFlags(std::string const& l); - void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); + void AppendFortranFormatFlags(std::string& flags, + cmSourceFile const& source); // append intertarget dependencies void AppendTargetDepends(std::vector<std::string>& depends); @@ -138,7 +140,7 @@ protected: void AppendLinkDepends(std::vector<std::string>& depends); // Lookup the link rule for this target. - std::string GetLinkRule(const char* linkRuleVar); + std::string GetLinkRule(const std::string& linkRuleVar); /** In order to support parallel builds for custom commands with multiple outputs the outputs are given a serial order, and only @@ -163,22 +165,28 @@ protected: std::string const& options, std::vector<std::string>& makefile_depends); + /** Create list of flags for link libraries. */ + void CreateLinkLibs(std::string& linkLibs, bool relink, + bool useResponseFile, + std::vector<std::string>& makefile_depends); + /** Create lists of object files for linking and cleaning. */ void CreateObjectLists(bool useLinkScript, bool useArchiveRules, bool useResponseFile, std::string& buildObjs, - std::vector<std::string>& makefile_depends); + std::vector<std::string>& makefile_depends, + bool useWatcomQuote); - void AddIncludeFlags(std::string& flags, const char* lang); + void AddIncludeFlags(std::string& flags, const std::string& lang); virtual void CloseFileStreams(); - void RemoveForbiddenFlags(const char* flagVar, const char* linkLang, + void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang, std::string& linkFlags); cmTarget *Target; cmGeneratorTarget* GeneratorTarget; cmLocalUnixMakefileGenerator3 *LocalGenerator; cmGlobalUnixMakefileGenerator3 *GlobalGenerator; cmMakefile *Makefile; - const char *ConfigName; + std::string ConfigName; enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility }; CustomCommandDriveType CustomCommandDriver; @@ -203,7 +211,7 @@ protected: std::string FlagFileNameFull; cmGeneratedFileStream *FlagFileStream; class StringList: public std::vector<std::string> {}; - std::map<cmStdString, StringList> FlagFileDepends; + std::map<std::string, StringList> FlagFileDepends; // the stream for the info file std::string InfoFileNameFull; @@ -217,12 +225,12 @@ protected: std::vector<std::string> ExternalObjects; // Set of object file names that will be built in this directory. - std::set<cmStdString> ObjectFiles; + std::set<std::string> ObjectFiles; // Set of extra output files to be driven by the build. - std::set<cmStdString> ExtraFiles; + std::set<std::string> ExtraFiles; - typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType; + typedef std::map<std::string, std::string> MultipleOutputPairsType; MultipleOutputPairsType MultipleOutputPairs; // Target name info. @@ -233,11 +241,11 @@ protected: std::string TargetNamePDB; // Mac OS X content info. - std::set<cmStdString> MacContentFolders; + std::set<std::string> MacContentFolders; cmOSXBundleGenerator* OSXBundleGenerator; MacOSXContentGeneratorType* MacOSXContentGenerator; - typedef std::map<cmStdString, cmStdString> ByLanguageMap; + typedef std::map<std::string, std::string> ByLanguageMap; std::string GetFlags(const std::string &l); ByLanguageMap FlagsByLanguage; std::string GetDefines(const std::string &l); @@ -255,16 +263,16 @@ protected: void AddModuleDefinitionFlag(std::string& flags); // Add language feature flags. - void AddFeatureFlags(std::string& flags, const char* lang); + void AddFeatureFlags(std::string& flags, const std::string& lang); // Feature query methods. - const char* GetFeature(const char* feature); - bool GetFeatureAsBool(const char* feature); + const char* GetFeature(const std::string& feature); + bool GetFeatureAsBool(const std::string& feature); //================================================================== // Convenience routines that do nothing more than forward to // implementaitons - std::string Convert(const char* source, + std::string Convert(const std::string& source, cmLocalGenerator::RelativeRoot relative, cmLocalGenerator::OutputFormat output = cmLocalGenerator::UNCHANGED, diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 7751ad9..6b039bb 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -52,7 +52,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() *this->BuildFileStream << "# Include the progress variables for this target.\n" << this->LocalGenerator->IncludeDirective << " " << root - << this->Convert(this->ProgressFileNameFull.c_str(), + << this->Convert(this->ProgressFileNameFull, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) << "\n\n"; diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index 4236d10..f6a2c26 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -42,11 +42,11 @@ bool cmMarkAsAdvancedCommand if ( it.IsAtEnd() ) { this->Makefile->GetCacheManager() - ->AddCacheEntry(variable.c_str(), 0, 0, + ->AddCacheEntry(variable, 0, 0, cmCacheManager::UNINITIALIZED); overwrite = true; } - it.Find(variable.c_str()); + it.Find(variable); if ( it.IsAtEnd() ) { cmSystemTools::Error("This should never happen..."); diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h index b65e4a8..38064a3 100644 --- a/Source/cmMarkAsAdvancedCommand.h +++ b/Source/cmMarkAsAdvancedCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "mark_as_advanced";} + virtual std::string GetName() const {return "mark_as_advanced";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx index 9fc4265..f1942c5 100644 --- a/Source/cmMathCommand.cxx +++ b/Source/cmMathCommand.cxx @@ -28,7 +28,7 @@ bool cmMathCommand return this->HandleExprCommand(args); } std::string e = "does not recognize sub-command "+subCommand; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -49,13 +49,13 @@ bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args) { std::string e = "cannot parse the expression: \""+expression+"\": "; e += helper.GetError(); - this->SetError(e.c_str()); + this->SetError(e); return false; } char buffer[1024]; sprintf(buffer, "%d", helper.GetResult()); - this->Makefile->AddDefinition(outputVariable.c_str(), buffer); + this->Makefile->AddDefinition(outputVariable, buffer); return true; } diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h index c826ef1..76dc102 100644 --- a/Source/cmMathCommand.h +++ b/Source/cmMathCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "math";} + virtual std::string GetName() const { return "math";} cmTypeMacro(cmMathCommand, cmCommand); protected: diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index d85e720..88d6a77 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -77,7 +77,7 @@ bool cmMessageCommand if (type != cmake::MESSAGE) { - this->Makefile->IssueMessage(type, message.c_str()); + this->Makefile->IssueMessage(type, message); } else { diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h index fec9a32..c0ae2a3 100644 --- a/Source/cmMessageCommand.h +++ b/Source/cmMessageCommand.h @@ -39,7 +39,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "message";} + virtual std::string GetName() const { return "message";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 73ba815..2d1bc76 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmOSXBundleGenerator.h" #include "cmGeneratorTarget.h" +#include "cmCustomCommandGenerator.h" #include <assert.h> #include <algorithm> @@ -35,7 +36,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNameReal() , TargetNameImport() , TargetNamePDB() - , TargetLinkLanguage(0) + , TargetLinkLanguage("") { this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); @@ -72,10 +73,10 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() void cmNinjaNormalTargetGenerator::Generate() { - if (!this->TargetLinkLanguage) { + if (this->TargetLinkLanguage.empty()) { cmSystemTools::Error("CMake can not determine linker language for " "target: ", - this->GetTarget()->GetName()); + this->GetTarget()->GetName().c_str()); return; } @@ -109,9 +110,9 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() << "\n\n"; #endif - std::set<cmStdString> languages; + std::set<std::string> languages; this->GetTarget()->GetLanguages(languages); - for(std::set<cmStdString>::const_iterator l = languages.begin(); + for(std::set<std::string>::const_iterator l = languages.begin(); l != languages.end(); ++l) this->WriteLanguageRules(*l); @@ -140,7 +141,7 @@ std::string cmNinjaNormalTargetGenerator ::LanguageLinkerRule() const { - return std::string(this->TargetLinkLanguage) + return this->TargetLinkLanguage + "_" + cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) + "_LINKER"; @@ -163,7 +164,7 @@ cmNinjaNormalTargetGenerator cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.CMTarget = this->GetTarget(); - vars.Language = this->TargetLinkLanguage; + vars.Language = this->TargetLinkLanguage.c_str(); std::string responseFlag; if (!useResponseFile) { @@ -175,7 +176,7 @@ cmNinjaNormalTargetGenerator // build response file name std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG"; - const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar.c_str()); + const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar); if(flag) { responseFlag = flag; } else { @@ -189,7 +190,7 @@ cmNinjaNormalTargetGenerator linkOptionVar += "_COMPILER_LINKER_OPTION_FLAG_"; linkOptionVar += cmTarget::GetTargetTypeName(targetType); const std::string linkOption = - GetMakefile()->GetSafeDefinition(linkOptionVar.c_str()); + GetMakefile()->GetSafeDefinition(linkOptionVar); rspcontent = "$in_newline "+linkOption+" $LINK_PATH $LINK_LIBRARIES"; vars.Objects = responseFlag.c_str(); vars.LinkLibraries = ""; @@ -321,7 +322,7 @@ cmNinjaNormalTargetGenerator linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_CREATE_STATIC_LIBRARY"; if (const char *linkCmd = - this->GetMakefile()->GetDefinition(linkCmdVar.c_str())) + this->GetMakefile()->GetDefinition(linkCmdVar)) { cmSystemTools::ExpandListArgument(linkCmd, linkCmds); return linkCmds; @@ -341,7 +342,7 @@ cmNinjaNormalTargetGenerator linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_ARCHIVE_CREATE"; const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + this->GetMakefile()->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); } { @@ -349,7 +350,7 @@ cmNinjaNormalTargetGenerator linkCmdVar += this->TargetLinkLanguage; linkCmdVar += "_ARCHIVE_FINISH"; const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + this->GetMakefile()->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); } return linkCmds; @@ -374,7 +375,7 @@ cmNinjaNormalTargetGenerator } const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + this->GetMakefile()->GetRequiredDefinition(linkCmdVar); cmSystemTools::ExpandListArgument(linkCmd, linkCmds); return linkCmds; } @@ -497,7 +498,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (!install_name_dir.empty()) { vars["INSTALLNAME_DIR"] = - this->GetLocalGenerator()->Convert(install_name_dir.c_str(), + this->GetLocalGenerator()->Convert(install_name_dir, cmLocalGenerator::NONE, cmLocalGenerator::SHELL, false); } @@ -506,7 +507,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (!this->TargetNameImport.empty()) { const std::string impLibPath = this->GetLocalGenerator() - ->ConvertToOutputFormat(targetOutputImplib.c_str(), + ->ConvertToOutputFormat(targetOutputImplib, cmLocalGenerator::SHELL); vars["TARGET_IMPLIB"] = impLibPath; EnsureParentDirectoryExists(impLibPath); @@ -555,7 +556,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() for (std::vector<cmCustomCommand>::const_iterator ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { - this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, + cmCustomCommandGenerator ccg(*ci, this->GetConfigName(), + this->GetMakefile()); + this->GetLocalGenerator()->AppendCustomCommandLines(ccg, *cmdLineLists[i]); } } @@ -591,7 +594,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmSystemTools::GetEnv(forceRspFile) == 0) { #ifdef _WIN32 commandLineLengthLimit = 8000 - linkRuleLength; -#elif defined(__linux) || defined(__APPLE__) +#elif defined(__linux) || defined(__APPLE__) || defined(__HAIKU__) // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))-linkRuleLength-1000; #else diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index c7a089c..556ed5e 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -47,7 +47,7 @@ private: std::string TargetNameReal; std::string TargetNameImport; std::string TargetNamePDB; - const char *TargetLinkLanguage; + std::string TargetLinkLanguage; }; #endif // ! cmNinjaNormalTargetGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 900af8d..8865b3d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -91,26 +91,26 @@ cmGlobalNinjaGenerator* cmNinjaTargetGenerator::GetGlobalGenerator() const return this->LocalGenerator->GetGlobalNinjaGenerator(); } -const char* cmNinjaTargetGenerator::GetConfigName() const +std::string const& cmNinjaTargetGenerator::GetConfigName() const { return this->LocalGenerator->GetConfigName(); } // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -const char* cmNinjaTargetGenerator::GetFeature(const char* feature) +const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature) { return this->Target->GetFeature(feature, this->GetConfigName()); } // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature) +bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature) { return cmSystemTools::IsOn(this->GetFeature(feature)); } // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, - const char* lang) + const std::string& lang) { // Add language-specific flags. this->LocalGenerator->AddLanguageFlags(flags, lang, this->GetConfigName()); @@ -126,7 +126,7 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, // void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Refactor it. std::string -cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, +cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, const std::string& language) { // TODO: Fortran support. @@ -140,11 +140,11 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, std::string& languageFlags = this->LanguageFlags[language]; if(!hasLangCached) { - this->AddFeatureFlags(languageFlags, language.c_str()); + this->AddFeatureFlags(languageFlags, language); this->GetLocalGenerator()->AddArchitectureFlags(languageFlags, this->GeneratorTarget, - language.c_str(), + language, this->GetConfigName()); // Add shared-library flags if needed. @@ -153,17 +153,17 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, this->GetConfigName()); this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target, - language.c_str()); + language); std::vector<std::string> includes; this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, - language.c_str(), + language, this->GetConfigName()); // Add include directory flags. std::string includeFlags = this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget, - language.c_str(), + language, language == "RC" ? true : false); // full include paths for RC // needed by cmcldeps if(cmGlobalNinjaGenerator::IsMinGW()) @@ -177,7 +177,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, // Add target-specific flags. this->LocalGenerator->AddCompileOptions(languageFlags, this->Target, - language.c_str(), + language, this->GetConfigName()); } @@ -211,7 +211,7 @@ bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang) // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string cmNinjaTargetGenerator:: -ComputeDefines(cmSourceFile *source, const std::string& language) +ComputeDefines(cmSourceFile const* source, const std::string& language) { std::set<std::string> defines; @@ -232,12 +232,12 @@ ComputeDefines(cmSourceFile *source, const std::string& language) defPropName += cmSystemTools::UpperCase(this->GetConfigName()); this->LocalGenerator->AppendDefines (defines, - source->GetProperty(defPropName.c_str())); + source->GetProperty(defPropName)); } std::string definesString; this->LocalGenerator->JoinDefines(defines, definesString, - language.c_str()); + language); return definesString; } @@ -269,14 +269,14 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const std::string cmNinjaTargetGenerator -::GetSourceFilePath(cmSourceFile* source) const +::GetSourceFilePath(cmSourceFile const* source) const { return ConvertToNinjaPath(source->GetFullPath().c_str()); } std::string cmNinjaTargetGenerator -::GetObjectFilePath(cmSourceFile* source) const +::GetObjectFilePath(cmSourceFile const* source) const { std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); if(!path.empty()) @@ -320,6 +320,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID")) { std::string pdbPath; + std::string compilePdbPath; if(this->Target->GetType() == cmTarget::EXECUTABLE || this->Target->GetType() == cmTarget::STATIC_LIBRARY || this->Target->GetType() == cmTarget::SHARED_LIBRARY || @@ -329,11 +330,25 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const pdbPath += "/"; pdbPath += this->Target->GetPDBName(this->GetConfigName()); } + if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) + { + compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + if(compilePdbPath.empty()) + { + compilePdbPath = this->Target->GetSupportDirectory() + "/"; + } + } vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(pdbPath.c_str()).c_str(), + ConvertToNinjaPath(pdbPath.c_str()), cmLocalGenerator::SHELL); + vars["TARGET_COMPILE_PDB"] = + this->GetLocalGenerator()->ConvertToOutputFormat( + ConvertToNinjaPath(compilePdbPath.c_str()), + cmLocalGenerator::SHELL); + EnsureParentDirectoryExists(pdbPath); + EnsureParentDirectoryExists(compilePdbPath); return true; } return false; @@ -362,6 +377,7 @@ cmNinjaTargetGenerator vars.Object = "$out"; vars.Defines = "$DEFINES"; vars.TargetPDB = "$TARGET_PDB"; + vars.TargetCompilePDB = "$TARGET_COMPILE_PDB"; vars.ObjectDir = "$OBJECT_DIR"; cmMakefile* mf = this->GetMakefile(); @@ -402,9 +418,14 @@ cmNinjaTargetGenerator else { deptype = "gcc"; + const char* langdeptype = mf->GetDefinition("CMAKE_NINJA_DEPTYPE_" + lang); + if (langdeptype) + { + deptype = langdeptype; + } depfile = "$DEP_FILE"; const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang; - std::string depfileFlags = mf->GetSafeDefinition(flagsName.c_str()); + std::string depfileFlags = mf->GetSafeDefinition(flagsName); if (!depfileFlags.empty()) { cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE"); @@ -420,7 +441,7 @@ cmNinjaTargetGenerator // Rule for compiling object file. const std::string cmdVar = std::string("CMAKE_") + lang + "_COMPILE_OBJECT"; - std::string compileCmd = mf->GetRequiredDefinition(cmdVar.c_str()); + std::string compileCmd = mf->GetRequiredDefinition(cmdVar); std::vector<std::string> compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); @@ -464,44 +485,44 @@ cmNinjaTargetGenerator << this->GetTargetName() << "\n\n"; - std::vector<cmSourceFile*> customCommands; + std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); } - std::vector<cmSourceFile*> headerSources; + std::vector<cmSourceFile const*> headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector<cmSourceFile*> extraSources; + std::vector<cmSourceFile const*> extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector<cmSourceFile*> externalObjects; + std::vector<cmSourceFile const*> externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->Objects.push_back(this->GetSourceFilePath(*si)); } - std::vector<cmSourceFile*> objectSources; + std::vector<cmSourceFile const*> objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { this->WriteObjectBuildStatement(*si); } - if(!this->GeneratorTarget->ModuleDefinitionFile.empty()) + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + if(!def.empty()) { - this->ModuleDefinitionFile = this->ConvertToNinjaPath( - this->GeneratorTarget->ModuleDefinitionFile.c_str()); + this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str()); } { @@ -520,7 +541,7 @@ cmNinjaTargetGenerator void cmNinjaTargetGenerator -::WriteObjectBuildStatement(cmSourceFile* source) +::WriteObjectBuildStatement(cmSourceFile const* source) { std::string comment; const std::string language = source->GetLanguage(); @@ -554,14 +575,16 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. - std::vector<cmSourceFile*> customCommands; + std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); - const std::vector<std::string>& ccoutputs = cc->GetOutputs(); + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), + this->GetMakefile()); + const std::vector<std::string>& ccoutputs = ccg.GetOutputs(); std::transform(ccoutputs.begin(), ccoutputs.end(), std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } @@ -587,7 +610,7 @@ cmNinjaTargetGenerator std::string objectDir = this->Target->GetSupportDirectory(); vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(objectDir.c_str()).c_str(), + ConvertToNinjaPath(objectDir.c_str()), cmLocalGenerator::SHELL); this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars); @@ -612,7 +635,7 @@ cmNinjaTargetGenerator escapedSourceFileName = this->LocalGenerator->ConvertToOutputFormat( - escapedSourceFileName.c_str(), cmLocalGenerator::SHELL); + escapedSourceFileName, cmLocalGenerator::SHELL); compileObjectVars.Source = escapedSourceFileName.c_str(); compileObjectVars.Object = objectFileName.c_str(); @@ -625,7 +648,7 @@ cmNinjaTargetGenerator compileCmdVar += language; compileCmdVar += "_COMPILE_OBJECT"; std::string compileCmd = - this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); + this->GetMakefile()->GetRequiredDefinition(compileCmdVar); std::vector<std::string> compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); @@ -683,7 +706,7 @@ cmNinjaTargetGenerator // vs6's "cl -link" pass it to the linker. std::string flag = defFileFlag; flag += (this->LocalGenerator->ConvertToLinkReference( - this->ModuleDefinitionFile.c_str())); + this->ModuleDefinitionFile)); this->LocalGenerator->AppendFlags(flags, flag.c_str()); } @@ -715,7 +738,7 @@ cmNinjaTargetGenerator //---------------------------------------------------------------------------- void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( - cmSourceFile& source, const char* pkgloc) + cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. if(!this->Generator->GetTarget()->IsBundleOnApple()) diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 43f2279..8669e6e 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -65,24 +65,24 @@ protected: cmMakefile* GetMakefile() const { return this->Makefile; } - const char* GetConfigName() const; + std::string const& GetConfigName() const; std::string LanguageCompilerRule(const std::string& lang) const { return lang + "_COMPILER"; } - const char* GetFeature(const char* feature); - bool GetFeatureAsBool(const char* feature); - void AddFeatureFlags(std::string& flags, const char* lang); + const char* GetFeature(const std::string& feature); + bool GetFeatureAsBool(const std::string& feature); + void AddFeatureFlags(std::string& flags, const std::string& lang); /** * Compute the flags for compilation of object files for a given @a language. * @note Generally it is the value of the variable whose name is computed * by LanguageFlagsVarName(). */ - std::string ComputeFlagsForObject(cmSourceFile *source, + std::string ComputeFlagsForObject(cmSourceFile const* source, const std::string& language); - std::string ComputeDefines(cmSourceFile *source, + std::string ComputeDefines(cmSourceFile const* source, const std::string& language); std::string ConvertToNinjaPath(const char *path) const { @@ -96,10 +96,10 @@ protected: cmNinjaDeps ComputeLinkDeps() const; /// @return the source file path for the given @a source. - std::string GetSourceFilePath(cmSourceFile* source) const; + std::string GetSourceFilePath(cmSourceFile const* source) const; /// @return the object file path for the given @a source. - std::string GetObjectFilePath(cmSourceFile* source) const; + std::string GetObjectFilePath(cmSourceFile const* source) const; /// @return the file path where the target named @a name is generated. std::string GetTargetFilePath(const std::string& name) const; @@ -110,7 +110,7 @@ protected: void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); - void WriteObjectBuildStatement(cmSourceFile* source); + void WriteObjectBuildStatement(cmSourceFile const* source); void WriteCustomCommandBuildStatement(cmCustomCommand *cc); cmNinjaDeps GetObjects() const @@ -129,7 +129,7 @@ protected: MacOSXContentGeneratorType(cmNinjaTargetGenerator* g) : Generator(g) {} - void operator()(cmSourceFile& source, const char* pkgloc); + void operator()(cmSourceFile const& source, const char* pkgloc); private: cmNinjaTargetGenerator* Generator; @@ -140,7 +140,7 @@ protected: MacOSXContentGeneratorType* MacOSXContentGenerator; // Properly initialized by sub-classes. cmOSXBundleGenerator* OSXBundleGenerator; - std::set<cmStdString> MacContentFolders; + std::set<std::string> MacContentFolders; void addPoolNinjaVariable(const char* pool_property, cmTarget* target, diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 1a7b445..0fb40c0 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmTarget.h" +#include "cmCustomCommandGenerator.h" cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator( cmGeneratorTarget *target) @@ -37,8 +38,10 @@ void cmNinjaUtilityTargetGenerator::Generate() for (unsigned i = 0; i != 2; ++i) { for (std::vector<cmCustomCommand>::const_iterator ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { - this->GetLocalGenerator()->AppendCustomCommandDeps(&*ci, deps); - this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, commands); + cmCustomCommandGenerator ccg(*ci, this->GetConfigName(), + this->GetMakefile()); + this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps); + this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands); } } @@ -49,10 +52,12 @@ void cmNinjaUtilityTargetGenerator::Generate() { if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), + this->GetMakefile()); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); // Depend on all custom command outputs. - const std::vector<std::string>& ccOutputs = cc->GetOutputs(); + const std::vector<std::string>& ccOutputs = ccg.GetOutputs(); std::transform(ccOutputs.begin(), ccOutputs.end(), std::back_inserter(deps), MapToNinjaPath()); } diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 9a340dc..786e6e2 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -19,8 +19,8 @@ //---------------------------------------------------------------------------- cmOSXBundleGenerator:: cmOSXBundleGenerator(cmGeneratorTarget* target, - const char* configName) - : Target(target->Target) + const std::string& configName) + : GT(target) , Makefile(target->Target->GetMakefile()) , LocalGenerator(Makefile->GetLocalGenerator()) , ConfigName(configName) @@ -34,7 +34,7 @@ cmOSXBundleGenerator(cmGeneratorTarget* target, //---------------------------------------------------------------------------- bool cmOSXBundleGenerator::MustSkip() { - return !this->Target->HaveWellDefinedOutputFiles(); + return !this->GT->Target->HaveWellDefinedOutputFiles(); } //---------------------------------------------------------------------------- @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,10 +57,10 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; - this->LocalGenerator->GenerateAppleInfoPList(this->Target, - targetName.c_str(), + this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, + targetName, plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); outpath = newoutpath; @@ -77,21 +77,21 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); - std::string frameworkVersion = this->Target->GetFrameworkVersion(); + std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); // Configure the Info.plist file into the Resources directory. this->MacContentFolders->insert("Resources"); std::string plist = newoutpath; plist += "/Resources/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); - this->LocalGenerator->GenerateFrameworkInfoPList(this->Target, - name.c_str(), + this->LocalGenerator->GenerateFrameworkInfoPList(this->GT->Target, + name, plist.c_str()); // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to @@ -172,17 +172,17 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. - std::string plist = - this->Target->GetCFBundleDirectory(this->ConfigName, true); + std::string plist = root + "/" + + this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; - this->LocalGenerator->GenerateAppleInfoPList(this->Target, - targetName.c_str(), + this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, + targetName, plist.c_str()); this->Makefile->AddCMakeOutputFile(plist); } @@ -190,18 +190,19 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, //---------------------------------------------------------------------------- void cmOSXBundleGenerator:: -GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources, - MacOSXContentGeneratorType* generator) +GenerateMacOSXContentStatements( + std::vector<cmSourceFile const*> const& sources, + MacOSXContentGeneratorType* generator) { if (this->MustSkip()) return; - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { - cmTarget::SourceFileFlags tsFlags = - this->Target->GetTargetSourceFileFlags(*si); - if(tsFlags.Type != cmTarget::SourceFileTypeNormal) + cmGeneratorTarget::SourceFileFlags tsFlags = + this->GT->GetTargetSourceFileFlags(*si); + if(tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal) { (*generator)(**si, tsFlags.MacFolder); } @@ -215,7 +216,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->Target->GetMacContentDirectory(this->ConfigName, + this->GT->Target->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 29b7611..f945c15 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -27,7 +27,7 @@ class cmOSXBundleGenerator { public: cmOSXBundleGenerator(cmGeneratorTarget* target, - const char* configName); + const std::string& configName); // create an app bundle at a given root, and return // the directory within the bundle that contains the executable @@ -44,26 +44,27 @@ public: struct MacOSXContentGeneratorType { virtual ~MacOSXContentGeneratorType() {} - virtual void operator()(cmSourceFile& source, const char* pkgloc) = 0; + virtual void operator()(cmSourceFile const& source, + const char* pkgloc) = 0; }; void GenerateMacOSXContentStatements( - std::vector<cmSourceFile*> const& sources, + std::vector<cmSourceFile const*> const& sources, MacOSXContentGeneratorType* generator); std::string InitMacOSXContentDirectory(const char* pkgloc); - void SetMacContentFolders(std::set<cmStdString>* macContentFolders) + void SetMacContentFolders(std::set<std::string>* macContentFolders) { this->MacContentFolders = macContentFolders; } private: bool MustSkip(); private: - cmTarget* Target; + cmGeneratorTarget* GT; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; - const char* ConfigName; - std::set<cmStdString>* MacContentFolders; + std::string ConfigName; + std::set<std::string>* MacContentFolders; }; diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index 776a3a4..e505440 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -39,7 +39,7 @@ bool cmOptionCommand m += args[i]; m += " "; } - this->SetError(m.c_str()); + this->SetError(m); return false; } @@ -55,17 +55,14 @@ bool cmOptionCommand it.SetProperty("HELPSTRING", args[1].c_str()); return true; } - if ( it.GetValue() ) - { - initialValue = it.GetValue(); - } + initialValue = it.GetValue(); } if(args.size() == 3) { initialValue = args[2]; } bool init = cmSystemTools::IsOn(initialValue.c_str()); - this->Makefile->AddCacheDefinition(args[0].c_str(), init? "ON":"OFF", + this->Makefile->AddCacheDefinition(args[0], init? "ON":"OFF", args[1].c_str(), cmCacheManager::BOOL); return true; } diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h index 89e3ac1..12a6472 100644 --- a/Source/cmOptionCommand.h +++ b/Source/cmOptionCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "option";} + virtual std::string GetName() const {return "option";} /** * This determines if the command is invoked when in script mode. diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 86beb97..ec671fc 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -138,9 +138,9 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir, } // Check if the file will be built by cmake. - std::set<cmStdString> const& files = + std::set<std::string> const& files = (this->GlobalGenerator->GetDirectoryContent(dir, false)); - std::set<cmStdString>::const_iterator fi = files.find(name); + std::set<std::string>::const_iterator fi = files.find(name); return fi != files.end(); } @@ -200,7 +200,7 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir) { // We do not have the soname. Look for files in the directory // that may conflict. - std::set<cmStdString> const& files = + std::set<std::string> const& files = (this->GlobalGenerator ->GetDirectoryContent(dir, true)); @@ -208,9 +208,9 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir) // know the soname just look at all files that start with the // file name. Usually the soname starts with the library name. std::string base = this->FileName; - std::set<cmStdString>::const_iterator first = files.lower_bound(base); + std::set<std::string>::const_iterator first = files.lower_bound(base); ++base[base.size()-1]; - std::set<cmStdString>::const_iterator last = files.upper_bound(base); + std::set<std::string>::const_iterator last = files.upper_bound(base); if(first != last) { return true; @@ -251,8 +251,8 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) if(!this->OD->LinkExtensions.empty() && this->OD->RemoveLibraryExtension.find(this->FileName)) { - cmStdString lib = this->OD->RemoveLibraryExtension.match(1); - cmStdString ext = this->OD->RemoveLibraryExtension.match(2); + std::string lib = this->OD->RemoveLibraryExtension.match(1); + std::string ext = this->OD->RemoveLibraryExtension.match(2); for(std::vector<std::string>::iterator i = this->OD->LinkExtensions.begin(); i != this->OD->LinkExtensions.end(); ++i) @@ -261,7 +261,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) { std::string fname = lib; fname += *i; - if(this->FileMayConflict(dir, fname.c_str())) + if(this->FileMayConflict(dir, fname)) { return true; } @@ -407,7 +407,7 @@ cmOrderDirectories //---------------------------------------------------------------------------- void cmOrderDirectories -::SetImplicitDirectories(std::set<cmStdString> const& implicitDirs) +::SetImplicitDirectories(std::set<std::string> const& implicitDirs) { this->ImplicitDirectories = implicitDirs; } @@ -444,11 +444,11 @@ void cmOrderDirectories::CollectOriginalDirectories() int cmOrderDirectories::AddOriginalDirectory(std::string const& dir) { // Add the runtime directory with a unique index. - std::map<cmStdString, int>::iterator i = + std::map<std::string, int>::iterator i = this->DirectoryIndex.find(dir); if(i == this->DirectoryIndex.end()) { - std::map<cmStdString, int>::value_type + std::map<std::string, int>::value_type entry(dir, static_cast<int>(this->OriginalDirectories.size())); i = this->DirectoryIndex.insert(entry).first; this->OriginalDirectories.push_back(dir); diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 76bf429..07c85dd 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -34,7 +34,7 @@ public: void AddLinkLibrary(std::string const& fullPath); void AddUserDirectories(std::vector<std::string> const& extra); void AddLanguageDirectories(std::vector<std::string> const& dirs); - void SetImplicitDirectories(std::set<cmStdString> const& implicitDirs); + void SetImplicitDirectories(std::set<std::string> const& implicitDirs); void SetLinkExtensionInfo(std::vector<std::string> const& linkExtensions, std::string const& removeExtRegex); @@ -54,11 +54,11 @@ private: std::vector<std::string> LanguageDirectories; cmsys::RegularExpression RemoveLibraryExtension; std::vector<std::string> LinkExtensions; - std::set<cmStdString> ImplicitDirectories; - std::set<cmStdString> EmmittedConstraintSOName; - std::set<cmStdString> EmmittedConstraintLibrary; + std::set<std::string> ImplicitDirectories; + std::set<std::string> EmmittedConstraintSOName; + std::set<std::string> EmmittedConstraintLibrary; std::vector<std::string> OriginalDirectories; - std::map<cmStdString, int> DirectoryIndex; + std::map<std::string, int> DirectoryIndex; std::vector<int> DirectoryVisited; void CollectOriginalDirectories(); int AddOriginalDirectory(std::string const& dir); diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index c0d9e99..5016493 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -202,7 +202,7 @@ bool cmOutputRequiredFilesCommand { std::string err = "Can not open output file: "; err += this->OutputFile; - this->SetError(err.c_str()); + this->SetError(err); return false; } std::set<cmDependInformation const*> visited; diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h index dd5ed6c..95eba38 100644 --- a/Source/cmOutputRequiredFilesCommand.h +++ b/Source/cmOutputRequiredFilesCommand.h @@ -22,7 +22,7 @@ public: virtual cmCommand* Clone() { return new cmOutputRequiredFilesCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "output_required_files";} + virtual std::string GetName() const { return "output_required_files";} virtual bool IsDiscouraged() const { return true; } void ListDependencies(cmDependInformation const *info, diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 93072f5..2bd553f 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -488,7 +488,7 @@ bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy, cmPolicies::PolicyStatus* defaultSetting) { std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy; - std::string defaultValue = mf->GetSafeDefinition(defaultVar.c_str()); + std::string defaultValue = mf->GetSafeDefinition(defaultVar); if(defaultValue == "NEW") { *defaultSetting = cmPolicies::NEW; @@ -506,7 +506,7 @@ bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy, cmOStringStream e; e << defaultVar << " has value \"" << defaultValue << "\" but must be \"OLD\", \"NEW\", or \"\" (empty)."; - mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } @@ -651,5 +651,5 @@ cmPolicies::DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient, << "Please either update your CMakeLists.txt files to conform to " << "the new behavior or use an older version of CMake that still " << "supports the old behavior."; - mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); } diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index a9ce0cc..12318c8 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -28,20 +28,20 @@ bool cmProjectCommand srcdir += "_SOURCE_DIR"; this->Makefile->AddCacheDefinition - (bindir.c_str(), + (bindir, this->Makefile->GetCurrentOutputDirectory(), "Value Computed by CMake", cmCacheManager::STATIC); this->Makefile->AddCacheDefinition - (srcdir.c_str(), + (srcdir, this->Makefile->GetCurrentDirectory(), "Value Computed by CMake", cmCacheManager::STATIC); bindir = "PROJECT_BINARY_DIR"; srcdir = "PROJECT_SOURCE_DIR"; - this->Makefile->AddDefinition(bindir.c_str(), + this->Makefile->AddDefinition(bindir, this->Makefile->GetCurrentOutputDirectory()); - this->Makefile->AddDefinition(srcdir.c_str(), + this->Makefile->AddDefinition(srcdir, this->Makefile->GetCurrentDirectory()); this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str()); @@ -167,19 +167,19 @@ bool cmProjectCommand std::string vv; vv = args[0] + "_VERSION"; this->Makefile->AddDefinition("PROJECT_VERSION", vs.c_str()); - this->Makefile->AddDefinition(vv.c_str(), vs.c_str()); + this->Makefile->AddDefinition(vv, vs.c_str()); vv = args[0] + "_VERSION_MAJOR"; this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR", vb[0]); - this->Makefile->AddDefinition(vv.c_str(), vb[0]); + this->Makefile->AddDefinition(vv, vb[0]); vv = args[0] + "_VERSION_MINOR"; this->Makefile->AddDefinition("PROJECT_VERSION_MINOR", vb[1]); - this->Makefile->AddDefinition(vv.c_str(), vb[1]); + this->Makefile->AddDefinition(vv, vb[1]); vv = args[0] + "_VERSION_PATCH"; this->Makefile->AddDefinition("PROJECT_VERSION_PATCH", vb[2]); - this->Makefile->AddDefinition(vv.c_str(), vb[2]); + this->Makefile->AddDefinition(vv, vb[2]); vv = args[0] + "_VERSION_TWEAK"; this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]); - this->Makefile->AddDefinition(vv.c_str(), vb[3]); + this->Makefile->AddDefinition(vv, vb[3]); } else if(cmp0048 != cmPolicies::OLD) { @@ -199,7 +199,7 @@ bool cmProjectCommand for(std::vector<std::string>::iterator i = vv.begin(); i != vv.end(); ++i) { - const char* v = this->Makefile->GetDefinition(i->c_str()); + const char* v = this->Makefile->GetDefinition(*i); if(v && *v) { if(cmp0048 == cmPolicies::WARN) @@ -209,7 +209,7 @@ bool cmProjectCommand } else { - this->Makefile->AddDefinition(i->c_str(), ""); + this->Makefile->AddDefinition(*i, ""); } } } @@ -231,7 +231,7 @@ bool cmProjectCommand } this->Makefile->EnableLanguage(languages, false); std::string extraInclude = "CMAKE_PROJECT_" + args[0] + "_INCLUDE"; - const char* include = this->Makefile->GetDefinition(extraInclude.c_str()); + const char* include = this->Makefile->GetDefinition(extraInclude); if(include) { std::string fullFilePath; @@ -244,7 +244,7 @@ bool cmProjectCommand "could not find file:\n" " "; m += include; - this->SetError(m.c_str()); + this->SetError(m); return false; } } diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index f7d086d..7aacb55 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "project";} + virtual std::string GetName() const {return "project";} cmTypeMacro(cmProjectCommand, cmCommand); }; diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx index 3b37cf3..40976db 100644 --- a/Source/cmProperty.cxx +++ b/Source/cmProperty.cxx @@ -12,14 +12,15 @@ #include "cmProperty.h" #include "cmSystemTools.h" -void cmProperty::Set(const char *name, const char *value) +void cmProperty::Set(const std::string& name, const char *value) { this->Name = name; this->Value = value; this->ValueHasBeenSet = true; } -void cmProperty::Append(const char *name, const char *value, bool asString) +void cmProperty::Append(const std::string& name, const char *value, + bool asString) { this->Name = name; if(!this->Value.empty() && *value && !asString) diff --git a/Source/cmProperty.h b/Source/cmProperty.h index bb75bb0..789be1d 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -21,10 +21,11 @@ public: TEST, VARIABLE, CACHED_VARIABLE }; // set this property - void Set(const char *name, const char *value); + void Set(const std::string& name, const char *value); // append to this property - void Append(const char *name, const char *value, bool asString = false); + void Append(const std::string& name, const char *value, + bool asString = false); // get the value const char *GetValue() const; diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx index abc57ce..1af967c 100644 --- a/Source/cmPropertyDefinition.cxx +++ b/Source/cmPropertyDefinition.cxx @@ -13,7 +13,7 @@ #include "cmSystemTools.h" void cmPropertyDefinition -::DefineProperty(const char *name, cmProperty::ScopeType scope, +::DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *shortDescription, const char *fullDescription, bool chain) diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h index 1b6a7a6..9ca8222 100644 --- a/Source/cmPropertyDefinition.h +++ b/Source/cmPropertyDefinition.h @@ -27,7 +27,7 @@ class cmPropertyDefinition { public: /// Define this property - void DefineProperty(const char *name, cmProperty::ScopeType scope, + void DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chained); diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx index db29504..3875318 100644 --- a/Source/cmPropertyDefinitionMap.cxx +++ b/Source/cmPropertyDefinitionMap.cxx @@ -14,16 +14,11 @@ #include "cmDocumentationSection.h" void cmPropertyDefinitionMap -::DefineProperty(const char *name, cmProperty::ScopeType scope, +::DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chain) { - if (!name) - { - return; - } - cmPropertyDefinitionMap::iterator it = this->find(name); cmPropertyDefinition *prop; if (it == this->end()) @@ -34,13 +29,8 @@ void cmPropertyDefinitionMap } } -bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name) +bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) { - if (!name) - { - return false; - } - cmPropertyDefinitionMap::iterator it = this->find(name); if (it == this->end()) { @@ -50,13 +40,8 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name) return true; } -bool cmPropertyDefinitionMap::IsPropertyChained(const char *name) +bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) { - if (!name) - { - return false; - } - cmPropertyDefinitionMap::iterator it = this->find(name); if (it == this->end()) { diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h index 736e243..00c7328 100644 --- a/Source/cmPropertyDefinitionMap.h +++ b/Source/cmPropertyDefinitionMap.h @@ -17,20 +17,20 @@ class cmDocumentationSection; class cmPropertyDefinitionMap : -public std::map<cmStdString,cmPropertyDefinition> +public std::map<std::string,cmPropertyDefinition> { public: // define the property - void DefineProperty(const char *name, cmProperty::ScopeType scope, + void DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chain); // has a named property been defined - bool IsPropertyDefined(const char *name); + bool IsPropertyDefined(const std::string& name); // is a named property set to chain - bool IsPropertyChained(const char *name); + bool IsPropertyChained(const std::string& name); }; #endif diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index e94e3e9..e335b3b 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -13,7 +13,7 @@ #include "cmSystemTools.h" #include "cmake.h" -cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name) +cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name) { cmPropertyMap::iterator it = this->find(name); cmProperty *prop; @@ -28,13 +28,9 @@ cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name) return prop; } -void cmPropertyMap::SetProperty(const char *name, const char *value, +void cmPropertyMap::SetProperty(const std::string& name, const char *value, cmProperty::ScopeType scope) { - if (!name) - { - return; - } if(!value) { this->erase(name); @@ -46,11 +42,11 @@ void cmPropertyMap::SetProperty(const char *name, const char *value, prop->Set(name,value); } -void cmPropertyMap::AppendProperty(const char* name, const char* value, +void cmPropertyMap::AppendProperty(const std::string& name, const char* value, cmProperty::ScopeType scope, bool asString) { // Skip if nothing to append. - if(!name || !value || !*value) + if(!value || !*value) { return; } @@ -61,12 +57,12 @@ void cmPropertyMap::AppendProperty(const char* name, const char* value, } const char *cmPropertyMap -::GetPropertyValue(const char *name, +::GetPropertyValue(const std::string& name, cmProperty::ScopeType scope, bool &chain) const { chain = false; - if (!name) + if (name.empty()) { return 0; } diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 0c3aad4..fa33848 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -16,18 +16,18 @@ class cmake; -class cmPropertyMap : public std::map<cmStdString,cmProperty> +class cmPropertyMap : public std::map<std::string,cmProperty> { public: - cmProperty *GetOrCreateProperty(const char *name); + cmProperty *GetOrCreateProperty(const std::string& name); - void SetProperty(const char *name, const char *value, + void SetProperty(const std::string& name, const char *value, cmProperty::ScopeType scope); - void AppendProperty(const char* name, const char* value, + void AppendProperty(const std::string& name, const char* value, cmProperty::ScopeType scope, bool asString=false); - const char *GetPropertyValue(const char *name, + const char *GetPropertyValue(const std::string& name, cmProperty::ScopeType scope, bool &chain) const; diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index 0d3c994..a984260 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -32,13 +32,13 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn, // Get the variable holding the list of sources. std::string const& sourceList = args[1]; std::string sourceListValue = - this->Makefile->GetSafeDefinition(sourceList.c_str()); + this->Makefile->GetSafeDefinition(sourceList); // Create a rule for all sources listed. for(std::vector<std::string>::iterator j = (args.begin() + 2); j != args.end(); ++j) { - cmSourceFile *curr = this->Makefile->GetSource(j->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(*j); // if we should wrap the class if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) { @@ -50,7 +50,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn, newName += srcName; newName += ".cxx"; cmSourceFile* sf = - this->Makefile->GetOrCreateSource(newName.c_str(), true); + this->Makefile->GetOrCreateSource(newName, true); if (curr) { sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT")); @@ -97,9 +97,9 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn, depends.push_back(moc_exe); depends.push_back(hname); - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; const char* no_working_dir = 0; - this->Makefile->AddCustomCommandToOutput(newName.c_str(), + this->Makefile->AddCustomCommandToOutput(newName, depends, no_main_dependency, commandLines, @@ -109,7 +109,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn, } // Store the final list of source files. - this->Makefile->AddDefinition(sourceList.c_str(), + this->Makefile->AddDefinition(sourceList, sourceListValue.c_str()); return true; } diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h index 868eb91..85729dd 100644 --- a/Source/cmQTWrapCPPCommand.h +++ b/Source/cmQTWrapCPPCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "qt_wrap_cpp";} + virtual std::string GetName() const { return "qt_wrap_cpp";} }; diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index a6a4b51..dce59ef 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -35,15 +35,15 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn, std::string const& headerList = args[1]; std::string const& sourceList = args[2]; std::string headerListValue = - this->Makefile->GetSafeDefinition(headerList.c_str()); + this->Makefile->GetSafeDefinition(headerList); std::string sourceListValue = - this->Makefile->GetSafeDefinition(sourceList.c_str()); + this->Makefile->GetSafeDefinition(sourceList); // Create rules for all sources listed. for(std::vector<std::string>::iterator j = (args.begin() + 3); j != args.end(); ++j) { - cmSourceFile *curr = this->Makefile->GetSource(j->c_str()); + cmSourceFile *curr = this->Makefile->GetSource(*j); // if we should wrap the class if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) { @@ -128,10 +128,10 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn, std::vector<std::string> depends; depends.push_back(uiName); - const char* no_main_dependency = 0; + std::string no_main_dependency = ""; const char* no_comment = 0; const char* no_working_dir = 0; - this->Makefile->AddCustomCommandToOutput(hName.c_str(), + this->Makefile->AddCustomCommandToOutput(hName, depends, no_main_dependency, hCommandLines, @@ -139,7 +139,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn, no_working_dir); depends.push_back(hName); - this->Makefile->AddCustomCommandToOutput(cxxName.c_str(), + this->Makefile->AddCustomCommandToOutput(cxxName, depends, no_main_dependency, cxxCommandLines, @@ -148,7 +148,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn, depends.clear(); depends.push_back(hName); - this->Makefile->AddCustomCommandToOutput(mocName.c_str(), + this->Makefile->AddCustomCommandToOutput(mocName, depends, no_main_dependency, mocCommandLines, @@ -158,9 +158,9 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn, } // Store the final list of source files and headers. - this->Makefile->AddDefinition(sourceList.c_str(), + this->Makefile->AddDefinition(sourceList, sourceListValue.c_str()); - this->Makefile->AddDefinition(headerList.c_str(), + this->Makefile->AddDefinition(headerList, headerListValue.c_str()); return true; } diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h index 3406dac..4aa9a61 100644 --- a/Source/cmQTWrapUICommand.h +++ b/Source/cmQTWrapUICommand.h @@ -43,7 +43,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "qt_wrap_ui";} + virtual std::string GetName() const { return "qt_wrap_ui";} }; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 2c5dd45..a6e6af7 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -105,7 +105,7 @@ static std::string extractSubDir(const std::string& absPath, static void copyTargetProperty(cmTarget* destinationTarget, cmTarget* sourceTarget, - const char* propertyName) + const std::string& propertyName) { const char* propertyValue = sourceTarget->GetProperty(propertyName); if (propertyValue) @@ -188,7 +188,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) mocCppFile += automocTargetName; mocCppFile += ".cpp"; cmSourceFile* mocCppSource = makefile->GetOrCreateSource( - mocCppFile.c_str(), + mocCppFile, true); makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); @@ -251,7 +251,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) bool usePRE_BUILD = false; cmLocalGenerator* localGen = makefile->GetLocalGenerator(); cmGlobalGenerator* gg = localGen->GetGlobalGenerator(); - if(strstr(gg->GetName(), "Visual Studio")) + if(gg->GetName().find("Visual Studio") != std::string::npos) { cmLocalVisualStudioGenerator* vslg = static_cast<cmLocalVisualStudioGenerator*>(localGen); @@ -290,7 +290,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) #endif { cmTarget* autogenTarget = makefile->AddUtilityCommand( - autogenTargetName.c_str(), true, + autogenTargetName, true, workingDirectory.c_str(), depends, commandLines, false, autogenComment.c_str()); // Set target folder @@ -311,14 +311,14 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) copyTargetProperty(autogenTarget, target, "FOLDER"); } - target->AddUtility(autogenTargetName.c_str()); + target->AddUtility(autogenTargetName); } return true; } static void GetCompileDefinitionsAndDirectories(cmTarget const* target, - const char * config, + const std::string& config, std::string &incs, std::string &defs) { @@ -368,7 +368,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) std::string autogenTargetName = getAutogenTargetName(target); makefile->AddDefinition("_moc_target_name", - cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(autogenTargetName).c_str()); std::string targetDir = getAutogenTargetDir(target); @@ -378,7 +378,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0)) + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -397,7 +397,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) this->SetupSourceFiles(target); } makefile->AddDefinition("_cpp_files", - cmLocalGenerator::EscapeForCMake(this->Sources.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->Sources).c_str()); if (target->GetPropertyAsBool("AUTOMOC")) { this->SetupAutoMocTarget(target, autogenTargetName, @@ -513,7 +513,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", rcc_output_file.c_str(), false); cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + = makefile->GetOrCreateSource(rcc_output_file, true); newRccFiles.push_back(rccCppSource); } } @@ -564,38 +564,38 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); std::string _moc_options = (tmp!=0 ? tmp : ""); makefile->AddDefinition("_moc_options", - cmLocalGenerator::EscapeForCMake(_moc_options.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(_moc_options).c_str()); makefile->AddDefinition("_skip_moc", - cmLocalGenerator::EscapeForCMake(this->SkipMoc.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->SkipMoc).c_str()); makefile->AddDefinition("_moc_headers", - cmLocalGenerator::EscapeForCMake(this->Headers.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->Headers).c_str()); bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); std::string _moc_incs; std::string _moc_compile_defs; std::vector<std::string> configs; - const char *config = makefile->GetConfigurations(configs); + const std::string& config = makefile->GetConfigurations(configs); GetCompileDefinitionsAndDirectories(target, config, _moc_incs, _moc_compile_defs); makefile->AddDefinition("_moc_incs", - cmLocalGenerator::EscapeForCMake(_moc_incs.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(_moc_incs).c_str()); makefile->AddDefinition("_moc_compile_defs", - cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(_moc_compile_defs).c_str()); for (std::vector<std::string>::const_iterator li = configs.begin(); li != configs.end(); ++li) { std::string config_moc_incs; std::string config_moc_compile_defs; - GetCompileDefinitionsAndDirectories(target, li->c_str(), + GetCompileDefinitionsAndDirectories(target, *li, config_moc_incs, config_moc_compile_defs); if (config_moc_incs != _moc_incs) { configIncludes[*li] = - cmLocalGenerator::EscapeForCMake(config_moc_incs.c_str()); + cmLocalGenerator::EscapeForCMake(config_moc_incs); if(_moc_incs.empty()) { _moc_incs = config_moc_incs; @@ -604,7 +604,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, if (config_moc_compile_defs != _moc_compile_defs) { configDefines[*li] = - cmLocalGenerator::EscapeForCMake(config_moc_compile_defs.c_str()); + cmLocalGenerator::EscapeForCMake(config_moc_compile_defs); if(_moc_compile_defs.empty()) { _moc_compile_defs = config_moc_compile_defs; @@ -622,7 +622,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, autogenTargetName.c_str()); return; } - makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0)); + makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation("")); } else if (strcmp(qtVersion, "4") == 0) { @@ -633,7 +633,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, autogenTargetName.c_str()); return; } - makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(0)); + makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation("")); } else { @@ -672,7 +672,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, ++o; } if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), - cmStrCmp(o)) != cmArrayEnd(valueOptions)) + cmStrCmp(*it)) != cmArrayEnd(valueOptions)) { assert(existingIt + 1 != opts.end()); *(existingIt + 1) = *(it + 1); @@ -687,7 +687,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -static void GetUicOpts(cmTarget const* target, const char * config, +static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { std::vector<std::string> opts; @@ -709,9 +709,9 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, { cmMakefile *makefile = target->GetMakefile(); - std::set<cmStdString> skipped; + std::set<std::string> skipped; std::vector<std::string> skipVec; - cmSystemTools::ExpandListArgument(this->SkipUic.c_str(), skipVec); + cmSystemTools::ExpandListArgument(this->SkipUic, skipVec); for (std::vector<std::string>::const_iterator li = skipVec.begin(); li != skipVec.end(); ++li) @@ -720,7 +720,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, } makefile->AddDefinition("_skip_uic", - cmLocalGenerator::EscapeForCMake(this->SkipUic.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(this->SkipUic).c_str()); std::vector<cmSourceFile*> uiFilesWithOptions = makefile->GetQtUiFilesWithOptions(); @@ -729,23 +729,23 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, std::string _uic_opts; std::vector<std::string> configs; - const char *config = makefile->GetConfigurations(configs); + const std::string& config = makefile->GetConfigurations(configs); GetUicOpts(target, config, _uic_opts); if (!_uic_opts.empty()) { - _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts.c_str()); + _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts); makefile->AddDefinition("_uic_target_options", _uic_opts.c_str()); } for (std::vector<std::string>::const_iterator li = configs.begin(); li != configs.end(); ++li) { std::string config_uic_opts; - GetUicOpts(target, li->c_str(), config_uic_opts); + GetUicOpts(target, *li, config_uic_opts); if (config_uic_opts != _uic_opts) { configUicOptions[*li] = - cmLocalGenerator::EscapeForCMake(config_uic_opts.c_str()); + cmLocalGenerator::EscapeForCMake(config_uic_opts); if(_uic_opts.empty()) { _uic_opts = config_uic_opts; @@ -780,11 +780,11 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, } makefile->AddDefinition("_qt_uic_options_files", - cmLocalGenerator::EscapeForCMake(uiFileFiles.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(uiFileFiles).c_str()); makefile->AddDefinition("_qt_uic_options_options", - cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(uiFileOptions).c_str()); - const char* targetName = target->GetName(); + std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) { cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic"); @@ -794,7 +794,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, } else { - makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0)); + makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation("")); } } else if (strcmp(qtVersion, "4") == 0) @@ -803,15 +803,15 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, if (!qt4Uic) { cmSystemTools::Error("Qt4::uic target not found ", - targetName); + targetName.c_str()); return; } - makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0)); + makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation("")); } else { cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " - "Qt 5 ", targetName); + "Qt 5 ", targetName.c_str()); } } @@ -843,7 +843,7 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts, ++o; } if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), - cmStrCmp(o)) != cmArrayEnd(valueOptions)) + cmStrCmp(*it)) != cmArrayEnd(valueOptions)) { assert(existingIt + 1 != opts.end()); *(existingIt + 1) = *(it + 1); @@ -926,24 +926,24 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) } makefile->AddDefinition("_rcc_files", - cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(_rcc_files).c_str()); makefile->AddDefinition("_qt_rcc_options_files", - cmLocalGenerator::EscapeForCMake(rccFileFiles.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(rccFileFiles).c_str()); makefile->AddDefinition("_qt_rcc_options_options", - cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str()); + cmLocalGenerator::EscapeForCMake(rccFileOptions).c_str()); - const char* targetName = target->GetName(); + std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) { cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc"); if (!qt5Rcc) { cmSystemTools::Error("Qt5::rcc target not found ", - targetName); + targetName.c_str()); return; } - makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0)); + makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation("")); } else if (strcmp(qtVersion, "4") == 0) { @@ -951,20 +951,20 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) if (!qt4Rcc) { cmSystemTools::Error("Qt4::rcc target not found ", - targetName); + targetName.c_str()); return; } - makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0)); + makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation("")); } else { cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " - "Qt 5 ", targetName); + "Qt 5 ", targetName.c_str()); } } static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, - const char* targetDirectory) + const std::string& targetDirectory) { cmGlobalGenerator* gg = new cmGlobalGenerator(); gg->SetCMakeInstance(cm); @@ -979,7 +979,8 @@ static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, return gg; } -bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) +bool cmQtAutoGenerators::Run(const std::string& targetDirectory, + const std::string& config) { bool success = true; cmake cm; @@ -1005,10 +1006,11 @@ bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) } bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, - const char* targetDirectory, - const char *config) + const std::string& targetDirectory, + const std::string& config) { - std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + std::string filename( + cmSystemTools::CollapseFullPath(targetDirectory.c_str())); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutogenInfo.cmake"; @@ -1039,26 +1041,26 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, { std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS"; std::string compileDefsProp = compileDefsPropOrig; - if(config) + if(!config.empty()) { compileDefsProp += "_"; compileDefsProp += config; } - const char *compileDefs = makefile->GetDefinition(compileDefsProp.c_str()); + const char *compileDefs = makefile->GetDefinition(compileDefsProp); this->MocCompileDefinitionsStr = compileDefs ? compileDefs - : makefile->GetSafeDefinition(compileDefsPropOrig.c_str()); + : makefile->GetSafeDefinition(compileDefsPropOrig); } { std::string includesPropOrig = "AM_MOC_INCLUDES"; std::string includesProp = includesPropOrig; - if(config) + if(!config.empty()) { includesProp += "_"; includesProp += config; } - const char *includes = makefile->GetDefinition(includesProp.c_str()); + const char *includes = makefile->GetDefinition(includesProp); this->MocIncludesStr = includes ? includes - : makefile->GetSafeDefinition(includesPropOrig.c_str()); + : makefile->GetSafeDefinition(includesPropOrig); } this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS"); this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); @@ -1070,16 +1072,16 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, = makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"); std::string uicOptionsPropOrig = "AM_UIC_TARGET_OPTIONS"; std::string uicOptionsProp = uicOptionsPropOrig; - if(config) + if(!config.empty()) { uicOptionsProp += "_"; uicOptionsProp += config; } const char *uicTargetOptions - = makefile->GetSafeDefinition(uicOptionsProp.c_str()); + = makefile->GetSafeDefinition(uicOptionsProp); cmSystemTools::ExpandListArgument( uicTargetOptions ? uicTargetOptions - : makefile->GetSafeDefinition(uicOptionsPropOrig.c_str()), + : makefile->GetSafeDefinition(uicOptionsPropOrig), this->UicTargetOptions); const char *uicOptionsOptions = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"); @@ -1148,9 +1150,10 @@ std::string cmQtAutoGenerators::MakeCompileSettingsString(cmMakefile* makefile) bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile, - const char* targetDirectory) + const std::string& targetDirectory) { - std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + std::string filename( + cmSystemTools::CollapseFullPath(targetDirectory.c_str())); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutomocOldMocDefinitions.cmake"; @@ -1164,9 +1167,11 @@ bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile, void -cmQtAutoGenerators::WriteOldMocDefinitionsFile(const char* targetDirectory) +cmQtAutoGenerators::WriteOldMocDefinitionsFile( + const std::string& targetDirectory) { - std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + std::string filename( + cmSystemTools::CollapseFullPath(targetDirectory.c_str())); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutomocOldMocDefinitions.cmake"; @@ -1175,7 +1180,7 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile(const char* targetDirectory) std::ios::out | std::ios::trunc); outfile << "set(AM_OLD_COMPILE_SETTINGS " << cmLocalGenerator::EscapeForCMake( - this->CurrentCompileSettingsStr.c_str()) << ")\n"; + this->CurrentCompileSettingsStr) << ")\n"; outfile.close(); } @@ -1786,8 +1791,8 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, std::string::size_type matchOffset = 0; - const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + const std::string realName = + cmsys::SystemTools::GetRealPath(absFilename.c_str()); matchOffset = 0; if ((strstr(contentsString.c_str(), "ui_") != NULL) @@ -1804,7 +1809,7 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, // finding the correct header, so we need to remove the ui_ part basename = basename.substr(3); - includedUis[absPath] = basename; + includedUis[realName] = basename; matchOffset += uiIncludeRegExp.end(); } while(uiIncludeRegExp.find(contentsString.c_str() + matchOffset)); @@ -1907,7 +1912,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, |cmsysTerminal_Color_ForegroundBold, msg.c_str(), true, this->ColorOutput); - std::vector<cmStdString> command; + std::vector<std::string> command; command.push_back(this->MocExecutable); for (std::list<std::string>::const_iterator it = this->MocIncludes.begin(); it != this->MocIncludes.end(); @@ -1936,7 +1941,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, if (this->Verbose) { - for(std::vector<cmStdString>::const_iterator cmdIt = command.begin(); + for(std::vector<std::string>::const_iterator cmdIt = command.begin(); cmdIt != command.end(); ++cmdIt) { @@ -1960,7 +1965,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, return false; } -bool cmQtAutoGenerators::GenerateUi(const std::string& path, +bool cmQtAutoGenerators::GenerateUi(const std::string& realName, const std::string& uiFileName) { if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false)) @@ -1968,6 +1973,9 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path, cmsys::SystemTools::MakeDirectory(this->Builddir.c_str()); } + const std::string path = cmsys::SystemTools::GetFilenamePath( + realName.c_str()) + '/'; + std::string ui_output_file = "ui_" + uiFileName + ".h"; std::string ui_input_file = path + uiFileName + ".ui"; @@ -1983,7 +1991,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path, |cmsysTerminal_Color_ForegroundBold, msg.c_str(), true, this->ColorOutput); - std::vector<cmStdString> command; + std::vector<std::string> command; command.push_back(this->UicExecutable); std::vector<std::string> opts = this->UicTargetOptions; @@ -2008,7 +2016,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path, if (this->Verbose) { - for(std::vector<cmStdString>::const_iterator cmdIt = command.begin(); + for(std::vector<std::string>::const_iterator cmdIt = command.begin(); cmdIt != command.end(); ++cmdIt) { @@ -2046,7 +2054,7 @@ bool cmQtAutoGenerators::GenerateQrc() { continue; } - std::vector<cmStdString> command; + std::vector<std::string> command; command.push_back(this->RccExecutable); std::string basename = cmsys::SystemTools:: @@ -2074,13 +2082,15 @@ bool cmQtAutoGenerators::GenerateQrc() } } + command.push_back("-name"); + command.push_back(basename); command.push_back("-o"); command.push_back(rcc_output_file); command.push_back(*si); if (this->Verbose) { - for(std::vector<cmStdString>::const_iterator cmdIt = command.begin(); + for(std::vector<std::string>::const_iterator cmdIt = command.begin(); cmdIt != command.end(); ++cmdIt) { diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 2840fbf..8003795 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -21,7 +21,7 @@ class cmQtAutoGenerators { public: cmQtAutoGenerators(); - bool Run(const char* targetDirectory, const char *config); + bool Run(const std::string& targetDirectory, const std::string& config); bool InitializeAutogenTarget(cmTarget* target); void SetupAutoGenerateTarget(cmTarget const* target); @@ -37,18 +37,18 @@ private: void SetupAutoRccTarget(cmTarget const* target); bool ReadAutogenInfoFile(cmMakefile* makefile, - const char* targetDirectory, - const char *config); + const std::string& targetDirectory, + const std::string& config); bool ReadOldMocDefinitionsFile(cmMakefile* makefile, - const char* targetDirectory); - void WriteOldMocDefinitionsFile(const char* targetDirectory); + const std::string& targetDirectory); + void WriteOldMocDefinitionsFile(const std::string& targetDirectory); std::string MakeCompileSettingsString(cmMakefile* makefile); bool RunAutogen(cmMakefile* makefile); bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); - bool GenerateUi(const std::string& path, const std::string& uiFileName); + bool GenerateUi(const std::string& realName, const std::string& uiFileName); bool GenerateQrc(); void ParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 11a9913..7ff12dd 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -326,11 +326,11 @@ std::string cmRST::ReplaceSubstitutions(std::string const& line) std::string::size_type start = this->Substitution.start(2); std::string::size_type end = this->Substitution.end(2); std::string substitute = this->Substitution.match(3); - std::map<cmStdString, cmStdString>::iterator + std::map<std::string, std::string>::iterator replace = this->Replace.find(substitute); if(replace != this->Replace.end()) { - std::pair<std::set<cmStdString>::iterator, bool> replaced = + std::pair<std::set<std::string>::iterator, bool> replaced = this->Replaced.insert(substitute); if(replaced.second) { diff --git a/Source/cmRST.h b/Source/cmRST.h index 3356008..b9b2366 100644 --- a/Source/cmRST.h +++ b/Source/cmRST.h @@ -92,8 +92,8 @@ private: std::vector<std::string> MarkupLines; std::string DocDir; - std::map<cmStdString, cmStdString> Replace; - std::set<cmStdString> Replaced; + std::map<std::string, std::string> Replace; + std::set<std::string> Replaced; std::string ReplaceName; }; diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index ad73908..94161f8 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "remove";} + virtual std::string GetName() const {return "remove";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h index 4e291fc..cac94be 100644 --- a/Source/cmRemoveDefinitionsCommand.h +++ b/Source/cmRemoveDefinitionsCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "remove_definitions";} + virtual std::string GetName() const {return "remove_definitions";} cmTypeMacro(cmRemoveDefinitionsCommand, cmCommand); }; diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h index 2822b62..4ff81ef 100644 --- a/Source/cmReturnCommand.h +++ b/Source/cmReturnCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "return";} + virtual std::string GetName() const {return "return";} cmTypeMacro(cmReturnCommand, cmCommand); }; diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 3b6a49b..e44b236 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -15,11 +15,11 @@ //---------------------------------------------------------------------------- cmScriptGenerator -::cmScriptGenerator(const char* config_var, +::cmScriptGenerator(const std::string& config_var, std::vector<std::string> const& configurations): RuntimeConfigVariable(config_var), Configurations(configurations), - ConfigurationName(0), + ConfigurationName(""), ConfigurationTypes(0), ActionsPerConfig(false) { @@ -34,21 +34,21 @@ cmScriptGenerator //---------------------------------------------------------------------------- void cmScriptGenerator -::Generate(std::ostream& os, const char* config, +::Generate(std::ostream& os, const std::string& config, std::vector<std::string> const& configurationTypes) { this->ConfigurationName = config; this->ConfigurationTypes = &configurationTypes; this->GenerateScript(os); - this->ConfigurationName = 0; + this->ConfigurationName = ""; this->ConfigurationTypes = 0; } //---------------------------------------------------------------------------- -static void cmScriptGeneratorEncodeConfig(const char* config, +static void cmScriptGeneratorEncodeConfig(const std::string& config, std::string& result) { - for(const char* c = config; *c; ++c) + for(const char* c = config.c_str(); *c; ++c) { if(*c >= 'a' && *c <= 'z') { @@ -73,12 +73,12 @@ static void cmScriptGeneratorEncodeConfig(const char* config, //---------------------------------------------------------------------------- std::string -cmScriptGenerator::CreateConfigTest(const char* config) +cmScriptGenerator::CreateConfigTest(const std::string& config) { std::string result = "\"${"; result += this->RuntimeConfigVariable; result += "}\" MATCHES \"^("; - if(config && *config) + if(!config.empty()) { cmScriptGeneratorEncodeConfig(config, result); } @@ -99,7 +99,7 @@ cmScriptGenerator::CreateConfigTest(std::vector<std::string> const& configs) { result += sep; sep = "|"; - cmScriptGeneratorEncodeConfig(ci->c_str(), result); + cmScriptGeneratorEncodeConfig(*ci, result); } result += ")$\""; return result; @@ -142,14 +142,15 @@ void cmScriptGenerator::GenerateScriptActions(std::ostream& os, } //---------------------------------------------------------------------------- -void cmScriptGenerator::GenerateScriptForConfig(std::ostream&, const char*, +void cmScriptGenerator::GenerateScriptForConfig(std::ostream&, + const std::string&, Indent const&) { // No actions for this generator. } //---------------------------------------------------------------------------- -bool cmScriptGenerator::GeneratesForConfig(const char* config) +bool cmScriptGenerator::GeneratesForConfig(const std::string& config) { // If this is not a configuration-specific rule then we install. if(this->Configurations.empty()) @@ -159,7 +160,7 @@ bool cmScriptGenerator::GeneratesForConfig(const char* config) // This is a configuration-specific rule. Check if the config // matches this rule. - std::string config_upper = cmSystemTools::UpperCase(config?config:""); + std::string config_upper = cmSystemTools::UpperCase(config); for(std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index 8b2ca33..9ab04f1 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -47,11 +47,11 @@ inline std::ostream& operator<<(std::ostream& os, class cmScriptGenerator { public: - cmScriptGenerator(const char* config_var, + cmScriptGenerator(const std::string& config_var, std::vector<std::string> const& configurations); virtual ~cmScriptGenerator(); - void Generate(std::ostream& os, const char* config, + void Generate(std::ostream& os, const std::string& config, std::vector<std::string> const& configurationTypes); const std::vector<std::string>& GetConfigurations() const @@ -63,15 +63,15 @@ protected: virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent); virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); virtual void GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent); virtual void GenerateScriptNoConfig(std::ostream&, Indent const&) {} virtual bool NeedsScriptNoConfig() const { return false; } // Test if this generator does something for a given configuration. - bool GeneratesForConfig(const char*); + bool GeneratesForConfig(const std::string&); - std::string CreateConfigTest(const char* config); + std::string CreateConfigTest(const std::string& config); std::string CreateConfigTest(std::vector<std::string> const& configs); std::string CreateComponentTest(const char* component); @@ -80,7 +80,7 @@ protected: std::vector<std::string> const Configurations; // Information used during generation. - const char* ConfigurationName; + std::string ConfigurationName; std::vector<std::string> const* ConfigurationTypes; // True if the subclass needs to generate an explicit rule for each diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx index 6f62091..1ee3f29 100644 --- a/Source/cmSeparateArgumentsCommand.cxx +++ b/Source/cmSeparateArgumentsCommand.cxx @@ -53,7 +53,7 @@ bool cmSeparateArgumentsCommand { cmOStringStream e; e << "given unknown argument " << args[i]; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -61,11 +61,11 @@ bool cmSeparateArgumentsCommand if(mode == ModeOld) { // Original space-replacement version of command. - if(const char* def = this->Makefile->GetDefinition(var.c_str())) + if(const char* def = this->Makefile->GetDefinition(var)) { std::string value = def; cmSystemTools::ReplaceString(value, " ", ";"); - this->Makefile->AddDefinition(var.c_str(), value.c_str()); + this->Makefile->AddDefinition(var, value.c_str()); } } else @@ -102,7 +102,7 @@ bool cmSeparateArgumentsCommand value += *si; } } - this->Makefile->AddDefinition(var.c_str(), value.c_str()); + this->Makefile->AddDefinition(var, value.c_str()); } return true; diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index ce02360..a527ae7 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "separate_arguments";} + virtual std::string GetName() const {return "separate_arguments";} cmTypeMacro(cmSeparateArgumentsCommand, cmCommand); }; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 36363a1..0ca36eb 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -59,7 +59,7 @@ bool cmSetCommand // SET (VAR) // Removes the definition of VAR. if (args.size() == 1) { - this->Makefile->RemoveDefinition(args[0].c_str()); + this->Makefile->RemoveDefinition(args[0]); return true; } // SET (VAR PARENT_SCOPE) // Removes the definition of VAR diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index 6cef0a0..4adc2d9 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "set";} + virtual std::string GetName() const {return "set";} cmTypeMacro(cmSetCommand, cmCommand); }; diff --git a/Source/cmSetDirectoryPropertiesCommand.cxx b/Source/cmSetDirectoryPropertiesCommand.cxx index 62c9b87..3d4b7a9 100644 --- a/Source/cmSetDirectoryPropertiesCommand.cxx +++ b/Source/cmSetDirectoryPropertiesCommand.cxx @@ -30,7 +30,7 @@ bool cmSetDirectoryPropertiesCommand args.end(), errors); if (!ret) { - this->SetError(errors.c_str()); + this->SetError(errors); } return ret; } @@ -62,7 +62,7 @@ bool cmSetDirectoryPropertiesCommand "Commands and macros cannot be set using SET_CMAKE_PROPERTIES"; return false; } - mf->SetProperty(prop.c_str(), value.c_str()); + mf->SetProperty(prop, value.c_str()); } return true; diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h index 6240598..f444a1b 100644 --- a/Source/cmSetDirectoryPropertiesCommand.h +++ b/Source/cmSetDirectoryPropertiesCommand.h @@ -37,7 +37,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_directory_properties";} + virtual std::string GetName() const { return "set_directory_properties";} /** * Static entry point for use by other commands diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 1a6f1d6..5f970f8 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -66,7 +66,7 @@ bool cmSetPropertyCommand cmOStringStream e; e << "given invalid scope " << *arg << ". " << "Valid scopes are GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, CACHE."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } @@ -114,7 +114,7 @@ bool cmSetPropertyCommand { cmOStringStream e; e << "given invalid argument \"" << *arg << "\"."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -203,7 +203,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() // Lookup the generator. if(cmLocalGenerator* lg = (this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str()))) + ->GetGlobalGenerator()->FindLocalGenerator(dir))) { // Use the makefile for the directory found. mf = lg->GetMakefile(); @@ -241,7 +241,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() //---------------------------------------------------------------------------- bool cmSetPropertyCommand::HandleTargetMode() { - for(std::set<cmStdString>::const_iterator ni = this->Names.begin(); + for(std::set<std::string>::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { if (this->Makefile->IsAlias(*ni)) @@ -262,7 +262,7 @@ bool cmSetPropertyCommand::HandleTargetMode() cmOStringStream e; e << "could not find TARGET " << *ni << ". Perhaps it has not yet been created."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -297,11 +297,11 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target) //---------------------------------------------------------------------------- bool cmSetPropertyCommand::HandleSourceMode() { - for(std::set<cmStdString>::const_iterator ni = this->Names.begin(); + for(std::set<std::string>::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { // Get the source file. - if(cmSourceFile* sf = this->Makefile->GetOrCreateSource(ni->c_str())) + if(cmSourceFile* sf = this->Makefile->GetOrCreateSource(*ni)) { if(!this->HandleSource(sf)) { @@ -312,7 +312,7 @@ bool cmSetPropertyCommand::HandleSourceMode() { cmOStringStream e; e << "given SOURCE name that could not be found or created: " << *ni; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -345,13 +345,13 @@ bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf) bool cmSetPropertyCommand::HandleTestMode() { // Look for tests with all names given. - std::set<cmStdString>::iterator next; - for(std::set<cmStdString>::iterator ni = this->Names.begin(); + std::set<std::string>::iterator next; + for(std::set<std::string>::iterator ni = this->Names.begin(); ni != this->Names.end(); ni = next) { next = ni; ++next; - if(cmTest* test = this->Makefile->GetTest(ni->c_str())) + if(cmTest* test = this->Makefile->GetTest(*ni)) { if(this->HandleTest(test)) { @@ -369,12 +369,12 @@ bool cmSetPropertyCommand::HandleTestMode() { cmOStringStream e; e << "given TEST names that do not exist:\n"; - for(std::set<cmStdString>::const_iterator ni = this->Names.begin(); + for(std::set<std::string>::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { e << " " << *ni << "\n"; } - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } return true; @@ -414,7 +414,7 @@ bool cmSetPropertyCommand::HandleCacheMode() cmOStringStream e; e << "given non-boolean value \"" << this->PropertyValue << "\" for CACHE property \"ADVANCED\". "; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -424,7 +424,7 @@ bool cmSetPropertyCommand::HandleCacheMode() { cmOStringStream e; e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\""; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } @@ -436,11 +436,11 @@ bool cmSetPropertyCommand::HandleCacheMode() e << "given invalid CACHE property " << this->PropertyName << ". " << "Settable CACHE properties are: " << "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } - for(std::set<cmStdString>::const_iterator ni = this->Names.begin(); + for(std::set<std::string>::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { // Get the source file. @@ -460,7 +460,7 @@ bool cmSetPropertyCommand::HandleCacheMode() cmOStringStream e; e << "could not find CACHE variable " << *ni << ". Perhaps it has not yet been created."; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } } diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index 5470314..eaa0233 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -34,7 +34,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_property";} + virtual std::string GetName() const { return "set_property";} /** * This determines if the command is invoked when in script mode. @@ -44,7 +44,7 @@ public: cmTypeMacro(cmSetPropertyCommand, cmCommand); private: - std::set<cmStdString> Names; + std::set<std::string> Names; std::string PropertyName; std::string PropertyValue; bool Remove; diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 619dfc5..19c6819 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.cxx +++ b/Source/cmSetSourceFilesPropertiesCommand.cxx @@ -51,7 +51,7 @@ bool cmSetSourceFilesPropertiesCommand args.end(), errors); if (!ret) { - this->SetError(errors.c_str()); + this->SetError(errors); } return ret; } @@ -154,14 +154,14 @@ bool cmSetSourceFilesPropertiesCommand { // get the source file cmSourceFile* sf = - mf->GetOrCreateSource(j->c_str(), generated); + mf->GetOrCreateSource(*j, generated); if(sf) { // now loop through all the props and set them unsigned int k; for (k = 0; k < propertyPairs.size(); k = k + 2) { - sf->SetProperty(propertyPairs[k].c_str(),propertyPairs[k+1].c_str()); + sf->SetProperty(propertyPairs[k],propertyPairs[k+1].c_str()); } } } diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h index 8541a96..5fa5a3a 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.h +++ b/Source/cmSetSourceFilesPropertiesCommand.h @@ -32,7 +32,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_source_files_properties";} + virtual std::string GetName() const { return "set_source_files_properties";} cmTypeMacro(cmSetSourceFilesPropertiesCommand, cmCommand); diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index dab4180..bf3519c 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -78,12 +78,12 @@ bool cmSetTargetPropertiesCommand return false; } bool ret = cmSetTargetPropertiesCommand::SetOneTarget - (args[i].c_str(),propertyPairs,this->Makefile); + (args[i],propertyPairs,this->Makefile); if (!ret) { std::string message = "Can not find target to add properties to: "; message += args[i]; - this->SetError(message.c_str()); + this->SetError(message); return false; } } @@ -91,7 +91,7 @@ bool cmSetTargetPropertiesCommand } bool cmSetTargetPropertiesCommand -::SetOneTarget(const char *tname, +::SetOneTarget(const std::string& tname, std::vector<std::string> &propertyPairs, cmMakefile *mf) { @@ -101,9 +101,9 @@ bool cmSetTargetPropertiesCommand unsigned int k; for (k = 0; k < propertyPairs.size(); k = k + 2) { - target->SetProperty(propertyPairs[k].c_str(), + target->SetProperty(propertyPairs[k], propertyPairs[k+1].c_str()); - target->CheckProperty(propertyPairs[k].c_str(), mf); + target->CheckProperty(propertyPairs[k], mf); } } // if file is not already in the makefile, then add it diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 6221a18..3981ef3 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -32,12 +32,12 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_target_properties";} + virtual std::string GetName() const { return "set_target_properties";} /** * Used by this command and cmSetPropertiesCommand */ - static bool SetOneTarget(const char *tname, + static bool SetOneTarget(const std::string& tname, std::vector<std::string> &propertyPairs, cmMakefile *mf); diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index 3d52cf2..b026ff3 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -76,12 +76,12 @@ bool cmSetTestsPropertiesCommand { std::string errors; bool ret = - cmSetTestsPropertiesCommand::SetOneTest(args[i].c_str(), + cmSetTestsPropertiesCommand::SetOneTest(args[i], propertyPairs, this->Makefile, errors); if (!ret) { - this->SetError(errors.c_str()); + this->SetError(errors); return ret; } } @@ -91,7 +91,7 @@ bool cmSetTestsPropertiesCommand bool cmSetTestsPropertiesCommand -::SetOneTest(const char *tname, +::SetOneTest(const std::string& tname, std::vector<std::string> &propertyPairs, cmMakefile *mf, std::string &errors) { @@ -101,7 +101,7 @@ bool cmSetTestsPropertiesCommand unsigned int k; for (k = 0; k < propertyPairs.size(); k = k + 2) { - test->SetProperty(propertyPairs[k].c_str(), + test->SetProperty(propertyPairs[k], propertyPairs[k+1].c_str()); } } diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index 9e85495..dabe944 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -32,11 +32,11 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "set_tests_properties";} + virtual std::string GetName() const { return "set_tests_properties";} cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand); - static bool SetOneTest(const char *tname, + static bool SetOneTest(const std::string& tname, std::vector<std::string> &propertyPairs, cmMakefile *mf, std::string &errors); diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 2bdd1ad..e61caab 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -31,7 +31,7 @@ bool cmSiteNameCommand paths.push_back("/usr/local/bin"); const char* cacheValue - = this->Makefile->GetDefinition(args[0].c_str()); + = this->Makefile->GetDefinition(args[0]); if(cacheValue) { return true; @@ -85,7 +85,7 @@ bool cmSiteNameCommand } #endif this->Makefile-> - AddCacheDefinition(args[0].c_str(), + AddCacheDefinition(args[0], siteName.c_str(), "Name of the computer/site where compile is being run", cmCacheManager::STRING); diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h index eb9d4d8..ec63ef8 100644 --- a/Source/cmSiteNameCommand.h +++ b/Source/cmSiteNameCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "site_name";} + virtual std::string GetName() const {return "site_name";} cmTypeMacro(cmSiteNameCommand, cmCommand); }; diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 23422a2..b9b6251 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -18,7 +18,7 @@ #include "cmake.h" //---------------------------------------------------------------------------- -cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name): +cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name): Location(mf, name) { this->CustomCommand = 0; @@ -39,7 +39,7 @@ std::string const& cmSourceFile::GetExtension() const } //---------------------------------------------------------------------------- -const char* cmSourceFile::GetLanguage() +std::string cmSourceFile::GetLanguage() { // If the language was set explicitly by the user then use it. if(const char* lang = this->GetProperty("LANGUAGE")) @@ -76,7 +76,7 @@ const char* cmSourceFile::GetLanguage() } //---------------------------------------------------------------------------- -const char* cmSourceFile::GetLanguage() const +std::string cmSourceFile::GetLanguage() const { // If the language was set explicitly by the user then use it. if(const char* lang = this->GetProperty("LANGUAGE")) @@ -87,11 +87,11 @@ const char* cmSourceFile::GetLanguage() const // If the language was determined from the source file extension use it. if(!this->Language.empty()) { - return this->Language.c_str(); + return this->Language; } // The language is not known. - return 0; + return ""; } //---------------------------------------------------------------------------- @@ -164,14 +164,14 @@ bool cmSourceFile::FindFullPath(std::string* error) } tryPath += this->Location.GetName(); tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str(), *di); - if(this->TryFullPath(tryPath.c_str(), 0)) + if(this->TryFullPath(tryPath, "")) { return true; } for(std::vector<std::string>::const_iterator ei = srcExts.begin(); ei != srcExts.end(); ++ei) { - if(this->TryFullPath(tryPath.c_str(), ei->c_str())) + if(this->TryFullPath(tryPath, *ei)) { return true; } @@ -179,7 +179,7 @@ bool cmSourceFile::FindFullPath(std::string* error) for(std::vector<std::string>::const_iterator ei = hdrExts.begin(); ei != hdrExts.end(); ++ei) { - if(this->TryFullPath(tryPath.c_str(), ei->c_str())) + if(this->TryFullPath(tryPath, *ei)) { return true; } @@ -217,10 +217,11 @@ bool cmSourceFile::FindFullPath(std::string* error) } //---------------------------------------------------------------------------- -bool cmSourceFile::TryFullPath(const char* tp, const char* ext) +bool cmSourceFile::TryFullPath(const std::string& path, + const std::string& ext) { - std::string tryPath = tp; - if(ext && *ext) + std::string tryPath = path; + if(!ext.empty()) { tryPath += "."; tryPath += ext; @@ -266,7 +267,8 @@ void cmSourceFile::CheckLanguage(std::string const& ext) // Try to identify the source file language from the extension. cmMakefile const* mf = this->Location.GetMakefile(); cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator(); - if(const char* l = gg->GetLanguageFromExtension(ext.c_str())) + std::string l = gg->GetLanguageFromExtension(ext.c_str()); + if(!l.empty()) { this->Language = l; } @@ -279,13 +281,8 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc) } //---------------------------------------------------------------------------- -void cmSourceFile::SetProperty(const char* prop, const char* value) +void cmSourceFile::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } - this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE); std::string ext = @@ -293,7 +290,7 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) if (ext == ".ui") { cmMakefile const* mf = this->Location.GetMakefile(); - if (strcmp(prop, "AUTOUIC_OPTIONS") == 0) + if (prop == "AUTOUIC_OPTIONS") { const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this); } @@ -301,19 +298,15 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmSourceFile::AppendProperty(const char* prop, const char* value, +void cmSourceFile::AppendProperty(const std::string& prop, const char* value, bool asString) { - if (!prop) - { - return; - } this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE, asString); } //---------------------------------------------------------------------------- -const char* cmSourceFile::GetPropertyForUser(const char *prop) +const char* cmSourceFile::GetPropertyForUser(const std::string& prop) { // This method is a consequence of design history and backwards // compatibility. GetProperty is (and should be) a const method. @@ -329,7 +322,7 @@ const char* cmSourceFile::GetPropertyForUser(const char *prop) // cmSourceFileLocation class to commit to a particular full path to // the source file as late as possible. If the users requests the // LOCATION property we must commit now. - if(strcmp(prop, "LOCATION") == 0) + if(prop == "LOCATION") { // Commit to a location. this->GetFullPath(); @@ -340,10 +333,10 @@ const char* cmSourceFile::GetPropertyForUser(const char *prop) } //---------------------------------------------------------------------------- -const char* cmSourceFile::GetProperty(const char* prop) const +const char* cmSourceFile::GetProperty(const std::string& prop) const { // Check for computed properties. - if(strcmp(prop, "LOCATION") == 0) + if(prop == "LOCATION") { if(this->FullPath.empty()) { @@ -368,7 +361,7 @@ const char* cmSourceFile::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -bool cmSourceFile::GetPropertyAsBool(const char* prop) const +bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 4440b05..17c96ac 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -31,7 +31,7 @@ public: * Construct with the makefile storing the source and the initial * name referencing it. */ - cmSourceFile(cmMakefile* mf, const char* name); + cmSourceFile(cmMakefile* mf, const std::string& name); ~cmSourceFile(); @@ -43,14 +43,15 @@ public: void SetCustomCommand(cmCustomCommand *cc); ///! Set/Get a property of this source file - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value,bool asString=false); - const char *GetProperty(const char *prop) const; - bool GetPropertyAsBool(const char *prop) const; + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, + const char* value,bool asString=false); + const char *GetProperty(const std::string& prop) const; + bool GetPropertyAsBool(const std::string& prop) const; /** Implement getting a property when called from a CMake language command like get_property or get_source_file_property. */ - const char* GetPropertyForUser(const char *prop); + const char* GetPropertyForUser(const std::string& prop); /** * The full path to the file. The non-const version of this method @@ -78,8 +79,8 @@ public: /** * Get the language of the compiler to use for this source file. */ - const char* GetLanguage(); - const char* GetLanguage() const; + std::string GetLanguage(); + std::string GetLanguage() const; /** * Return the vector that holds the list of dependencies @@ -106,7 +107,7 @@ private: bool FindFullPathFailed; bool FindFullPath(std::string* error); - bool TryFullPath(const char* tryPath, const char* ext); + bool TryFullPath(const std::string& path, const std::string& ext); void CheckExtension(); void CheckLanguage(std::string const& ext); diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 5a8578b..30a53cb 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -18,9 +18,10 @@ //---------------------------------------------------------------------------- cmSourceFileLocation -::cmSourceFileLocation(cmMakefile const* mf, const char* name): Makefile(mf) +::cmSourceFileLocation(cmMakefile const* mf, const std::string& name) + : Makefile(mf) { - this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name); + this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str()); this->AmbiguousExtension = true; this->Directory = cmSystemTools::GetFilenamePath(name); this->Name = cmSystemTools::GetFilenameName(name); @@ -28,7 +29,7 @@ cmSourceFileLocation } //---------------------------------------------------------------------------- -void cmSourceFileLocation::Update(const char* name) +void cmSourceFileLocation::Update(const std::string& name) { if(this->AmbiguousDirectory) { @@ -80,7 +81,7 @@ void cmSourceFileLocation::DirectoryUseBinary() } //---------------------------------------------------------------------------- -void cmSourceFileLocation::UpdateExtension(const char* name) +void cmSourceFileLocation::UpdateExtension(const std::string& name) { // Check the extension. std::string ext = cmSystemTools::GetFilenameLastExtension(name); @@ -92,7 +93,7 @@ void cmSourceFileLocation::UpdateExtension(const char* name) cmMakefile const* mf = this->Makefile; const std::vector<std::string>& srcExts = mf->GetSourceExtensions(); const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions(); - if(gg->GetLanguageFromExtension(ext.c_str()) || + if(!gg->GetLanguageFromExtension(ext.c_str()).empty() || std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() || std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end()) { @@ -136,10 +137,10 @@ void cmSourceFileLocation::UpdateExtension(const char* name) } //---------------------------------------------------------------------------- -void cmSourceFileLocation::UpdateDirectory(const char* name) +void cmSourceFileLocation::UpdateDirectory(const std::string& name) { // If a full path was given we know the directory. - if(cmSystemTools::FileIsFullPath(name)) + if(cmSystemTools::FileIsFullPath(name.c_str())) { this->Directory = cmSystemTools::GetFilenamePath(name); this->AmbiguousDirectory = false; diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index c03eee7..c83e8c0 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -33,7 +33,7 @@ public: * Construct for a source file created in a given cmMakefile * instance with an initial name. */ - cmSourceFileLocation(cmMakefile const* mf, const char* name); + cmSourceFileLocation(cmMakefile const* mf, const std::string& name); /** * Return whether the givne source file location could refers to the @@ -76,7 +76,7 @@ public: * final name (but could be). Otherwise the returned name is the * final name. */ - const char* GetName() const { return this->Name.c_str(); } + const std::string& GetName() const { return this->Name; } /** * Get the cmMakefile instance for which the source file was created. @@ -93,9 +93,9 @@ private: // Update the location with additional knowledge. void Update(cmSourceFileLocation const& loc); - void Update(const char* name); - void UpdateExtension(const char* name); - void UpdateDirectory(const char* name); + void Update(const std::string& name); + void UpdateExtension(const std::string& name); + void UpdateDirectory(const std::string& name); }; #endif diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index d272b6c..8fed95e 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -73,7 +73,7 @@ void cmSourceGroup::SetGroupRegex(const char* regex) } //---------------------------------------------------------------------------- -void cmSourceGroup::AddGroupFile(const char* name) +void cmSourceGroup::AddGroupFile(const std::string& name) { this->GroupFiles.insert(name); } @@ -99,7 +99,7 @@ bool cmSourceGroup::MatchesRegex(const char* name) //---------------------------------------------------------------------------- bool cmSourceGroup::MatchesFiles(const char* name) { - std::set<cmStdString>::const_iterator i = this->GroupFiles.find(name); + std::set<std::string>::const_iterator i = this->GroupFiles.find(name); if(i != this->GroupFiles.end()) { return true; diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 3bbdef9..e8cf519 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -46,7 +46,7 @@ public: /** * Add a file name to the explicit list of files for this group. */ - void AddGroupFile(const char* name); + void AddGroupFile(const std::string& name); /** * Add child to this sourcegroup @@ -118,7 +118,7 @@ private: /** * Set of file names explicitly added to this group. */ - std::set<cmStdString> GroupFiles; + std::set<std::string> GroupFiles; /** * Vector of all source files that have been assigned to diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 9cb80f6..edba5ba 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -78,7 +78,7 @@ bool cmSourceGroupCommand else if(doingFiles) { // Convert name to full path and add to the group's list. - std::string src = args[i].c_str(); + std::string src = args[i]; if(!cmSystemTools::FileIsFullPath(src.c_str())) { src = this->Makefile->GetCurrentDirectory(); @@ -86,14 +86,14 @@ bool cmSourceGroupCommand src += args[i]; } src = cmSystemTools::CollapseFullPath(src.c_str()); - sg->AddGroupFile(src.c_str()); + sg->AddGroupFile(src); } else { cmOStringStream err; - err << "Unknown argument \"" << args[i].c_str() << "\". " + err << "Unknown argument \"" << args[i] << "\". " << "Perhaps the FILES keyword is missing.\n"; - this->SetError(err.str().c_str()); + this->SetError(err.str()); return false; } } diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 5d8b48c..410411b 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -41,7 +41,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "source_group";} + virtual std::string GetName() const {return "source_group";} cmTypeMacro(cmSourceGroupCommand, cmCommand); }; diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index b4ae657..ed8efcc 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -241,7 +241,7 @@ inline bool operator==(std::string const& a, const char* b) // std::string is really basic_string<....lots of stuff....> // when combined with a map or set, the symbols can be > 2000 chars! #include <cmsys/String.hxx> -typedef cmsys::String cmStdString; +//typedef cmsys::String std::string; // Define cmOStringStream and cmIStringStream wrappers to hide // differences between std::stringstream and the old strstream. @@ -449,11 +449,16 @@ bool cmHasLiteralSuffix(T str1, const char (&str2)[N]) struct cmStrCmp { cmStrCmp(const char *test) : m_test(test) {} - cmStrCmp(std::string &test) : m_test(test.c_str()) {} + cmStrCmp(const std::string &test) : m_test(test) {} + + bool operator()(const std::string& input) const + { + return m_test == input; + } bool operator()(const char * input) const { - return strcmp(input, m_test) == 0; + return strcmp(input, m_test.c_str()) == 0; } // For use with binary_search @@ -463,7 +468,7 @@ struct cmStrCmp { } private: - const char * const m_test; + const std::string m_test; }; #endif diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index f9b69e3..7bc7b05 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -103,7 +103,7 @@ bool cmStringCommand } std::string e = "does not recognize sub-command "+subCommand; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -115,15 +115,15 @@ bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args) { cmOStringStream e; e << args[0] << " requires an output variable and an input string"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; } cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str())); if(hash.get()) { - std::string out = hash->HashString(args[2].c_str()); - this->Makefile->AddDefinition(args[1].c_str(), out.c_str()); + std::string out = hash->HashString(args[2]); + this->Makefile->AddDefinition(args[1], out.c_str()); return true; } return false; @@ -158,7 +158,7 @@ bool cmStringCommand::HandleToUpperLowerCommand( } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -185,12 +185,12 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args) std::string error = "Character with code "; error += args[cc]; error += " does not exist."; - this->SetError(error.c_str()); + this->SetError(error); return false; } } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -226,7 +226,7 @@ bool cmStringCommand::HandleConfigureCommand( { cmOStringStream err; err << "Unrecognized argument \"" << args[i] << "\""; - this->SetError(err.str().c_str()); + this->SetError(err.str()); return false; } } @@ -236,7 +236,7 @@ bool cmStringCommand::HandleConfigureCommand( this->Makefile->ConfigureString(args[1], output, atOnly, escapeQuotes); // Store the output in the provided variable. - this->Makefile->AddDefinition(args[2].c_str(), output.c_str()); + this->Makefile->AddDefinition(args[2], output.c_str()); return true; } @@ -282,7 +282,7 @@ bool cmStringCommand::HandleRegexCommand(std::vector<std::string> const& args) } std::string e = "sub-command REGEX does not recognize mode "+mode; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -308,7 +308,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) { std::string e = "sub-command REGEX, mode MATCH failed to compile regex \""+regex+"\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -324,14 +324,14 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) std::string e = "sub-command REGEX, mode MATCH regex \""+regex+ "\" matched an empty string."; - this->SetError(e.c_str()); + this->SetError(e); return false; } output = input.substr(l, r-l); } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -358,7 +358,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) std::string e = "sub-command REGEX, mode MATCHALL failed to compile regex \""+ regex+"\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -374,7 +374,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) { std::string e = "sub-command REGEX, mode MATCHALL regex \""+ regex+"\" matched an empty string."; - this->SetError(e.c_str()); + this->SetError(e); return false; } if(output.length() > 0) @@ -386,7 +386,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) } // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -439,7 +439,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) std::string e = "sub-command REGEX, mode REPLACE: Unknown escape \""; e += replace.substr(r, 2); e += "\" in replace-expression."; - this->SetError(e.c_str()); + this->SetError(e); return false; } r += 2; @@ -462,7 +462,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) std::string e = "sub-command REGEX, mode REPLACE failed to compile regex \""+ regex+"\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -483,7 +483,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) { std::string e = "sub-command REGEX, mode REPLACE regex \""+ regex+"\" matched an empty string."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -513,7 +513,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) "sub-command REGEX, mode REPLACE: replace expression \""+ replace+"\" contains an out-of-range escape for regex \""+ regex+"\"."; - this->SetError(e.c_str()); + this->SetError(e); return false; } } @@ -527,7 +527,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) output += input.substr(base, input.length()-base); // Store the output in the provided variable. - this->Makefile->AddDefinition(outvar.c_str(), output.c_str()); + this->Makefile->AddDefinition(outvar, output.c_str()); return true; } @@ -616,12 +616,12 @@ bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& { cmOStringStream s; s << pos; - this->Makefile->AddDefinition(outvar.c_str(), s.str().c_str()); + this->Makefile->AddDefinition(outvar, s.str().c_str()); return true; } // the character was not found, but this is not really an error - this->Makefile->AddDefinition(outvar.c_str(), "-1"); + this->Makefile->AddDefinition(outvar, "-1"); return true; } @@ -643,7 +643,7 @@ bool cmStringCommand::HandleCompareCommand(std::vector<std::string> const& std::string e = "sub-command COMPARE, mode "; e += mode; e += " needs at least 5 arguments total to command."; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -669,16 +669,16 @@ bool cmStringCommand::HandleCompareCommand(std::vector<std::string> const& } if(result) { - this->Makefile->AddDefinition(outvar.c_str(), "1"); + this->Makefile->AddDefinition(outvar, "1"); } else { - this->Makefile->AddDefinition(outvar.c_str(), "0"); + this->Makefile->AddDefinition(outvar, "0"); } return true; } std::string e = "sub-command COMPARE does not recognize mode "+mode; - this->SetError(e.c_str()); + this->SetError(e); return false; } @@ -705,7 +705,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const& cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(), replaceExpression.c_str()); - this->Makefile->AddDefinition(variableName.c_str(), input.c_str()); + this->Makefile->AddDefinition(variableName, input.c_str()); return true; } @@ -731,7 +731,7 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const& cmOStringStream ostr; ostr << "begin index: " << begin << " is out of range 0 - " << stringLength; - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return false; } int leftOverLength = intStringLength - begin; @@ -740,11 +740,11 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const& cmOStringStream ostr; ostr << "end index: " << end << " is out of range -1 - " << leftOverLength; - this->SetError(ostr.str().c_str()); + this->SetError(ostr.str()); return false; } - this->Makefile->AddDefinition(variableName.c_str(), + this->Makefile->AddDefinition(variableName, stringValue.substr(begin, end).c_str()); return true; } @@ -766,7 +766,7 @@ bool cmStringCommand char buffer[1024]; sprintf(buffer, "%d", static_cast<int>(length)); - this->Makefile->AddDefinition(variableName.c_str(), buffer); + this->Makefile->AddDefinition(variableName, buffer); return true; } @@ -787,7 +787,7 @@ bool cmStringCommand value += args[i]; } - this->Makefile->AddDefinition(variableName.c_str(), value.c_str()); + this->Makefile->AddDefinition(variableName, value.c_str()); return true; } @@ -804,7 +804,7 @@ bool cmStringCommand const std::string& input = args[1]; const std::string& variableName = args[2]; - this->Makefile->AddDefinition(variableName.c_str(), + this->Makefile->AddDefinition(variableName, cmSystemTools::MakeCidentifier(input.c_str()).c_str()); return true; } @@ -853,7 +853,7 @@ bool cmStringCommand::HandleStripCommand( outLength=endPos - startPos + 1; } - this->Makefile->AddDefinition(variableName.c_str(), + this->Makefile->AddDefinition(variableName, stringValue.substr(startPos, outLength).c_str()); return true; } @@ -937,7 +937,7 @@ bool cmStringCommand } result.push_back(0); - this->Makefile->AddDefinition(variableName.c_str(), &*result.begin()); + this->Makefile->AddDefinition(variableName, &*result.begin()); return true; } @@ -977,14 +977,14 @@ bool cmStringCommand { std::string e = " TIMESTAMP sub-command does not recognize option " + args[argsIndex] + "."; - this->SetError(e.c_str()); + this->SetError(e); return false; } } cmTimestamp timestamp; std::string result = timestamp.CurrentTime(formatString, utcFlag); - this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str()); + this->Makefile->AddDefinition(outputVariable, result.c_str()); return true; } diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 66b48e6..b8053c5 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -50,7 +50,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "string";} + virtual std::string GetName() const { return "string";} cmTypeMacro(cmStringCommand, cmCommand); static void ClearMatches(cmMakefile* mf); diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index e497b46..cdde916 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -47,7 +47,7 @@ bool cmSubdirCommand std::string binPath = std::string(this->Makefile->GetCurrentOutputDirectory()) + "/" + i->c_str(); - this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(), + this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, preorder, false); } // otherwise it is a full path @@ -57,15 +57,15 @@ bool cmSubdirCommand // element from the source path and use that std::string binPath = std::string(this->Makefile->GetCurrentOutputDirectory()) + - "/" + cmSystemTools::GetFilenameName(i->c_str()); - this->Makefile->AddSubDirectory(i->c_str(), binPath.c_str(), + "/" + cmSystemTools::GetFilenameName(*i); + this->Makefile->AddSubDirectory(*i, binPath, excludeFromAll, preorder, false); } else { std::string error = "Incorrect SUBDIRS command. Directory: "; error += *i + " does not exist."; - this->SetError(error.c_str()); + this->SetError(error); res = false; } } diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h index 8be8335..6addd8f 100644 --- a/Source/cmSubdirCommand.h +++ b/Source/cmSubdirCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "subdirs";} + virtual std::string GetName() const { return "subdirs";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h index f78cfb7..75a5685 100644 --- a/Source/cmSubdirDependsCommand.h +++ b/Source/cmSubdirDependsCommand.h @@ -20,7 +20,7 @@ public: virtual cmCommand* Clone() { return new cmSubdirDependsCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "subdir_depends";} + virtual std::string GetName() const { return "subdir_depends";} virtual bool IsDiscouraged() const { return true; } cmTypeMacro(cmSubdirDependsCommand, cmCommand); }; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index ff05975..5beb36d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -179,10 +179,11 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64) } #endif -std::string cmSystemTools::EscapeQuotes(const char* str) +std::string cmSystemTools::EscapeQuotes(const std::string& str) { - std::string result = ""; - for(const char* ch = str; *ch != '\0'; ++ch) + std::string result; + result.reserve(str.size()); + for(const char* ch = str.c_str(); *ch != '\0'; ++ch) { if(*ch == '"') { @@ -476,13 +477,6 @@ public: args.push_back(*arg); } } - void Store(std::vector<cmStdString>& args) const - { - for(char** arg = this->ArgV; arg && *arg; ++arg) - { - args.push_back(*arg); - } - } }; //---------------------------------------------------------------------------- @@ -494,15 +488,6 @@ void cmSystemTools::ParseUnixCommandLine(const char* command, argv.Store(args); } -//---------------------------------------------------------------------------- -void cmSystemTools::ParseUnixCommandLine(const char* command, - std::vector<cmStdString>& args) -{ - // Invoke the underlying parser. - cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0); - argv.Store(args); -} - std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg, int shell_flags) { @@ -522,9 +507,9 @@ std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg, return result; } -std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command) +std::vector<std::string> cmSystemTools::ParseArguments(const char* command) { - std::vector<cmStdString> args; + std::vector<std::string> args; std::string arg; bool win_path = false; @@ -605,22 +590,6 @@ std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command) } -bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command, - std::string* output , - int* retVal , const char* dir , - OutputOption outputflag , - double timeout ) -{ - std::vector<std::string> cmd; - for(std::vector<cmStdString>::const_iterator i = command.begin(); - i != command.end(); ++i) - { - cmd.push_back(*i); - } - return cmSystemTools::RunSingleCommand(cmd, output, retVal, dir, - outputflag, timeout); -} - bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, std::string* output , int* retVal , const char* dir , @@ -780,7 +749,7 @@ bool cmSystemTools::RunSingleCommand( outputflag = OUTPUT_NONE; } - std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); + std::vector<std::string> args = cmSystemTools::ParseArguments(command); if(args.size() < 1) { @@ -944,7 +913,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) #endif } -bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) +bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out) { #if defined(CMAKE_BUILD_WITH_CMAKE) cmCryptoHashMD5 md5; @@ -959,7 +928,7 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) #endif } -std::string cmSystemTools::ComputeStringMD5(const char* input) +std::string cmSystemTools::ComputeStringMD5(const std::string& input) { #if defined(CMAKE_BUILD_WITH_CMAKE) cmCryptoHashMD5 md5; @@ -971,13 +940,14 @@ std::string cmSystemTools::ComputeStringMD5(const char* input) #endif } -void cmSystemTools::Glob(const char *directory, const char *regexp, +void cmSystemTools::Glob(const std::string& directory, + const std::string& regexp, std::vector<std::string>& files) { cmsys::Directory d; - cmsys::RegularExpression reg(regexp); + cmsys::RegularExpression reg(regexp.c_str()); - if (d.Load(directory)) + if (d.Load(directory.c_str())) { size_t numf; unsigned int i; @@ -994,14 +964,13 @@ void cmSystemTools::Glob(const char *directory, const char *regexp, } -void cmSystemTools::GlobDirs(const char *fullPath, +void cmSystemTools::GlobDirs(const std::string& path, std::vector<std::string>& files) { - std::string path = fullPath; std::string::size_type pos = path.find("/*"); if(pos == std::string::npos) { - files.push_back(fullPath); + files.push_back(path); return; } std::string startPath = path.substr(0, pos); @@ -1021,7 +990,7 @@ void cmSystemTools::GlobDirs(const char *fullPath, if(cmSystemTools::FileIsDirectory(fname.c_str())) { fname += finishPath; - cmSystemTools::GlobDirs(fname.c_str(), files); + cmSystemTools::GlobDirs(fname, files); } } } @@ -1044,7 +1013,7 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, bool emptyArgs) { // If argument is empty, it is an empty list. - if(arg.length() == 0 && !emptyArgs) + if(!emptyArgs && arg.empty()) { return; } @@ -1054,10 +1023,11 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, newargs.push_back(arg); return; } - std::vector<char> newArgVec; + std::string newArg; + const char *last = arg.c_str(); // Break the string at non-escaped semicolons not nested in []. int squareNesting = 0; - for(const char* c = arg.c_str(); *c; ++c) + for(const char* c = last; *c; ++c) { switch(*c) { @@ -1065,34 +1035,21 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, { // We only want to allow escaping of semicolons. Other // escapes should not be processed here. - ++c; - if(*c == ';') - { - newArgVec.push_back(*c); - } - else + const char* next = c + 1; + if(*next == ';') { - newArgVec.push_back('\\'); - if(*c) - { - newArgVec.push_back(*c); - } - else - { - // Terminate the loop properly. - --c; - } + newArg.append(last, c - last); + // Skip over the escape character + last = c = next; } } break; case '[': { ++squareNesting; - newArgVec.push_back(*c); } break; case ']': { --squareNesting; - newArgVec.push_back(*c); } break; case ';': { @@ -1100,36 +1057,33 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, // brackets. if(squareNesting == 0) { - if ( newArgVec.size() || emptyArgs ) + newArg.append(last, c - last); + // Skip over the semicolon + last = c + 1; + if ( !newArg.empty() || emptyArgs ) { // Add the last argument if the string is not empty. - newArgVec.push_back(0); - newargs.push_back(&*newArgVec.begin()); - newArgVec.clear(); + newargs.push_back(newArg); + newArg = ""; } } - else - { - newArgVec.push_back(*c); - } } break; default: { // Just append this character. - newArgVec.push_back(*c); } break; } } - if ( newArgVec.size() || emptyArgs ) + newArg.append(last); + if ( !newArg.empty() || emptyArgs ) { // Add the last argument if the string is not empty. - newArgVec.push_back(0); - newargs.push_back(&*newArgVec.begin()); + newargs.push_back(newArg); } } -bool cmSystemTools::SimpleGlob(const cmStdString& glob, - std::vector<cmStdString>& files, +bool cmSystemTools::SimpleGlob(const std::string& glob, + std::vector<std::string>& files, int type /* = 0 */) { files.clear(); @@ -1247,7 +1201,7 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) return cmSystemTools::UNKNOWN_FILE_FORMAT; } -bool cmSystemTools::Split(const char* s, std::vector<cmStdString>& l) +bool cmSystemTools::Split(const char* s, std::vector<std::string>& l) { std::vector<std::string> temp; bool res = Superclass::Split(s, temp); @@ -1459,7 +1413,7 @@ bool cmSystemTools::IsPathToFramework(const char* path) } bool cmSystemTools::CreateTar(const char* outFileName, - const std::vector<cmStdString>& files, + const std::vector<std::string>& files, bool gzip, bool bzip2, bool verbose) { #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1479,7 +1433,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, cmArchiveWrite::CompressNone)), cmArchiveWrite::TypeTAR); a.SetVerbose(verbose); - for(std::vector<cmStdString>::const_iterator i = files.begin(); + for(std::vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) { std::string path = *i; @@ -1662,7 +1616,6 @@ long copy_data(struct archive *ar, struct archive *aw) return (r); } } - return r; } bool extract_tar(const char* outFileName, bool verbose, @@ -2151,7 +2104,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) // remove symlinks exe = cmSystemTools::GetRealPath(exe.c_str()); exe_dir = - cmSystemTools::GetFilenamePath(exe.c_str()); + cmSystemTools::GetFilenamePath(exe); } else { @@ -2331,10 +2284,10 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath, bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath, std::string& soname) { - std::vector<cmStdString> cmds; + std::vector<std::string> cmds; cmds.push_back("otool"); cmds.push_back("-D"); - cmds.push_back(fullPath.c_str()); + cmds.push_back(fullPath); std::string output; if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE)) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 4a5d298..27b4bce 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -47,7 +47,7 @@ public: KeyWOW64 view = KeyWOW64_Default); ///! Escape quotes in a string. - static std::string EscapeQuotes(const char* str); + static std::string EscapeQuotes(const std::string& str); /** Map help document name to file name. */ static std::string HelpFileName(std::string); @@ -158,9 +158,10 @@ public: static std::string FileExistsInParentDirectories(const char* fname, const char* directory, const char* toplevel); - static void Glob(const char *directory, const char *regexp, + static void Glob(const std::string& directory, const std::string& regexp, std::vector<std::string>& files); - static void GlobDirs(const char *fullPath, std::vector<std::string>& files); + static void GlobDirs(const std::string& fullPath, + std::vector<std::string>& files); /** * Try to find a list of files that match the "simple" globbing @@ -171,8 +172,8 @@ public: * want to find. 0 means all files, -1 means directories, 1 means * files only. This method returns true if search was succesfull. */ - static bool SimpleGlob(const cmStdString& glob, - std::vector<cmStdString>& files, + static bool SimpleGlob(const std::string& glob, + std::vector<std::string>& files, int type = 0); ///! Copy a file. @@ -185,10 +186,10 @@ public: static bool RenameFile(const char* oldname, const char* newname); ///! Compute the md5sum of a file - static bool ComputeFileMD5(const char* source, char* md5out); + static bool ComputeFileMD5(const std::string& source, char* md5out); /** Compute the md5sum of a string. */ - static std::string ComputeStringMD5(const char* input); + static std::string ComputeStringMD5(const std::string& input); /** * Run a single executable command @@ -233,18 +234,13 @@ public: int* retVal = 0, const char* dir = 0, OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); - static bool RunSingleCommand(std::vector<cmStdString> const& command, - std::string* output = 0, - int* retVal = 0, const char* dir = 0, - OutputOption outputflag = OUTPUT_MERGE, - double timeout = 0.0); static std::string PrintSingleCommand(std::vector<std::string> const&); /** * Parse arguments out of a single string command */ - static std::vector<cmStdString> ParseArguments(const char* command); + static std::vector<std::string> ParseArguments(const char* command); /** Parse arguments out of a windows command line string. */ static void ParseWindowsCommandLine(const char* command, @@ -253,8 +249,6 @@ public: /** Parse arguments out of a unix command line string. */ static void ParseUnixCommandLine(const char* command, std::vector<std::string>& args); - static void ParseUnixCommandLine(const char* command, - std::vector<cmStdString>& args); /** Compute an escaped version of the given argument for use in a windows shell. See kwsys/System.h.in for details. */ @@ -320,7 +314,7 @@ public: /** Split a string on its newlines into multiple lines. Returns false only if the last line stored had no newline. */ - static bool Split(const char* s, std::vector<cmStdString>& l); + static bool Split(const char* s, std::vector<std::string>& l); static void SetForceUnixPaths(bool v) { s_ForceUnixPaths = v; @@ -389,7 +383,7 @@ public: static bool ListTar(const char* outFileName, bool gzip, bool verbose); static bool CreateTar(const char* outFileName, - const std::vector<cmStdString>& files, bool gzip, + const std::vector<std::string>& files, bool gzip, bool bzip2, bool verbose); static bool ExtractTar(const char* inFileName, bool gzip, bool verbose); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e2a568b..32aaccc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -71,6 +71,12 @@ struct cmTarget::ImportInfo cmTarget::LinkInterface LinkInterface; }; +//---------------------------------------------------------------------------- +struct cmTarget::CompileInfo +{ + std::string CompilePdbDir; +}; + struct TargetConfigPair : public std::pair<cmTarget const* , std::string> { TargetConfigPair(cmTarget const* tgt, const std::string &config) : std::pair<cmTarget const* , std::string>(tgt, config) {} @@ -83,17 +89,12 @@ public: cmTargetInternals() { this->PolicyWarnedCMP0022 = false; - this->SourceFileFlagsConstructed = false; } cmTargetInternals(cmTargetInternals const&) { this->PolicyWarnedCMP0022 = false; - this->SourceFileFlagsConstructed = false; } ~cmTargetInternals(); - typedef cmTarget::SourceFileFlags SourceFileFlags; - mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; - mutable bool SourceFileFlagsConstructed; // The backtrace when the target was created. cmListFileBacktrace Backtrace; @@ -101,21 +102,33 @@ public: // Cache link interface computation from each configuration. struct OptionalLinkInterface: public cmTarget::LinkInterface { - OptionalLinkInterface(): Exists(false) {} + OptionalLinkInterface(): + Exists(false), Complete(false), ExplicitLibraries(0) {} bool Exists; + bool Complete; + const char* ExplicitLibraries; }; + void ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* head, + const char *explicitLibraries) const; + typedef std::map<TargetConfigPair, OptionalLinkInterface> LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; bool PolicyWarnedCMP0022; - typedef std::map<cmStdString, cmTarget::OutputInfo> OutputInfoMapType; + typedef std::map<std::string, cmTarget::OutputInfo> OutputInfoMapType; OutputInfoMapType OutputInfoMap; typedef std::map<TargetConfigPair, cmTarget::ImportInfo> ImportInfoMapType; ImportInfoMapType ImportInfoMap; + typedef std::map<std::string, cmTarget::CompileInfo> CompileInfoMapType; + CompileInfoMapType CompileInfoMap; + // Cache link implementation computation from each configuration. typedef std::map<TargetConfigPair, cmTarget::LinkImplementation> LinkImplMapType; @@ -222,7 +235,7 @@ void cmTarget::DefineProperties(cmake *cm) "", "", true); } -void cmTarget::SetType(TargetType type, const char* name) +void cmTarget::SetType(TargetType type, const std::string& name) { this->Name = name; // only add dependency information for library targets @@ -267,6 +280,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("Fortran_FORMAT", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("GNUtoMS", 0); @@ -295,6 +309,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) "LIBRARY_OUTPUT_DIRECTORY_", "RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_", + "COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_", 0}; for(std::vector<std::string>::iterator ci = configNames.begin(); @@ -310,7 +325,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) } std::string property = *p; property += configUpper; - this->SetPropertyDefault(property.c_str(), 0); + this->SetPropertyDefault(property, 0); } // Initialize per-configuration name postfix property from the @@ -323,7 +338,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) { std::string property = cmSystemTools::UpperCase(*ci); property += "_POSTFIX"; - this->SetPropertyDefault(property.c_str(), 0); + this->SetPropertyDefault(property, 0); } } @@ -342,10 +357,10 @@ void cmTarget::SetMakefile(cmMakefile* mf) { this->InsertInclude(*it); } - const std::set<cmStdString> parentSystemIncludes = + const std::set<std::string> parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); - for (std::set<cmStdString>::const_iterator it + for (std::set<std::string>::const_iterator it = parentSystemIncludes.begin(); it != parentSystemIncludes.end(); ++it) { @@ -401,7 +416,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) } //---------------------------------------------------------------------------- -void cmTarget::AddUtility(const char *u, cmMakefile *makefile) +void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { if(this->Utilities.insert(u).second && makefile) { @@ -410,9 +425,10 @@ void cmTarget::AddUtility(const char *u, cmMakefile *makefile) } //---------------------------------------------------------------------------- -cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const +cmListFileBacktrace const* cmTarget::GetUtilityBacktrace( + const std::string& u) const { - std::map<cmStdString, cmListFileBacktrace>::const_iterator i = + std::map<std::string, cmListFileBacktrace>::const_iterator i = this->UtilityBacktraces.find(u); if(i == this->UtilityBacktraces.end()) return 0; @@ -526,10 +542,11 @@ bool cmTarget::IsBundleOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::FindSourceFiles() +void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const { + assert(this->GetType() != INTERFACE_LIBRARY); for(std::vector<cmSourceFile*>::const_iterator - si = this->SourceFiles.begin(); + si = this->SourceFiles.begin(); si != this->SourceFiles.end(); ++si) { std::string e; @@ -541,16 +558,9 @@ bool cmTarget::FindSourceFiles() cm->IssueMessage(cmake::FATAL_ERROR, e, this->GetBacktrace()); } - return false; + return; } } - return true; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const -{ - assert(this->GetType() != INTERFACE_LIBRARY); files = this->SourceFiles; } @@ -583,7 +593,7 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs) } //---------------------------------------------------------------------------- -cmSourceFile* cmTarget::AddSource(const char* s) +cmSourceFile* cmTarget::AddSource(const std::string& s) { std::string src = s; @@ -615,7 +625,7 @@ cmSourceFile* cmTarget::AddSource(const char* s) << s << "\" expanded to \"" << src << "\" in target \"" << this->GetName() << "\". This behavior will be removed in a " "future version of CMake."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return 0; @@ -623,7 +633,7 @@ cmSourceFile* cmTarget::AddSource(const char* s) } } - cmSourceFile* sf = this->Makefile->GetOrCreateSource(src.c_str()); + cmSourceFile* sf = this->Makefile->GetOrCreateSource(src); this->AddSourceFile(sf); return sf; } @@ -647,111 +657,8 @@ void cmTarget::ProcessSourceExpression(std::string const& expr) } //---------------------------------------------------------------------------- -struct cmTarget::SourceFileFlags -cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const -{ - struct SourceFileFlags flags; - this->ConstructSourceFileFlags(); - std::map<cmSourceFile const*, SourceFileFlags>::iterator si = - this->Internal->SourceFlagsMap.find(sf); - if(si != this->Internal->SourceFlagsMap.end()) - { - flags = si->second; - } - return flags; -} - -//---------------------------------------------------------------------------- -void cmTarget::ConstructSourceFileFlags() const -{ - if(this->Internal->SourceFileFlagsConstructed) - { - return; - } - this->Internal->SourceFileFlagsConstructed = true; - - // Process public headers to mark the source files. - if(const char* files = this->GetProperty("PUBLIC_HEADER")) - { - std::vector<std::string> relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - for(std::vector<std::string>::iterator it = relFiles.begin(); - it != relFiles.end(); ++it) - { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) - { - SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf]; - flags.MacFolder = "Headers"; - flags.Type = cmTarget::SourceFileTypePublicHeader; - } - } - } - - // Process private headers after public headers so that they take - // precedence if a file is listed in both. - if(const char* files = this->GetProperty("PRIVATE_HEADER")) - { - std::vector<std::string> relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - for(std::vector<std::string>::iterator it = relFiles.begin(); - it != relFiles.end(); ++it) - { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) - { - SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf]; - flags.MacFolder = "PrivateHeaders"; - flags.Type = cmTarget::SourceFileTypePrivateHeader; - } - } - } - - // Mark sources listed as resources. - if(const char* files = this->GetProperty("RESOURCE")) - { - std::vector<std::string> relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - for(std::vector<std::string>::iterator it = relFiles.begin(); - it != relFiles.end(); ++it) - { - if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str())) - { - SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf]; - flags.MacFolder = "Resources"; - flags.Type = cmTarget::SourceFileTypeResource; - } - } - } - - // Handle the MACOSX_PACKAGE_LOCATION property on source files that - // were not listed in one of the other lists. - std::vector<cmSourceFile*> sources; - this->GetSourceFiles(sources); - for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); - si != sources.end(); ++si) - { - cmSourceFile* sf = *si; - if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) - { - SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf]; - if(flags.Type == cmTarget::SourceFileTypeNormal) - { - flags.MacFolder = location; - if(strcmp(location, "Resources") == 0) - { - flags.Type = cmTarget::SourceFileTypeResource; - } - else - { - flags.Type = cmTarget::SourceFileTypeMacContent; - } - } - } - } -} - -//---------------------------------------------------------------------------- void cmTarget::MergeLinkLibraries( cmMakefile& mf, - const char *selfname, + const std::string& selfname, const LinkLibraryVectorType& libs ) { // Only add on libraries we haven't added on before. @@ -761,15 +668,15 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf, for( ; i != libs.end(); ++i ) { // This is equivalent to the target_link_libraries plain signature. - this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second ); + this->AddLinkLibrary( mf, selfname, i->first, i->second ); this->AppendProperty("INTERFACE_LINK_LIBRARIES", - this->GetDebugGeneratorExpressions(i->first.c_str(), i->second).c_str()); + this->GetDebugGeneratorExpressions(i->first, i->second).c_str()); } this->PrevLinkedLibraries = libs; } //---------------------------------------------------------------------------- -void cmTarget::AddLinkDirectory(const char* d) +void cmTarget::AddLinkDirectory(const std::string& d) { // Make sure we don't add unnecessary search directories. if(this->LinkDirectoriesEmmitted.insert(d).second) @@ -785,10 +692,11 @@ const std::vector<std::string>& cmTarget::GetLinkDirectories() const } //---------------------------------------------------------------------------- -cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const +cmTarget::LinkLibraryType cmTarget::ComputeLinkType( + const std::string& config) const { // No configuration is always optimized. - if(!(config && *config)) + if(config.empty()) { return cmTarget::OPTIMIZED; } @@ -814,7 +722,7 @@ cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const //---------------------------------------------------------------------------- void cmTarget::ClearDependencyInformation( cmMakefile& mf, - const char* target ) + const std::string& target ) { // Clear the dependencies. The cache variable must exist iff we are // recording dependency information for this target. @@ -822,12 +730,12 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf, depname += "_LIB_DEPENDS"; if (this->RecordDependencies) { - mf.AddCacheDefinition(depname.c_str(), "", + mf.AddCacheDefinition(depname, "", "Dependencies for target", cmCacheManager::STATIC); } else { - if (mf.GetDefinition( depname.c_str() )) + if (mf.GetDefinition( depname )) { std::string message = "Target "; message += target; @@ -848,7 +756,7 @@ bool cmTarget::NameResolvesToFramework(const std::string& libname) const } //---------------------------------------------------------------------------- -void cmTarget::GetDirectLinkLibraries(const char *config, +void cmTarget::GetDirectLinkLibraries(const std::string& config, std::vector<std::string> &libs, cmTarget const* head) const { @@ -869,11 +777,11 @@ void cmTarget::GetDirectLinkLibraries(const char *config, &dagChecker), libs); - std::set<cmStdString> seenProps = cge->GetSeenTargetProperties(); - for (std::set<cmStdString>::const_iterator it = seenProps.begin(); + std::set<std::string> seenProps = cge->GetSeenTargetProperties(); + for (std::set<std::string>::const_iterator it = seenProps.begin(); it != seenProps.end(); ++it) { - if (!this->GetProperty(it->c_str())) + if (!this->GetProperty(*it)) { this->LinkImplicitNullProperties.insert(*it); } @@ -882,7 +790,7 @@ void cmTarget::GetDirectLinkLibraries(const char *config, } //---------------------------------------------------------------------------- -void cmTarget::GetInterfaceLinkLibraries(const char *config, +void cmTarget::GetInterfaceLinkLibraries(const std::string& config, std::vector<std::string> &libs, cmTarget const* head) const { @@ -938,9 +846,9 @@ std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value, } //---------------------------------------------------------------------------- -static std::string targetNameGenex(const char *lib) +static std::string targetNameGenex(const std::string& lib) { - return std::string("$<TARGET_NAME:") + lib + ">"; + return "$<TARGET_NAME:" + lib + ">"; } //---------------------------------------------------------------------------- @@ -980,7 +888,7 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, = (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); s << "The uses of the " << sigString << " signature are here:\n"; - std::set<cmStdString> emitted; + std::set<std::string> emitted; for(std::vector<cmListFileBacktrace>::const_iterator it = sigs.begin(); it != sigs.end(); ++it) { @@ -1002,7 +910,8 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, //---------------------------------------------------------------------------- void cmTarget::AddLinkLibrary(cmMakefile& mf, - const char *target, const char* lib, + const std::string& target, + const std::string& lib, LinkLibraryType llt) { cmTarget *tgt = this->Makefile->FindTargetToUse(lib); @@ -1011,7 +920,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string libName = (isNonImportedTarget && llt != GENERAL) ? targetNameGenex(lib) - : std::string(lib); + : lib; this->AppendProperty("LINK_LIBRARIES", this->GetDebugGeneratorExpressions(libName, llt).c_str()); @@ -1019,7 +928,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, if (cmGeneratorExpression::Find(lib) != std::string::npos || (tgt && tgt->GetType() == INTERFACE_LIBRARY) - || (strcmp( target, lib ) == 0)) + || (target == lib )) { return; } @@ -1044,7 +953,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string targetEntry = target; targetEntry += "_LIB_DEPENDS"; std::string dependencies; - const char* old_val = mf.GetDefinition( targetEntry.c_str() ); + const char* old_val = mf.GetDefinition( targetEntry ); if( old_val ) { dependencies += old_val; @@ -1064,7 +973,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, dependencies += ";"; dependencies += lib; dependencies += ";"; - mf.AddCacheDefinition( targetEntry.c_str(), dependencies.c_str(), + mf.AddCacheDefinition( targetEntry, dependencies.c_str(), "Dependencies for the target", cmCacheManager::STATIC ); } @@ -1073,9 +982,9 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, //---------------------------------------------------------------------------- void -cmTarget::AddSystemIncludeDirectories(const std::set<cmStdString> &incs) +cmTarget::AddSystemIncludeDirectories(const std::set<std::string> &incs) { - for(std::set<cmStdString>::const_iterator li = incs.begin(); + for(std::set<std::string>::const_iterator li = incs.begin(); li != incs.end(); ++li) { this->SystemIncludeDirectories.insert(*li); @@ -1338,7 +1247,7 @@ void cmTarget::GatherDependencies( const cmMakefile& mf, return; } - const char* deps = mf.GetDefinition( (lib.first+"_LIB_DEPENDS").c_str() ); + const char* deps = mf.GetDefinition( lib.first+"_LIB_DEPENDS" ); if( deps && strcmp(deps,"") != 0 ) { // Make sure this library is in the map, even if it has an empty @@ -1387,7 +1296,7 @@ void cmTarget::GatherDependencies( const cmMakefile& mf, } //---------------------------------------------------------------------------- -static bool whiteListedInterfaceProperty(const char *prop) +static bool whiteListedInterfaceProperty(const std::string& prop) { if(cmHasLiteralPrefix(prop, "INTERFACE_")) { @@ -1407,7 +1316,7 @@ static bool whiteListedInterfaceProperty(const char *prop) if (std::binary_search(cmArrayBegin(builtIns), cmArrayEnd(builtIns), - prop, + prop.c_str(), cmStrCmp(prop))) { return true; @@ -1422,30 +1331,26 @@ static bool whiteListedInterfaceProperty(const char *prop) } //---------------------------------------------------------------------------- -void cmTarget::SetProperty(const char* prop, const char* value) +void cmTarget::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { cmOStringStream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if (strcmp(prop, "NAME") == 0) + if (prop == "NAME") { cmOStringStream e; e << "NAME property is read-only\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + if(prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1456,7 +1361,7 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } - if(strcmp(prop,"COMPILE_OPTIONS") == 0) + if(prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1467,7 +1372,7 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } - if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + if(prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1478,15 +1383,15 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } - if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported()) + if(prop == "EXPORT_NAME" && this->IsImported()) { cmOStringStream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if (strcmp(prop, "LINK_LIBRARIES") == 0) + if (prop == "LINK_LIBRARIES") { this->Internal->LinkImplementationPropertyEntries.clear(); cmListFileBacktrace lfbt; @@ -1500,30 +1405,26 @@ void cmTarget::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmTarget::AppendProperty(const char* prop, const char* value, +void cmTarget::AppendProperty(const std::string& prop, const char* value, bool asString) { - if (!prop) - { - return; - } if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { cmOStringStream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if (strcmp(prop, "NAME") == 0) + if (prop == "NAME") { cmOStringStream e; e << "NAME property is read-only\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + if(prop == "INCLUDE_DIRECTORIES") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1532,7 +1433,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } - if(strcmp(prop,"COMPILE_OPTIONS") == 0) + if(prop == "COMPILE_OPTIONS") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1541,7 +1442,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } - if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + if(prop == "COMPILE_DEFINITIONS") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1550,15 +1451,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } - if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported()) + if(prop == "EXPORT_NAME" && this->IsImported()) { cmOStringStream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if (strcmp(prop, "LINK_LIBRARIES") == 0) + if (prop == "LINK_LIBRARIES") { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); @@ -1571,7 +1472,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, } //---------------------------------------------------------------------------- -const char* cmTarget::GetExportName() const +std::string cmTarget::GetExportName() const { const char *exportName = this->GetProperty("EXPORT_NAME"); @@ -1665,7 +1566,7 @@ static void processIncludeDirectories(cmTarget const* tgt, std::vector<std::string> &includes, std::set<std::string> &uniqueIncludes, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugIncludes) + const std::string& config, bool debugIncludes) { cmMakefile *mf = tgt->GetMakefile(); @@ -1674,7 +1575,7 @@ static void processIncludeDirectories(cmTarget const* tgt, { bool testIsOff = true; bool cacheIncludes = false; - std::vector<std::string> entryIncludes = (*it)->CachedEntries; + std::vector<std::string>& entryIncludes = (*it)->CachedEntries; if(!entryIncludes.empty()) { testIsOff = false; @@ -1752,7 +1653,7 @@ static void processIncludeDirectories(cmTarget const* tgt, "successfully.\n" "* The installation package was faulty and references files it " "does not provide.\n"; - tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + tgt->GetMakefile()->IssueMessage(messageType, e.str()); return; } @@ -1791,7 +1692,7 @@ static void processIncludeDirectories(cmTarget const* tgt, } if (!noMessage) { - tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str()); + tgt->GetMakefile()->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { return; @@ -1830,7 +1731,7 @@ static void processIncludeDirectories(cmTarget const* tgt, //---------------------------------------------------------------------------- std::vector<std::string> -cmTarget::GetIncludeDirectories(const char *config) const +cmTarget::GetIncludeDirectories(const std::string& config) const { std::vector<std::string> includes; std::set<std::string> uniqueIncludes; @@ -1867,8 +1768,7 @@ cmTarget::GetIncludeDirectories(const char *config) const config, debugIncludes); - std::string configString = config ? config : ""; - if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString]) + if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config]) { for (std::vector<cmValueWithOrigin>::const_iterator it = this->Internal->LinkImplementationPropertyEntries.begin(), @@ -1905,7 +1805,7 @@ cmTarget::GetIncludeDirectories(const char *config) const includeGenex); this->Internal - ->CachedLinkInterfaceIncludeDirectoriesEntries[configString].push_back( + ->CachedLinkInterfaceIncludeDirectoriesEntries[config].push_back( new cmTargetInternals::TargetPropertyEntry(cge, it->Value)); } @@ -1933,14 +1833,14 @@ cmTarget::GetIncludeDirectories(const char *config) const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(libDir.c_str()); this->Internal - ->CachedLinkInterfaceIncludeDirectoriesEntries[configString] + ->CachedLinkInterfaceIncludeDirectoriesEntries[config] .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } } } processIncludeDirectories(this, - this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[configString], + this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config], includes, uniqueIncludes, &dagChecker, @@ -1954,7 +1854,7 @@ cmTarget::GetIncludeDirectories(const char *config) const } else { - this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString] + this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config] = true; } @@ -1967,7 +1867,7 @@ static void processCompileOptionsInternal(cmTarget const* tgt, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugOptions, const char *logName) + const std::string& config, bool debugOptions, const char *logName) { cmMakefile *mf = tgt->GetMakefile(); @@ -2026,7 +1926,7 @@ static void processCompileOptions(cmTarget const* tgt, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugOptions) + const std::string& config, bool debugOptions) { processCompileOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, config, debugOptions, "options"); @@ -2034,7 +1934,7 @@ static void processCompileOptions(cmTarget const* tgt, //---------------------------------------------------------------------------- void cmTarget::GetAutoUicOptions(std::vector<std::string> &result, - const char *config) const + const std::string& config) const { const char *prop = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", @@ -2060,7 +1960,7 @@ void cmTarget::GetAutoUicOptions(std::vector<std::string> &result, //---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector<std::string> &result, - const char *config) const + const std::string& config) const { std::set<std::string> uniqueOptions; cmListFileBacktrace lfbt; @@ -2096,8 +1996,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, config, debugOptions); - std::string configString = config ? config : ""; - if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString]) + if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[config]) { for (std::vector<cmValueWithOrigin>::const_iterator it = this->Internal->LinkImplementationPropertyEntries.begin(), @@ -2134,14 +2033,14 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, optionGenex); this->Internal - ->CachedLinkInterfaceCompileOptionsEntries[configString].push_back( + ->CachedLinkInterfaceCompileOptionsEntries[config].push_back( new cmTargetInternals::TargetPropertyEntry(cge, it->Value)); } } processCompileOptions(this, - this->Internal->CachedLinkInterfaceCompileOptionsEntries[configString], + this->Internal->CachedLinkInterfaceCompileOptionsEntries[config], result, uniqueOptions, &dagChecker, @@ -2154,7 +2053,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, } else { - this->Internal->CacheLinkInterfaceCompileOptionsDone[configString] = true; + this->Internal->CacheLinkInterfaceCompileOptionsDone[config] = true; } } @@ -2164,7 +2063,7 @@ static void processCompileDefinitions(cmTarget const* tgt, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugOptions) + const std::string& config, bool debugOptions) { processCompileOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker, config, debugOptions, @@ -2173,7 +2072,7 @@ static void processCompileDefinitions(cmTarget const* tgt, //---------------------------------------------------------------------------- void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, - const char *config) const + const std::string& config) const { std::set<std::string> uniqueOptions; cmListFileBacktrace lfbt; @@ -2209,8 +2108,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, config, debugDefines); - std::string configString = config ? config : ""; - if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]) + if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config]) { for (std::vector<cmValueWithOrigin>::const_iterator it = this->Internal->LinkImplementationPropertyEntries.begin(), @@ -2247,15 +2145,15 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, defsGenex); this->Internal - ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back( + ->CachedLinkInterfaceCompileDefinitionsEntries[config].push_back( new cmTargetInternals::TargetPropertyEntry(cge, it->Value)); } - if (config) + if (!config.empty()) { std::string configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); - const char *configProp = this->GetProperty(configPropName.c_str()); + const char *configProp = this->GetProperty(configPropName); if (configProp) { switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) @@ -2266,7 +2164,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, e << this->Makefile->GetCMakeInstance()->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0043); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, - e.str().c_str()); + e.str()); } case cmPolicies::OLD: { @@ -2274,7 +2172,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(configProp); this->Internal - ->CachedLinkInterfaceCompileDefinitionsEntries[configString] + ->CachedLinkInterfaceCompileDefinitionsEntries[config] .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); } break; @@ -2289,7 +2187,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, } processCompileDefinitions(this, - this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[configString], + this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[config], list, uniqueOptions, &dagChecker, @@ -2303,13 +2201,13 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, } else { - this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString] + this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config] = true; } } //---------------------------------------------------------------------------- -void cmTarget::MaybeInvalidatePropertyCache(const char* prop) +void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop) { // Wipe out maps caching information affected by this property. if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) @@ -2324,8 +2222,8 @@ void cmTarget::MaybeInvalidatePropertyCache(const char* prop) //---------------------------------------------------------------------------- static void cmTargetCheckLINK_INTERFACE_LIBRARIES( - const char* prop, const char* value, cmMakefile* context, bool imported - ) + const std::string& prop, const char* value, cmMakefile* context, + bool imported) { // Look for link-type keywords in the value. static cmsys::RegularExpression @@ -2389,7 +2287,8 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value, } //---------------------------------------------------------------------------- -void cmTarget::CheckProperty(const char* prop, cmMakefile* context) const +void cmTarget::CheckProperty(const std::string& prop, + cmMakefile* context) const { // Certain properties need checking. if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) @@ -2432,7 +2331,8 @@ bool cmTarget::HaveWellDefinedOutputFiles() const } //---------------------------------------------------------------------------- -cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const +cmTarget::OutputInfo const* cmTarget::GetOutputInfo( + const std::string& config) const { // There is no output information for imported targets. if(this->IsImported()) @@ -2454,7 +2354,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const // Lookup/compute/cache the output information for this configuration. std::string config_upper; - if(config && *config) + if(!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } @@ -2466,7 +2366,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const OutputInfo info; this->ComputeOutputDir(config, false, info.OutDir); this->ComputeOutputDir(config, true, info.ImpDir); - if(!this->ComputePDBOutputDir(config, info.PdbDir)) + if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } @@ -2477,7 +2377,48 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetDirectory(const char* config, bool implib) const +cmTarget::CompileInfo const* cmTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->GetType()); + this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); + abort(); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; + CompileInfoMapType::const_iterator i = + this->Internal->CompileInfoMap.find(config_upper); + if(i == this->Internal->CompileInfoMap.end()) + { + CompileInfo info; + this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->Internal->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +std::string cmTarget::GetDirectory(const std::string& config, + bool implib) const { if (this->IsImported()) { @@ -2495,7 +2436,7 @@ std::string cmTarget::GetDirectory(const char* config, bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBDirectory(const char* config) const +std::string cmTarget::GetPDBDirectory(const std::string& config) const { if(OutputInfo const* info = this->GetOutputInfo(config)) { @@ -2506,34 +2447,37 @@ std::string cmTarget::GetPDBDirectory(const char* config) const } //---------------------------------------------------------------------------- -const char* cmTarget::GetLocation(const char* config) const +std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const { - if (this->IsImported()) - { - return this->ImportedGetLocation(config); - } - else + if(CompileInfo const* info = this->GetCompileInfo(config)) { - return this->NormalGetLocation(config); + return info->CompilePdbDir; } + return ""; } //---------------------------------------------------------------------------- -const char* cmTarget::ImportedGetLocation(const char* config) const +const char* cmTarget::GetLocation(const std::string& config) const { static std::string location; - location = this->ImportedGetFullPath(config, false); + if (this->IsImported()) + { + location = this->ImportedGetFullPath(config, false); + } + else + { + location = this->GetFullPath(config, false); + } return location.c_str(); } //---------------------------------------------------------------------------- -const char* cmTarget::NormalGetLocation(const char* config) const +const char* cmTarget::GetLocationForBuild() const { static std::string location; - // Handle the configuration-specific case first. - if(config) + if(this->IsImported()) { - location = this->GetFullPath(config, false); + location = this->ImportedGetFullPath("", false); return location.c_str(); } @@ -2553,7 +2497,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const if(this->IsAppBundleOnApple()) { - std::string macdir = this->BuildMacContentDirectory("", config, false); + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { location += "/"; @@ -2561,7 +2505,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const } } location += "/"; - location += this->GetFullName(config, false); + location += this->GetFullName("", false); return location.c_str(); } @@ -2604,14 +2548,15 @@ void cmTarget::GetTargetVersion(bool soversion, } //---------------------------------------------------------------------------- -const char* cmTarget::GetFeature(const char* feature, const char* config) const +const char* cmTarget::GetFeature(const std::string& feature, + const std::string& config) const { - if(config && *config) + if(!config.empty()) { std::string featureConfig = feature; featureConfig += "_"; featureConfig += cmSystemTools::UpperCase(config); - if(const char* value = this->GetProperty(featureConfig.c_str())) + if(const char* value = this->GetProperty(featureConfig)) { return value; } @@ -2624,7 +2569,7 @@ const char* cmTarget::GetFeature(const char* feature, const char* config) const } //---------------------------------------------------------------------------- -const char *cmTarget::GetProperty(const char* prop) const +const char *cmTarget::GetProperty(const std::string& prop) const { return this->GetProperty(prop, cmProperty::TARGET); } @@ -2660,34 +2605,29 @@ bool cmTarget::HandleLocationPropertyPolicy() const << this->GetName() << "\". Use the target name directly with " "add_custom_command, or use the generator expression $<TARGET_FILE>, " "as appropriate.\n"; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); } return messageType != cmake::FATAL_ERROR; } //---------------------------------------------------------------------------- -const char *cmTarget::GetProperty(const char* prop, +const char *cmTarget::GetProperty(const std::string& prop, cmProperty::ScopeType scope) const { - if(!prop) - { - return 0; - } - if (this->GetType() == INTERFACE_LIBRARY && !whiteListedInterfaceProperty(prop)) { cmOStringStream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " "The property \"" << prop << "\" is not allowed."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return 0; } - if (strcmp(prop, "NAME") == 0) + if (prop == "NAME") { - return this->GetName(); + return this->GetName().c_str(); } // Watch for special "computed" properties that are dependent on @@ -2698,7 +2638,7 @@ const char *cmTarget::GetProperty(const char* prop, this->GetType() == cmTarget::MODULE_LIBRARY || this->GetType() == cmTarget::UNKNOWN_LIBRARY) { - if(strcmp(prop,"LOCATION") == 0) + if(prop == "LOCATION") { if (!this->HandleLocationPropertyPolicy()) { @@ -2714,7 +2654,7 @@ const char *cmTarget::GetProperty(const char* prop, // cannot take into account the per-configuration name of the // target because the configuration type may not be known at // CMake time. - this->Properties.SetProperty("LOCATION", this->GetLocation(0), + this->Properties.SetProperty("LOCATION", this->GetLocationForBuild(), cmProperty::TARGET); } @@ -2725,15 +2665,15 @@ const char *cmTarget::GetProperty(const char* prop, { return 0; } - std::string configName = prop+9; + const char* configName = prop.c_str() + 9; this->Properties.SetProperty(prop, - this->GetLocation(configName.c_str()), + this->GetLocation(configName), cmProperty::TARGET); } // Support "<CONFIG>_LOCATION". if(cmHasLiteralSuffix(prop, "_LOCATION")) { - std::string configName(prop, strlen(prop) - 9); + std::string configName(prop.c_str(), prop.size() - 9); if(configName != "IMPORTED") { if (!this->HandleLocationPropertyPolicy()) @@ -2741,12 +2681,12 @@ const char *cmTarget::GetProperty(const char* prop, return 0; } this->Properties.SetProperty(prop, - this->GetLocation(configName.c_str()), + this->GetLocation(configName), cmProperty::TARGET); } } } - if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) + if(prop == "INCLUDE_DIRECTORIES") { static std::string output; output = ""; @@ -2764,7 +2704,7 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } - if(strcmp(prop,"COMPILE_OPTIONS") == 0) + if(prop == "COMPILE_OPTIONS") { static std::string output; output = ""; @@ -2782,7 +2722,7 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } - if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + if(prop == "COMPILE_DEFINITIONS") { static std::string output; output = ""; @@ -2800,7 +2740,7 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } - if(strcmp(prop,"LINK_LIBRARIES") == 0) + if(prop == "LINK_LIBRARIES") { static std::string output; output = ""; @@ -2817,12 +2757,12 @@ const char *cmTarget::GetProperty(const char* prop, return output.c_str(); } - if (strcmp(prop,"IMPORTED") == 0) + if (prop == "IMPORTED") { return this->IsImported()?"TRUE":"FALSE"; } - if(!strcmp(prop,"SOURCES")) + if(prop == "SOURCES") { cmOStringStream ss; const char* sep = ""; @@ -2851,7 +2791,7 @@ const char *cmTarget::GetProperty(const char* prop, } // the type property returns what type the target is - if (!strcmp(prop,"TYPE")) + if (prop == "TYPE") { return cmTarget::GetTargetTypeName(this->GetType()); } @@ -2866,7 +2806,7 @@ const char *cmTarget::GetProperty(const char* prop, } //---------------------------------------------------------------------------- -bool cmTarget::GetPropertyAsBool(const char* prop) const +bool cmTarget::GetPropertyAsBool(const std::string& prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } @@ -2875,8 +2815,9 @@ bool cmTarget::GetPropertyAsBool(const char* prop) const class cmTargetCollectLinkLanguages { public: - cmTargetCollectLinkLanguages(cmTarget const* target, const char* config, - std::set<cmStdString>& languages, + cmTargetCollectLinkLanguages(cmTarget const* target, + const std::string& config, + std::set<std::string>& languages, cmTarget const* head): Config(config), Languages(languages), HeadTarget(head), Makefile(target->GetMakefile()), Target(target) @@ -2947,8 +2888,8 @@ public: } } private: - const char* Config; - std::set<cmStdString>& Languages; + std::string Config; + std::set<std::string>& Languages; cmTarget const* HeadTarget; cmMakefile* Makefile; const cmTarget* Target; @@ -2956,20 +2897,19 @@ private: }; //---------------------------------------------------------------------------- -const char* cmTarget::GetLinkerLanguage(const char* config, +std::string cmTarget::GetLinkerLanguage(const std::string& config, cmTarget const* head) const { cmTarget const* headTarget = head ? head : this; - const char* lang = this->GetLinkClosure(config, headTarget) - ->LinkerLanguage.c_str(); - return *lang? lang : 0; + return this->GetLinkClosure(config, headTarget)->LinkerLanguage; } //---------------------------------------------------------------------------- -cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config, +cmTarget::LinkClosure const* cmTarget::GetLinkClosure( + const std::string& config, cmTarget const* head) const { - TargetConfigPair key(head, cmSystemTools::UpperCase(config ? config : "")); + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkClosureMapType::iterator i = this->Internal->LinkClosureMap.find(key); if(i == this->Internal->LinkClosureMap.end()) @@ -2989,14 +2929,14 @@ class cmTargetSelectLinker cmTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GG; - std::set<cmStdString> Preferred; + std::set<std::string> Preferred; public: cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) { this->Makefile = this->Target->GetMakefile(); this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); } - void Consider(const char* lang) + void Consider(const std::string& lang) { int preference = this->GG->GetLinkerPreference(lang); if(preference > this->Preference) @@ -3021,7 +2961,7 @@ public: e << "Target " << this->Target->GetName() << " contains multiple languages with the highest linker preference" << " (" << this->Preference << "):\n"; - for(std::set<cmStdString>::const_iterator + for(std::set<std::string>::const_iterator li = this->Preferred.begin(); li != this->Preferred.end(); ++li) { e << " " << *li << "\n"; @@ -3036,11 +2976,11 @@ public: }; //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, +void cmTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc, cmTarget const* head) const { // Get languages built in this target. - std::set<cmStdString> languages; + std::set<std::string> languages; LinkImplementation const* impl = this->GetLinkImplementation(config, head); for(std::vector<std::string>::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) @@ -3057,7 +2997,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, } // Store the transitive closure of languages. - for(std::set<cmStdString>::const_iterator li = languages.begin(); + for(std::set<std::string>::const_iterator li = languages.begin(); li != languages.end(); ++li) { lc.Languages.push_back(*li); @@ -3081,17 +3021,17 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, for(std::vector<std::string>::const_iterator li = impl->Languages.begin(); li != impl->Languages.end(); ++li) { - tsl.Consider(li->c_str()); + tsl.Consider(*li); } // Now consider languages that propagate from linked targets. - for(std::set<cmStdString>::const_iterator sit = languages.begin(); + for(std::set<std::string>::const_iterator sit = languages.begin(); sit != languages.end(); ++sit) { std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates.c_str())) + if(this->Makefile->IsOn(propagates)) { - tsl.Consider(sit->c_str()); + tsl.Consider(*sit); } } @@ -3149,7 +3089,7 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const char* config) const +std::string cmTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; @@ -3157,8 +3097,7 @@ std::string cmTarget::GetPDBName(const char* config) const this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector<std::string> props; - std::string configUpper = - cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(config); if(!configUpper.empty()) { // PDB_NAME_<CONFIG> @@ -3171,7 +3110,7 @@ std::string cmTarget::GetPDBName(const char* config) const for(std::vector<std::string>::const_iterator i = props.begin(); i != props.end(); ++i) { - if(const char* outName = this->GetProperty(i->c_str())) + if(const char* outName = this->GetProperty(*i)) { base = outName; break; @@ -3181,7 +3120,50 @@ std::string cmTarget::GetPDBName(const char* config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const char* config) const +std::string cmTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string cmTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- +bool cmTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. @@ -3193,7 +3175,7 @@ bool cmTarget::HasSOName(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const char* config) const +std::string cmTarget::GetSOName(const std::string& config) const { if(this->IsImported()) { @@ -3235,7 +3217,7 @@ std::string cmTarget::GetSOName(const char* config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasMacOSXRpathInstallNameDir(const char* config) const +bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; bool macosx_rpath = false; @@ -3347,7 +3329,8 @@ bool cmTarget::MacOSXRpathInstallNameDirDefault() const } //---------------------------------------------------------------------------- -bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const +bool cmTarget::IsImportedSharedLibWithoutSOName( + const std::string& config) const { if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY) { @@ -3360,7 +3343,7 @@ bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::NormalGetRealName(const char* config) const +std::string cmTarget::NormalGetRealName(const std::string& config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3371,7 +3354,7 @@ std::string cmTarget::NormalGetRealName(const char* config) const msg += this->GetName(); this->GetMakefile()-> IssueMessage(cmake::INTERNAL_ERROR, - msg.c_str()); + msg); } if(this->GetType() == cmTarget::EXECUTABLE) @@ -3398,7 +3381,8 @@ std::string cmTarget::NormalGetRealName(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const char* config, bool implib) const +std::string cmTarget::GetFullName(const std::string& config, + bool implib) const { if(this->IsImported()) { @@ -3412,7 +3396,7 @@ std::string cmTarget::GetFullName(const char* config, bool implib) const //---------------------------------------------------------------------------- std::string -cmTarget::GetFullNameImported(const char* config, bool implib) const +cmTarget::GetFullNameImported(const std::string& config, bool implib) const { return cmSystemTools::GetFilenameName( this->ImportedGetFullPath(config, implib)); @@ -3420,14 +3404,15 @@ cmTarget::GetFullNameImported(const char* config, bool implib) const //---------------------------------------------------------------------------- void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, const char* config, + std::string& suffix, + const std::string& config, bool implib) const { this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullPath(const char* config, bool implib, +std::string cmTarget::GetFullPath(const std::string& config, bool implib, bool realname) const { if(this->IsImported()) @@ -3441,8 +3426,8 @@ std::string cmTarget::GetFullPath(const char* config, bool implib, } //---------------------------------------------------------------------------- -std::string cmTarget::NormalGetFullPath(const char* config, bool implib, - bool realname) const +std::string cmTarget::NormalGetFullPath(const std::string& config, + bool implib, bool realname) const { std::string fpath = this->GetDirectory(config, implib); fpath += "/"; @@ -3470,7 +3455,7 @@ std::string cmTarget::NormalGetFullPath(const char* config, bool implib, //---------------------------------------------------------------------------- std::string -cmTarget::ImportedGetFullPath(const char* config, bool implib) const +cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { std::string result; if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this)) @@ -3487,7 +3472,7 @@ cmTarget::ImportedGetFullPath(const char* config, bool implib) const //---------------------------------------------------------------------------- std::string -cmTarget::GetFullNameInternal(const char* config, bool implib) const +cmTarget::GetFullNameInternal(const std::string& config, bool implib) const { std::string prefix; std::string base; @@ -3497,7 +3482,7 @@ cmTarget::GetFullNameInternal(const char* config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const char* config, +void cmTarget::GetFullNameInternal(const std::string& config, bool implib, std::string& outPrefix, std::string& outBase, @@ -3543,11 +3528,11 @@ void cmTarget::GetFullNameInternal(const char* config, ? this->GetProperty("IMPORT_SUFFIX") : this->GetProperty("SUFFIX")); const char* configPostfix = 0; - if(config && *config) + if(!config.empty()) { std::string configProp = cmSystemTools::UpperCase(config); configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp.c_str()); + configPostfix = this->GetProperty(configProp); // Mac application bundles and frameworks have no postfix. if(configPostfix && (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) @@ -3559,17 +3544,18 @@ void cmTarget::GetFullNameInternal(const char* config, const char* suffixVar = this->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - if(const char* ll = this->GetLinkerLanguage(config, this)) + std::string ll = this->GetLinkerLanguage(config, this); + if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) { std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff.c_str()); + targetSuffix = this->Makefile->GetDefinition(langSuff); } if(!targetPrefix && prefixVar && *prefixVar) { std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix.c_str()); + targetPrefix = this->Makefile->GetDefinition(langPrefix); } } @@ -3639,7 +3625,7 @@ void cmTarget::GetLibraryNames(std::string& name, std::string& realName, std::string& impName, std::string& pdbName, - const char* config) const + const std::string& config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3649,7 +3635,7 @@ void cmTarget::GetLibraryNames(std::string& name, std::string msg = "GetLibraryNames called on imported target: "; msg += this->GetName(); this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg.c_str()); + msg); return; } @@ -3743,7 +3729,7 @@ void cmTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, std::string& pdbName, - const char* config) const + const std::string& config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -3753,7 +3739,7 @@ void cmTarget::GetExecutableNames(std::string& name, std::string msg = "GetExecutableNames called on imported target: "; msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg.c_str()); + this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); } // This versioning is supported only for executables and then only @@ -3821,14 +3807,14 @@ bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, } //---------------------------------------------------------------------------- -void cmTarget::SetPropertyDefault(const char* property, +void cmTarget::SetPropertyDefault(const std::string& property, const char* default_value) { // Compute the name of the variable holding the default value. std::string var = "CMAKE_"; var += property; - if(const char* value = this->Makefile->GetDefinition(var.c_str())) + if(const char* value = this->Makefile->GetDefinition(var)) { this->SetProperty(property, value); } @@ -3839,7 +3825,7 @@ void cmTarget::SetPropertyDefault(const char* property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveBuildTreeRPATH(const char *config) const +bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const { if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { @@ -3859,7 +3845,7 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const char* config) const +bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const { // Only executables and shared libraries can have an rpath and may // need relinking. @@ -3896,12 +3882,13 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) const } // Check for rpath support on this platform. - if(const char* ll = this->GetLinkerLanguage(config, this)) + std::string ll = this->GetLinkerLanguage(config, this); + if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; flagVar += ll; flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar.c_str())) + if(!this->Makefile->IsSet(flagVar)) { // There is no rpath support on this platform so nothing needs // relinking. @@ -3922,7 +3909,8 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) const +std::string cmTarget::GetInstallNameDirForBuildTree( + const std::string& config) const { // If building directly for installation then the build tree install_name // is the same as the install tree. @@ -4044,10 +4032,11 @@ const char* cmTarget::GetOutputTargetType(bool implib) const } //---------------------------------------------------------------------------- -bool cmTarget::ComputeOutputDir(const char* config, +bool cmTarget::ComputeOutputDir(const std::string& config, bool implib, std::string& out) const { bool usesDefaultOutputDir = false; + std::string conf = config; // Look for a target property defining the target output directory // based on the target type. @@ -4061,7 +4050,7 @@ bool cmTarget::ComputeOutputDir(const char* config, } // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(conf); const char* configProp = 0; std::string configPropStr = targetTypeName; if(!configPropStr.empty()) @@ -4078,7 +4067,7 @@ bool cmTarget::ComputeOutputDir(const char* config, out = config_outdir; // Skip per-configuration subdirectory. - config = 0; + conf = ""; } else if(const char* outdir = this->GetProperty(propertyName)) { @@ -4111,37 +4100,39 @@ bool cmTarget::ComputeOutputDir(const char* config, (out.c_str(), this->Makefile->GetStartOutputDirectory())); // The generator may add the configuration's subdirectory. - if(config && *config) + if(!conf.empty()) { const char *platforms = this->Makefile->GetDefinition( "CMAKE_XCODE_EFFECTIVE_PLATFORMS"); std::string suffix = usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : ""; this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", config, suffix.c_str(), out); + AppendDirectoryForConfig("/", conf, suffix, out); } return usesDefaultOutputDir; } //---------------------------------------------------------------------------- -bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const +bool cmTarget::ComputePDBOutputDir(const std::string& kind, + const std::string& config, + std::string& out) const { // Look for a target property defining the target output directory // based on the target type. - std::string targetTypeName = "PDB"; const char* propertyName = 0; - std::string propertyNameStr = targetTypeName; + std::string propertyNameStr = kind; if(!propertyNameStr.empty()) { propertyNameStr += "_OUTPUT_DIRECTORY"; propertyName = propertyNameStr.c_str(); } + std::string conf = config; // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(conf); const char* configProp = 0; - std::string configPropStr = targetTypeName; + std::string configPropStr = kind; if(!configPropStr.empty()) { configPropStr += "_OUTPUT_DIRECTORY_"; @@ -4156,7 +4147,7 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const out = config_outdir; // Skip per-configuration subdirectory. - config = 0; + conf = ""; } else if(const char* outdir = this->GetProperty(propertyName)) { @@ -4175,27 +4166,29 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const (out.c_str(), this->Makefile->GetStartOutputDirectory())); // The generator may add the configuration's subdirectory. - if(config && *config) + if(!conf.empty()) { this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", config, "", out); + AppendDirectoryForConfig("/", conf, "", out); } return true; } //---------------------------------------------------------------------------- -bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) const +bool cmTarget::UsesDefaultOutputDir(const std::string& config, + bool implib) const { std::string dir; return this->ComputeOutputDir(config, implib, dir); } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const char* config, bool implib) const +std::string cmTarget::GetOutputName(const std::string& config, + bool implib) const { std::vector<std::string> props; std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config? config : ""); + std::string configUpper = cmSystemTools::UpperCase(config); if(!type.empty() && !configUpper.empty()) { // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG> @@ -4219,7 +4212,7 @@ std::string cmTarget::GetOutputName(const char* config, bool implib) const for(std::vector<std::string>::const_iterator i = props.begin(); i != props.end(); ++i) { - if(const char* outName = this->GetProperty(i->c_str())) + if(const char* outName = this->GetProperty(*i)) { return outName; } @@ -4529,7 +4522,7 @@ std::string compatibilityAgree(CompatibleType t, bool dominant) template<typename PropertyType> PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, - const char *config, + const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) @@ -4537,19 +4530,20 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, PropertyType propContent = getTypedProperty<PropertyType>(tgt, p.c_str(), 0); const bool explicitlySet = tgt->GetProperties() - .find(p.c_str()) + .find(p) != tgt->GetProperties().end(); const bool impliedByUse = tgt->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); - cmComputeLinkInformation *info = tgt->GetLinkInformation(config); - if(!info) + std::vector<cmTarget*> deps; + tgt->GetTransitiveTargetClosure(config, tgt, deps); + + if(deps.empty()) { return propContent; } - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); bool propInitialized = explicitlySet; std::string report = " * Target \""; @@ -4569,7 +4563,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, report += "\" property not set.\n"; } - for(cmComputeLinkInformation::ItemVector::const_iterator li = + for(std::vector<cmTarget*>::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -4579,23 +4573,20 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, // target itself has a POSITION_INDEPENDENT_CODE which disagrees // with a dependency. - if (!li->Target) - { - continue; - } + cmTarget const* theTarget = *li; - const bool ifaceIsSet = li->Target->GetProperties() + const bool ifaceIsSet = theTarget->GetProperties() .find("INTERFACE_" + p) - != li->Target->GetProperties().end(); + != theTarget->GetProperties().end(); PropertyType ifacePropContent = - getTypedProperty<PropertyType>(li->Target, + getTypedProperty<PropertyType>(theTarget, ("INTERFACE_" + p).c_str(), 0); std::string reportEntry; if (ifaceIsSet) { reportEntry += " * Target \""; - reportEntry += li->Target->GetName(); + reportEntry += theTarget->GetName(); reportEntry += "\" property value \""; reportEntry += valueAsString<PropertyType>(ifacePropContent); reportEntry += "\" "; @@ -4616,7 +4607,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, e << "Property " << p << " on target \"" << tgt->GetName() << "\" does\nnot match the " "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << li->Target->GetName() << "\".\n"; + "dependency \"" << theTarget->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); break; } @@ -4650,7 +4641,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, << tgt->GetName() << "\" is\nimplied to be " << defaultValue << " because it was used to determine the link libraries\n" "already. The INTERFACE_" << p << " property on\ndependency \"" - << li->Target->GetName() << "\" is in conflict.\n"; + << theTarget->GetName() << "\" is in conflict.\n"; cmSystemTools::Error(e.str().c_str()); break; } @@ -4681,7 +4672,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { cmOStringStream e; e << "The INTERFACE_" << p << " property of \"" - << li->Target->GetName() << "\" does\nnot agree with the value " + << theTarget->GetName() << "\" does\nnot agree with the value " "of " << p << " already determined\nfor \"" << tgt->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); @@ -4715,7 +4706,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, //---------------------------------------------------------------------------- bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) const + const std::string& config) const { return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE", BoolType, 0); @@ -4723,8 +4714,8 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, //---------------------------------------------------------------------------- const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const char *config) const + const std::string &p, + const std::string& config) const { return checkInterfacePropertyCompatibility<const char *>(this, p, @@ -4735,8 +4726,8 @@ const char * cmTarget::GetLinkInterfaceDependentStringProperty( //---------------------------------------------------------------------------- const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const char *config) const + const std::string &p, + const std::string& config) const { return checkInterfacePropertyCompatibility<const char *>(this, p, @@ -4747,8 +4738,8 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( //---------------------------------------------------------------------------- const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const char *config) const + const std::string &p, + const std::string& config) const { return checkInterfacePropertyCompatibility<const char *>(this, p, @@ -4759,26 +4750,22 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( //---------------------------------------------------------------------------- bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, - const char *interfaceProperty, - const char *config) + const std::string& interfaceProperty, + const std::string& config) { - cmComputeLinkInformation *info = tgt->GetLinkInformation(config); - if(!info) + std::vector<cmTarget*> deps; + tgt->GetTransitiveTargetClosure(config, tgt, deps); + + if(deps.empty()) { return false; } - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - for(cmComputeLinkInformation::ItemVector::const_iterator li = + for(std::vector<cmTarget*>::const_iterator li = deps.begin(); li != deps.end(); ++li) { - if (!li->Target) - { - continue; - } - const char *prop = li->Target->GetProperty(interfaceProperty); + const char *prop = (*li)->GetProperty(interfaceProperty); if (!prop) { continue; @@ -4802,7 +4789,7 @@ bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) const + const std::string& config) const { if (this->TargetTypeValue == OBJECT_LIBRARY || this->TargetTypeValue == INTERFACE_LIBRARY) @@ -4816,7 +4803,7 @@ bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const char *config) const + const std::string& config) const { if (this->TargetTypeValue == OBJECT_LIBRARY || this->TargetTypeValue == INTERFACE_LIBRARY) @@ -4830,7 +4817,7 @@ bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const char *config) const + const std::string& config) const { if (this->TargetTypeValue == OBJECT_LIBRARY || this->TargetTypeValue == INTERFACE_LIBRARY) @@ -4843,7 +4830,7 @@ bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const char *config) const + const std::string& config) const { if (this->TargetTypeValue == OBJECT_LIBRARY || this->TargetTypeValue == INTERFACE_LIBRARY) @@ -4855,12 +4842,13 @@ bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, } //---------------------------------------------------------------------------- -void cmTarget::GetLanguages(std::set<cmStdString>& languages) const +void cmTarget::GetLanguages(std::set<std::string>& languages) const { for(std::vector<cmSourceFile*>::const_iterator i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i) { - if(const char* lang = (*i)->GetLanguage()) + const std::string& lang = (*i)->GetLanguage(); + if(!lang.empty()) { languages.insert(lang); } @@ -4868,7 +4856,7 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const char* config) const +bool cmTarget::IsChrpathUsed(const std::string& config) const { // Only certain target types have an rpath. if(!(this->GetType() == cmTarget::SHARED_LIBRARY || @@ -4911,12 +4899,13 @@ bool cmTarget::IsChrpathUsed(const char* config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - if(const char* ll = this->GetLinkerLanguage(config, this)) + std::string ll = this->GetLinkerLanguage(config, this); + if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; sepVar += ll; sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar.c_str()); + const char* sep = this->Makefile->GetDefinition(sepVar); if(sep && *sep) { // TODO: Add ELF check to ABI detection and get rid of @@ -4935,7 +4924,8 @@ bool cmTarget::IsChrpathUsed(const char* config) const //---------------------------------------------------------------------------- cmTarget::ImportInfo const* -cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const +cmTarget::GetImportInfo(const std::string& config, + cmTarget const* headTarget) const { // There is no imported information for non-imported targets. if(!this->IsImported()) @@ -4946,7 +4936,7 @@ cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const // Lookup/compute/cache the import information for this // configuration. std::string config_upper; - if(config && *config) + if(!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } @@ -5004,7 +4994,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, { std::string mapProp = "MAP_IMPORTED_CONFIG_"; mapProp += desired_config; - if(const char* mapValue = this->GetProperty(mapProp.c_str())) + if(const char* mapValue = this->GetProperty(mapProp)) { cmSystemTools::ExpandListArgument(mapValue, mappedConfigs); } @@ -5020,15 +5010,15 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, !*loc && !*imp && mci != mappedConfigs.end(); ++mci) { // Look for this configuration. - std::string mcUpper = cmSystemTools::UpperCase(mci->c_str()); + std::string mcUpper = cmSystemTools::UpperCase(*mci); std::string locProp = "IMPORTED_LOCATION_"; locProp += mcUpper; - *loc = this->GetProperty(locProp.c_str()); + *loc = this->GetProperty(locProp); if(allowImp) { std::string impProp = "IMPORTED_IMPLIB_"; impProp += mcUpper; - *imp = this->GetProperty(impProp.c_str()); + *imp = this->GetProperty(impProp); } // If it was found, use it for all properties below. @@ -5053,12 +5043,12 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, { std::string locProp = "IMPORTED_LOCATION"; locProp += suffix; - *loc = this->GetProperty(locProp.c_str()); + *loc = this->GetProperty(locProp); if(allowImp) { std::string impProp = "IMPORTED_IMPLIB"; impProp += suffix; - *imp = this->GetProperty(impProp.c_str()); + *imp = this->GetProperty(impProp); } } @@ -5095,12 +5085,12 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, suffix += cmSystemTools::UpperCase(*aci); std::string locProp = "IMPORTED_LOCATION"; locProp += suffix; - *loc = this->GetProperty(locProp.c_str()); + *loc = this->GetProperty(locProp); if(allowImp) { std::string impProp = "IMPORTED_IMPLIB"; impProp += suffix; - *imp = this->GetProperty(impProp.c_str()); + *imp = this->GetProperty(impProp); } } } @@ -5136,7 +5126,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, // Get the link interface. { std::string linkProp = "INTERFACE_LINK_LIBRARIES"; - const char *propertyLibs = this->GetProperty(linkProp.c_str()); + const char *propertyLibs = this->GetProperty(linkProp); if (this->GetType() != INTERFACE_LIBRARY) { @@ -5144,13 +5134,13 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; linkProp += suffix; - propertyLibs = this->GetProperty(linkProp.c_str()); + propertyLibs = this->GetProperty(linkProp); } if(!propertyLibs) { linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - propertyLibs = this->GetProperty(linkProp.c_str()); + propertyLibs = this->GetProperty(linkProp); } } if(propertyLibs) @@ -5163,7 +5153,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, linkProp, 0, 0); cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs) ->Evaluate(this->Makefile, - desired_config.c_str(), + desired_config, false, headTarget, this, @@ -5188,7 +5178,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string impProp = "IMPORTED_LOCATION"; impProp += suffix; - if(const char* config_location = this->GetProperty(impProp.c_str())) + if(const char* config_location = this->GetProperty(impProp)) { info.Location = config_location; } @@ -5203,7 +5193,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string soProp = "IMPORTED_SONAME"; soProp += suffix; - if(const char* config_soname = this->GetProperty(soProp.c_str())) + if(const char* config_soname = this->GetProperty(soProp)) { info.SOName = config_soname; } @@ -5218,7 +5208,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string soProp = "IMPORTED_NO_SONAME"; soProp += suffix; - if(const char* config_no_soname = this->GetProperty(soProp.c_str())) + if(const char* config_no_soname = this->GetProperty(soProp)) { info.NoSOName = cmSystemTools::IsOn(config_no_soname); } @@ -5238,7 +5228,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string impProp = "IMPORTED_IMPLIB"; impProp += suffix; - if(const char* config_implib = this->GetProperty(impProp.c_str())) + if(const char* config_implib = this->GetProperty(impProp)) { info.ImportLibrary = config_implib; } @@ -5252,7 +5242,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES"; linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp.c_str())) + if(const char* config_libs = this->GetProperty(linkProp)) { cmSystemTools::ExpandListArgument(config_libs, info.LinkInterface.SharedDeps); @@ -5269,7 +5259,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES"; linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp.c_str())) + if(const char* config_libs = this->GetProperty(linkProp)) { cmSystemTools::ExpandListArgument(config_libs, info.LinkInterface.Languages); @@ -5287,7 +5277,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; linkProp += suffix; - if(const char* config_reps = this->GetProperty(linkProp.c_str())) + if(const char* config_reps = this->GetProperty(linkProp)) { sscanf(config_reps, "%u", &info.LinkInterface.Multiplicity); } @@ -5300,7 +5290,8 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } //---------------------------------------------------------------------------- -cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, +cmTarget::LinkInterface const* cmTarget::GetLinkInterface( + const std::string& config, cmTarget const* head) const { // Imported targets have their own link interface. @@ -5322,7 +5313,7 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, } // Lookup any existing link interface for this configuration. - TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : "")); + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkInterfaceMapType::iterator i = this->Internal->LinkInterfaceMap.find(key); @@ -5330,24 +5321,124 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, { // Compute the link interface for this configuration. cmTargetInternals::OptionalLinkInterface iface; - iface.Exists = this->ComputeLinkInterface(config, iface, head); + iface.ExplicitLibraries = + this->ComputeLinkInterfaceLibraries(config, iface, head, iface.Exists); + if (iface.Exists) + { + this->Internal->ComputeLinkInterface(this, config, iface, + head, iface.ExplicitLibraries); + } // Store the information for this configuration. cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); i = this->Internal->LinkInterfaceMap.insert(entry).first; } + else if(!i->second.Complete && i->second.Exists) + { + this->Internal->ComputeLinkInterface(this, config, i->second, head, + i->second.ExplicitLibraries); + } - return i->second.Exists? &i->second : 0; + return i->second.Exists ? &i->second : 0; } //---------------------------------------------------------------------------- -void cmTarget::GetTransitivePropertyLinkLibraries( - const char* config, +cmTarget::LinkInterface const* +cmTarget::GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* head) const +{ + // Imported targets have their own link interface. + if(this->IsImported()) + { + if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, head)) + { + return &info->LinkInterface; + } + return 0; + } + + // Link interfaces are not supported for executables that do not + // export symbols. + if(this->GetType() == cmTarget::EXECUTABLE && + !this->IsExecutableWithExports()) + { + return 0; + } + + // Lookup any existing link interface for this configuration. + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); + + cmTargetInternals::LinkInterfaceMapType::iterator + i = this->Internal->LinkInterfaceMap.find(key); + if(i == this->Internal->LinkInterfaceMap.end()) + { + // Compute the link interface for this configuration. + cmTargetInternals::OptionalLinkInterface iface; + iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config, + iface, + head, + iface.Exists); + + // Store the information for this configuration. + cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface); + i = this->Internal->LinkInterfaceMap.insert(entry).first; + } + + return i->second.Exists ? &i->second : 0; +} + +//---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + std::string const& name, + std::vector<cmTarget*>& tgts, std::set<cmTarget*>& emitted) +{ + if (cmTarget* tgt = headTarget->GetMakefile() + ->FindTargetToUse(name)) + { + if (emitted.insert(tgt).second) + { + tgts.push_back(tgt); + std::vector<std::string> ilibs; + cmTarget::LinkInterface const* iface = + tgt->GetLinkInterfaceLibraries(config, headTarget); + if (iface) + { + for(std::vector<std::string>::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } + } +} + +//---------------------------------------------------------------------------- +void cmTarget::GetTransitiveTargetClosure(const std::string& config, + cmTarget const* headTarget, + std::vector<cmTarget*> &tgts) const +{ + std::set<cmTarget*> emitted; + + cmTarget::LinkImplementation const* impl + = this->GetLinkImplementationLibraries(config, headTarget); + + for(std::vector<std::string>::const_iterator it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } +} + +//---------------------------------------------------------------------------- +void cmTarget::GetTransitivePropertyTargets(const std::string& config, cmTarget const* headTarget, - std::vector<std::string> &libs) const + std::vector<cmTarget*> &tgts) const { - cmTarget::LinkInterface const* iface = this->GetLinkInterface(config, - headTarget); + cmTarget::LinkInterface const* iface + = this->GetLinkInterfaceLibraries(config, headTarget); if (!iface) { return; @@ -5356,7 +5447,15 @@ void cmTarget::GetTransitivePropertyLinkLibraries( || this->GetPolicyStatusCMP0022() == cmPolicies::WARN || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) { - libs = iface->Libraries; + for(std::vector<std::string>::const_iterator it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + if (cmTarget* tgt = headTarget->GetMakefile() + ->FindTargetToUse(*it)) + { + tgts.push_back(tgt); + } + } return; } @@ -5374,21 +5473,34 @@ void cmTarget::GetTransitivePropertyLinkLibraries( cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), linkIfaceProp, 0, 0); dagChecker.SetTransitivePropertiesOnly(); + std::vector<std::string> libs; cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate( this->Makefile, config, false, headTarget, this, &dagChecker), libs); + + for(std::vector<std::string>::const_iterator it = libs.begin(); + it != libs.end(); ++it) + { + if (cmTarget* tgt = headTarget->GetMakefile() + ->FindTargetToUse(*it)) + { + tgts.push_back(tgt); + } + } } //---------------------------------------------------------------------------- -bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget const* headTarget) const +const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config, + LinkInterface& iface, + cmTarget const* headTarget, + bool &exists) const { // Construct the property name suffix for this configuration. std::string suffix = "_"; - if(config && *config) + if(!config.empty()) { suffix += cmSystemTools::UpperCase(config); } @@ -5406,7 +5518,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); + explicitLibraries = this->GetProperty(linkIfaceProp); } else if(this->GetType() == cmTarget::SHARED_LIBRARY || this->IsExecutableWithExports()) @@ -5417,13 +5529,13 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; - explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); + explicitLibraries = this->GetProperty(linkIfaceProp); // If not set, try the generic property. if(!explicitLibraries) { linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; - explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); + explicitLibraries = this->GetProperty(linkIfaceProp); } } @@ -5460,8 +5572,10 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, (this->GetType() == cmTarget::EXECUTABLE || (this->GetType() == cmTarget::MODULE_LIBRARY))) { - return false; + exists = false; + return 0; } + exists = true; if(explicitLibraries) { @@ -5476,52 +5590,6 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, false, headTarget, this, &dagChecker), iface.Libraries); - - if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY - || this->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // Shared libraries may have runtime implementation dependencies - // on other shared libraries that are not in the interface. - std::set<cmStdString> emitted; - for(std::vector<std::string>::const_iterator - li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) - { - emitted.insert(*li); - } - if (this->GetType() != cmTarget::INTERFACE_LIBRARY) - { - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); - for(std::vector<std::string>::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) - { - if(emitted.insert(*li).second) - { - if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li)) - { - // This is a runtime dependency on another shared library. - if(tgt->GetType() == cmTarget::SHARED_LIBRARY) - { - iface.SharedDeps.push_back(*li); - } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. - } - } - } - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - iface.Languages = impl->Languages; - } - } - } } else if (this->PolicyStatusCMP0022 == cmPolicies::WARN || this->PolicyStatusCMP0022 == cmPolicies::OLD) @@ -5531,17 +5599,9 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // to the link implementation. { // The link implementation is the default link interface. - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); - iface.ImplementationIsInterface = true; + LinkImplementation const* impl = + this->GetLinkImplementationLibraries(config, headTarget); iface.Libraries = impl->Libraries; - iface.WrongConfigLibraries = impl->WrongConfigLibraries; - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - iface.Languages = impl->Languages; - } - if(this->PolicyStatusCMP0022 == cmPolicies::WARN && !this->Internal->PolicyWarnedCMP0022) { @@ -5606,30 +5666,148 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, } } } + return explicitLibraries; +} - if(this->GetType() == cmTarget::STATIC_LIBRARY) +//---------------------------------------------------------------------------- +void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, + const std::string& config, + OptionalLinkInterface& iface, + cmTarget const* headTarget, + const char* explicitLibraries) const +{ + if(explicitLibraries) + { + if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY + || thisTarget->GetType() == cmTarget::STATIC_LIBRARY + || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY) + { + // Shared libraries may have runtime implementation dependencies + // on other shared libraries that are not in the interface. + std::set<std::string> emitted; + for(std::vector<std::string>::const_iterator + li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li) + { + emitted.insert(*li); + } + if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY) + { + cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementation(config, headTarget); + for(std::vector<std::string>::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + { + if(emitted.insert(*li).second) + { + if(cmTarget* tgt = thisTarget->Makefile->FindTargetToUse(*li)) + { + // This is a runtime dependency on another shared library. + if(tgt->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. + } + } + } + if(thisTarget->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + iface.Languages = impl->Languages; + } + } + } + } + else if (thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN + || thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD) + { + // The link implementation is the default link interface. + cmTarget::LinkImplementation const* + impl = thisTarget->GetLinkImplementation(config, headTarget); + iface.ImplementationIsInterface = true; + iface.WrongConfigLibraries = impl->WrongConfigLibraries; + if(thisTarget->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + iface.Languages = impl->Languages; + } + } + + if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY) { + // Construct the property name suffix for this configuration. + std::string suffix = "_"; + if(!config.empty()) + { + suffix += cmSystemTools::UpperCase(config); + } + else + { + suffix += "NOCONFIG"; + } + // How many repetitions are needed if this library has cyclic // dependencies? std::string propName = "LINK_INTERFACE_MULTIPLICITY"; propName += suffix; - if(const char* config_reps = this->GetProperty(propName.c_str())) + if(const char* config_reps = thisTarget->GetProperty(propName)) { sscanf(config_reps, "%u", &iface.Multiplicity); } else if(const char* reps = - this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) + thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY")) { sscanf(reps, "%u", &iface.Multiplicity); } } + iface.Complete = true; +} + +//---------------------------------------------------------------------------- +cmTarget::LinkImplementation const* +cmTarget::GetLinkImplementation(const std::string& config, + cmTarget const* head) const +{ + // There is no link implementation for imported targets. + if(this->IsImported()) + { + return 0; + } - return true; + // Lookup any existing link implementation for this configuration. + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); + + cmTargetInternals::LinkImplMapType::iterator + i = this->Internal->LinkImplMap.find(key); + if(i == this->Internal->LinkImplMap.end()) + { + // Compute the link implementation for this configuration. + LinkImplementation impl; + this->ComputeLinkImplementation(config, impl, head); + this->ComputeLinkImplementationLanguages(impl); + + // Store the information for this configuration. + cmTargetInternals::LinkImplMapType::value_type entry(key, impl); + i = this->Internal->LinkImplMap.insert(entry).first; + } + else if (i->second.Languages.empty()) + { + this->ComputeLinkImplementationLanguages(i->second); + } + + return &i->second; } //---------------------------------------------------------------------------- cmTarget::LinkImplementation const* -cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const +cmTarget::GetLinkImplementationLibraries(const std::string& config, + cmTarget const* head) const { // There is no link implementation for imported targets. if(this->IsImported()) @@ -5638,7 +5816,7 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const } // Lookup any existing link implementation for this configuration. - TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : "")); + TargetConfigPair key(head, cmSystemTools::UpperCase(config)); cmTargetInternals::LinkImplMapType::iterator i = this->Internal->LinkImplMap.find(key); @@ -5657,7 +5835,7 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const } //---------------------------------------------------------------------------- -void cmTarget::ComputeLinkImplementation(const char* config, +void cmTarget::ComputeLinkImplementation(const std::string& config, LinkImplementation& impl, cmTarget const* head) const { @@ -5729,9 +5907,14 @@ void cmTarget::ComputeLinkImplementation(const char* config, impl.WrongConfigLibraries.push_back(item); } } +} +//---------------------------------------------------------------------------- +void +cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const +{ // This target needs runtime libraries for its source languages. - std::set<cmStdString> languages; + std::set<std::string> languages; // Get languages used in our source files. this->GetLanguages(languages); // Get languages used in object library sources. @@ -5748,7 +5931,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, } } // Copy the set of langauges to the link implementation. - for(std::set<cmStdString>::iterator li = languages.begin(); + for(std::set<std::string>::iterator li = languages.begin(); li != languages.end(); ++li) { impl.Languages.push_back(*li); @@ -5816,15 +5999,15 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const template<typename PropertyType> PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string prop, - const char *config, + const std::string& prop, + const std::string& config, CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string prop, - const char *config, + const std::string& prop, + const std::string& config, CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); @@ -5832,8 +6015,8 @@ bool getLinkInterfaceDependentProperty(cmTarget const* tgt, template<> const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string prop, - const char *config, + const std::string& prop, + const std::string& config, CompatibleType t, const char **) { @@ -5857,9 +6040,9 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, template<typename PropertyType> void checkPropertyConsistency(cmTarget const* depender, cmTarget const* dependee, - const char *propName, - std::set<cmStdString> &emitted, - const char *config, + const std::string& propName, + std::set<std::string> &emitted, + const std::string& config, CompatibleType t, PropertyType *) { @@ -5902,10 +6085,10 @@ void checkPropertyConsistency(cmTarget const* depender, } } -static cmStdString intersect(const std::set<cmStdString> &s1, - const std::set<cmStdString> &s2) +static std::string intersect(const std::set<std::string> &s1, + const std::set<std::string> &s2) { - std::set<cmStdString> intersect; + std::set<std::string> intersect; std::set_intersection(s1.begin(),s1.end(), s2.begin(),s2.end(), std::inserter(intersect,intersect.begin())); @@ -5915,11 +6098,11 @@ static cmStdString intersect(const std::set<cmStdString> &s1, } return ""; } -static cmStdString intersect(const std::set<cmStdString> &s1, - const std::set<cmStdString> &s2, - const std::set<cmStdString> &s3) +static std::string intersect(const std::set<std::string> &s1, + const std::set<std::string> &s2, + const std::set<std::string> &s3) { - cmStdString result; + std::string result; result = intersect(s1, s2); if (!result.empty()) return result; @@ -5928,12 +6111,12 @@ static cmStdString intersect(const std::set<cmStdString> &s1, return result; return intersect(s2, s3); } -static cmStdString intersect(const std::set<cmStdString> &s1, - const std::set<cmStdString> &s2, - const std::set<cmStdString> &s3, - const std::set<cmStdString> &s4) +static std::string intersect(const std::set<std::string> &s1, + const std::set<std::string> &s2, + const std::set<std::string> &s3, + const std::set<std::string> &s4) { - cmStdString result; + std::string result; result = intersect(s1, s2); if (!result.empty()) return result; @@ -5948,14 +6131,14 @@ static cmStdString intersect(const std::set<cmStdString> &s1, //---------------------------------------------------------------------------- void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const char* config) const + const std::string& config) const { const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - std::set<cmStdString> emittedBools; - std::set<cmStdString> emittedStrings; - std::set<cmStdString> emittedMinNumbers; - std::set<cmStdString> emittedMaxNumbers; + std::set<std::string> emittedBools; + std::set<std::string> emittedStrings; + std::set<std::string> emittedMinNumbers; + std::set<std::string> emittedMaxNumbers; for(cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin(); @@ -5967,32 +6150,32 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } checkPropertyConsistency<bool>(this, li->Target, - "COMPATIBLE_INTERFACE_BOOL", - emittedBools, config, BoolType, 0); + std::string("COMPATIBLE_INTERFACE_BOOL"), + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char *>(this, li->Target, - "COMPATIBLE_INTERFACE_STRING", - emittedStrings, config, - StringType, 0); + std::string("COMPATIBLE_INTERFACE_STRING"), + emittedStrings, config, + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char *>(this, li->Target, - "COMPATIBLE_INTERFACE_NUMBER_MIN", - emittedMinNumbers, config, - NumberMinType, 0); + std::string("COMPATIBLE_INTERFACE_NUMBER_MIN"), + emittedMinNumbers, config, + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char *>(this, li->Target, - "COMPATIBLE_INTERFACE_NUMBER_MAX", - emittedMaxNumbers, config, - NumberMaxType, 0); + std::string("COMPATIBLE_INTERFACE_NUMBER_MAX"), + emittedMaxNumbers, config, + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -6007,7 +6190,7 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, if (!prop.empty()) { std::set<std::string> props; - std::set<cmStdString>::const_iterator i = emittedBools.find(prop); + std::set<std::string>::const_iterator i = emittedBools.find(prop); if (i != emittedBools.end()) { props.insert("COMPATIBLE_INTERFACE_BOOL"); @@ -6052,12 +6235,12 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, //---------------------------------------------------------------------------- cmComputeLinkInformation* -cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const +cmTarget::GetLinkInformation(const std::string& config, + cmTarget const* head) const { cmTarget const* headTarget = head ? head : this; // Lookup any existing information for this configuration. - TargetConfigPair key(headTarget, - cmSystemTools::UpperCase(config?config:"")); + TargetConfigPair key(headTarget, cmSystemTools::UpperCase(config)); cmTargetLinkInformationMap::iterator i = this->LinkInformation.find(key); if(i == this->LinkInformation.end()) @@ -6084,7 +6267,7 @@ cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const char* config, +std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; @@ -6099,7 +6282,7 @@ std::string cmTarget::GetFrameworkDirectory(const char* config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const char* config, +std::string cmTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; @@ -6118,7 +6301,7 @@ std::string cmTarget::GetCFBundleDirectory(const char* config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const char* config, +std::string cmTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath = this->GetFullName(config, false); @@ -6130,7 +6313,7 @@ std::string cmTarget::GetAppBundleDirectory(const char* config, //---------------------------------------------------------------------------- std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const char* config, + const std::string& config, bool contentOnly) const { std::string fpath = base; @@ -6150,7 +6333,7 @@ std::string cmTarget::BuildMacContentDirectory(const std::string& base, } //---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const char* config, +std::string cmTarget::GetMacContentDirectory(const std::string& config, bool implib) const { // Start with the output directory for the target. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0e9d682..3ef853b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -96,13 +96,13 @@ public: /** * Set the target type */ - void SetType(TargetType f, const char* name); + void SetType(TargetType f, const std::string& name); void MarkAsImported(); ///! Set/Get the name of the target - const char* GetName() const {return this->Name.c_str();} - const char* GetExportName() const; + const std::string& GetName() const {return this->Name;} + std::string GetExportName() const; ///! Set the cmMakefile that owns this target void SetMakefile(cmMakefile *mf); @@ -143,68 +143,40 @@ public: } /** - * Flags for a given source file as used in this target. Typically assigned - * via SET_TARGET_PROPERTIES when the property is a list of source files. - */ - enum SourceFileType - { - SourceFileTypeNormal, - SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property - SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property - SourceFileTypeResource, // is in "RESOURCE" target property *or* - // has MACOSX_PACKAGE_LOCATION=="Resources" - SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources" - }; - struct SourceFileFlags - { - SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {} - SourceFileFlags(SourceFileFlags const& r): - Type(r.Type), MacFolder(r.MacFolder) {} - SourceFileType Type; - const char* MacFolder; // location inside Mac content folders - }; - - /** - * Get the flags for a given source file as used in this target - */ - struct SourceFileFlags - GetTargetSourceFileFlags(const cmSourceFile* sf) const; - - /** * Add sources to the target. */ void AddSources(std::vector<std::string> const& srcs); - cmSourceFile* AddSource(const char* src); + cmSourceFile* AddSource(const std::string& src); enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; //* how we identify a library, by name and type - typedef std::pair<cmStdString, LinkLibraryType> LibraryID; + typedef std::pair<std::string, LinkLibraryType> LibraryID; typedef std::vector<LibraryID > LinkLibraryVectorType; const LinkLibraryVectorType &GetLinkLibraries() const { return this->LinkLibraries;} const LinkLibraryVectorType &GetOriginalLinkLibraries() const {return this->OriginalLinkLibraries;} - void GetDirectLinkLibraries(const char *config, + void GetDirectLinkLibraries(const std::string& config, std::vector<std::string> &, cmTarget const* head) const; - void GetInterfaceLinkLibraries(const char *config, + void GetInterfaceLinkLibraries(const std::string& config, std::vector<std::string> &, cmTarget const* head) const; /** Compute the link type to use for the given configuration. */ - LinkLibraryType ComputeLinkType(const char* config) const; + LinkLibraryType ComputeLinkType(const std::string& config) const; /** * Clear the dependency information recorded for this target, if any. */ - void ClearDependencyInformation(cmMakefile& mf, const char* target); + void ClearDependencyInformation(cmMakefile& mf, const std::string& target); // Check to see if a library is a framework and treat it different on Mac bool NameResolvesToFramework(const std::string& libname) const; void AddLinkLibrary(cmMakefile& mf, - const char *target, const char* lib, + const std::string& target, const std::string& lib, LinkLibraryType llt); enum TLLSignature { KeywordTLLSignature, @@ -213,12 +185,12 @@ public: bool PushTLLCommandTrace(TLLSignature signature); void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const; - void MergeLinkLibraries( cmMakefile& mf, const char* selfname, + void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname, const LinkLibraryVectorType& libs ); const std::vector<std::string>& GetLinkDirectories() const; - void AddLinkDirectory(const char* d); + void AddLinkDirectory(const std::string& d); /** * Set the path where this target should be installed. This is relative to @@ -245,23 +217,26 @@ public: * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE * commands. It is not a full path nor does it have an extension. */ - void AddUtility(const char* u, cmMakefile *makefile = 0); + void AddUtility(const std::string& u, cmMakefile *makefile = 0); ///! Get the utilities used by this target - std::set<cmStdString>const& GetUtilities() const { return this->Utilities; } - cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const; + std::set<std::string>const& GetUtilities() const { return this->Utilities; } + cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const; /** Finalize the target at the end of the Configure step. */ void FinishConfigure(); ///! Set/Get a property of this target file - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value,bool asString=false); - const char *GetProperty(const char *prop) const; - const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; - bool GetPropertyAsBool(const char *prop) const; - void CheckProperty(const char* prop, cmMakefile* context) const; - - const char* GetFeature(const char* feature, const char* config) const; + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, const char* value, + bool asString=false); + const char *GetProperty(const std::string& prop) const; + const char *GetProperty(const std::string& prop, + cmProperty::ScopeType scope) const; + bool GetPropertyAsBool(const std::string& prop) const; + void CheckProperty(const std::string& prop, cmMakefile* context) const; + + const char* GetFeature(const std::string& feature, + const std::string& config) const; bool IsImported() const {return this->IsImportedTarget;} @@ -293,11 +268,16 @@ public: /** Get the link interface for the given configuration. Returns 0 if the target cannot be linked. */ - LinkInterface const* GetLinkInterface(const char* config, + LinkInterface const* GetLinkInterface(const std::string& config, cmTarget const* headTarget) const; - void GetTransitivePropertyLinkLibraries(const char* config, + LinkInterface const* GetLinkInterfaceLibraries(const std::string& config, + cmTarget const* headTarget) const; + void GetTransitivePropertyTargets(const std::string& config, + cmTarget const* headTarget, + std::vector<cmTarget*> &libs) const; + void GetTransitiveTargetClosure(const std::string& config, cmTarget const* headTarget, - std::vector<std::string> &libs) const; + std::vector<cmTarget*> &libs) const; /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ @@ -313,7 +293,11 @@ public: // Needed only for OLD behavior of CMP0003. std::vector<std::string> WrongConfigLibraries; }; - LinkImplementation const* GetLinkImplementation(const char* config, + LinkImplementation const* GetLinkImplementation(const std::string& config, + cmTarget const* head) const; + + LinkImplementation const* GetLinkImplementationLibraries( + const std::string& config, cmTarget const* head) const; /** Link information from the transitive closure of the link @@ -326,7 +310,7 @@ public: // Languages whose runtime libraries must be linked. std::vector<std::string> Languages; }; - LinkClosure const* GetLinkClosure(const char* config, + LinkClosure const* GetLinkClosure(const std::string& config, cmTarget const* head) const; /** Strip off leading and trailing whitespace from an item named in @@ -337,18 +321,29 @@ public: configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical output directory is given. */ - std::string GetDirectory(const char* config = 0, bool implib = false) const; + std::string GetDirectory(const std::string& config = "", + bool implib = false) const; /** Get the directory in which this targets .pdb files will be placed. If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical pdb output directory is given. */ - std::string GetPDBDirectory(const char* config = 0) const; + std::string GetPDBDirectory(const std::string& config) const; + + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; /** Get the location of the target in the build tree for the given - configuration. This location is suitable for use as the LOCATION - target property. */ - const char* GetLocation(const char* config) const; + configuration. */ + const char* GetLocation(const std::string& config) const; + + /** Get the location of the target in the build tree with a placeholder + referencing the configuration in the native build system. This + location is suitable for use as the LOCATION target property. */ + const char* GetLocationForBuild() const; /** Get the target major and minor version numbers interpreted from the VERSION property. Version 0 is returned if the property is @@ -361,44 +356,47 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - /** - * Make sure the full path to all source files is known. - */ - bool FindSourceFiles(); - ///! Return the preferred linker language for this target - const char* GetLinkerLanguage(const char* config = 0, + std::string GetLinkerLanguage(const std::string& config = "", cmTarget const* head = 0) const; /** Get the full name of the target according to the settings in its makefile. */ - std::string GetFullName(const char* config=0, bool implib = false) const; + std::string GetFullName(const std::string& config="", + bool implib = false) const; void GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, - const char* config=0, bool implib = false) const; + const std::string& config="", + bool implib = false) const; /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const char* config=0) const; + std::string GetPDBName(const std::string& config) const; + + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const char* config) const; + bool HasSOName(const std::string& config) const; /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const char* config) const; + std::string GetSOName(const std::string& config) const; /** Whether this library has \@rpath and platform supports it. */ - bool HasMacOSXRpathInstallNameDir(const char* config) const; + bool HasMacOSXRpathInstallNameDir(const std::string& config) const; /** Whether this library defaults to \@rpath. */ bool MacOSXRpathInstallNameDirDefault() const; /** Test for special case of a third-party shared library that has no soname at all. */ - bool IsImportedSharedLibWithoutSOName(const char* config) const; + bool IsImportedSharedLibWithoutSOName(const std::string& config) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ - std::string GetFullPath(const char* config=0, bool implib = false, + std::string GetFullPath(const std::string& config="", bool implib = false, bool realname = false) const; /** Get the names of the library needed to generate a build rule @@ -406,14 +404,15 @@ public: should be called only on a library target. */ void GetLibraryNames(std::string& name, std::string& soName, std::string& realName, std::string& impName, - std::string& pdbName, const char* config) const; + std::string& pdbName, const std::string& config) const; /** Get the names of the executable needed to generate a build rule that takes into account executable version numbers. This should be called only on an executable target. */ void GetExecutableNames(std::string& name, std::string& realName, std::string& impName, - std::string& pdbName, const char* config) const; + std::string& pdbName, + const std::string& config) const; /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; @@ -426,24 +425,24 @@ public: /** * Compute whether this target must be relinked before installing. */ - bool NeedRelinkBeforeInstall(const char* config) const; + bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const char *config) const; + bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const char* config) const; + bool IsChrpathUsed(const std::string& config) const; /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const char* config) const; + std::string GetInstallNameDirForBuildTree(const std::string& config) const; /** Return the install name directory for the target in the * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* GetLinkInformation(const char* config, + cmComputeLinkInformation* GetLinkInformation(const std::string& config, cmTarget const* head = 0) const; // Get the properties @@ -462,14 +461,14 @@ public: const char* GetExportMacro() const; void GetCompileDefinitions(std::vector<std::string> &result, - const char *config) const; + const std::string& config) const; // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough // information to forward these property changes to the targets // until we have per-target object file properties. - void GetLanguages(std::set<cmStdString>& languages) const; + void GetLanguages(std::set<std::string>& languages) const; /** Return whether this target is an executable with symbol exports enabled. */ @@ -510,26 +509,29 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const char* config, bool implib) const; + bool UsesDefaultOutputDir(const std::string& config, bool implib) const; /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const char* config, + std::string GetMacContentDirectory(const std::string& config, bool implib) const; /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const char* config, bool rootDir) const; + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const char* config, bool contentOnly) const; + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const char* config, + std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; - std::vector<std::string> GetIncludeDirectories(const char *config) const; + std::vector<std::string> GetIncludeDirectories( + const std::string& config) const; void InsertInclude(const cmValueWithOrigin &entry, bool before = false); void InsertCompileOption(const cmValueWithOrigin &entry, @@ -539,36 +541,36 @@ public: void AppendBuildInterfaceIncludes(); void GetCompileOptions(std::vector<std::string> &result, - const char *config) const; + const std::string& config) const; void GetAutoUicOptions(std::vector<std::string> &result, - const char *config) const; + const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) const; + const std::string& config) const; bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const char *config) const; + const std::string& config) const; bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const char *config) const; + const std::string& config) const; bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const char *config) const; + const std::string& config) const; bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) const; + const std::string& config) const; const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const char *config) const; + const std::string& config) const; const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const char *config) const; + const std::string& config) const; const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const char *config) const; + const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; - void AddSystemIncludeDirectories(const std::set<cmStdString> &incs); + void AddSystemIncludeDirectories(const std::set<std::string> &incs); void AddSystemIncludeDirectories(const std::vector<std::string> &incs); - std::set<cmStdString> const & GetSystemIncludeDirectories() const + std::set<std::string> const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } bool LinkLanguagePropagatesToDependents() const @@ -584,7 +586,7 @@ private: // The set of include directories that are marked as system include // directories. - std::set<cmStdString> SystemIncludeDirectories; + std::set<std::string> SystemIncludeDirectories; std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands; @@ -641,39 +643,40 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const char* config, bool implib) const; - void GetFullNameInternal(const char* config, bool implib, + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. - void SetPropertyDefault(const char* property, const char* default_value); + void SetPropertyDefault(const std::string& property, + const char* default_value); // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; // Get the target base name. - std::string GetOutputName(const char* config, bool implib) const; + std::string GetOutputName(const std::string& config, bool implib) const; - const char* ImportedGetLocation(const char* config) const; - const char* NormalGetLocation(const char* config) const; + std::string GetFullNameImported(const std::string& config, + bool implib) const; - std::string GetFullNameImported(const char* config, bool implib) const; - - std::string ImportedGetFullPath(const char* config, bool implib) const; - std::string NormalGetFullPath(const char* config, bool implib, + std::string ImportedGetFullPath(const std::string& config, + bool implib) const; + std::string NormalGetFullPath(const std::string& config, bool implib, bool realname) const; /** Get the real name of the target. Allowed only for non-imported targets. When a library or executable file is versioned this is the full versioned name. If the target is not versioned this is the same as GetFullName. */ - std::string NormalGetRealName(const char* config) const; + std::string NormalGetRealName(const std::string& config) const; /** Append to @a base the mac content directory and return it. */ std::string BuildMacContentDirectory(const std::string& base, - const char* config, + const std::string& config, bool contentOnly) const; private: @@ -688,13 +691,13 @@ private: LinkLibraryVectorType PrevLinkedLibraries; bool LinkLibrariesAnalyzed; std::vector<std::string> LinkDirectories; - std::set<cmStdString> LinkDirectoriesEmmitted; + std::set<std::string> LinkDirectoriesEmmitted; bool HaveInstallRule; std::string InstallPath; std::string RuntimeInstallPath; mutable std::string ExportMacro; - std::set<cmStdString> Utilities; - std::map<cmStdString, cmListFileBacktrace> UtilityBacktraces; + std::set<std::string> Utilities; + std::map<std::string, cmListFileBacktrace> UtilityBacktraces; bool RecordDependencies; mutable cmPropertyMap Properties; LinkLibraryVectorType OriginalLinkLibraries; @@ -710,34 +713,43 @@ private: // Cache target output paths for each configuration. struct OutputInfo; - OutputInfo const* GetOutputInfo(const char* config) const; + OutputInfo const* GetOutputInfo(const std::string& config) const; bool - ComputeOutputDir(const char* config, bool implib, std::string& out) const; - bool ComputePDBOutputDir(const char* config, std::string& out) const; + ComputeOutputDir(const std::string& config, + bool implib, std::string& out) const; + bool ComputePDBOutputDir(const std::string& kind, const std::string& config, + std::string& out) const; // Cache import information from properties for each configuration. struct ImportInfo; - ImportInfo const* GetImportInfo(const char* config, + ImportInfo const* GetImportInfo(const std::string& config, cmTarget const* workingTarget) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info, cmTarget const* head) const; + // Cache target compile paths for each configuration. + struct CompileInfo; + CompileInfo const* GetCompileInfo(const std::string& config) const; + mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const char* config) const; + const std::string& config) const; - bool ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget const* head) const; + const char* ComputeLinkInterfaceLibraries(const std::string& config, + LinkInterface& iface, + cmTarget const* head, + bool &exists) const; - void ComputeLinkImplementation(const char* config, + void ComputeLinkImplementation(const std::string& config, LinkImplementation& impl, cmTarget const* head) const; - void ComputeLinkClosure(const char* config, LinkClosure& lc, + void ComputeLinkImplementationLanguages(LinkImplementation& impl) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc, cmTarget const* head) const; void ClearLinkMaps(); - void MaybeInvalidatePropertyCache(const char* prop); + void MaybeInvalidatePropertyCache(const std::string& prop); void ProcessSourceExpression(std::string const& expr); @@ -759,7 +771,6 @@ private: friend class cmTargetTraceDependencies; cmTargetInternalPointer Internal; - void ConstructSourceFileFlags() const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, @@ -768,9 +779,9 @@ private: const char* version) const; }; -typedef std::map<cmStdString,cmTarget> cmTargets; +typedef std::map<std::string,cmTarget> cmTargets; -class cmTargetSet: public std::set<cmStdString> {}; -class cmTargetManifest: public std::map<cmStdString, cmTargetSet> {}; +class cmTargetSet: public std::set<std::string> {}; +class cmTargetManifest: public std::map<std::string, cmTargetSet> {}; #endif diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 7405e90..5ba9e03 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -36,7 +36,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "target_compile_definitions";} + virtual std::string GetName() const { return "target_compile_definitions";} cmTypeMacro(cmTargetCompileDefinitionsCommand, cmTargetPropCommandBase); diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index 3713e5a..d58dc07 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -36,7 +36,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "target_compile_options";} + virtual std::string GetName() const { return "target_compile_options";} cmTypeMacro(cmTargetCompileOptionsCommand, cmTargetPropCommandBase); diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 6863ee5..c8b22fb 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -37,7 +37,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "target_include_directories";} + virtual std::string GetName() const { return "target_include_directories";} cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmTargetPropCommandBase); diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 95a2cba..1c2e625 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -39,7 +39,7 @@ bool cmTargetLinkLibrariesCommand // Lookup the target for which libraries are specified. this->Target = this->Makefile->GetCMakeInstance() - ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); + ->GetGlobalGenerator()->FindTarget(args[0]); if(!this->Target) { cmake::MessageType t = cmake::FATAL_ERROR; // fail by default @@ -125,7 +125,7 @@ bool cmTargetLinkLibrariesCommand e << "Utility target \"" << this->Target->GetName() << "\" " << modal << " not be used as the target of a target_link_libraries call."; - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if(messageType == cmake::FATAL_ERROR) { return false; @@ -273,7 +273,7 @@ bool cmTargetLinkLibrariesCommand { // The link type was specified by the previous argument. haveLLT = false; - if (!this->HandleLibrary(args[i].c_str(), llt)) + if (!this->HandleLibrary(args[i], llt)) { return false; } @@ -290,7 +290,7 @@ bool cmTargetLinkLibrariesCommand std::string linkType = args[0]; linkType += "_LINK_TYPE"; const char* linkTypeString = - this->Makefile->GetDefinition( linkType.c_str() ); + this->Makefile->GetDefinition( linkType ); if(linkTypeString) { if(strcmp(linkTypeString, "debug") == 0) @@ -302,7 +302,7 @@ bool cmTargetLinkLibrariesCommand llt = cmTarget::OPTIMIZED; } } - if (!this->HandleLibrary(args[i].c_str(), llt)) + if (!this->HandleLibrary(args[i], llt)) { return false; } @@ -353,7 +353,7 @@ cmTargetLinkLibrariesCommand //---------------------------------------------------------------------------- bool -cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, +cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, cmTarget::LinkLibraryType llt) { if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY @@ -409,7 +409,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, sig == cmTarget::KeywordTLLSignature ? cmTarget::PlainTLLSignature : cmTarget::KeywordTLLSignature); - this->Makefile->IssueMessage(messageType, e.str().c_str()); + this->Makefile->IssueMessage(messageType, e.str()); if(messageType == cmake::FATAL_ERROR) { return false; @@ -481,13 +481,13 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, { prop = "LINK_INTERFACE_LIBRARIES_"; prop += *i; - this->Target->AppendProperty(prop.c_str(), lib); + this->Target->AppendProperty(prop, lib.c_str()); } } if(llt == cmTarget::OPTIMIZED || llt == cmTarget::GENERAL) { // Put in the non-DEBUG configuration interfaces. - this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib); + this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib.c_str()); // Make sure the DEBUG configuration interfaces exist so that the // general one will not be used as a fall-back. @@ -496,9 +496,9 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, { prop = "LINK_INTERFACE_LIBRARIES_"; prop += *i; - if(!this->Target->GetProperty(prop.c_str())) + if(!this->Target->GetProperty(prop)) { - this->Target->SetProperty(prop.c_str(), ""); + this->Target->SetProperty(prop, ""); } } } diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 6fbf722..47dd8bd 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -42,7 +42,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "target_link_libraries";} + virtual std::string GetName() const { return "target_link_libraries";} cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand); private: @@ -62,7 +62,7 @@ private: ProcessingState CurrentProcessingState; - bool HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt); + bool HandleLibrary(const std::string& lib, cmTarget::LinkLibraryType llt); }; diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 195690e..d356611 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -16,8 +16,9 @@ //---------------------------------------------------------------------------- bool cmTargetPropCommandBase -::HandleArguments(std::vector<std::string> const& args, const char *prop, - ArgumentFlags flags) +::HandleArguments(std::vector<std::string> const& args, + const std::string& prop, + ArgumentFlags flags) { if(args.size() < 2) { @@ -33,7 +34,7 @@ bool cmTargetPropCommandBase } this->Target = this->Makefile->GetCMakeInstance() - ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); + ->GetGlobalGenerator()->FindTarget(args[0]); if(!this->Target) { this->Target = this->Makefile->FindTargetToUse(args[0]); @@ -164,15 +165,15 @@ void cmTargetPropCommandBase::HandleInterfaceContent(cmTarget *tgt, if (prepend) { const std::string propName = std::string("INTERFACE_") + this->Property; - const char *propValue = tgt->GetProperty(propName.c_str()); + const char *propValue = tgt->GetProperty(propName); const std::string totalContent = this->Join(content) + (propValue ? std::string(";") + propValue : std::string()); - tgt->SetProperty(propName.c_str(), totalContent.c_str()); + tgt->SetProperty(propName, totalContent.c_str()); } else { - tgt->AppendProperty(("INTERFACE_" + this->Property).c_str(), + tgt->AppendProperty("INTERFACE_" + this->Property, this->Join(content).c_str()); } } diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index c402836..555a08a 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -29,7 +29,8 @@ public: }; bool HandleArguments(std::vector<std::string> const& args, - const char *prop, ArgumentFlags flags = NO_FLAGS); + const std::string& prop, + ArgumentFlags flags = NO_FLAGS); cmTypeMacro(cmTargetPropCommandBase, cmCommand); protected: diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 9cda978..28a7bb1 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -38,12 +38,8 @@ cmListFileBacktrace const& cmTest::GetBacktrace() const } //---------------------------------------------------------------------------- -void cmTest::SetName(const char* name) +void cmTest::SetName(const std::string& name) { - if ( !name ) - { - name = ""; - } this->Name = name; } @@ -54,7 +50,7 @@ void cmTest::SetCommand(std::vector<std::string> const& command) } //---------------------------------------------------------------------------- -const char *cmTest::GetProperty(const char* prop) const +const char *cmTest::GetProperty(const std::string& prop) const { bool chain = false; const char *retVal = @@ -67,28 +63,20 @@ const char *cmTest::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -bool cmTest::GetPropertyAsBool(const char* prop) const +bool cmTest::GetPropertyAsBool(const std::string& prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } //---------------------------------------------------------------------------- -void cmTest::SetProperty(const char* prop, const char* value) +void cmTest::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } - this->Properties.SetProperty(prop, value, cmProperty::TEST); } //---------------------------------------------------------------------------- -void cmTest::AppendProperty(const char* prop, const char* value, bool asString) +void cmTest::AppendProperty(const std::string& prop, + const char* value, bool asString) { - if (!prop) - { - return; - } this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString); } diff --git a/Source/cmTest.h b/Source/cmTest.h index 1fe8fc0..b3785f6 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -31,8 +31,8 @@ public: ~cmTest(); ///! Set the test name - void SetName(const char* name); - const char* GetName() const { return this->Name.c_str(); } + void SetName(const std::string& name); + std::string GetName() const { return this->Name; } void SetCommand(std::vector<std::string> const& command); std::vector<std::string> const& GetCommand() const @@ -46,10 +46,11 @@ public: void Print() const; ///! Set/Get a property of this source file - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value,bool asString=false); - const char *GetProperty(const char *prop) const; - bool GetPropertyAsBool(const char *prop) const; + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, + const char* value,bool asString=false); + const char *GetProperty(const std::string& prop) const; + bool GetPropertyAsBool(const std::string& prop) const; cmPropertyMap &GetProperties() { return this->Properties; }; /** Get the cmMakefile instance that owns this test. */ @@ -64,7 +65,7 @@ public: private: cmPropertyMap Properties; - cmStdString Name; + std::string Name; std::vector<std::string> Command; bool OldStyle; diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 5dc3e60..c1b1f8b 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -64,7 +64,7 @@ void cmTestGenerator::GenerateScriptActions(std::ostream& os, //---------------------------------------------------------------------------- void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent) { this->TestGenerated = true; @@ -97,7 +97,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Generate the command line with full escapes. cmLocalGenerator* lg = mf->GetLocalGenerator(); - os << lg->EscapeForCMake(exe.c_str()); + os << lg->EscapeForCMake(exe); for(std::vector<std::string>::const_iterator ci = command.begin()+1; ci != command.end(); ++ci) { diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h index 2c69fc3..5446553 100644 --- a/Source/cmTestGenerator.h +++ b/Source/cmTestGenerator.h @@ -32,7 +32,7 @@ protected: virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent); virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); virtual void GenerateScriptForConfig(std::ostream& os, - const char* config, + const std::string& config, Indent const& indent); virtual void GenerateScriptNoConfig(std::ostream& os, Indent const& indent); virtual bool NeedsScriptNoConfig() const; diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 8e6bbc1..a09c47f 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "try_compile";} + virtual std::string GetName() const { return "try_compile";} cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile); diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index cfedaa5..cc6e139 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -162,7 +162,7 @@ bool cmTryRunCommand // now put the output into the variables if(this->RunOutputVariable.size()) { - this->Makefile->AddDefinition(this->RunOutputVariable.c_str(), + this->Makefile->AddDefinition(this->RunOutputVariable, runOutputContents.c_str()); } @@ -171,12 +171,12 @@ bool cmTryRunCommand // if the TryCompileCore saved output in this outputVariable then // prepend that output to this output const char* compileOutput - = this->Makefile->GetDefinition(this->OutputVariable.c_str()); + = this->Makefile->GetDefinition(this->OutputVariable); if (compileOutput) { runOutputContents = std::string(compileOutput) + runOutputContents; } - this->Makefile->AddDefinition(this->OutputVariable.c_str(), + this->Makefile->AddDefinition(this->OutputVariable, runOutputContents.c_str()); } } @@ -214,7 +214,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, { strcpy(retChar, "FAILED_TO_RUN"); } - this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), retChar, + this->Makefile->AddCacheDefinition(this->RunResultVariable, retChar, "Result of TRY_RUN", cmCacheManager::INTERNAL); } @@ -235,10 +235,10 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, copyDest += cmake::GetCMakeFilesDirectory(); copyDest += "/"; copyDest += cmSystemTools::GetFilenameWithoutExtension( - this->OutputFile.c_str()); + this->OutputFile); copyDest += "-"; copyDest += this->RunResultVariable; - copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile.c_str()); + copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile); cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), copyDest.c_str()); std::string resultFileName = this->Makefile->GetHomeOutputDirectory(); @@ -250,7 +250,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, std::string internalRunOutputName=this->RunResultVariable+"__TRYRUN_OUTPUT"; bool error = false; - if (this->Makefile->GetDefinition(this->RunResultVariable.c_str()) == 0) + if (this->Makefile->GetDefinition(this->RunResultVariable) == 0) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced @@ -258,7 +258,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment += "Run result of TRY_RUN(), indicates whether the executable " "would have been able to run on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), + this->Makefile->AddCacheDefinition(this->RunResultVariable, "PLEASE_FILL_OUT-FAILED_TO_RUN", comment.c_str(), cmCacheManager::STRING); @@ -276,7 +276,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, // is the output from the executable used ? if (out!=0) { - if (this->Makefile->GetDefinition(internalRunOutputName.c_str()) == 0) + if (this->Makefile->GetDefinition(internalRunOutputName) == 0) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced @@ -285,7 +285,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, "would have printed on stdout and stderr on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(internalRunOutputName.c_str(), + this->Makefile->AddCacheDefinition(internalRunOutputName, "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(), cmCacheManager::STRING); @@ -355,13 +355,13 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, file << comment << "\n\n"; file << "set( " << this->RunResultVariable << " \n \"" - << this->Makefile->GetDefinition(this->RunResultVariable.c_str()) + << this->Makefile->GetDefinition(this->RunResultVariable) << "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n"; if (out!=0) { file << "set( " << internalRunOutputName << " \n \"" - << this->Makefile->GetDefinition(internalRunOutputName.c_str()) + << this->Makefile->GetDefinition(internalRunOutputName) << "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n"; } file.close(); @@ -383,6 +383,6 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, if (out!=0) { - (*out) = this->Makefile->GetDefinition(internalRunOutputName.c_str()); + (*out) = this->Makefile->GetDefinition(internalRunOutputName); } } diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index d0bf9ce..9b97b16 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -40,7 +40,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "try_run";} + virtual std::string GetName() const { return "try_run";} cmTypeMacro(cmTryRunCommand, cmCoreTryCompile); private: diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h index 2308139..62c2bd3 100644 --- a/Source/cmUnsetCommand.h +++ b/Source/cmUnsetCommand.h @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const {return "unset";} + virtual std::string GetName() const {return "unset";} cmTypeMacro(cmUnsetCommand, cmCommand); }; diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index d4ec20f..8d26f86 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -38,7 +38,7 @@ bool cmUseMangledMesaCommand std::string e = "Bad path to Mesa, could not find: "; e += glh; e += " "; - this->SetError(e.c_str()); + this->SetError(e); return false; } const char* destDir = args[1].c_str(); @@ -107,12 +107,12 @@ CopyAndFullPathMesaHeader(const char* source, if(glDirLine.find(includeFile.c_str())) { std::string gfile = glDirLine.match(3); - fout << "#include \"" << outdir << "/" << gfile.c_str() << "\"\n"; + fout << "#include \"" << outdir << "/" << gfile << "\"\n"; } else if(glLine.find(includeFile.c_str())) { fout << "#include \"" << outdir << "/" << - includeLine.match(1).c_str() << "\"\n"; + includeLine.match(1) << "\"\n"; } else { diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h index dca75a5..da927c7 100644 --- a/Source/cmUseMangledMesaCommand.h +++ b/Source/cmUseMangledMesaCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmUseMangledMesaCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "use_mangled_mesa";} + virtual std::string GetName() const { return "use_mangled_mesa";} virtual bool IsScriptable() const { return true; } virtual bool IsDiscouraged() const { return true; } protected: diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 11e5108..ba6b4ac 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -29,7 +29,7 @@ bool cmUtilitySourceCommand // The first argument is the cache entry name. std::string cacheEntry = *arg++; const char* cacheValue = - this->Makefile->GetDefinition(cacheEntry.c_str()); + this->Makefile->GetDefinition(cacheEntry); // If it exists already and appears up to date then we are done. If // the string contains "(IntDir)" but that is not the // CMAKE_CFG_INTDIR setting then the value is out of date. @@ -113,14 +113,14 @@ bool cmUtilitySourceCommand cmSystemTools::ReplaceString(utilityExecutable, "/./", "/"); // Enter the value into the cache. - this->Makefile->AddCacheDefinition(cacheEntry.c_str(), + this->Makefile->AddCacheDefinition(cacheEntry, utilityExecutable.c_str(), "Path to an internal program.", cmCacheManager::FILEPATH); // add a value into the cache that maps from the // full path to the name of the project cmSystemTools::ConvertToUnixSlashes(utilityExecutable); - this->Makefile->AddCacheDefinition(utilityExecutable.c_str(), + this->Makefile->AddCacheDefinition(utilityExecutable, utilityName.c_str(), "Executable to project name.", cmCacheManager::INTERNAL); diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h index 83d115c..23afdbe 100644 --- a/Source/cmUtilitySourceCommand.h +++ b/Source/cmUtilitySourceCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmUtilitySourceCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "utility_source";} + virtual std::string GetName() const { return "utility_source";} virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index ddb4003..80c1286 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -26,7 +26,7 @@ bool cmVariableRequiresCommand } std::string testVariable = args[0]; - if(!this->Makefile->IsOn(testVariable.c_str())) + if(!this->Makefile->IsOn(testVariable)) { return true; } @@ -36,7 +36,7 @@ bool cmVariableRequiresCommand bool hasAdvanced = false; for(unsigned int i = 2; i < args.size(); ++i) { - if(!this->Makefile->IsOn(args[i].c_str())) + if(!this->Makefile->IsOn(args[i])) { requirementsMet = false; notSet += args[i]; @@ -49,13 +49,13 @@ bool cmVariableRequiresCommand } } } - const char* reqVar = this->Makefile->GetDefinition(resultVariable.c_str()); + const char* reqVar = this->Makefile->GetDefinition(resultVariable); // if reqVar is unset, then set it to requirementsMet // if reqVar is set to true, but requirementsMet is false , then // set reqVar to false. if(!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar))) { - this->Makefile->AddDefinition(resultVariable.c_str(), requirementsMet); + this->Makefile->AddDefinition(resultVariable, requirementsMet); } if(!requirementsMet) diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h index 881b149..7e68de1 100644 --- a/Source/cmVariableRequiresCommand.h +++ b/Source/cmVariableRequiresCommand.h @@ -21,7 +21,7 @@ public: virtual cmCommand* Clone() { return new cmVariableRequiresCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - virtual const char* GetName() const { return "variable_requires";} + virtual std::string GetName() const { return "variable_requires";} virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 790c75a..c86fad0 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -81,7 +81,7 @@ protected: }; typedef std::vector< Pair* > VectorOfPairs; - typedef std::map<cmStdString, VectorOfPairs > StringToVectorOfPairs; + typedef std::map<std::string, VectorOfPairs > StringToVectorOfPairs; StringToVectorOfPairs WatchMap; }; diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index 33e159b..debe243 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -84,7 +84,7 @@ static void cmVariableWatchCommandVariableAccessed( if ( !processed ) { cmOStringStream msg; - msg << "Variable \"" << variable.c_str() << "\" was accessed using " + msg << "Variable \"" << variable << "\" was accessed using " << accessString << " with value \"" << (newValue?newValue:"") << "\"."; makefile->IssueMessage(cmake::LOG, msg.str()); } @@ -136,8 +136,8 @@ bool cmVariableWatchCommand if ( variable == "CMAKE_CURRENT_LIST_FILE" ) { cmOStringStream ostr; - ostr << "cannot be set on the variable: " << variable.c_str(); - this->SetError(ostr.str().c_str()); + ostr << "cannot be set on the variable: " << variable; + this->SetError(ostr.str()); return false; } diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h index fb6062c..c1ee9b1 100644 --- a/Source/cmVariableWatchCommand.h +++ b/Source/cmVariableWatchCommand.h @@ -54,7 +54,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "variable_watch";} + virtual std::string GetName() const { return "variable_watch";} cmTypeMacro(cmVariableWatchCommand, cmCommand); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ed7e243..bb76b7f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -19,6 +19,7 @@ #include "cmSourceFile.h" #include "cmVisualStudioGeneratorOptions.h" #include "cmLocalVisualStudio7Generator.h" +#include "cmCustomCommandGenerator.h" #include "cmVS10CLFlagTable.h" #include "cmVS10LinkFlagTable.h" #include "cmVS10LibFlagTable.h" @@ -140,7 +141,7 @@ cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() void cmVisualStudio10TargetGenerator::WritePlatformConfigTag( const char* tag, - const char* config, + const std::string& config, int indentLevel, const char* attribute, const char* end, @@ -221,7 +222,8 @@ void cmVisualStudio10TargetGenerator::Generate() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); std::string project_defaults= - "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; + "<?xml version=\"1.0\" encoding=\"" + + this->GlobalGenerator->Encoding() + "\"?>\n"; project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\""); project_defaults.append(toolsVer +"\" "); project_defaults.append( @@ -376,12 +378,12 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { - std::vector<cmSourceFile*> resxObjs; + std::vector<cmSourceFile const*> resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); - for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin(); + for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -550,9 +552,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); - std::vector<cmSourceFile*> customCommands; + std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -561,7 +563,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands() } //---------------------------------------------------------------------------- -void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) +void cmVisualStudio10TargetGenerator +::WriteCustomCommand(cmSourceFile const* sf) { if(this->SourcesVisited.insert(sf).second) { @@ -584,7 +587,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) } void -cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, +cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command) { @@ -616,8 +619,6 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, } } cmLocalVisualStudio7Generator* lg = this->LocalGenerator; - std::string comment = lg->ConstructComment(command); - comment = cmVS10EscapeComment(comment); std::vector<std::string> *configs = static_cast<cmGlobalVisualStudio7Generator *> (this->GlobalGenerator)->GetConfigurations(); @@ -627,8 +628,11 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, for(std::vector<std::string>::iterator i = configs->begin(); i != configs->end(); ++i) { + cmCustomCommandGenerator ccg(command, *i, this->Makefile); + std::string comment = lg->ConstructComment(ccg); + comment = cmVS10EscapeComment(comment); std::string script = - cmVS10EscapeXML(lg->ConstructScript(command, i->c_str())); + cmVS10EscapeXML(lg->ConstructScript(ccg)); this->WritePlatformConfigTag("Message",i->c_str(), 3); (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n"; this->WritePlatformConfigTag("Command", i->c_str(), 3); @@ -637,8 +641,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, (*this->BuildFileStream ) << source->GetFullPath(); for(std::vector<std::string>::const_iterator d = - command.GetDepends().begin(); - d != command.GetDepends().end(); + ccg.GetDepends().begin(); + d != ccg.GetDepends().end(); ++d) { std::string dep; @@ -652,8 +656,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, this->WritePlatformConfigTag("Outputs", i->c_str(), 3); const char* sep = ""; for(std::vector<std::string>::const_iterator o = - command.GetOutputs().begin(); - o != command.GetOutputs().end(); + ccg.GetOutputs().begin(); + o != ccg.GetOutputs().end(); ++o) { std::string out = *o; @@ -730,7 +734,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); std::string project_defaults= - "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; + "<?xml version=\"1.0\" encoding=\"" + + this->GlobalGenerator->Encoding() + "\"?>\n"; project_defaults.append("<Project ToolsVersion=\""); project_defaults.append(toolsVer +"\" "); project_defaults.append( @@ -743,12 +748,12 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups); } - std::vector<cmSourceFile*> resxObjs; + std::vector<cmSourceFile const*> resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); - for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin(); + for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -899,7 +904,7 @@ WriteGroupSources(const char* name, for(ToolSources::const_iterator s = sources.begin(); s != sources.end(); ++s) { - cmSourceFile* sf = s->SourceFile; + cmSourceFile const* sf = s->SourceFile; std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); @@ -926,7 +931,7 @@ WriteGroupSources(const char* name, } void cmVisualStudio10TargetGenerator::WriteSource( - const char* tool, cmSourceFile* sf, const char* end) + const char* tool, cmSourceFile const* sf, const char* end) { // Visual Studio tools append relative paths to the current dir, as in: // @@ -982,9 +987,9 @@ void cmVisualStudio10TargetGenerator::WriteSource( } void cmVisualStudio10TargetGenerator::WriteSources( - const char* tool, std::vector<cmSourceFile*> const& sources) + const char* tool, std::vector<cmSourceFile const*> const& sources) { - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { this->WriteSource(tool, *si); @@ -999,31 +1004,31 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } this->WriteString("<ItemGroup>\n", 1); - std::vector<cmSourceFile*> headerSources; + std::vector<cmSourceFile const*> headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->WriteSources("ClInclude", headerSources); - std::vector<cmSourceFile*> idlSources; + std::vector<cmSourceFile const*> idlSources; this->GeneratorTarget->GetIDLSources(idlSources); this->WriteSources("Midl", idlSources); - std::vector<cmSourceFile*> objectSources; + std::vector<cmSourceFile const*> objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - const char* lang = (*si)->GetLanguage(); + const std::string& lang = (*si)->GetLanguage(); const char* tool = NULL; - if (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") == 0) + if (lang == "C"|| lang == "CXX") { tool = "ClCompile"; } - else if (strcmp(lang, "ASM_MASM") == 0 && + else if (lang == "ASM_NASM" && this->GlobalGenerator->IsMasmEnabled()) { tool = "MASM"; } - else if (strcmp(lang, "RC") == 0) + else if (lang == "RC") { tool = "ResourceCompile"; } @@ -1047,7 +1052,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector<cmSourceFile*> externalObjects; + std::vector<cmSourceFile const*> externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) { @@ -1059,7 +1064,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() { // If an object file is generated in this target, then vs10 will use // it in the build, and we have to list it as None instead of Object. - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { @@ -1069,7 +1074,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector<cmSourceFile*> extraSources; + std::vector<cmSourceFile const*> extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->WriteSources("None", extraSources); @@ -1089,9 +1094,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( - cmSourceFile* source) + cmSourceFile const* source) { - cmSourceFile& sf = *source; + cmSourceFile const& sf = *source; std::string objectName; if(this->GeneratorTarget->HasExplicitObjectName(&sf)) @@ -1108,29 +1113,28 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( { defines += cdefs; } - const char* lang = + std::string lang = this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); - const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const char* linkLanguage = this->Target->GetLinkerLanguage(); + std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); + const std::string& linkLanguage = this->Target->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language - if(lang && sourceLang && strcmp(lang, sourceLang) != 0) + if(lang != sourceLang) { needForceLang = true; lang = sourceLang; } // if the source file does not match the linker language // then force c or c++ - if(needForceLang || (linkLanguage && lang - && strcmp(lang, linkLanguage) != 0)) + if(needForceLang || (linkLanguage != lang)) { - if(strcmp(lang, "CXX") == 0) + if(lang == "CXX") { // force a C++ file type flags += " /TP "; } - else if(strcmp(lang, "C") == 0) + else if(lang == "C") { // force to c flags += " /TC "; @@ -1341,17 +1345,17 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( // collect up flags for if(this->Target->GetType() < cmTarget::UTILITY) { - const char* linkLanguage = + const std::string& linkLanguage = this->Target->GetLinkerLanguage(configName.c_str()); - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", this->Name.c_str()); return false; } - if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0 - || strcmp(linkLanguage, "Fortran") == 0) + if(linkLanguage == "C" || linkLanguage == "CXX" + || linkLanguage == "Fortran") { std::string baseFlagVar = "CMAKE_"; baseFlagVar += linkLanguage; @@ -1365,11 +1369,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str()); } // set the correct language - if(strcmp(linkLanguage, "C") == 0) + if(linkLanguage == "C") { flags += " /TC "; } - if(strcmp(linkLanguage, "CXX") == 0) + if(linkLanguage == "CXX") { flags += " /TP "; } @@ -1427,6 +1431,17 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n", "CXX"); this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3); + + // Specify the compiler program database file if configured. + std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + if(!pdb.empty()) + { + this->ConvertToWindowsSlash(pdb); + this->WriteString("<ProgramDataBaseFileName>", 3); + *this->BuildFileStream << cmVS10EscapeXML(pdb) + << "</ProgramDataBaseFileName>\n"; + } + this->WriteString("</ClCompile>\n", 2); } @@ -1514,9 +1529,9 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmVSGetLinkFlagTable(this->LocalGenerator), 0, this)); Options& linkOptions = *pOptions; - const char* linkLanguage = + const std::string& linkLanguage = this->Target->GetLinkerLanguage(config.c_str()); - if(!linkLanguage) + if(linkLanguage.empty()) { cmSystemTools::Error ("CMake can not determine linker language for target: ", @@ -1666,10 +1681,10 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) linkOptions.AddFlag("ImportLibrary", imLib.c_str()); linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); linkOptions.Parse(flags.c_str()); - if(!this->GeneratorTarget->ModuleDefinitionFile.empty()) + std::string def = this->GeneratorTarget->GetModuleDefinitionFile(); + if(!def.empty()) { - linkOptions.AddFlag("ModuleDefinitionFile", - this->GeneratorTarget->ModuleDefinitionFile.c_str()); + linkOptions.AddFlag("ModuleDefinitionFile", def.c_str()); } this->LinkOptions[config] = pOptions.release(); @@ -1825,13 +1840,12 @@ void cmVisualStudio10TargetGenerator::WriteEvent( for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - const cmCustomCommand& command = *i; + cmCustomCommandGenerator ccg(*i, configName, this->Makefile); comment += pre; - comment += lg->ConstructComment(command); + comment += lg->ConstructComment(ccg); script += pre; pre = "\n"; - script += - cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str())); + script += cmVS10EscapeXML(lg->ConstructScript(ccg)); } comment = cmVS10EscapeComment(comment); this->WriteString("<Message>",3); diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index d1f3d19..d72c6fd 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -35,7 +35,7 @@ public: // used by cmVisualStudioGeneratorOptions void WritePlatformConfigTag( const char* tag, - const char* config, + const std::string& config, int indentLevel, const char* attribute = 0, const char* end = 0, @@ -45,7 +45,7 @@ public: private: struct ToolSource { - cmSourceFile* SourceFile; + cmSourceFile const* SourceFile; bool RelativePath; }; struct ToolSources: public std::vector<ToolSource> {}; @@ -55,8 +55,10 @@ private: void WriteString(const char* line, int indentLevel); void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); - void WriteSource(const char* tool, cmSourceFile* sf, const char* end = 0); - void WriteSources(const char* tool, std::vector<cmSourceFile*> const&); + void WriteSource(const char* tool, cmSourceFile const* sf, + const char* end = 0); + void WriteSources(const char* tool, + std::vector<cmSourceFile const*> const&); void WriteAllSources(); void WriteDotNetReferences(); void WriteEmbeddedResourceGroup(); @@ -77,13 +79,13 @@ private: std::vector<std::string> const & includes); void OutputIncludes(std::vector<std::string> const & includes); void OutputLinkIncremental(std::string const& configName); - void WriteCustomRule(cmSourceFile* source, + void WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command); void WriteCustomCommands(); - void WriteCustomCommand(cmSourceFile* sf); + void WriteCustomCommand(cmSourceFile const* sf); void WriteGroups(); void WriteProjectReferences(); - bool OutputSourceSpecificFlags(cmSourceFile* source); + bool OutputSourceSpecificFlags(cmSourceFile const* source); void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void WriteLibOptions(std::string const& config); void WriteEvents(std::string const& configName); @@ -98,7 +100,7 @@ private: private: typedef cmVisualStudioGeneratorOptions Options; - typedef std::map<cmStdString, Options*> OptionsMap; + typedef std::map<std::string, Options*> OptionsMap; OptionsMap ClOptions; OptionsMap LinkOptions; std::string PathToVcxproj; @@ -111,9 +113,9 @@ private: cmGlobalVisualStudio10Generator* GlobalGenerator; cmGeneratedFileStream* BuildFileStream; cmLocalVisualStudio7Generator* LocalGenerator; - std::set<cmSourceFile*> SourcesVisited; + std::set<cmSourceFile const*> SourcesVisited; - typedef std::map<cmStdString, ToolSources> ToolSourceMap; + typedef std::map<std::string, ToolSources> ToolSourceMap; ToolSourceMap Tools; }; diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 6aca787..81adb56 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -222,7 +222,7 @@ cmVisualStudioGeneratorOptions ::OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, const char* suffix, - const char* lang) + const std::string& lang) { if(this->Defines.empty()) { @@ -270,7 +270,7 @@ cmVisualStudioGeneratorOptions { define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str()); - if(0 == strcmp(lang, "RC")) + if(lang == "RC") { cmSystemTools::ReplaceString(define, "\"", "\\\""); } @@ -300,7 +300,7 @@ cmVisualStudioGeneratorOptions { if(this->Version >= cmLocalVisualStudioGenerator::VS10) { - for(std::map<cmStdString, cmStdString>::iterator m = this->FlagMap.begin(); + for(std::map<std::string, std::string>::iterator m = this->FlagMap.begin(); m != this->FlagMap.end(); ++m) { fout << indent; @@ -326,7 +326,7 @@ cmVisualStudioGeneratorOptions } else { - for(std::map<cmStdString, cmStdString>::iterator m = this->FlagMap.begin(); + for(std::map<std::string, std::string>::iterator m = this->FlagMap.begin(); m != this->FlagMap.end(); ++m) { fout << indent << m->first << "=\"" << m->second << "\"\n"; diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 90f7667..214b893 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -55,7 +55,7 @@ public: void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, const char* suffix, - const char* lang); + const std::string& lang); void OutputFlagMap(std::ostream& fout, const char* indent); void OutputAdditionalOptions(std::ostream& fout, const char* prefix, diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx index 219a5eb..ca226fb 100644 --- a/Source/cmVisualStudioWCEPlatformParser.cxx +++ b/Source/cmVisualStudioWCEPlatformParser.cxx @@ -62,7 +62,7 @@ const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const return 0; } -void cmVisualStudioWCEPlatformParser::StartElement(const char* name, +void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name, const char** attributes) { if(this->FoundRequiredName) @@ -72,7 +72,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name, this->CharacterData = ""; - if(strcmp(name, "PlatformData") == 0) + if(name == "PlatformData") { this->PlatformName = ""; this->OSMajorVersion = ""; @@ -80,7 +80,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name, this->Macros.clear(); } - if(strcmp(name, "Macro") == 0) + if(name == "Macro") { std::string macroName; std::string macroValue; @@ -102,7 +102,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name, this->Macros[macroName] = macroValue; } } - else if(strcmp(name, "Directories") == 0) + else if(name == "Directories") { for(const char** attr = attributes; *attr; attr += 2) { @@ -122,11 +122,11 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name, } } -void cmVisualStudioWCEPlatformParser::EndElement(const char* name) +void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name) { if(!this->RequiredName) { - if(strcmp(name, "PlatformName") == 0) + if(name == "PlatformName") { this->AvailablePlatforms.push_back(this->CharacterData); } @@ -138,19 +138,19 @@ void cmVisualStudioWCEPlatformParser::EndElement(const char* name) return; } - if(strcmp(name, "PlatformName") == 0) + if(name == "PlatformName") { this->PlatformName = this->CharacterData; } - else if(strcmp(name, "OSMajorVersion") == 0) + else if(name == "OSMajorVersion") { this->OSMajorVersion = this->CharacterData; } - else if(strcmp(name, "OSMinorVersion") == 0) + else if(name == "OSMinorVersion") { this->OSMinorVersion = this->CharacterData; } - else if(strcmp(name, "Platform") == 0) + else if(name == "Platform") { if(this->PlatformName == this->RequiredName) { diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h index 466e1dd..042df01 100644 --- a/Source/cmVisualStudioWCEPlatformParser.h +++ b/Source/cmVisualStudioWCEPlatformParser.h @@ -41,8 +41,8 @@ public: return this->AvailablePlatforms; } protected: - virtual void StartElement(const char* name, const char** attributes); - void EndElement(const char* name); + virtual void StartElement(const std::string& name, const char** attributes); + void EndElement(const std::string& name); void CharacterDataHandler(const char* data, int length); private: diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h index 45badd0..9fafffc 100644 --- a/Source/cmWhileCommand.h +++ b/Source/cmWhileCommand.h @@ -66,7 +66,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "while";} + virtual std::string GetName() const { return "while";} cmTypeMacro(cmWhileCommand, cmCommand); }; diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index aa6b9f8..af955ec 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -47,7 +47,7 @@ bool cmWriteFileCommand { std::string e = "attempted to write a file: " + fileName + " into a source directory."; - this->SetError(e.c_str()); + this->SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -79,7 +79,7 @@ bool cmWriteFileCommand std::string error = "Internal CMake error when trying to open file: "; error += fileName.c_str(); error += " for writing."; - this->SetError(error.c_str()); + this->SetError(error); return false; } file << message << std::endl; diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h index 84a38fc..0d06878 100644 --- a/Source/cmWriteFileCommand.h +++ b/Source/cmWriteFileCommand.h @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "write_file";} + virtual std::string GetName() const { return "write_file";} /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 6abf6bf..3302a8d 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -108,7 +108,7 @@ void cmXCodeObject::Print(std::ostream& out) { out << separator; } - std::map<cmStdString, cmXCodeObject*>::iterator i; + std::map<std::string, cmXCodeObject*>::iterator i; cmXCodeObject::Indent(3*indentFactor, out); out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator; for(i = this->ObjectAttributes.begin(); @@ -138,7 +138,7 @@ void cmXCodeObject::Print(std::ostream& out) } else if(object->TypeValue == ATTRIBUTE_GROUP) { - std::map<cmStdString, cmXCodeObject*>::iterator j; + std::map<std::string, cmXCodeObject*>::iterator j; out << i->first << " = {" << separator; for(j = object->ObjectAttributes.begin(); j != object->ObjectAttributes.end(); ++j) @@ -236,7 +236,7 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy) } //---------------------------------------------------------------------------- -void cmXCodeObject::PrintString(std::ostream& os,cmStdString String) +void cmXCodeObject::PrintString(std::ostream& os,std::string String) { // The string needs to be quoted if it contains any characters // considered special by the Xcode project file parser. @@ -266,7 +266,7 @@ void cmXCodeObject::PrintString(std::ostream& os) const } //---------------------------------------------------------------------------- -void cmXCodeObject::SetString(const char* s) +void cmXCodeObject::SetString(const std::string& s) { this->String = s; } diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index b89f78c..ed2940a 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -30,20 +30,20 @@ public: PBXCopyFilesBuildPhase, None }; - class StringVec: public std::vector<cmStdString> {}; + class StringVec: public std::vector<std::string> {}; static const char* PBXTypeNames[]; virtual ~cmXCodeObject(); cmXCodeObject(PBXType ptype, Type type); Type GetType() { return this->TypeValue;} PBXType GetIsA() { return this->IsA;} - void SetString(const char* s); - const char* GetString() + void SetString(const std::string& s); + const std::string& GetString() { - return this->String.c_str(); + return this->String; } - void AddAttribute(const char* name, cmXCodeObject* value) + void AddAttribute(const std::string& name, cmXCodeObject* value) { this->ObjectAttributes[name] = value; } @@ -79,11 +79,11 @@ public: static void PrintList(std::vector<cmXCodeObject*> const&, std::ostream& out); - const char* GetId() + const std::string& GetId() { - return this->Id.c_str(); + return this->Id; } - void SetId(const char* id) + void SetId(const std::string& id) { this->Id = id; } @@ -95,8 +95,8 @@ public: { this->Target = t; } - const char* GetComment() {return this->Comment.c_str();} - bool HasComment() { return (this->Comment.size() != 0);} + const std::string& GetComment() {return this->Comment;} + bool HasComment() { return (!this->Comment.empty());} cmXCodeObject* GetObject(const char* name) { if(this->ObjectAttributes.count(name)) @@ -122,49 +122,41 @@ public: void CopyAttributes(cmXCodeObject* ); - void AddDependLibrary(const char* configName, - const char* l) + void AddDependLibrary(const std::string& configName, + const std::string& l) { - if(!configName) - { - configName = ""; - } this->DependLibraries[configName].push_back(l); } - std::map<cmStdString, StringVec> const& GetDependLibraries() + std::map<std::string, StringVec> const& GetDependLibraries() { return this->DependLibraries; } - void AddDependTarget(const char* configName, - const char* tName) + void AddDependTarget(const std::string& configName, + const std::string& tName) { - if(!configName) - { - configName = ""; - } this->DependTargets[configName].push_back(tName); } - std::map<cmStdString, StringVec> const& GetDependTargets() + std::map<std::string, StringVec> const& GetDependTargets() { return this->DependTargets; } std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;} - void SetComment(const char* c) { this->Comment = c;} - static void PrintString(std::ostream& os,cmStdString String); + void SetComment(const std::string& c) { this->Comment = c;} + static void PrintString(std::ostream& os,std::string String); protected: void PrintString(std::ostream& os) const; cmTarget* Target; Type TypeValue; - cmStdString Id; + std::string Id; PBXType IsA; int Version; - cmStdString Comment; - cmStdString String; + std::string Comment; + std::string String; cmXCodeObject* Object; std::vector<cmXCodeObject*> List; - std::map<cmStdString, StringVec> DependLibraries; - std::map<cmStdString, StringVec> DependTargets; - std::map<cmStdString, cmXCodeObject*> ObjectAttributes; + std::map<std::string, StringVec> DependLibraries; + std::map<std::string, StringVec> DependTargets; + std::map<std::string, cmXCodeObject*> ObjectAttributes; }; #endif diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx index 0c53440..a73fd70 100644 --- a/Source/cmXMLParser.cxx +++ b/Source/cmXMLParser.cxx @@ -152,14 +152,14 @@ int cmXMLParser::ParsingComplete() } //---------------------------------------------------------------------------- -void cmXMLParser::StartElement(const char * name, +void cmXMLParser::StartElement(const std::string& name, const char ** /*atts*/) { std::cout << "Start element: " << name << std::endl; } //---------------------------------------------------------------------------- -void cmXMLParser::EndElement(const char * name) +void cmXMLParser::EndElement(const std::string& name) { std::cout << "End element: " << name << std::endl; } diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h index d916075..84a5a7d 100644 --- a/Source/cmXMLParser.h +++ b/Source/cmXMLParser.h @@ -74,11 +74,11 @@ protected: * element. atts = Null-terminated array of attribute name/value pairs. * Even indices are attribute names, and odd indices are values. */ - virtual void StartElement(const char* name, const char** atts); + virtual void StartElement(const std::string& name, const char** atts); //! Called at the end of an element in the XML source opened when //StartElement was called. - virtual void EndElement(const char* name); + virtual void EndElement(const std::string& name); //! Called when there is character data to handle. virtual void CharacterDataHandler(const char* data, int length); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index abbabe7..2cf636c 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -60,13 +60,15 @@ # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" # include "cmGlobalJOMMakefileGenerator.h" -# include "cmGlobalWatcomWMakeGenerator.h" # define CMAKE_HAVE_VS_GENERATORS # endif # include "cmGlobalMSYSMakefileGenerator.h" # include "cmGlobalMinGWMakefileGenerator.h" #else #endif +#if defined(CMAKE_USE_WMAKE) +# include "cmGlobalWatcomWMakeGenerator.h" +#endif #include "cmGlobalUnixMakefileGenerator3.h" #include "cmGlobalNinjaGenerator.h" #include "cmExtraCodeLiteGenerator.h" @@ -221,13 +223,13 @@ void cmake::CleanupCommandsAndMacros() } } -bool cmake::CommandExists(const char* name) const +bool cmake::CommandExists(const std::string& name) const { std::string sName = cmSystemTools::LowerCase(name); return (this->Commands.find(sName) != this->Commands.end()); } -cmCommand *cmake::GetCommand(const char *name) +cmCommand *cmake::GetCommand(const std::string& name) { cmCommand* rm = 0; std::string sName = cmSystemTools::LowerCase(name); @@ -239,7 +241,8 @@ cmCommand *cmake::GetCommand(const char *name) return rm; } -void cmake::RenameCommand(const char*oldName, const char* newName) +void cmake::RenameCommand(const std::string& oldName, + const std::string& newName) { // if the command already exists, free the old one std::string sOldName = cmSystemTools::LowerCase(oldName); @@ -262,7 +265,7 @@ void cmake::RenameCommand(const char*oldName, const char* newName) this->Commands.erase(pos); } -void cmake::RemoveCommand(const char* name) +void cmake::RemoveCommand(const std::string& name) { std::string sName = cmSystemTools::LowerCase(name); RegisteredCommandsMap::iterator pos = this->Commands.find(sName); @@ -305,7 +308,7 @@ void cmake::RemoveUnscriptableCommands() it != unscriptableCommands.end(); ++it) { - this->RemoveCommand(it->c_str()); + this->RemoveCommand(*it); } } @@ -334,23 +337,23 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } std::string var, value; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; - if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type)) + if(cmCacheManager::ParseEntry(entry, var, value, type)) { // The value is transformed if it is a filepath for example, so // we can't compare whether the value is already in the cache until // after we call AddCacheEntry. const char *cachedValue = - this->CacheManager->GetCacheValue(var.c_str()); + this->CacheManager->GetCacheValue(var); - this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(), + this->CacheManager->AddCacheEntry(var, value.c_str(), "No help, variable specified on the command line.", type); if(this->WarnUnusedCli) { if (!cachedValue - || strcmp(this->CacheManager->GetCacheValue(var.c_str()), + || strcmp(this->CacheManager->GetCacheValue(var), cachedValue) != 0) { - this->WatchUnusedCli(var.c_str()); + this->WatchUnusedCli(var); } } } @@ -389,7 +392,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } } cmsys::RegularExpression regex( - cmsys::Glob::PatternToRegex(entryPattern.c_str(), true, true).c_str()); + cmsys::Glob::PatternToRegex(entryPattern, 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 = @@ -413,7 +416,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) currentEntry != entriesToDelete.end(); ++currentEntry) { - this->CacheManager->RemoveCacheEntry(currentEntry->c_str()); + this->CacheManager->RemoveCacheEntry(*currentEntry); } } else if(arg.find("-C",0) == 0) @@ -432,7 +435,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) return false; } } - std::cerr << "loading initial cache file " << path.c_str() << "\n"; + std::cerr << "loading initial cache file " << path << "\n"; this->ReadListFile(args, path.c_str()); } else if(arg.find("-P",0) == 0) @@ -485,13 +488,13 @@ void cmake::ReadListFile(const std::vector<std::string>& args, { cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); lg->GetMakefile()->SetHomeOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetStartOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetHomeDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetStartDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); if (this->GetWorkingMode() != NORMAL_MODE) { std::string file(cmSystemTools::CollapseFullPath(path)); @@ -525,13 +528,13 @@ bool cmake::FindPackage(const std::vector<std::string>& args) cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); cmMakefile* mf = lg->GetMakefile(); mf->SetHomeOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetStartOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetHomeDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetStartDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetArgcArgv(args); @@ -565,7 +568,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) cmSystemTools::ExpandListArgument(includes, includeDirs); std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0, - language.c_str(), false); + language, false); std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); @@ -584,7 +587,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) libIt != libList.end(); ++libIt) { - mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), + mf->AddLinkLibraryForTarget(targetName, *libIt, cmTarget::GENERAL); } @@ -635,7 +638,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, std::string path = arg.substr(2); path = cmSystemTools::CollapseFullPath(path.c_str()); cmSystemTools::ConvertToUnixSlashes(path); - this->SetHomeDirectory(path.c_str()); + this->SetHomeDirectory(path); } else if(arg.find("-S",0) == 0) { @@ -651,7 +654,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, std::string path = arg.substr(2); path = cmSystemTools::CollapseFullPath(path.c_str()); cmSystemTools::ConvertToUnixSlashes(path); - this->SetHomeOutputDirectory(path.c_str()); + this->SetHomeOutputDirectory(path); } else if((i < args.size()-2) && (arg.find("--check-build-system",0) == 0)) { @@ -789,7 +792,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, value = args[i]; } cmGlobalGenerator* gen = - this->CreateGlobalGenerator(value.c_str()); + this->CreateGlobalGenerator(value); if(!gen) { cmSystemTools::Error("Could not create named generator ", @@ -810,13 +813,13 @@ void cmake::SetArgs(const std::vector<std::string>& args, if(!directoriesSet) { this->SetHomeOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); this->SetStartOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); this->SetStartDirectory - (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + (cmSystemTools::GetCurrentWorkingDirectory()); } this->SetStartDirectory(this->GetHomeDirectory()); @@ -852,15 +855,15 @@ void cmake::SetDirectoriesFromFile(const char* arg) { argIsFile = true; std::string fullPath = cmSystemTools::CollapseFullPath(arg); - std::string name = cmSystemTools::GetFilenameName(fullPath.c_str()); + std::string name = cmSystemTools::GetFilenameName(fullPath); name = cmSystemTools::LowerCase(name); if(name == "cmakecache.txt") { - cachePath = cmSystemTools::GetFilenamePath(fullPath.c_str()); + cachePath = cmSystemTools::GetFilenamePath(fullPath); } else if(name == "cmakelists.txt") { - listPath = cmSystemTools::GetFilenamePath(fullPath.c_str()); + listPath = cmSystemTools::GetFilenamePath(fullPath); } } else @@ -868,12 +871,12 @@ void cmake::SetDirectoriesFromFile(const char* arg) // Specified file or directory does not exist. Try to set things // up to produce a meaningful error message. std::string fullPath = cmSystemTools::CollapseFullPath(arg); - std::string name = cmSystemTools::GetFilenameName(fullPath.c_str()); + std::string name = cmSystemTools::GetFilenameName(fullPath); name = cmSystemTools::LowerCase(name); if(name == "cmakecache.txt" || name == "cmakelists.txt") { argIsFile = true; - listPath = cmSystemTools::GetFilenamePath(fullPath.c_str()); + listPath = cmSystemTools::GetFilenamePath(fullPath); } else { @@ -886,11 +889,11 @@ void cmake::SetDirectoriesFromFile(const char* arg) { cmCacheManager* cachem = this->GetCacheManager(); cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(cachem->LoadCache(cachePath.c_str()) && + if(cachem->LoadCache(cachePath) && it.Find("CMAKE_HOME_DIRECTORY")) { - this->SetHomeOutputDirectory(cachePath.c_str()); - this->SetStartOutputDirectory(cachePath.c_str()); + this->SetHomeOutputDirectory(cachePath); + this->SetStartOutputDirectory(cachePath); this->SetHomeDirectory(it.GetValue()); this->SetStartDirectory(it.GetValue()); return; @@ -900,23 +903,23 @@ void cmake::SetDirectoriesFromFile(const char* arg) // If there is a CMakeLists.txt file, use it as the source tree. if(listPath.length() > 0) { - this->SetHomeDirectory(listPath.c_str()); - this->SetStartDirectory(listPath.c_str()); + this->SetHomeDirectory(listPath); + this->SetStartDirectory(listPath); if(argIsFile) { // Source CMakeLists.txt file given. It was probably dropped // onto the executable in a GUI. Default to an in-source build. - this->SetHomeOutputDirectory(listPath.c_str()); - this->SetStartOutputDirectory(listPath.c_str()); + this->SetHomeOutputDirectory(listPath); + this->SetStartOutputDirectory(listPath); } else { // Source directory given on command line. Use current working // directory as build tree. std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - this->SetHomeOutputDirectory(cwd.c_str()); - this->SetStartOutputDirectory(cwd.c_str()); + this->SetHomeOutputDirectory(cwd); + this->SetStartOutputDirectory(cwd); } return; } @@ -926,10 +929,10 @@ void cmake::SetDirectoriesFromFile(const char* arg) // current working directory as the build tree. std::string full = cmSystemTools::CollapseFullPath(arg); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - this->SetHomeDirectory(full.c_str()); - this->SetStartDirectory(full.c_str()); - this->SetHomeOutputDirectory(cwd.c_str()); - this->SetStartOutputDirectory(cwd.c_str()); + this->SetHomeDirectory(full); + this->SetStartDirectory(full); + this->SetHomeOutputDirectory(cwd); + this->SetStartOutputDirectory(cwd); } // at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the @@ -965,7 +968,7 @@ int cmake::AddCMakePaths() return 1; } -void cmake::AddExtraGenerator(const char* name, +void cmake::AddExtraGenerator(const std::string& name, CreateExtraGeneratorFunctionType newFunction) { cmExternalMakefileProjectGenerator* extraGenerator = newFunction(); @@ -978,8 +981,8 @@ void cmake::AddExtraGenerator(const char* name, ++it ) { std::string fullName = cmExternalMakefileProjectGenerator:: - CreateFullGeneratorName(it->c_str(), name); - this->ExtraGenerators[fullName.c_str()] = newFunction; + CreateFullGeneratorName(*it, name); + this->ExtraGenerators[fullName] = newFunction; } delete extraGenerator; } @@ -1034,9 +1037,10 @@ void cmake::GetRegisteredGenerators(std::vector<std::string>& names) } } -cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) +cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname) { cmExternalMakefileProjectGenerator* extraGenerator = 0; + std::string name = gname; RegisteredExtraGeneratorsMap::const_iterator extraGenIt = this->ExtraGenerators.find(name); if (extraGenIt != this->ExtraGenerators.end()) @@ -1069,13 +1073,13 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) return generator; } -void cmake::SetHomeDirectory(const char* dir) +void cmake::SetHomeDirectory(const std::string& dir) { this->cmHomeDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory); } -void cmake::SetHomeOutputDirectory(const char* lib) +void cmake::SetHomeOutputDirectory(const std::string& lib) { this->HomeOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory); @@ -1202,7 +1206,7 @@ struct SaveCacheEntry cmCacheManager::CacheEntryType type; }; -int cmake::HandleDeleteCacheVariables(const char* var) +int cmake::HandleDeleteCacheVariables(const std::string& var) { std::vector<std::string> argsSplit; cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true); @@ -1228,7 +1232,7 @@ int cmake::HandleDeleteCacheVariables(const char* var) i++; save.value = *i; warning << *i << "\n"; - if(ci.Find(save.key.c_str())) + if(ci.Find(save.key)) { save.type = ci.GetType(); save.help = ci.GetProperty("HELPSTRING"); @@ -1244,7 +1248,7 @@ int cmake::HandleDeleteCacheVariables(const char* var) for(std::vector<SaveCacheEntry>::iterator i = saved.begin(); i != saved.end(); ++i) { - this->AddCacheEntry(i->key.c_str(), i->value.c_str(), + this->AddCacheEntry(i->key, i->value.c_str(), i->help.c_str(), i->type); } cmSystemTools::Message(warning.str().c_str()); @@ -1324,8 +1328,9 @@ int cmake::ActualConfigure() if(genName) { std::string fullName = cmExternalMakefileProjectGenerator:: - CreateFullGeneratorName(genName, extraGenName); - this->GlobalGenerator = this->CreateGlobalGenerator(fullName.c_str()); + CreateFullGeneratorName(genName, + extraGenName ? extraGenName : ""); + this->GlobalGenerator = this->CreateGlobalGenerator(fullName); } if(this->GlobalGenerator) { @@ -1408,8 +1413,8 @@ int cmake::ActualConfigure() message += "\nDoes not match the generator used previously: "; message += genName; message += - "\nEither remove the CMakeCache.txt file or choose a different" - " binary directory."; + "\nEither remove the CMakeCache.txt file and CMakeFiles " + "directory or choose a different binary directory."; cmSystemTools::Error(message.c_str()); return -2; } @@ -1417,13 +1422,13 @@ int cmake::ActualConfigure() if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR")) { this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", - this->GlobalGenerator->GetName(), + this->GlobalGenerator->GetName().c_str(), "Name of generator.", cmCacheManager::INTERNAL); this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR", - this->GlobalGenerator->GetExtraGeneratorName(), - "Name of external makefile project generator.", - cmCacheManager::INTERNAL); + this->GlobalGenerator->GetExtraGeneratorName().c_str(), + "Name of external makefile project generator.", + cmCacheManager::INTERNAL); } if(const char* tsName = @@ -1440,8 +1445,8 @@ int cmake::ActualConfigure() message += "\nDoes not match the toolset used previously: "; message += tsName; message += - "\nEither remove the CMakeCache.txt file or choose a different" - " binary directory."; + "\nEither remove the CMakeCache.txt file and CMakeFiles " + "directory or choose a different binary directory."; cmSystemTools::Error(message.c_str()); return -2; } @@ -1689,8 +1694,8 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) { return ret; } - this->SetStartDirectory(oldstartdir.c_str()); - this->SetStartOutputDirectory(oldstartoutputdir.c_str()); + this->SetStartDirectory(oldstartdir); + this->SetStartOutputDirectory(oldstartoutputdir); return ret; } @@ -1725,7 +1730,7 @@ int cmake::Generate() return 0; } -void cmake::AddCacheEntry(const char* key, const char* value, +void cmake::AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type) { @@ -1734,7 +1739,7 @@ void cmake::AddCacheEntry(const char* key, const char* value, cmCacheManager::CacheEntryType(type)); } -const char* cmake::GetCacheDefinition(const char* name) const +const char* cmake::GetCacheDefinition(const std::string& name) const { return this->CacheManager->GetCacheValue(name); } @@ -1778,8 +1783,6 @@ void cmake::AddDefaultGenerators() cmGlobalNMakeMakefileGenerator::NewFactory()); this->Generators.push_back( cmGlobalJOMMakefileGenerator::NewFactory()); - this->Generators.push_back( - cmGlobalWatcomWMakeGenerator::NewFactory()); # endif this->Generators.push_back( cmGlobalMSYSMakefileGenerator::NewFactory()); @@ -1790,6 +1793,10 @@ void cmake::AddDefaultGenerators() cmGlobalUnixMakefileGenerator3::NewFactory()); this->Generators.push_back( cmGlobalNinjaGenerator::NewFactory()); +#if defined(CMAKE_USE_WMAKE) + this->Generators.push_back( + cmGlobalWatcomWMakeGenerator::NewFactory()); +#endif #ifdef CMAKE_USE_XCODE this->Generators.push_back( cmGlobalXCodeGenerator::NewFactory()); @@ -1851,7 +1858,7 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) { cmDocumentationEntry e; cmExternalMakefileProjectGenerator* generator = (i->second)(); - generator->GetDocumentation(e, i->first.c_str()); + generator->GetDocumentation(e, i->first); e.Name = i->first; delete generator; v.push_back(e); @@ -1919,7 +1926,7 @@ int cmake::CheckBuildSystem() { cmOStringStream msg; msg << "Re-run cmake missing file: " - << this->CheckBuildSystemArgument.c_str() << "\n"; + << this->CheckBuildSystemArgument << "\n"; cmSystemTools::Stdout(msg.str().c_str()); } return 1; @@ -1939,7 +1946,7 @@ int cmake::CheckBuildSystem() { cmOStringStream msg; msg << "Re-run cmake error reading : " - << this->CheckBuildSystemArgument.c_str() << "\n"; + << this->CheckBuildSystemArgument << "\n"; cmSystemTools::Stdout(msg.str().c_str()); } // There was an error reading the file. Just rerun. @@ -2073,8 +2080,8 @@ int cmake::CheckBuildSystem() if(verbose) { cmOStringStream msg; - msg << "Re-run cmake file: " << out_oldest.c_str() - << " older than: " << dep_newest.c_str() << "\n"; + msg << "Re-run cmake file: " << out_oldest + << " older than: " << dep_newest << "\n"; cmSystemTools::Stdout(msg.str().c_str()); } return 1; @@ -2144,7 +2151,8 @@ void cmake::GenerateGraphViz(const char* fileName) const #endif } -void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope, +void cmake::DefineProperty(const std::string& name, + cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chained) @@ -2155,7 +2163,7 @@ void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope, } cmPropertyDefinition *cmake -::GetPropertyDefinition(const char *name, +::GetPropertyDefinition(const std::string& name, cmProperty::ScopeType scope) { if (this->IsPropertyDefined(name,scope)) @@ -2165,25 +2173,22 @@ cmPropertyDefinition *cmake return 0; } -bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope) +bool cmake::IsPropertyDefined(const std::string& name, + cmProperty::ScopeType scope) { return this->PropertyDefinitions[scope].IsPropertyDefined(name); } -bool cmake::IsPropertyChained(const char *name, cmProperty::ScopeType scope) +bool cmake::IsPropertyChained(const std::string& name, + cmProperty::ScopeType scope) { return this->PropertyDefinitions[scope].IsPropertyChained(name); } -void cmake::SetProperty(const char* prop, const char* value) +void cmake::SetProperty(const std::string& prop, const char* value) { - if (!prop) - { - return; - } - // Special hook to invalidate cached value. - if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0) + if(prop == "DEBUG_CONFIGURATIONS") { this->DebugConfigs.clear(); } @@ -2191,15 +2196,11 @@ void cmake::SetProperty(const char* prop, const char* value) this->Properties.SetProperty(prop, value, cmProperty::GLOBAL); } -void cmake::AppendProperty(const char* prop, const char* value, bool asString) +void cmake::AppendProperty(const std::string& prop, + const char* value, bool asString) { - if (!prop) - { - return; - } - // Special hook to invalidate cached value. - if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0) + if(prop == "DEBUG_CONFIGURATIONS") { this->DebugConfigs.clear(); } @@ -2207,23 +2208,19 @@ void cmake::AppendProperty(const char* prop, const char* value, bool asString) this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString); } -const char *cmake::GetProperty(const char* prop) +const char *cmake::GetProperty(const std::string& prop) { return this->GetProperty(prop, cmProperty::GLOBAL); } -const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) +const char *cmake::GetProperty(const std::string& prop, + cmProperty::ScopeType scope) { - if(!prop) - { - return 0; - } bool chain = false; // watch for special properties - std::string propname = prop; std::string output = ""; - if ( propname == "CACHE_VARIABLES" ) + if ( prop == "CACHE_VARIABLES" ) { cmCacheManager::CacheIterator cit = this->GetCacheManager()->GetCacheIterator(); @@ -2237,7 +2234,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) } this->SetProperty("CACHE_VARIABLES", output.c_str()); } - else if ( propname == "COMMANDS" ) + else if ( prop == "COMMANDS" ) { cmake::RegisteredCommandsMap::iterator cmds = this->GetCommands()->begin(); @@ -2252,12 +2249,12 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) } this->SetProperty("COMMANDS",output.c_str()); } - else if ( propname == "IN_TRY_COMPILE" ) + else if ( prop == "IN_TRY_COMPILE" ) { this->SetProperty("IN_TRY_COMPILE", this->GetIsInTryCompile()? "1":"0"); } - else if ( propname == "ENABLED_LANGUAGES" ) + else if ( prop == "ENABLED_LANGUAGES" ) { std::string lang; if(this->GlobalGenerator) @@ -2278,7 +2275,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) return this->Properties.GetPropertyValue(prop, scope, chain); } -bool cmake::GetPropertyAsBool(const char* prop) +bool cmake::GetPropertyAsBool(const std::string& prop) { return cmSystemTools::IsOn(this->GetProperty(prop)); } @@ -2320,7 +2317,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) value = args[i]; } cmGlobalGenerator* gen = - this->CreateGlobalGenerator(value.c_str()); + this->CreateGlobalGenerator(value); if(!gen) { cmSystemTools::Error("Could not create named generator ", @@ -2358,8 +2355,8 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // Copy file if(!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) { - std::cerr << "Error copying file \"" << inFile.c_str() - << "\" to \"" << outFile.c_str() << "\".\n"; + std::cerr << "Error copying file \"" << inFile + << "\" to \"" << outFile << "\".\n"; return 1; } @@ -2657,7 +2654,7 @@ int cmake::Build(const std::string& dir, cmSystemTools::ConvertToUnixSlashes(cachePath); cmCacheManager* cachem = this->GetCacheManager(); cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(!cachem->LoadCache(cachePath.c_str())) + if(!cachem->LoadCache(cachePath)) { std::cerr << "Error: could not load cache\n"; return 1; @@ -2677,16 +2674,16 @@ int cmake::Build(const std::string& dir, return 1; } projName = it.GetValue(); - return gen->Build(0, dir.c_str(), - projName.c_str(), target.c_str(), + return gen->Build("", dir, + projName, target, &output, - 0, - config.c_str(), clean, false, 0, + "", + config, clean, false, 0, cmSystemTools::OUTPUT_PASSTHROUGH, nativeOptions); } -void cmake::WatchUnusedCli(const char* var) +void cmake::WatchUnusedCli(const std::string& var) { #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this); @@ -2697,7 +2694,7 @@ void cmake::WatchUnusedCli(const char* var) #endif } -void cmake::UnwatchUnusedCli(const char* var) +void cmake::UnwatchUnusedCli(const std::string& var) { #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning); @@ -2711,7 +2708,7 @@ void cmake::RunCheckForUnusedVariables() bool haveUnused = false; cmOStringStream msg; msg << "Manually-specified variables were not used by the project:"; - for(std::map<cmStdString, bool>::const_iterator + for(std::map<std::string, bool>::const_iterator it = this->UsedCliVariables.begin(); it != this->UsedCliVariables.end(); ++it) { diff --git a/Source/cmake.h b/Source/cmake.h index dfec55c..6772740 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -91,7 +91,7 @@ class cmake */ FIND_PACKAGE_MODE }; - typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap; + typedef std::map<std::string, cmCommand*> RegisteredCommandsMap; /// Default constructor cmake(); @@ -110,12 +110,12 @@ class cmake * CMakeLists files by recursing up the tree starting at the StartDirectory * and going up until it reaches the HomeDirectory. */ - void SetHomeDirectory(const char* dir); + void SetHomeDirectory(const std::string& dir); const char* GetHomeDirectory() const { return this->cmHomeDirectory.c_str(); } - void SetHomeOutputDirectory(const char* lib); + void SetHomeOutputDirectory(const std::string& lib); const char* GetHomeOutputDirectory() const { return this->HomeOutputDirectory.c_str(); @@ -130,7 +130,7 @@ class cmake * recursing up the tree starting at the StartDirectory and going up until * it reaches the HomeDirectory. */ - void SetStartDirectory(const char* dir) + void SetStartDirectory(const std::string& dir) { this->cmStartDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); @@ -139,7 +139,7 @@ class cmake { return this->cmStartDirectory.c_str(); } - void SetStartOutputDirectory(const char* lib) + void SetStartOutputDirectory(const std::string& lib) { this->StartOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); @@ -175,7 +175,7 @@ class cmake void PreLoadCMakeFiles(); ///! Create a GlobalGenerator - cmGlobalGenerator* CreateGlobalGenerator(const char* name); + cmGlobalGenerator* CreateGlobalGenerator(const std::string& name); ///! Return the global generator assigned to this instance of cmake cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; } @@ -203,9 +203,9 @@ class cmake /** * Given a variable name, return its value (as a string). */ - const char* GetCacheDefinition(const char*) const; + const char* GetCacheDefinition(const std::string&) const; ///! Add an entry into the cache - void AddCacheEntry(const char* key, const char* value, + void AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type); @@ -218,20 +218,20 @@ class cmake * Add a command to this cmake instance */ void AddCommand(cmCommand* ); - void RenameCommand(const char* oldName, const char* newName); - void RemoveCommand(const char* name); + void RenameCommand(const std::string& oldName, const std::string& newName); + void RemoveCommand(const std::string& name); void RemoveUnscriptableCommands(); /** * Get a command by its name */ - cmCommand *GetCommand(const char *name); + cmCommand *GetCommand(const std::string& name); /** Get list of all commands */ RegisteredCommandsMap* GetCommands() { return &this->Commands; } /** Check if a command exists. */ - bool CommandExists(const char* name) const; + bool CommandExists(const std::string& name) const; ///! Parse command line arguments void SetArgs(const std::vector<std::string>&, @@ -269,11 +269,13 @@ class cmake void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&); ///! Set/Get a property of this target file - void SetProperty(const char *prop, const char *value); - void AppendProperty(const char *prop, const char *value,bool asString=false); - const char *GetProperty(const char *prop); - const char *GetProperty(const char *prop, cmProperty::ScopeType scope); - bool GetPropertyAsBool(const char *prop); + void SetProperty(const std::string& prop, const char *value); + void AppendProperty(const std::string& prop, + const char *value,bool asString=false); + const char *GetProperty(const std::string& prop); + const char *GetProperty(const std::string& prop, + cmProperty::ScopeType scope); + bool GetPropertyAsBool(const std::string& prop); // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; @@ -317,18 +319,18 @@ class cmake void MarkCliAsUsed(const std::string& variable); // Define a property - void DefineProperty(const char *name, cmProperty::ScopeType scope, + void DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, bool chain = false); // get property definition cmPropertyDefinition *GetPropertyDefinition - (const char *name, cmProperty::ScopeType scope); + (const std::string& name, cmProperty::ScopeType scope); // Is a property defined? - bool IsPropertyDefined(const char *name, cmProperty::ScopeType scope); - bool IsPropertyChained(const char *name, cmProperty::ScopeType scope); + bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope); + bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope); /** Get the list of configurations (in upper case) considered to be debugging configurations.*/ @@ -355,21 +357,21 @@ class cmake const std::vector<std::string>& nativeOptions, bool clean); - void UnwatchUnusedCli(const char* var); - void WatchUnusedCli(const char* var); + void UnwatchUnusedCli(const std::string& var); + void WatchUnusedCli(const std::string& var); protected: void RunCheckForUnusedVariables(); void InitializeProperties(); - int HandleDeleteCacheVariables(const char* var); + int HandleDeleteCacheVariables(const std::string& var); cmPropertyMap Properties; - std::set<std::pair<cmStdString,cmProperty::ScopeType> > AccessedProperties; + std::set<std::pair<std::string,cmProperty::ScopeType> > AccessedProperties; std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions; typedef cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)(); - typedef std::map<cmStdString, + typedef std::map<std::string, CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap; typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector; RegisteredCommandsMap Commands; @@ -378,7 +380,7 @@ protected: void AddDefaultCommands(); void AddDefaultGenerators(); void AddDefaultExtraGenerators(); - void AddExtraGenerator(const char* name, + void AddExtraGenerator(const std::string& name, CreateExtraGeneratorFunctionType newFunction); cmPolicies *Policies; @@ -430,7 +432,7 @@ private: bool WarnUnused; bool WarnUnusedCli; bool CheckSystemVars; - std::map<cmStdString, bool> UsedCliVariables; + std::map<std::string, bool> UsedCliVariables; std::string CMakeEditCommand; std::string CXXEnvironment; std::string CCEnvironment; diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index faa5fa7..55fc633 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -198,7 +198,7 @@ static int process( const std::string& srcfilename, std::vector<std::string> args; cmSystemTools::ParseWindowsCommandLine(cmd.c_str(), args); // convert to correct vector type for RunSingleCommand - std::vector<cmStdString> command; + std::vector<std::string> command; for(std::vector<std::string>::iterator i = args.begin(); i != args.end(); ++i) { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 4ac1986..9aee975 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -102,8 +102,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str())) { - std::cerr << "Error copying file \"" << args[2].c_str() - << "\" to \"" << args[3].c_str() << "\".\n"; + std::cerr << "Error copying file \"" << args[2] + << "\" to \"" << args[3] << "\".\n"; return 1; } return 0; @@ -116,7 +116,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) args[3].c_str())) { std::cerr << "Error copying file (if different) from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() + << args[2] << "\" to \"" << args[3] << "\".\n"; return 1; } @@ -129,7 +129,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str())) { std::cerr << "Error copying directory from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() + << args[2] << "\" to \"" << args[3] << "\".\n"; return 1; } @@ -143,7 +143,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { std::string e = cmSystemTools::GetLastSystemError(); std::cerr << "Error renaming from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() + << args[2] << "\" to \"" << args[3] << "\": " << e << "\n"; return 1; } @@ -156,7 +156,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str())) { std::cerr << "Files \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() + << args[2] << "\" to \"" << args[3] << "\" are different.\n"; return 1; } @@ -199,7 +199,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::vector<std::string>::iterator it; for ( it = env.begin(); it != env.end(); ++ it ) { - std::cout << it->c_str() << std::endl; + std::cout << *it << std::endl; } return 0; } @@ -209,7 +209,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { if(!cmSystemTools::MakeDirectory(args[2].c_str())) { - std::cerr << "Error making directory \"" << args[2].c_str() + std::cerr << "Error making directory \"" << args[2] << "\".\n"; return 1; } @@ -221,7 +221,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if(cmSystemTools::FileIsDirectory(args[2].c_str()) && !cmSystemTools::RemoveADirectory(args[2].c_str())) { - std::cerr << "Error removing directory \"" << args[2].c_str() + std::cerr << "Error removing directory \"" << args[2] << "\".\n"; return 1; } @@ -613,16 +613,16 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) startDir = cmSystemTools::CollapseFullPath(startDir.c_str()); homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str()); startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str()); - cm.SetHomeDirectory(homeDir.c_str()); - cm.SetStartDirectory(startDir.c_str()); - cm.SetHomeOutputDirectory(homeOutDir.c_str()); - cm.SetStartOutputDirectory(startOutDir.c_str()); - if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen.c_str())) + cm.SetHomeDirectory(homeDir); + cm.SetStartDirectory(startDir); + cm.SetHomeOutputDirectory(homeOutDir); + cm.SetStartOutputDirectory(startOutDir); + if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) { cm.SetGlobalGenerator(ggd); cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); - lgd->GetMakefile()->SetStartDirectory(startDir.c_str()); - lgd->GetMakefile()->SetStartOutputDirectory(startOutDir.c_str()); + lgd->GetMakefile()->SetStartDirectory(startDir); + lgd->GetMakefile()->SetStartOutputDirectory(startOutDir); lgd->GetMakefile()->MakeStartDirectoriesCurrent(); // Actually scan dependencies. @@ -666,8 +666,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) else if (args[1] == "cmake_autogen" && args.size() >= 4) { cmQtAutoGenerators autogen; - const char *config = args[3].empty() ? 0 : args[3].c_str(); - bool autogenSuccess = autogen.Run(args[2].c_str(), config); + std::string const& config = args[3]; + bool autogenSuccess = autogen.Run(args[2], config); return autogenSuccess ? 0 : 1; } #endif @@ -677,7 +677,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { std::string flags = args[2]; std::string outFile = args[3]; - std::vector<cmStdString> files; + std::vector<std::string> files; for (std::string::size_type cc = 4; cc < args.size(); cc ++) { files.push_back(args[cc]); @@ -1143,7 +1143,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type) } int cmcmd::ParseVisualStudioLinkCommand(std::vector<std::string>& args, - std::vector<cmStdString>& command, + std::vector<std::string>& command, std::string& targetName) { std::vector<std::string>::iterator i = args.begin(); @@ -1171,17 +1171,17 @@ int cmcmd::ParseVisualStudioLinkCommand(std::vector<std::string>& args, } bool cmcmd::RunCommand(const char* comment, - std::vector<cmStdString>& command, + std::vector<std::string>& command, bool verbose, int* retCodeOut) { if(verbose) { std::cout << comment << ":\n"; - for(std::vector<cmStdString>::iterator i = command.begin(); + for(std::vector<std::string>::iterator i = command.begin(); i != command.end(); ++i) { - std::cout << i->c_str() << " "; + std::cout << *i << " "; } std::cout << "\n"; } @@ -1239,16 +1239,16 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, // 7. Finally, the Linker does another incremental link, but since the // only thing that has changed is the *.res file that contains the // manifest it is a short link. - std::vector<cmStdString> linkCommand; + std::vector<std::string> linkCommand; std::string targetName; if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) { return -1; } std::string manifestArg = "/MANIFESTFILE:"; - std::vector<cmStdString> rcCommand; + std::vector<std::string> rcCommand; rcCommand.push_back(cmSystemTools::FindProgram("rc.exe")); - std::vector<cmStdString> mtCommand; + std::vector<std::string> mtCommand; mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); std::string tempManifest; tempManifest = targetName; @@ -1257,7 +1257,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, resourceInputFile += ".resource.txt"; if(verbose) { - std::cout << "Create " << resourceInputFile.c_str() << "\n"; + std::cout << "Create " << resourceInputFile << "\n"; } // Create input file for rc command cmsys::ofstream fout(resourceInputFile.c_str()); @@ -1269,7 +1269,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, manifestFile += ".embed.manifest"; std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str()); fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID " - "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath.c_str() << "\""; + "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath << "\""; fout.close(); manifestArg += tempManifest; // add the manifest arg to the linkCommand @@ -1281,7 +1281,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, { if(verbose) { - std::cout << "Create empty: " << manifestFile.c_str() << "\n"; + std::cout << "Create empty: " << manifestFile << "\n"; } cmsys::ofstream foutTmp(manifestFile.c_str()); } @@ -1349,7 +1349,7 @@ int cmcmd::VisualStudioLinkNonIncremental(std::vector<std::string>& args, bool hasManifest, bool verbose) { - std::vector<cmStdString> linkCommand; + std::vector<std::string> linkCommand; std::string targetName; if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) { @@ -1368,7 +1368,7 @@ int cmcmd::VisualStudioLinkNonIncremental(std::vector<std::string>& args, { return 0; } - std::vector<cmStdString> mtCommand; + std::vector<std::string> mtCommand; mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); mtCommand.push_back("/nologo"); mtCommand.push_back("/manifest"); diff --git a/Source/cmcmd.h b/Source/cmcmd.h index 4517ebf..2bfbae7 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -43,10 +43,10 @@ protected: bool hasManifest, bool verbose); static int ParseVisualStudioLinkCommand(std::vector<std::string>& args, - std::vector<cmStdString>& command, + std::vector<std::string>& command, std::string& targetName); static bool RunCommand(const char* comment, - std::vector<cmStdString>& command, + std::vector<std::string>& command, bool verbose, int* retCodeOut = 0); }; diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 24ea518..977d57b 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -685,6 +685,7 @@ IF(KWSYS_USE_SystemInformation) # usually it's in libc but on FreeBSD # it's in libexecinfo FIND_LIBRARY(EXECINFO_LIB "execinfo") + MARK_AS_ADVANCED(EXECINFO_LIB) IF (NOT EXECINFO_LIB) SET(EXECINFO_LIB "") ENDIF() @@ -1076,6 +1077,11 @@ IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")) ) ENDIF() +IF(WIN32) + # Help enforce the use of wide Windows apis. + ADD_DEFINITIONS(-DUNICODE -D_UNICODE) +ENDIF() + IF(KWSYS_USE_String) # Activate code in "String.c". See the comment in the source. SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES @@ -1222,6 +1228,9 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # Some Apple compilers produce bad optimizations in this source. IF(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|LLVM)$") SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0) + ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL") + # Tell IBM XL not to warn about our test infinite loop + SET_PROPERTY(SOURCE testProcess.c PROPERTY COMPILE_FLAGS -qsuppress=1500-010) ENDIF() # Test SharedForward diff --git a/Source/kwsys/FStream.cxx b/Source/kwsys/FStream.cxx new file mode 100644 index 0000000..018652c --- /dev/null +++ b/Source/kwsys/FStream.cxx @@ -0,0 +1,76 @@ +/*============================================================================ + KWSys - Kitware System Library + 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 "kwsysPrivate.h" +#include KWSYS_HEADER(FStream.hxx) + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "FStream.hxx.in" +#endif + +namespace KWSYS_NAMESPACE +{ +namespace FStream +{ + +BOM ReadBOM(std::istream& in) +{ + if(!in.good()) + { + return BOM_None; + } + unsigned long orig = in.tellg(); + unsigned char bom[4]; + in.read(reinterpret_cast<char*>(bom), 2); + if(!in.good()) + { + in.seekg(orig); + return BOM_None; + } + if(bom[0] == 0xEF && bom[1] == 0xBB) + { + in.read(reinterpret_cast<char*>(bom+2), 1); + if(in.good() && bom[2] == 0xBF) + { + return BOM_UTF8; + } + } + else if(bom[0] == 0xFE && bom[1] == 0xFF) + { + return BOM_UTF16BE; + } + else if(bom[0] == 0x00 && bom[1] == 0x00) + { + in.read(reinterpret_cast<char*>(bom+2), 2); + if(in.good() && bom[2] == 0xFE && bom[3] == 0xFF) + { + return BOM_UTF32BE; + } + } + else if(bom[0] == 0xFF && bom[1] == 0xFE) + { + unsigned long p = in.tellg(); + in.read(reinterpret_cast<char*>(bom+2), 2); + if(in.good() && bom[2] == 0x00 && bom[3] == 0x00) + { + return BOM_UTF32LE; + } + in.seekg(p); + return BOM_UTF16LE; + } + in.seekg(orig); + return BOM_None; +} + +} // FStream namespace +} //KWSYS_NAMESPACE diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in index 916a93e..45425ff 100644 --- a/Source/kwsys/FStream.hxx.in +++ b/Source/kwsys/FStream.hxx.in @@ -161,13 +161,28 @@ class basic_ofstream : public std::basic_ostream<CharType,Traits> typedef basic_ofstream<char> ofstream; #else - using @KWSYS_NAMESPACE@_ios_namespace::basic_filebuf; using @KWSYS_NAMESPACE@_ios_namespace::ofstream; using @KWSYS_NAMESPACE@_ios_namespace::ifstream; #endif + namespace FStream + { + enum BOM + { + BOM_None, + BOM_UTF8, + BOM_UTF16BE, + BOM_UTF16LE, + BOM_UTF32BE, + BOM_UTF32LE + }; + + // Read a BOM, if one exists. + // If a BOM exists, the stream is advanced to after the BOM. + // This function requires a seekable stream (but not a relative + // seekable stream). + BOM ReadBOM(std::istream& in); + } } - - #endif diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in index 8bbc74a..dd4d462 100644 --- a/Source/kwsys/SharedForward.h.in +++ b/Source/kwsys/SharedForward.h.in @@ -415,7 +415,7 @@ static int kwsys_shared_forward_realpath(const char* in_path, char* out_path) { #if defined(_WIN32) && !defined(__CYGWIN__) /* Implementation for Windows. */ - DWORD n = GetFullPathName(in_path, KWSYS_SHARED_FORWARD_MAXPATH, + DWORD n = GetFullPathNameA(in_path, KWSYS_SHARED_FORWARD_MAXPATH, out_path, 0); return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH; #else @@ -429,9 +429,9 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2) { #if defined(_WIN32) int result = 0; - HANDLE h1 = CreateFile(file1, GENERIC_READ, FILE_SHARE_READ, NULL, + HANDLE h1 = CreateFileA(file1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); - HANDLE h2 = CreateFile(file2, GENERIC_READ, FILE_SHARE_READ, NULL, + HANDLE h2 = CreateFileA(file2, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if(h1 != INVALID_HANDLE_VALUE && h2 != INVALID_HANDLE_VALUE) { @@ -462,7 +462,7 @@ static void kwsys_shared_forward_strerror(char* message) #if defined(_WIN32) && !defined(__CYGWIN__) /* Implementation for Windows. */ DWORD original = GetLastError(); - DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + DWORD length = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, original, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), message, KWSYS_SHARED_FORWARD_MAXPATH, 0); diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 5f20853..720a7c3 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -4698,11 +4698,28 @@ bool SystemInformationImplementation::QueryHaikuInfo() { #if defined(__HAIKU__) + // CPU count system_info info; get_system_info(&info); - this->NumberOfPhysicalCPU = info.cpu_count; - this->CPUSpeedInMHz = info.cpu_clock_speed / 1000000.0F; + + // CPU speed + uint32 topologyNodeCount = 0; + cpu_topology_node_info* topology = 0; + get_cpu_topology_info(0, &topologyNodeCount); + if (topologyNodeCount != 0) + topology = new cpu_topology_node_info[topologyNodeCount]; + get_cpu_topology_info(topology, &topologyNodeCount); + + for (uint32 i = 0; i < topologyNodeCount; i++) { + if (topology[i].type == B_TOPOLOGY_CORE) { + this->CPUSpeedInMHz = topology[i].data.core.default_frequency / + 1000000.0f; + break; + } + } + + delete[] topology; // Physical Memory this->TotalPhysicalMemory = (info.max_pages * B_PAGE_SIZE) / (1024 * 1024) ; @@ -5006,21 +5023,26 @@ bool SystemInformationImplementation::QueryHPUXProcessor() case CPU_PA_RISC1_0: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x100; + break; case CPU_PA_RISC1_1: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x110; + break; case CPU_PA_RISC2_0: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x200; -# ifdef CPU_HP_INTEL_EM_1_0 + break; +# if defined(CPU_HP_INTEL_EM_1_0) || defined(CPU_IA64_ARCHREV_0) +# ifdef CPU_HP_INTEL_EM_1_0 case CPU_HP_INTEL_EM_1_0: -# endif -# ifdef CPU_IA64_ARCHREV_0 +# endif +# ifdef CPU_IA64_ARCHREV_0 case CPU_IA64_ARCHREV_0: -# endif +# endif this->ChipID.Vendor = "GenuineIntel"; this->Features.HasIA64 = true; break; +# endif default: return false; } diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index f4a443f..32e79e6 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -188,6 +188,9 @@ static inline char *realpath(const char *path, char *resolved_path) #endif #if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) + +#include <wctype.h> + inline int Mkdir(const char* dir) { return _wmkdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); @@ -4915,8 +4918,8 @@ void SystemTools::ClassInitialize() // Strip off one directory level and see if the logical // mapping still works. - pwd_str = SystemTools::GetFilenamePath(pwd_str.c_str()); - cwd_str = SystemTools::GetFilenamePath(cwd_str.c_str()); + pwd_str = SystemTools::GetFilenamePath(pwd_str); + cwd_str = SystemTools::GetFilenamePath(cwd_str); Realpath(pwd_str.c_str(), pwd_path); } diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx index 8942549..9abfd4c 100644 --- a/Source/kwsys/testFStream.cxx +++ b/Source/kwsys/testFStream.cxx @@ -16,11 +16,17 @@ #endif #include KWSYS_HEADER(FStream.hxx) +#include KWSYS_HEADER(ios/iostream) +#include <string.h> +#ifdef __BORLANDC__ +# include <mem.h> /* memcmp */ +#endif // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 # include "FStream.hxx.in" +# include "kwsys_ios_iostream.h.in" #endif @@ -36,6 +42,141 @@ static int testNoFile() return 0; } +static kwsys::FStream::BOM expected_bom[5] = +{ + kwsys::FStream::BOM_UTF8, + kwsys::FStream::BOM_UTF16LE, + kwsys::FStream::BOM_UTF16BE, + kwsys::FStream::BOM_UTF32LE, + kwsys::FStream::BOM_UTF32BE +}; + +static unsigned char expected_bom_data[5][5] = +{ + {3, 0xEF, 0xBB, 0xBF}, + {2, 0xFF, 0xFE}, + {2, 0xFE, 0xFF}, + {4, 0xFF, 0xFE, 0x00, 0x00}, + {4, 0x00, 0x00, 0xFE, 0xFF}, +}; + +static unsigned char file_data[5][45] = +{ + {11, 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'}, + {22, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20, 0x00, + 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64, 0x00}, + {22, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20, + 0x00, 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64}, + {44, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, + 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, + 0x6C, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00}, + {44, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C, + 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72, + 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x64}, +}; + +//---------------------------------------------------------------------------- +static int testBOM() +{ + // test various encodings in binary mode + for(int i=0; i<5; i++) + { + { + kwsys::ofstream out("bom.txt", kwsys::ofstream::binary); + out.write(reinterpret_cast<const char*>(expected_bom_data[i]+1), + *expected_bom_data[i]); + out.write(reinterpret_cast<const char*>(file_data[i]+1), + file_data[i][0]); + } + + kwsys::ifstream in("bom.txt", kwsys::ofstream::binary); + kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in); + if(bom != expected_bom[i]) + { + kwsys_ios::cout << "Unexpected BOM " << i << std::endl; + return 1; + } + char data[45]; + in.read(data, file_data[i][0]); + if(!in.good()) + { + kwsys_ios::cout << "Unable to read data " << i << std::endl; + return 1; + } + + if(memcmp(data, file_data[i]+1, file_data[i][0]) != 0) + { + kwsys_ios::cout << "Incorrect read data " << i << std::endl; + return 1; + } + + } + + // test text file without bom + { + { + kwsys::ofstream out("bom.txt"); + out << "Hello World"; + } + + kwsys::ifstream in("bom.txt"); + kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in); + if(bom != kwsys::FStream::BOM_None) + { + kwsys_ios::cout << "Unexpected BOM for none case" << std::endl; + return 1; + } + char data[45]; + in.read(data, file_data[0][0]); + if(!in.good()) + { + kwsys_ios::cout << "Unable to read data for none case" << std::endl; + return 1; + } + + if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0) + { + kwsys_ios::cout << "Incorrect read data for none case" << std::endl; + return 1; + } + } + + // test text file with utf-8 bom + { + { + kwsys::ofstream out("bom.txt"); + out.write(reinterpret_cast<const char*>(expected_bom_data[0]+1), + *expected_bom_data[0]); + out << "Hello World"; + } + + kwsys::ifstream in("bom.txt"); + kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in); + if(bom != kwsys::FStream::BOM_UTF8) + { + kwsys_ios::cout << "Unexpected BOM for utf-8 case" << std::endl; + return 1; + } + char data[45]; + in.read(data, file_data[0][0]); + if(!in.good()) + { + kwsys_ios::cout << "Unable to read data for utf-8 case" << std::endl; + return 1; + } + + if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0) + { + kwsys_ios::cout << "Incorrect read data for utf-8 case" << std::endl; + return 1; + } + } + + return 0; +} + //---------------------------------------------------------------------------- int testFStream(int, char*[]) @@ -43,6 +184,7 @@ int testFStream(int, char*[]) int ret = 0; ret |= testNoFile(); + ret |= testBOM(); return ret; } diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 82537ef..0e0a872 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -58,7 +58,7 @@ static char* lowercase(const char *string) int main(int ac, char *av[]) { - int i, NumTests, testNum, partial_match; + int i, NumTests, testNum = 0, partial_match; char *arg, *test_name; int count; int testToRun = -1; @@ -81,7 +81,6 @@ int main(int ac, char *av[]) } printf("To run a test, enter the test number: "); fflush(stdout); - testNum = 0; if( scanf("%d", &testNum) != 1 ) { printf("Couldn't parse that input as a number\n"); diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 9727930..a875f07 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -68,6 +68,8 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_exe.h "#define link_depends_no_shared_exe_value 0\n") set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt) +file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external original\n") + help_xcode_depends() message("Building project first time") @@ -166,6 +168,19 @@ else() "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.") endif() +if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out) + file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out) + if("${external_out}" STREQUAL "external original") + message(STATUS "external.out contains '${external_out}'") + else() + message(SEND_ERROR "Project did not initially build properly: " + "external.out contains '${external_out}'") + endif() +else() + message(SEND_ERROR "Project did not initially build properly: " + "external.out is missing") +endif() + message("Waiting 3 seconds...") # any additional argument will cause ${bar} to wait forever execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out) @@ -191,6 +206,8 @@ if(TEST_LINK_DEPENDS) file(WRITE ${TEST_LINK_DEPENDS} "2") endif() +file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external changed\n") + help_xcode_depends() message("Building project second time") @@ -294,3 +311,16 @@ else() message(SEND_ERROR "Project did not rebuild properly. " "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.") endif() + +if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out) + file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out) + if("${external_out}" STREQUAL "external changed") + message(STATUS "external.out contains '${external_out}'") + else() + message(SEND_ERROR "Project did not rebuild properly: " + "external.out contains '${external_out}'") + endif() +else() + message(SEND_ERROR "Project did not rebuild properly: " + "external.out is missing") +endif() diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 8806ecd..9ee4a43 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -139,3 +139,15 @@ add_custom_target(header_tgt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_executable(ninjadep ninjadep.cpp) add_dependencies(ninjadep header_tgt) + +include(ExternalProject) +ExternalProject_Add(ExternalBuild + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/External + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/External + STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/External/Stamp + BUILD_ALWAYS 1 + CMAKE_ARGS + -Dexternal_in=${CMAKE_CURRENT_BINARY_DIR}/external.in + -Dexternal_out=${CMAKE_CURRENT_BINARY_DIR}/external.out + INSTALL_COMMAND "" + ) diff --git a/Tests/BuildDepends/Project/External/CMakeLists.txt b/Tests/BuildDepends/Project/External/CMakeLists.txt new file mode 100644 index 0000000..c6015b6 --- /dev/null +++ b/Tests/BuildDepends/Project/External/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.0) +project(BuildDependsExternal NONE) +if(NOT DEFINED external_in) + message(FATAL_ERROR "Define external_in") +endif() +if(NOT DEFINED external_out) + message(FATAL_ERROR "Define external_out") +endif() +add_custom_command( + OUTPUT ${external_out} + COMMAND ${CMAKE_COMMAND} -E copy ${external_in} ${external_out} + DEPENDS ${external_in} + ) +add_custom_target(drive ALL DEPENDS ${external_out}) diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in index 0f7074b..aaefe43 100644 --- a/Tests/CMakeBuildTest.cmake.in +++ b/Tests/CMakeBuildTest.cmake.in @@ -11,8 +11,8 @@ file(REMOVE "@CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt") message("running: ${CMAKE_COMMAND}") execute_process(COMMAND "${CMAKE_COMMAND}" "@CMAKE_BUILD_TEST_SOURCE_DIR@" - "-G@CMAKE_TEST_GENERATOR@" - -T "@CMAKE_TEST_GENERATOR_TOOLSET@" + "-G@CMAKE_GENERATOR@" + -T "@CMAKE_GENERATOR_TOOLSET@" WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@" RESULT_VARIABLE RESULT) if(RESULT) diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index dc1ce24..279bcd5 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -2,14 +2,14 @@ class CompileCommandParser { public: - class CommandType: public std::map<cmStdString, cmStdString> + class CommandType: public std::map<std::string, std::string> { public: - cmStdString const& at(cmStdString const& k) const + std::string const& at(std::string const& k) const { const_iterator i = this->find(k); if(i != this->end()) { return i->second; } - static cmStdString emptyString; + static std::string emptyString; return emptyString; } }; @@ -127,7 +127,7 @@ int main () it = parser.GetTranslationUnits().begin(), end = parser.GetTranslationUnits().end(); it != end; ++it) { - std::vector<cmStdString> command; + std::vector<std::string> command; cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command); if (!cmSystemTools::RunSingleCommand( command, 0, 0, it->at("directory").c_str())) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8074a01..726e790 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -45,26 +45,27 @@ configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in # Testing if(BUILD_TESTING) - set(CMAKE_TEST_DEVENV "") - if(NOT CMAKE_TEST_DIFFERENT_GENERATOR) - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "") - else() - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") - endif() - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND - NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") - set(CMAKE_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") - endif() + set(CMake_TEST_DEVENV "") + if(CMAKE_GENERATOR MATCHES "Visual Studio [7-9] " AND + NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") + set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") endif() - if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32)) - set(TEST_CompileCommandOutput 1) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "") + else() + set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") + endif() + + if(NOT CMake_TEST_EXTERNAL_CMAKE) + if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32)) + set(TEST_CompileCommandOutput 1) + endif() endif() set(MAKE_IS_GNU ) - if(CMAKE_TEST_MAKEPROGRAM MATCHES make) - execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version + if(CMAKE_MAKE_PROGRAM MATCHES make) + execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) if("${res}" STREQUAL "0") if("${out}" MATCHES "GNU") @@ -75,34 +76,38 @@ if(BUILD_TESTING) # some old versions of make simply cannot handle spaces in paths if (MAKE_IS_GNU OR - CMAKE_TEST_MAKEPROGRAM MATCHES "nmake|gmake|wmake" OR - CMAKE_TEST_GENERATOR MATCHES "Visual Studio|XCode|Borland") + CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR + CMAKE_GENERATOR MATCHES "Visual Studio|XCode|Borland") set(MAKE_SUPPORTS_SPACES 1) else() set(MAKE_SUPPORTS_SPACES 0) endif() set(build_generator_args - --build-generator ${CMAKE_TEST_GENERATOR} + --build-generator ${CMAKE_GENERATOR} ) - if(CMAKE_TEST_GENERATOR_TOOLSET) + if(CMAKE_GENERATOR_TOOLSET) list(APPEND build_generator_args - --build-generator-toolset ${CMAKE_TEST_GENERATOR_TOOLSET} + --build-generator-toolset ${CMAKE_GENERATOR_TOOLSET} ) endif() set(build_options) - if(CMAKE_TEST_MAKEPROGRAM) - list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) + list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) endif() - add_subdirectory(CMakeLib) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_subdirectory(CMakeLib) + endif() add_subdirectory(CMakeOnly) add_subdirectory(RunCMake) add_subdirectory(FindPackageModeMakefileTest) - add_subdirectory(CTestTestMemcheck) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_subdirectory(CTestTestMemcheck) + endif() # Collect a list of all test build directories. set(TEST_BUILD_DIRS) @@ -199,8 +204,8 @@ if(BUILD_TESTING) set(TEST_RESOURCES TRUE) endif() # for borland and watcom there is no resource support - if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake" OR - "${CMAKE_TEST_GENERATOR}" MATCHES "Borland") + if("${CMAKE_GENERATOR}" MATCHES "WMake" OR + "${CMAKE_GENERATOR}" MATCHES "Borland") set(TEST_RESOURCES FALSE) endif() if(TEST_RESOURCES) @@ -249,7 +254,9 @@ if(BUILD_TESTING) ADD_TEST_MACRO(SetLang SetLang) ADD_TEST_MACRO(EmptyProperty EmptyProperty) ADD_TEST_MACRO(ExternalOBJ ExternalOBJ) - ADD_TEST_MACRO(LoadCommand LoadedCommand) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + ADD_TEST_MACRO(LoadCommand LoadedCommand) + endif() ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory) ADD_TEST_MACRO(LinkLanguage LinkLanguage) ADD_TEST_MACRO(LinkLine LinkLine) @@ -260,7 +267,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Assembler HelloAsm) ADD_TEST_MACRO(SourceGroups SourceGroups) ADD_TEST_MACRO(Preprocess Preprocess) - set(ExportImport_BUILD_OPTIONS -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) @@ -276,7 +283,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CrossCompile CrossCompile) set_tests_properties(CrossCompile PROPERTIES PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode") - if("${CMAKE_TEST_GENERATOR}" MATCHES "Make") + if("${CMAKE_GENERATOR}" MATCHES "Make") ADD_TEST_MACRO(Policy0002 Policy0002) endif() if(CTEST_TEST_OSX_ARCH) @@ -315,7 +322,7 @@ if(BUILD_TESTING) MINGW OR CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") - if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake") + if(NOT "${CMAKE_GENERATOR}" STREQUAL "Watcom WMake") add_test(BundleUtilities ${CMAKE_CTEST_COMMAND} --build-and-test @@ -381,6 +388,7 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData") ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) + ADD_TEST_MACRO(Module.FindDependency FindDependency) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") include(CheckCXXCompilerFlag) @@ -465,7 +473,7 @@ if(BUILD_TESTING) # build the "Simple" test with the ExtraGenerators, if available # This doesn't test whether the generated project files work (unfortunately), # mainly it tests that cmake doesn't crash when generating these project files. - if(${CMAKE_TEST_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_TEST_GENERATOR} MATCHES "KDevelop") + if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "KDevelop") # check which generators we have execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput) @@ -477,7 +485,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator" --build-two-config --build-generator "Eclipse CDT4 - Unix Makefiles" - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project Simple --build-options ${build_options} --test-command Simple) @@ -492,7 +500,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator" --build-two-config --build-generator "CodeBlocks - Unix Makefiles" - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project Simple --build-options ${build_options} --test-command Simple) @@ -506,7 +514,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator" --build-two-config --build-generator "KDevelop3 - Unix Makefiles" - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project Simple --build-options ${build_options} --test-command Simple) @@ -517,7 +525,7 @@ if(BUILD_TESTING) # test for correct sub-project generation # not implemented in VS 6, VS 7.0, Xcode, or Ninja - if(NOT CMAKE_TEST_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja") + if(NOT CMAKE_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja") # run cmake and configure all of SubProject # but only build the independent executable car add_test(SubProject ${CMAKE_CTEST_COMMAND} @@ -536,17 +544,17 @@ if(BUILD_TESTING) # the bar library which should be referenced because # foo links to the static library bar, but bar is not # directly in the foo sub project - if(CMAKE_TEST_MAKEPROGRAM) + if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) set(SubProject-Stage2_BUILD_MAKEPROGRAM - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM} ) endif() add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SubProject/foo" "${CMake_BINARY_DIR}/Tests/SubProject/foo" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator ${CMAKE_GENERATOR} + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" ${SubProject-Stage2_BUILD_MAKEPROGRAM} --build-nocmake --build-project foo @@ -567,7 +575,7 @@ if(BUILD_TESTING) file(WRITE "${_TEST_DIR}/nightly-cmake.sh" "cd ${_TEST_DIR} ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script} -${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake +${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake ") add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh) if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY) @@ -821,6 +829,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(WIX_LIGHT_EXECUTABLE) add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} --build-and-test "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator" "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator" @@ -829,6 +838,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-options ${build_options} --test-command ${CMAKE_CMAKE_COMMAND} "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator" + "-Dconfig=\${CTEST_CONFIGURATION_TYPE}" -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake") endif() endif() @@ -995,7 +1005,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(CTEST_RUN_CMakeTestBadCommandLines) add_test(CMakeTestBadCommandLines ${CMAKE_CMAKE_COMMAND} -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines - -D gen=${CMAKE_TEST_GENERATOR} + -D gen=${CMAKE_GENERATOR} -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR} -P ${CMake_SOURCE_DIR}/Tests/CMakeTestBadCommandLines/RunCMake.cmake ) @@ -1010,7 +1020,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ if(CTEST_RUN_CMakeTestMultipleConfigures) add_test(CMakeTestMultipleConfigures ${CMAKE_CMAKE_COMMAND} -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures - -D gen=${CMAKE_TEST_GENERATOR} + -D gen=${CMAKE_GENERATOR} -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR} -P ${CMake_SOURCE_DIR}/Tests/CMakeTestMultipleConfigures/RunCMake.cmake ) @@ -1018,16 +1028,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures") endif() - add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig" - "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig" - ${build_generator_args} - --build-project LoadCommand - --build-options ${build_options} - --test-command LoadedCommand - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig") + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig" + "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig" + ${build_generator_args} + --build-project LoadCommand + --build-options ${build_options} + --test-command LoadedCommand + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig") + endif() add_test(complex ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1233,8 +1245,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ COMMAND ${CMAKE_CMAKE_COMMAND} -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate - -DCMAKE_TEST_GENERATOR=${CMAKE_TEST_GENERATOR} - -DCMAKE_TEST_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake ) @@ -1405,7 +1417,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${build_generator_args} --build-project MacRuntimePath --build-options ${build_options} - -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} + -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} ) endif() @@ -1452,19 +1464,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) endif() - if(NOT CMAKE_TEST_DIFFERENT_GENERATOR) - add_test(kwsys ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Source/kwsys" - "${CMake_BINARY_DIR}/Tests/kwsys" - ${build_generator_args} - --build-project kwsys - --build-options ${build_options} - --test-command kwsysTestsCxx testIOS - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys") - endif() - if(MAKE_SUPPORTS_SPACES) add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1511,19 +1510,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif () list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir") - if(CMAKE_TEST_MSVC) + if(MSVC) ADD_TEST_MACRO(ForceInclude foo) ADD_TEST_MACRO(PDBDirectoryAndName myexe) ADD_TEST_MACRO(PrecompiledHeader foo) endif() - if(CMAKE_TEST_MSVC OR - "${CMAKE_TEST_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") + if(MSVC OR + "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") ADD_TEST_MACRO(ModuleDefinition example_exe) endif() ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) - if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") + if("${CMAKE_GENERATOR}" MATCHES "Makefile") add_test(MakeClean ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/MakeClean" @@ -1545,10 +1544,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # Look for evidence that this is a VCExpress build. If so, avoid # the MFC test by default. - string(TOLOWER "${CMAKE_MAKE_PROGRAM};${CMAKE_TEST_MAKEPROGRAM}" mkprog) + string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog) if(mkprog MATCHES "vcexpress") message(STATUS - "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test") + "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test") set(CTEST_RUN_MFC OFF) endif() @@ -1569,7 +1568,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # For the Watcom WMake generator, avoid the MFC test by default. if(CTEST_RUN_MFC) - if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake") + if("${CMAKE_GENERATOR}" MATCHES "WMake") message(STATUS "using the Watcom WMake generator, avoiding MFC test") set(CTEST_RUN_MFC OFF) @@ -1642,13 +1641,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC") endif() - if(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") + if(${CMAKE_GENERATOR} MATCHES "Visual Studio") if(NOT MSVC60) ADD_TEST_MACRO(SBCS SBCS) endif() - if(NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [6789]( |$)" - AND NOT CMAKE_TEST_GENERATOR_TOOLSET) + if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [6789]( |$)" + AND NOT CMAKE_GENERATOR_TOOLSET) ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx) endif() @@ -1674,7 +1673,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command VSMidl) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl") - if(CMAKE_TEST_DEVENV) + if(CMake_TEST_DEVENV) # The test (and tested property) works with .sln files, so it's skipped when: # * Using VS6, which doesn't use .sln files # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file @@ -1686,9 +1685,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild" --build-config ${config} --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-makeprogram ${CMAKE_TEST_DEVENV} - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMake_TEST_DEVENV} + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project VSExcludeFromDefaultBuild --test-command ${CMAKE_COMMAND} -D "activeConfig=${config}" @@ -1704,15 +1703,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild") endif() - if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])") + if(CMAKE_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])") # This is Visual Studio 10 or above, so the default build tool is MSBuild. add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir" "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir" --build-two-config - --build-generator ${CMAKE_TEST_GENERATOR} - --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-generator ${CMAKE_GENERATOR} + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-project VSProjectInSubdir --build-target test) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir") @@ -1750,7 +1749,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE} -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest - -Dgen=${CMAKE_TEST_GENERATOR} + -Dgen=${CMAKE_GENERATOR} -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest") @@ -1803,7 +1802,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") - if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) + if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails # this test. (See #13371) # Apparently Visual Studio does not support it either. As the MakeClean @@ -1876,11 +1875,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # A test for ctest_build() with targets in subdirectories set(ctest_configure_options) - if(CMAKE_TEST_GENERATOR_TOOLSET) - list(APPEND ctest_configure_options -T ${CMAKE_TEST_GENERATOR_TOOLSET}) + if(CMAKE_GENERATOR_TOOLSET) + list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET}) endif() - if(CMAKE_TEST_MAKEPROGRAM) - list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}) + if(CMake_TEST_EXPLICIT_MAKE_PROGRAM) + list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}) endif() configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY) @@ -2219,7 +2218,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log" ) # with watcom the SEGFAULT is not found, it just fails - if(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") + if(CMAKE_GENERATOR MATCHES "Watcom WMake") set_tests_properties(CTestTestCrash PROPERTIES PASS_REGULAR_EXPRESSION "Failed") else() @@ -2498,7 +2497,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" ) - if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_TEST_GENERATOR}" MATCHES "Ninja") + if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja") configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES) add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND} @@ -2535,7 +2534,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif () endif () - if("${CMAKE_TEST_GENERATOR}" MATCHES Xcode) + if("${CMAKE_GENERATOR}" MATCHES Xcode) set(CMAKE_SKIP_BOOTSTRAP_TEST 1) endif() if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") @@ -2580,7 +2579,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project testf --build-two-config --build-options ${build_options} - -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} + -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM} --test-command testf) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") @@ -2607,7 +2606,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ find_package(Java COMPONENTS Development QUIET) if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW - AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode") + AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode") get_filename_component(JNIPATH ${JAVA_COMPILE} PATH) find_file(JNI_H jni.h "${JNIPATH}/../include" @@ -2631,7 +2630,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ endif() # add some cross compiler tests, for now only with makefile based generators - if(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") + if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop") # if sdcc is found, build the SimpleCOnly project with sdcc find_program(SDCC_EXECUTABLE sdcc) @@ -2784,5 +2783,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle) endif() - add_subdirectory(CMakeTests) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + add_subdirectory(CMakeTests) + endif() endif() diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 691728a..15493be 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -8,11 +8,14 @@ endif () # Avoid ctest truncation of output message(STATUS "CTEST_FULL_OUTPUT") +set(ORIGINAL_MODULE_PATH "${CMAKE_MODULE_PATH}") + file(GLOB FIND_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/Find*.cmake" ) macro(do_find MODULE_NAME) message(STATUS " Checking Find${MODULE_NAME}") find_package(${MODULE_NAME}) + set(CMAKE_MODULE_PATH "${ORIGINAL_MODULE_PATH}") endmacro() # It is only possible to use either Qt3 or Qt4 in one project. diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in index a266415..285643a 100644 --- a/Tests/CMakeOnly/Test.cmake.in +++ b/Tests/CMakeOnly/Test.cmake.in @@ -8,8 +8,8 @@ file(REMOVE_RECURSE "${binary_dir}") file(MAKE_DIRECTORY "${binary_dir}") execute_process( COMMAND ${CMAKE_COMMAND} ${CMAKE_ARGS} - "${source_dir}" -G "@CMAKE_TEST_GENERATOR@" - -T "@CMAKE_TEST_GENERATOR_TOOLSET@" + "${source_dir}" -G "@CMAKE_GENERATOR@" + -T "@CMAKE_GENERATOR_TOOLSET@" WORKING_DIRECTORY "${binary_dir}" RESULT_VARIABLE result ) diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt index d673d14..638e788 100644 --- a/Tests/CPackWiXGenerator/CMakeLists.txt +++ b/Tests/CPackWiXGenerator/CMakeLists.txt @@ -9,6 +9,11 @@ target_link_libraries(my-libapp mylib) add_executable(my-other-app myotherapp.cpp) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty + DESTINATION extras + COMPONENT extras) + install(TARGETS mylib ARCHIVE DESTINATION lib @@ -58,6 +63,9 @@ set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patch.xml") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt") +set(CPACK_WIX_PROPERTY_ARPCOMMENTS "My Custom ARPCOMMENTS") +set(CPACK_WIX_PROPERTY_ARPHELPLINK "http://www.cmake.org") + include(CPack) cpack_add_install_type(Full DISPLAY_NAME "Everything") @@ -69,6 +77,12 @@ cpack_add_component_group(Development EXPANDED DESCRIPTION "All of the tools you'll ever need to develop software") +cpack_add_component(extras + DISPLAY_NAME "Extras" + DESCRIPTION "Extras" + GROUP Runtime + INSTALL_TYPES Full) + cpack_add_component(applications REQUIRED DISPLAY_NAME "MyLib Application" diff --git a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake index 30e33cf2..ca9fd90 100644 --- a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake +++ b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake @@ -10,7 +10,12 @@ message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}") message(STATUS "CPackWiXGenerator_BINARY_DIR: ${CPackWiXGenerator_BINARY_DIR}") +if(config) + set(_C_config -C ${config}) +endif() + execute_process(COMMAND "${CMAKE_CPACK_COMMAND}" + ${_C_config} RESULT_VARIABLE CPack_result OUTPUT_VARIABLE CPack_output ERROR_VARIABLE CPack_error diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in index abf010b..670a874 100644 --- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in +++ b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.10) set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") set(CTEST_PROJECT_NAME "VSProjectInSubdir") set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@") diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in index 0bba6d6..608501c 100644 --- a/Tests/CTestConfig/dashboard.cmake.in +++ b/Tests/CTestConfig/dashboard.cmake.in @@ -18,8 +18,8 @@ endif() message("cmake initial configure") execute_process(COMMAND ${CMAKE_COMMAND} ${arg} - -G "@CMAKE_TEST_GENERATOR@" - -T "@CMAKE_TEST_GENERATOR_TOOLSET@" + -G "@CMAKE_GENERATOR@" + -T "@CMAKE_GENERATOR_TOOLSET@" ${CTEST_SOURCE_DIRECTORY} WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} RESULT_VARIABLE rv) diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in index 83267a4..166de3b 100644 --- a/Tests/CTestConfig/script.cmake.in +++ b/Tests/CTestConfig/script.cmake.in @@ -1,5 +1,5 @@ -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_PROJECT_NAME "CTestConfig") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script") diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in index a7420fc..601aab4 100644 --- a/Tests/CTestTestBadExe/test.cmake.in +++ b/Tests/CTestTestBadExe/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-BadExe") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestBadExe") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestBadExe") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in index b18cdf3..8413443 100644 --- a/Tests/CTestTestChecksum/test.cmake.in +++ b/Tests/CTestTestChecksum/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Checksum") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in index 42225d3..d3510bb 100644 --- a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in +++ b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuild set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir1") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in index 010fe1c..99b002c 100644 --- a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in +++ b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuild set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir2") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCostSerial/test.cmake.in b/Tests/CTestTestCostSerial/test.cmake.in index e2dda95..ce8720c 100644 --- a/Tests/CTestTestCostSerial/test.cmake.in +++ b/Tests/CTestTestCostSerial/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-CostSerial") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCostSerial") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCostSerial") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in index 7ac1bb9..5906d12 100644 --- a/Tests/CTestTestCrash/test.cmake.in +++ b/Tests/CTestTestCrash/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Crash") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCrash") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCrash") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in index 94b9cac..478badb 100644 --- a/Tests/CTestTestCycle/test.cmake.in +++ b/Tests/CTestTestCycle/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Cycle") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCycle") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCycle") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in index 98b2a27..a7de8cc 100644 --- a/Tests/CTestTestDepends/test.cmake.in +++ b/Tests/CTestTestDepends/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Depends") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestDepends") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestDepends") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in index 1dee1ae..143daf8 100644 --- a/Tests/CTestTestFailure/testNoBuild.cmake.in +++ b/Tests/CTestTestFailure/testNoBuild.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoBuild") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in index 04e444d..11a1930 100644 --- a/Tests/CTestTestFailure/testNoExe.cmake.in +++ b/Tests/CTestTestFailure/testNoExe.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoExe") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestFdSetSize/test.cmake.in b/Tests/CTestTestFdSetSize/test.cmake.in index c24f505..fbe0e82 100644 --- a/Tests/CTestTestFdSetSize/test.cmake.in +++ b/Tests/CTestTestFdSetSize/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-FdSetSize") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFdSetSize") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFdSetSize") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index 9bd7249..8984463 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -19,14 +19,6 @@ add_executable(pseudo_valgrind "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx") set_target_properties(pseudo_valgrind PROPERTIES OUTPUT_NAME valgrind) target_link_libraries(pseudo_valgrind CMakeLib) -# Xcode 2.x forgets to create the output directory before linking -# the individual architectures. -if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") - add_custom_command(TARGET pseudo_valgrind - PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" - ) -endif() - add_executable(pseudo_purify "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx") set_target_properties(pseudo_purify PROPERTIES OUTPUT_NAME purify) target_link_libraries(pseudo_purify CMakeLib) @@ -196,3 +188,18 @@ set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES set_tests_properties(CTestTestMemcheckDummyValgrindTwoTargets PROPERTIES PASS_REGULAR_EXPRESSION "\nMemory check project ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets\n.*\n *Start 1: RunCMake\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.1.log\" \"-q\".*\n *Start 2: RunCMakeAgain\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.2.log\" \"-q\".*\n") + +# Xcode 2.x forgets to create the output directory before linking +# the individual architectures. +if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + foreach(t + memcheck_fail + pseudo_BC + pseudo_purify + pseudo_valgrind + ) + add_custom_command(TARGET ${t} + PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" + ) + endforeach() +endif() diff --git a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt index c5aa2cd..3a45bfe 100644 --- a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt @@ -1,17 +1,22 @@ # A dummy checker implementation that does not write the requested output file # so it triggers an error for every checker. -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c" "int main(){return 0;}\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in" "int main(){return 0;}\n") + +configure_file( + "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in" + "${CMAKE_CURRENT_BINARY_DIR}/ret0.c" + ) foreach(_pseudo IN ITEMS valgrind purify BC) add_executable(pseudonl_${_pseudo} "${CMAKE_CURRENT_BINARY_DIR}/ret0.c") set_target_properties(pseudonl_${_pseudo} PROPERTIES OUTPUT_NAME ${_pseudo}) -endforeach() -# Xcode 2.x forgets to create the output directory before linking -# the individual architectures. -if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") - add_custom_command(TARGET pseudonl_valgrind + # Xcode 2.x forgets to create the output directory before linking + # the individual architectures. + if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + add_custom_command(TARGET pseudonl_${_pseudo} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" ) -endif() + endif() +endforeach() diff --git a/Tests/CTestTestMemcheck/test.cmake.in b/Tests/CTestTestMemcheck/test.cmake.in index 6c388c5..471e5a5 100644 --- a/Tests/CTestTestMemcheck/test.cmake.in +++ b/Tests/CTestTestMemcheck/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Memcheck@SUBTEST_ set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@") set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in index 5826342..48631ca 100644 --- a/Tests/CTestTestParallel/test.cmake.in +++ b/Tests/CTestTestParallel/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Parallel") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestResourceLock/test.cmake.in b/Tests/CTestTestResourceLock/test.cmake.in index f69b519..6ec6dfe 100644 --- a/Tests/CTestTestResourceLock/test.cmake.in +++ b/Tests/CTestTestResourceLock/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ResourceLock") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestResourceLock") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestResourceLock") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestScheduler/test.cmake.in b/Tests/CTestTestScheduler/test.cmake.in index 26d8058..06ba33e 100644 --- a/Tests/CTestTestScheduler/test.cmake.in +++ b/Tests/CTestTestScheduler/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Scheduler") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestScheduler") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestScheduler") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestSkipReturnCode/test.cmake.in b/Tests/CTestTestSkipReturnCode/test.cmake.in index ebee01b..d3c44f5 100644 --- a/Tests/CTestTestSkipReturnCode/test.cmake.in +++ b/Tests/CTestTestSkipReturnCode/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-SkipReturnCode") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSkipReturnCode") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSkipReturnCode") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in index d4e5a25..8adf941 100644 --- a/Tests/CTestTestStopTime/test.cmake.in +++ b/Tests/CTestTestStopTime/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-StopTime") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestStopTime") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestStopTime") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in index 2b4ef4f..5a6caf1 100644 --- a/Tests/CTestTestSubdir/test.cmake.in +++ b/Tests/CTestTestSubdir/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Subdir") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSubdir") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSubdir") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in index d3d0888..4178849 100644 --- a/Tests/CTestTestTimeout/test.cmake.in +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Timeout") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestTimeout") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestTimeout") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestUpload/test.cmake.in b/Tests/CTestTestUpload/test.cmake.in index 340877f..bb6ba25 100644 --- a/Tests/CTestTestUpload/test.cmake.in +++ b/Tests/CTestTestUpload/test.cmake.in @@ -7,8 +7,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Upload") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestUpload") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestUpload") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") CTEST_START(Experimental) diff --git a/Tests/CTestTestZeroTimeout/test.cmake.in b/Tests/CTestTestZeroTimeout/test.cmake.in index 3252754..beb6d90 100644 --- a/Tests/CTestTestZeroTimeout/test.cmake.in +++ b/Tests/CTestTestZeroTimeout/test.cmake.in @@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ZeroTimeout") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestZeroTimeout") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestZeroTimeout") set(CTEST_CVS_COMMAND "@CVSCOMMAND@") -set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") -set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index bbae387..a194a5f 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -185,7 +185,7 @@ add_executable(CustomCommand # here to test adding the generation rule after referencing the # generated source in a target. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/generated.c - DEPENDS generator + DEPENDS $<1:generator> $<0:does_not_exist> COMMAND generator ARGS ${PROJECT_BINARY_DIR}/generated.c ) @@ -221,8 +221,11 @@ add_subdirectory(GeneratorInExtraDir) add_executable(tcat tcat.cxx) +# Test that list expansion from a generator expression works. +set_property(TARGET tcat PROPERTY DEPSLIST tcat gen_redirect_in.c) + add_custom_command(OUTPUT gen_redirect.c - DEPENDS tcat gen_redirect_in.c + DEPENDS $<TARGET_PROPERTY:tcat,DEPSLIST> COMMAND tcat < ${CMAKE_CURRENT_SOURCE_DIR}/gen_redirect_in.c > gen_redirect.c COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> gen_redirect.c VERBATIM diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index 02a0371..a6f8921 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.7.20090711) project(ExportImport C CXX) -if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() # Wipe out the install tree to make sure the exporter works. diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in index fba6ee2..f600d90 100644 --- a/Tests/ExportImport/InitialCache.cmake.in +++ b/Tests/ExportImport/InitialCache.cmake.in @@ -1,4 +1,4 @@ -set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program") +set(CMAKE_MAKE_PROGRAM "@CMake_TEST_NESTED_MAKE_PROGRAM@" CACHE FILEPATH "Make Program") set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler") set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags") set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags") diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index d9344ec..0ed5561 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -98,6 +98,7 @@ ExternalProject_Add(${proj} CVS_TAG "" DEPENDS "MinimalNoOpProject" NonExternalProjectTarget DOWNLOAD_COMMAND "" + DOWNLOAD_NO_PROGRESS 1 INSTALL_COMMAND "" PATCH_COMMAND "" STEP_TARGETS install update diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake index b6f848a..ea59a8e 100644 --- a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake +++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake @@ -12,7 +12,7 @@ macro(check_a_tag desired_tag resulting_sha fetch_expected) # Configure execute_process(COMMAND ${CMAKE_COMMAND} - -G ${CMAKE_TEST_GENERATOR} -T "${CMAKE_TEST_GENERATOR_TOOLSET}" + -G ${CMAKE_GENERATOR} -T "${CMAKE_GENERATOR_TOOLSET}" -DTEST_GIT_TAG:STRING=${desired_tag} ${ExternalProjectUpdate_SOURCE_DIR} WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR} diff --git a/Tests/FindPackageTest/FindLotsOfComponents.cmake b/Tests/FindPackageTest/FindLotsOfComponents.cmake index 9076d86..5d959c5 100644 --- a/Tests/FindPackageTest/FindLotsOfComponents.cmake +++ b/Tests/FindPackageTest/FindLotsOfComponents.cmake @@ -4,7 +4,7 @@ set(LotsOfComponents_AComp_FOUND TRUE) set(LotsOfComponents_BComp_FOUND FALSE) set(LotsOfComponents_CComp_FOUND TRUE) -include(FindPackageHandleStandardArgs) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(LotsOfComponents REQUIRED_VARS LOC_FOO HANDLE_COMPONENTS) diff --git a/Tests/FindPackageTest/FindSomePackage.cmake b/Tests/FindPackageTest/FindSomePackage.cmake index 83d1d0e..7283d24 100644 --- a/Tests/FindPackageTest/FindSomePackage.cmake +++ b/Tests/FindPackageTest/FindSomePackage.cmake @@ -1,6 +1,6 @@ set(SOP_FOO TRUE) -include(FindPackageHandleStandardArgs) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(SomePackage REQUIRED_VARS SOP_FOO FOUND_VAR SomePackage_FOUND ) diff --git a/Tests/FindPackageTest/FindUpperCasePackage.cmake b/Tests/FindPackageTest/FindUpperCasePackage.cmake index 66c2fea..425d417 100644 --- a/Tests/FindPackageTest/FindUpperCasePackage.cmake +++ b/Tests/FindPackageTest/FindUpperCasePackage.cmake @@ -1,6 +1,6 @@ set(UCP_FOO TRUE) -include(FindPackageHandleStandardArgs) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(UpperCasePackage REQUIRED_VARS UCP_FOO FOUND_VAR UPPERCASEPACKAGE_FOUND ) diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index adc4308..bf6d629 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.6) project(testf C CXX Fortran) -if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() message("CTEST_FULL_OUTPUT ") @@ -208,7 +208,7 @@ if(TEST_MODULE_DEPENDS) -DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE} -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL} -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} - -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM} + -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_NESTED_MAKE_PROGRAM} ${External_BUILD_TYPE} VERBATIM ) diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in index 3436309..28c38e4 100644 --- a/Tests/FortranC/Flags.cmake.in +++ b/Tests/FortranC/Flags.cmake.in @@ -14,8 +14,8 @@ set(COMMAND) execute_process( WORKING_DIRECTORY "${bld}" - COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@" - -T "@CMAKE_TEST_GENERATOR_TOOLSET@" + COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_GENERATOR@" + -T "@CMAKE_GENERATOR_TOOLSET@" "-DFortranC_TEST_FLAGS=1" "-DCMAKE_C_COMPILER=${bld}/cc.sh" "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@" diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt index 5c7b921..eeb3653 100644 --- a/Tests/MacRuntimePath/CMakeLists.txt +++ b/Tests/MacRuntimePath/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.8) project(MacRuntimePath) -if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") - set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}") +if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() # Wipe out the install tree to make sure the exporter works. diff --git a/Tests/MacRuntimePath/InitialCache.cmake.in b/Tests/MacRuntimePath/InitialCache.cmake.in index 3dc9041..a9f6a3c 100644 --- a/Tests/MacRuntimePath/InitialCache.cmake.in +++ b/Tests/MacRuntimePath/InitialCache.cmake.in @@ -1,4 +1,4 @@ -set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program") +set(CMAKE_MAKE_PROGRAM "@CMake_TEST_NESTED_MAKE_PROGRAM@" CACHE FILEPATH "Make Program") set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler") set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags") set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags") diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt new file mode 100644 index 0000000..dcb998a --- /dev/null +++ b/Tests/Module/FindDependency/CMakeLists.txt @@ -0,0 +1,11 @@ + +cmake_minimum_required(VERSION 3.0) +project(FindDependency) + +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages") + +find_package(Pack1 REQUIRED) +find_package(Pack4 4.3 EXACT REQUIRED) + +add_executable(FindDependency main.cpp) +target_link_libraries(FindDependency Pack1::Lib Pack4::Lib) diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp new file mode 100644 index 0000000..50c5958 --- /dev/null +++ b/Tests/Module/FindDependency/main.cpp @@ -0,0 +1,29 @@ + +#ifndef HAVE_PACK1 +#error Expected HAVE_PACK1 +#endif + +#ifndef HAVE_PACK2 +#error Expected HAVE_PACK2 +#endif + +#ifndef HAVE_PACK3 +#error Expected HAVE_PACK3 +#endif + +#ifndef HAVE_PACK4 +#error Expected HAVE_PACK4 +#endif + +#ifndef HAVE_PACK5 +#error Expected HAVE_PACK5 +#endif + +#ifndef HAVE_PACK6 +#error Expected HAVE_PACK6 +#endif + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake b/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake new file mode 100644 index 0000000..ff533c2 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake @@ -0,0 +1,9 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack2 2.3) +find_dependency(Pack3) + +add_library(Pack1::Lib INTERFACE IMPORTED) +set_property(TARGET Pack1::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK1) +set_property(TARGET Pack1::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack2::Lib Pack3::Lib) diff --git a/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake new file mode 100644 index 0000000..dfb7b6c --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake b/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake new file mode 100644 index 0000000..672288e --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake @@ -0,0 +1,5 @@ + +set(PACK2_VAR ON) + +add_library(Pack2::Lib INTERFACE IMPORTED) +set_property(TARGET Pack2::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK2) diff --git a/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake new file mode 100644 index 0000000..42f58c0 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "2.4") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake b/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake new file mode 100644 index 0000000..25c32f3 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake @@ -0,0 +1,5 @@ + +set(PACK3_VAR ON) + +add_library(Pack3::Lib INTERFACE IMPORTED) +set_property(TARGET Pack3::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK3) diff --git a/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake new file mode 100644 index 0000000..870f747 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.4") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake new file mode 100644 index 0000000..62fddb1 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake @@ -0,0 +1,9 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack5 3.1) # Actual version is 3.3. EXACT not propagated. +find_dependency(Pack6 5.5 EXACT) + +add_library(Pack4::Lib INTERFACE IMPORTED) +set_property(TARGET Pack4::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK4) +set_property(TARGET Pack4::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack5::Lib Pack6::Lib) diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake new file mode 100644 index 0000000..ae982b0 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "4.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake new file mode 100644 index 0000000..1edda9a --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake @@ -0,0 +1,3 @@ + +add_library(Pack5::Lib INTERFACE IMPORTED) +set_property(TARGET Pack5::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK5) diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake new file mode 100644 index 0000000..e944f96 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "3.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake new file mode 100644 index 0000000..d6c85fb --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake @@ -0,0 +1,3 @@ + +add_library(Pack6::Lib INTERFACE IMPORTED) +set_property(TARGET Pack6::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK6) diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake new file mode 100644 index 0000000..0dd00d2 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "5.5") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt index 28e46b1..90af600 100644 --- a/Tests/PDBDirectoryAndName/CMakeLists.txt +++ b/Tests/PDBDirectoryAndName/CMakeLists.txt @@ -6,6 +6,13 @@ if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel") endif() +# Intel 11.1 does not support /Fd but Intel 14.0 does. +# TODO: Did a version in between these add it? +if(CMAKE_C_COMPILER_ID STREQUAL Intel AND + CMAKE_C_COMPILER_VERSION VERSION_LESS 14.0) + set(NO_COMPILE_PDB 1) +endif() + set(my_targets "") add_library(mylibA SHARED mylibA.c) @@ -17,12 +24,12 @@ list(APPEND my_targets mylibA) add_library(mylibB STATIC mylibB.c) set_target_properties(mylibB PROPERTIES - PDB_NAME "mylibB_Special" - PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB" + COMPILE_PDB_NAME "mylibB_Special" + COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB" ) -# TODO: The only .pdb available for a static library is that generated -# by the compiler /Fd option which is not the same as the linker /pdb. -# list(APPEND my_targets mylibB) +if(NOT NO_COMPILE_PDB) + list(APPEND my_targets mylibB) +endif() add_library(mylibC SHARED mylibC.c) set_target_properties(mylibC PROPERTIES @@ -32,10 +39,11 @@ list(APPEND my_targets mylibC) add_library(mylibD STATIC mylibD.c) set_target_properties(mylibD PROPERTIES - PDB_NAME "mylibD_Special" + COMPILE_PDB_NAME "mylibD_Special" ) -# TODO: See comment for mylibB. -# list(APPEND my_targets mylibD) +if(NOT NO_COMPILE_PDB) + list(APPEND my_targets mylibD) +endif() add_executable(myexe myexe.c) set_target_properties(myexe PROPERTIES @@ -66,6 +74,12 @@ set(pdbs "") foreach(t ${my_targets}) get_property(pdb_name TARGET ${t} PROPERTY PDB_NAME) get_property(pdb_dir TARGET ${t} PROPERTY PDB_OUTPUT_DIRECTORY) + if(NOT pdb_name) + get_property(pdb_name TARGET ${t} PROPERTY COMPILE_PDB_NAME) + endif() + if(NOT pdb_dir) + get_property(pdb_dir TARGET ${t} PROPERTY COMPILE_PDB_OUTPUT_DIRECTORY) + endif() if(NOT pdb_dir) set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR}) endif() diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt index af9fc3f..7430084 100644 --- a/Tests/Qt4Targets/CMakeLists.txt +++ b/Tests/Qt4Targets/CMakeLists.txt @@ -36,3 +36,30 @@ add_executable(Qt4WrapMacroTest WIN32 main_wrap_test.cpp ${moc_file}) set_property(TARGET Qt4WrapMacroTest PROPERTY AUTOMOC OFF) target_include_directories(Qt4WrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface") target_link_libraries(Qt4WrapMacroTest Qt4::QtGui) + +set(timeformat "%Y%j%H%M%S") +try_compile(RESULT + "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild" + "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc" + IncrementalMoc + CMAKE_FLAGS -DADD_DEF=0 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}") +file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_before "${timeformat}") +if (NOT tsvar_before) + message(SEND_ERROR "Unable to read timestamp from moc file from first build!") +endif() + +execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2) # Ensure that the timestamp will change. + +try_compile(RESULT + "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild" + "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc" + IncrementalMoc + CMAKE_FLAGS -DADD_DEF=1 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}") +file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_after "${timeformat}") +if (NOT tsvar_after) + message(SEND_ERROR "Unable to read timestamp from moc file from second build!") +endif() + +if (NOT tsvar_after GREATER tsvar_before) + message(SEND_ERROR "Rebuild did not re-create moc file. Before: ${tsvar_before}. After: ${tsvar_after}") +endif() diff --git a/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt new file mode 100644 index 0000000..4ba0ced --- /dev/null +++ b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt @@ -0,0 +1,13 @@ + +cmake_minimum_required(VERSION 2.8.12) +project(IncrementalMoc) + +find_package(Qt4 REQUIRED) + +qt4_generate_moc(foo.h moc_foo.cpp) + +add_library(testlib foo.cpp moc_foo.cpp) +target_link_libraries(testlib Qt4::QtCore) +if (ADD_DEF) + target_compile_definitions(testlib PRIVATE NEW_DEF) +endif() diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.cpp b/Tests/Qt4Targets/IncrementalMoc/foo.cpp new file mode 100644 index 0000000..e924f7e --- /dev/null +++ b/Tests/Qt4Targets/IncrementalMoc/foo.cpp @@ -0,0 +1,8 @@ + +#include "foo.h" + +Foo::Foo() + : QObject(0) +{ + +} diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.h b/Tests/Qt4Targets/IncrementalMoc/foo.h new file mode 100644 index 0000000..38d899f --- /dev/null +++ b/Tests/Qt4Targets/IncrementalMoc/foo.h @@ -0,0 +1,9 @@ + +#include <QObject> + +class Foo : QObject +{ + Q_OBJECT +public: + Foo(); +}; diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 0821b45..d2116aa 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -64,9 +64,9 @@ add_custom_command( DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" ) -add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp +add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot> - test.qrc resourcetester.cpp generated.cpp + test.qrc second_resource.qrc resourcetester.cpp generated.cpp ) set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h") diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp index 43314e1..0c64d80 100644 --- a/Tests/QtAutogen/resourcetester.cpp +++ b/Tests/QtAutogen/resourcetester.cpp @@ -16,6 +16,8 @@ void ResourceTester::doTest() { if (!QFile::exists(":/CMakeLists.txt")) qApp->exit(EXIT_FAILURE); + if (!QFile::exists(":/main.cpp")) + qApp->exit(EXIT_FAILURE); QTimer::singleShot(0, qApp, SLOT(quit())); } diff --git a/Tests/QtAutogen/second_resource.qrc b/Tests/QtAutogen/second_resource.qrc new file mode 100644 index 0000000..27bfb14 --- /dev/null +++ b/Tests/QtAutogen/second_resource.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>main.cpp</file> +</qresource> +</RCC> diff --git a/Tests/QtAutogen/second_widget.cpp b/Tests/QtAutogen/second_widget.cpp new file mode 100644 index 0000000..65ba962 --- /dev/null +++ b/Tests/QtAutogen/second_widget.cpp @@ -0,0 +1,14 @@ + +#include "second_widget.h" +#include "ui_second_widget.h" + +SecondWidget::SecondWidget(QWidget *parent) + : QWidget(parent), ui(new Ui::SecondWidget) +{ + ui->setupUi(this); +} + +SecondWidget::~SecondWidget() +{ + delete ui; +} diff --git a/Tests/QtAutogen/second_widget.h b/Tests/QtAutogen/second_widget.h new file mode 100644 index 0000000..fe4d175 --- /dev/null +++ b/Tests/QtAutogen/second_widget.h @@ -0,0 +1,19 @@ + +#include <QWidget> + +namespace Ui +{ +class SecondWidget; +} + +class SecondWidget : public QWidget +{ + Q_OBJECT +public: + explicit SecondWidget(QWidget *parent = 0); + + ~SecondWidget(); + +private: + Ui::SecondWidget* ui; +}; diff --git a/Tests/QtAutogen/second_widget.ui b/Tests/QtAutogen/second_widget.ui new file mode 100644 index 0000000..4effa58 --- /dev/null +++ b/Tests/QtAutogen/second_widget.ui @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SecondWidget</class> + <widget class="QWidget" name="SecondWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QPushButton" name="pushButton"> + <property name="geometry"> + <rect> + <x>80</x> + <y>20</y> + <width>94</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9bb097b..7691f32 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -3,8 +3,8 @@ macro(add_RunCMake_test test) add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND} -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} - -DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR} - -DRunCMake_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET} + -DRunCMake_GENERATOR=${CMAKE_GENERATOR} + -DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test} -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test} ${${test}_ARGS} @@ -35,19 +35,21 @@ add_RunCMake_test(CMP0046) add_RunCMake_test(CMP0049) add_RunCMake_test(CMP0050) add_RunCMake_test(CTest) -if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) endif() add_RunCMake_test(CompilerNotFound) add_RunCMake_test(Configure) add_RunCMake_test(DisallowedCommands) add_RunCMake_test(ExternalData) +add_RunCMake_test(FeatureSummary) add_RunCMake_test(FPHSA) add_RunCMake_test(GeneratorExpression) add_RunCMake_test(GeneratorToolset) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(ObjectLibrary) +add_RunCMake_test(find_dependency) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) set(SKIP_VISIBILITY 0) @@ -94,6 +96,7 @@ add_RunCMake_test(TargetPolicies) add_RunCMake_test(alias_targets) add_RunCMake_test(interface_library) add_RunCMake_test(no_install_prefix) +add_RunCMake_test(configure_file) find_package(Qt4 QUIET) find_package(Qt5Core QUIET) @@ -105,7 +108,12 @@ if (QT4_FOUND) add_RunCMake_test(ObsoleteQtMacros) endif() -if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + add_RunCMake_test(FindPkgConfig) +endif() + +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) add_RunCMake_test(SolutionGlobalSections) endif() diff --git a/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake b/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake new file mode 100644 index 0000000..b2dcd7f --- /dev/null +++ b/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) +include(CheckTypeSize) +check_type_size(int SIZEOF_INT LANGUAGE CXX) +check_type_size(int SIZEOF_INT BUILTIN_TYPES_ONLY LANGUAGE CXX) diff --git a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake index fda7ebf..5b4e57e 100644 --- a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake @@ -12,3 +12,5 @@ run_cmake(CheckTypeSizeUnknownLanguage) run_cmake(CheckTypeSizeMissingLanguage) run_cmake(CheckTypeSizeUnknownArgument) run_cmake(CheckTypeSizeMixedArgs) + +run_cmake(CheckTypeSizeOkNoC) diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt index 17b8a5c..82a34d5 100644 --- a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt @@ -1,4 +1,11 @@ CMake Debug Log: + Boolean compatibility of property "BOOL_PROP7" for target + "CompatibleInterface" \(result: "FALSE"\): + + \* Target "CompatibleInterface" property is implied by use. + \* Target "iface1" property value "FALSE" \(Agree\) ++ +CMake Debug Log: Boolean compatibility of property "BOOL_PROP1" for target "CompatibleInterface" \(result: "TRUE"\): @@ -40,13 +47,6 @@ CMake Debug Log: \* Target "iface2" property value "FALSE" \(Agree\) + CMake Debug Log: - Boolean compatibility of property "BOOL_PROP7" for target - "CompatibleInterface" \(result: "FALSE"\): - - \* Target "CompatibleInterface" property is implied by use. - \* Target "iface1" property value "FALSE" \(Agree\) -+ -CMake Debug Log: String compatibility of property "STRING_PROP1" for target "CompatibleInterface" \(result: "prop1"\): diff --git a/Tests/RunCMake/FeatureSummary/CMakeLists.txt b/Tests/RunCMake/FeatureSummary/CMakeLists.txt new file mode 100644 index 0000000..72abfc8 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.11) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt new file mode 100644 index 0000000..9a3f023 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt @@ -0,0 +1,7 @@ +-- The following features have been enabled: + + \* Foo , Foo\. + +-- The following features have been disabled: + + \* Bar , Bar\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake new file mode 100644 index 0000000..ec5ebcb --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt new file mode 100644 index 0000000..4d8f25f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt @@ -0,0 +1,7 @@ +-- The following features have been disabled: + + \* Bar , Bar\. + +-- The following features have been enabled: + + \* Foo , Foo\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake new file mode 100644 index 0000000..d04ba88 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT DISABLED_FEATURES ENABLED_FEATURES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt new file mode 100644 index 0000000..18d9ebd --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + The WHAT argument of FEATURE_SUMMARY\(\) contains ALL, which cannot be + combined with other values\. +Call Stack \(most recent call first\): + FeatureSummaryWhatListAll\.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake new file mode 100644 index 0000000..1877ea5 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ENABLED_FEATURES ALL) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt new file mode 100644 index 0000000..3ad3750 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid + value\. +Call Stack \(most recent call first\): + FeatureSummaryWhatListUnknown\.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake new file mode 100644 index 0000000..46088d4 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ENABLED_FEATURES FOO) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt new file mode 100644 index 0000000..240632d --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt @@ -0,0 +1 @@ + \* Foo , Foo\. diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake new file mode 100644 index 0000000..593dfb6 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT ENABLED_FEATURES) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt new file mode 100644 index 0000000..c78853c --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\): + The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid + value\. +Call Stack \(most recent call first\): + FeatureSummaryWhatSingleUnknown\.cmake:[0-9]+ \(feature_summary\) + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake new file mode 100644 index 0000000..c2d6d2e --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake @@ -0,0 +1,9 @@ +include(FeatureSummary) + +set(WITH_FOO 1) +set(WITH_BAR 0) + +add_feature_info(Foo WITH_FOO "Foo.") +add_feature_info(Bar WITH_BAR "Bar.") + +feature_summary(WHAT FOO) diff --git a/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake new file mode 100644 index 0000000..1417338 --- /dev/null +++ b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(FeatureSummaryWhatAll) +run_cmake(FeatureSummaryWhatSingle) +run_cmake(FeatureSummaryWhatSingleUnknown) +run_cmake(FeatureSummaryWhatList) +run_cmake(FeatureSummaryWhatListUnknown) +run_cmake(FeatureSummaryWhatListAll) diff --git a/Tests/RunCMake/FindPkgConfig/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt new file mode 100644 index 0000000..72abfc8 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.11) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake new file mode 100644 index 0000000..924976e --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake @@ -0,0 +1,41 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + +if(WIN32) + set(expected_path "C:\\baz") +else() + set(expected_path "/baz") +endif() + + +pkg_check_modules(FOO "${expected_path}") + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() + + + +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) + +pkg_check_modules(BAR "${expected_path}" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH) + +if(NOT "BAR_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake new file mode 100644 index 0000000..4a66e85 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake @@ -0,0 +1,51 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + + +if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$") + # Cannot create directories for all the existing architectures... + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + endif() +else() + if(WIN32) + set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules(FOO "${expected_path}") + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake new file mode 100644 index 0000000..0b057b8 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake @@ -0,0 +1,51 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + + +if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$") + # Cannot create directories for all the existing architectures... + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") + endif() + endif() +else() + if(WIN32) + set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules(FOO "${expected_path}" NO_CMAKE_ENVIRONMENT_PATH) + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake new file mode 100644 index 0000000..a3154f1 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake @@ -0,0 +1,51 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + + +if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$") + # Cannot create directories for all the existing architectures... + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + endif() +else() + if(WIN32) + set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules(FOO "${expected_path}" NO_CMAKE_PATH) + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake new file mode 100644 index 0000000..bca93bb --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH) +run_cmake(FindPkgConfig_PKGCONFIG_PATH) +run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH) +run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH) diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat new file mode 100755 index 0000000..f2f86b0 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat @@ -0,0 +1,18 @@ +@ECHO OFF +IF "%1"=="" ( + EXIT /B 255 +) +IF "%1"=="--version" ( + ECHO 0.0-cmake-dummy + EXIT /B 0 +) + +IF "%1"=="--exists" ( + SHIFT + ECHO Expected: %* + ECHO Found: %PKG_CONFIG_PATH% + IF NOT "%*"=="%PKG_CONFIG_PATH%" ( + EXIT /B 1 + ) +) +EXIT /B 0 diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh new file mode 100755 index 0000000..852e841 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# This is a replacement for pkg-config that compares the string passed +# to the --exists argument with the PKG_CONFIG_PATH environment variable +# and returns 1 if they are different. + +case $1 in + --version) + echo "0.0-cmake-dummy" + ;; + --exists) + shift + echo "Expected: $@" + echo "Found: ${PKG_CONFIG_PATH}" + [ "$@" = "${PKG_CONFIG_PATH}" ] || exit 1 + ;; + *) + exit 255 + ;; +esac diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 1d1c523..ed3afc5 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -53,6 +53,7 @@ function(run_cmake test) -G "${RunCMake_GENERATOR}" -T "${RunCMake_GENERATOR_TOOLSET}" -DRunCMake_TEST=${test} + --no-warn-unused-cli ${RunCMake_TEST_OPTIONS} WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" OUTPUT_VARIABLE actual_stdout diff --git a/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt new file mode 100644 index 0000000..5dcd4d7 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt @@ -0,0 +1 @@ +-->wrong<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariable.cmake b/Tests/RunCMake/Syntax/AtWithVariable.cmake new file mode 100644 index 0000000..2bbf61d --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariable.cmake @@ -0,0 +1,9 @@ +set(right "wrong") +set(var "\${right}") +# Expanded here. +set(ref "@var@") + +# 'right' is dereferenced because 'var' was dereferenced when +# assigning to 'ref' above. +string(CONFIGURE "${ref}" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt new file mode 100644 index 0000000..cbd1be4 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt @@ -0,0 +1 @@ +-->\${right}<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake new file mode 100644 index 0000000..e06484c --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake @@ -0,0 +1,8 @@ +set(right "wrong") +set(var "\${right}") +# Expanded here. +set(ref "@var@") + +# No dereference done at all. +string(CONFIGURE "${ref}" output @ONLY) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt new file mode 100644 index 0000000..90bffb6 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt @@ -0,0 +1,5 @@ +-->==>\${right}<== +==><== +==>\${var}<== +==>\${empty}<== +<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake new file mode 100644 index 0000000..bdd7bcd --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake @@ -0,0 +1,9 @@ +set(right "wrong") +set(var "\${right}") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in" + "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" + @ONLY) +file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt new file mode 100644 index 0000000..cbd1be4 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt @@ -0,0 +1 @@ +-->\${right}<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake new file mode 100644 index 0000000..840c7f0 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake @@ -0,0 +1,8 @@ +# Literal since 'var' is not defined. +set(ref "@var@") +set(right "wrong") +set(var "\${right}") + +# 'var' is dereferenced here. +string(CONFIGURE "${ref}" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt new file mode 100644 index 0000000..cbd1be4 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt @@ -0,0 +1 @@ +-->\${right}<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake new file mode 100644 index 0000000..b657506 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake @@ -0,0 +1,8 @@ +# Literal since 'var' is not defined. +set(ref "@var@") +set(right "wrong") +set(var "\${right}") + +# 'var' is dereferenced, but now 'right' +string(CONFIGURE "${ref}" output @ONLY) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt new file mode 100644 index 0000000..43f029f --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt @@ -0,0 +1,5 @@ +-->==>\${right}<== +==><== +==>\${right}<== +==><== +<-- diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake new file mode 100644 index 0000000..c709099 --- /dev/null +++ b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake @@ -0,0 +1,8 @@ +set(right "wrong") +set(var "\${right}") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in" + "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt") +file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt new file mode 100644 index 0000000..077272d --- /dev/null +++ b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt @@ -0,0 +1 @@ +-->"<-- diff --git a/Tests/RunCMake/Syntax/EscapeQuotes.cmake b/Tests/RunCMake/Syntax/EscapeQuotes.cmake new file mode 100644 index 0000000..46d2b6f --- /dev/null +++ b/Tests/RunCMake/Syntax/EscapeQuotes.cmake @@ -0,0 +1,9 @@ +set(var "\"") +set(ref "@var@") +set(rref "\${var}") + +string(CONFIGURE "${ref}" output ESCAPE_QUOTES) +message("-->${output}<--") + +string(CONFIGURE "${rref}" output ESCAPE_QUOTES) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/EscapedAt-stderr.txt b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt new file mode 100644 index 0000000..a51c0d3 --- /dev/null +++ b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt @@ -0,0 +1 @@ +-->\\n<-- diff --git a/Tests/RunCMake/Syntax/EscapedAt.cmake b/Tests/RunCMake/Syntax/EscapedAt.cmake new file mode 100644 index 0000000..1ced620 --- /dev/null +++ b/Tests/RunCMake/Syntax/EscapedAt.cmake @@ -0,0 +1,5 @@ +set(var "n") +set(ref "\\@var@") + +string(CONFIGURE "${ref}" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt new file mode 100644 index 0000000..5da8b60 --- /dev/null +++ b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt @@ -0,0 +1 @@ +-->@foo@<-- diff --git a/Tests/RunCMake/Syntax/ExpandInAt.cmake b/Tests/RunCMake/Syntax/ExpandInAt.cmake new file mode 100644 index 0000000..98f0277 --- /dev/null +++ b/Tests/RunCMake/Syntax/ExpandInAt.cmake @@ -0,0 +1,6 @@ +set("\${varname}" bar) +set(var foo) +set(ref "@\${var}@") + +string(CONFIGURE "${ref}" output) +message("-->${output}<--") diff --git a/Tests/RunCMake/Syntax/ParenInENV-result.txt b/Tests/RunCMake/Syntax/ParenInENV-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInENV-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt new file mode 100644 index 0000000..7ecfe11 --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt @@ -0,0 +1,20 @@ +CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): + Syntax Warning in cmake code at + + .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21 + + Argument not separated from preceding token by whitespace. +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Error at ParenInENV.cmake:2 \(message\): + Syntax error in cmake code at + + .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2 + + when parsing string + + -->\$ENV{e + + syntax error, unexpected \$end, expecting } \(9\) +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/ParenInENV.cmake b/Tests/RunCMake/Syntax/ParenInENV.cmake new file mode 100644 index 0000000..148f726 --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInENV.cmake @@ -0,0 +1,2 @@ +set("ENV{e(x)}" value) +message(-->$ENV{e(x)}<--) diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt new file mode 100644 index 0000000..7020c7e --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt @@ -0,0 +1 @@ +-->value<-- diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake new file mode 100644 index 0000000..6333717 --- /dev/null +++ b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake @@ -0,0 +1,2 @@ +set("ENV{e(x)}" value) +message("-->$ENV{e(x)}<--") diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake index 5f05cfc..dcabd8a 100644 --- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake +++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake @@ -52,3 +52,16 @@ run_cmake(UnterminatedString) run_cmake(UnterminatedBracket0) run_cmake(UnterminatedBracket1) run_cmake(UnterminatedBracketComment) + +# Variable expansion tests +run_cmake(ExpandInAt) +run_cmake(EscapedAt) +run_cmake(EscapeQuotes) +run_cmake(AtWithVariable) +run_cmake(AtWithVariableEmptyExpansion) +run_cmake(AtWithVariableAtOnly) +run_cmake(AtWithVariableEmptyExpansionAtOnly) +run_cmake(AtWithVariableFile) +run_cmake(AtWithVariableAtOnlyFile) +run_cmake(ParenInENV) +run_cmake(ParenInQuotedENV) diff --git a/Tests/RunCMake/Syntax/atfile.txt.in b/Tests/RunCMake/Syntax/atfile.txt.in new file mode 100644 index 0000000..3775919 --- /dev/null +++ b/Tests/RunCMake/Syntax/atfile.txt.in @@ -0,0 +1,4 @@ +==>@var@<== +==>@empty@<== +==>${var}<== +==>${empty}<== diff --git a/Tests/RunCMake/configure_file/CMakeLists.txt b/Tests/RunCMake/configure_file/CMakeLists.txt new file mode 100644 index 0000000..2897109 --- /dev/null +++ b/Tests/RunCMake/configure_file/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/configure_file/NO-BOM.cmake b/Tests/RunCMake/configure_file/NO-BOM.cmake new file mode 100644 index 0000000..003d526 --- /dev/null +++ b/Tests/RunCMake/configure_file/NO-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(NO-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/NO-BOM.txt) diff --git a/Tests/RunCMake/configure_file/NO-BOM.txt.in b/Tests/RunCMake/configure_file/NO-BOM.txt.in new file mode 100644 index 0000000..557db03 --- /dev/null +++ b/Tests/RunCMake/configure_file/NO-BOM.txt.in @@ -0,0 +1 @@ +Hello World diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake new file mode 100644 index 0000000..c8bfa57 --- /dev/null +++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(NO-BOM) +run_cmake(UTF8-BOM) +run_cmake(UTF16LE-BOM) +run_cmake(UTF16BE-BOM) +run_cmake(UTF32LE-BOM) +run_cmake(UTF32BE-BOM) diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt new file mode 100644 index 0000000..5132c4d --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at UTF16BE-BOM.cmake:2 \(configure_file\): + File starts with a Byte-Order-Mark that is not UTF-8: + + .*/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake new file mode 100644 index 0000000..c570742 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF16BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16BE-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in Binary files differnew file mode 100644 index 0000000..70fd9cb --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt new file mode 100644 index 0000000..8f997bc --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at UTF16LE-BOM.cmake:2 \(configure_file\): + File starts with a Byte-Order-Mark that is not UTF-8: + + .*/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake new file mode 100644 index 0000000..05c9cd7 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF16LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16LE-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in Binary files differnew file mode 100644 index 0000000..036f8c5 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt new file mode 100644 index 0000000..12811aa --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at UTF32BE-BOM.cmake:2 \(configure_file\): + File starts with a Byte-Order-Mark that is not UTF-8: + + .*/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake new file mode 100644 index 0000000..0c6ea87 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF32BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32BE-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in Binary files differnew file mode 100644 index 0000000..c87cfd5 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt new file mode 100644 index 0000000..fa9e01a --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at UTF32LE-BOM.cmake:2 \(configure_file\): + File starts with a Byte-Order-Mark that is not UTF-8: + + .*/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake new file mode 100644 index 0000000..b6351b0 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF32LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32LE-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in Binary files differnew file mode 100644 index 0000000..27c8183 --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.cmake b/Tests/RunCMake/configure_file/UTF8-BOM.cmake new file mode 100644 index 0000000..af2adae --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF8-BOM.cmake @@ -0,0 +1,2 @@ + +configure_file(UTF8-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF8-BOM.txt) diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.txt.in b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in new file mode 100644 index 0000000..abc0aca --- /dev/null +++ b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in @@ -0,0 +1 @@ +Hello World diff --git a/Tests/RunCMake/find_dependency/CMakeLists.txt b/Tests/RunCMake/find_dependency/CMakeLists.txt new file mode 100644 index 0000000..04d09f2 --- /dev/null +++ b/Tests/RunCMake/find_dependency/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.8.4) +project(${RunCMake_TEST} NONE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt new file mode 100644 index 0000000..348f8bb --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency. EXACT may only be specified if a + VERSION is specified +Call Stack \(most recent call first\): + EXACT-no-version.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version.cmake b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake new file mode 100644 index 0000000..b05665b7 --- /dev/null +++ b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 EXACT) diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake new file mode 100644 index 0000000..7d55ef6 --- /dev/null +++ b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake @@ -0,0 +1,2 @@ + +add_library(Pack1::Lib INTERFACE IMPORTED) diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake new file mode 100644 index 0000000..dfb7b6c --- /dev/null +++ b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake @@ -0,0 +1,11 @@ + +set(PACKAGE_VERSION "1.3") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake new file mode 100644 index 0000000..9403136 --- /dev/null +++ b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +run_cmake(EXACT-no-version) +run_cmake(empty-version) +run_cmake(empty-arg-3) +run_cmake(invalid-arg-3) +run_cmake(extra-args) diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-result.txt b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt new file mode 100644 index 0000000..bf9b02b --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + empty-arg-3.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/empty-arg-3.cmake b/Tests/RunCMake/find_dependency/empty-arg-3.cmake new file mode 100644 index 0000000..b08200a --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 "") diff --git a/Tests/RunCMake/find_dependency/empty-version-result.txt b/Tests/RunCMake/find_dependency/empty-version-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/empty-version-stderr.txt b/Tests/RunCMake/find_dependency/empty-version-stderr.txt new file mode 100644 index 0000000..b5e9f46 --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*/Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency. VERSION is empty +Call Stack \(most recent call first\): + empty-version.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/empty-version.cmake b/Tests/RunCMake/find_dependency/empty-version.cmake new file mode 100644 index 0000000..e6f17cd --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 "") diff --git a/Tests/RunCMake/find_dependency/extra-args-result.txt b/Tests/RunCMake/find_dependency/extra-args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/extra-args-stderr.txt b/Tests/RunCMake/find_dependency/extra-args-stderr.txt new file mode 100644 index 0000000..83a7f02 --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + extra-args.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/extra-args.cmake b/Tests/RunCMake/find_dependency/extra-args.cmake new file mode 100644 index 0000000..209645a --- /dev/null +++ b/Tests/RunCMake/find_dependency/extra-args.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 EXACT PATHS "${CMAKE_BINARY_DIR}") diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt new file mode 100644 index 0000000..fee8d5d --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + invalid-arg-3.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3.cmake b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake new file mode 100644 index 0000000..40ede07 --- /dev/null +++ b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 EXACTYPO) diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index 95428b6..841aba5 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -10,7 +10,7 @@ set(RELEASE_SCRIPTS_BATCH_1 dashmacmini2_release.cmake # Mac Darwin universal ppc;i386 dashmacmini5_release.cmake # Mac Darwin64 universal x86_64;i386 magrathea_release.cmake # Linux - v20n250_aix_release.cmake # AIX 5.3 + ibm_aix_release.cmake # AIX ferrari_sgi64_release.cmake # IRIX 64 ferrari_sgi_release.cmake # IRIX ) diff --git a/Utilities/Release/v20n250_aix_release.cmake b/Utilities/Release/ibm_aix_release.cmake index cc8cd05..5a6efe6 100644 --- a/Utilities/Release/v20n250_aix_release.cmake +++ b/Utilities/Release/ibm_aix_release.cmake @@ -1,8 +1,7 @@ set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory") -set(FINAL_PATH /u/noibm34/cmake-release) -set(PROCESSORS 2) -set(HOST "sshserv.centers.ihost.com") -set(EXTRA_HOP "rsh p90n03") +set(PROCESSORS 64) +set(HOST "ibm-backend") +set(SCRIPT_NAME aix) set(MAKE_PROGRAM "make") set(CC "xlc_r") set(CXX "xlC_r") @@ -12,11 +11,5 @@ set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE ") -set(EXTRA_COPY " -rm -rf ~/cmake-release -mkdir ~/cmake-release -mv *.sh ~/cmake-release -mv *.Z ~/cmake-release -mv *.gz ~/cmake-release") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/release_cmake.cmake b/Utilities/Release/release_cmake.cmake index 630f54f..7a1652d 100644 --- a/Utilities/Release/release_cmake.cmake +++ b/Utilities/Release/release_cmake.cmake @@ -4,9 +4,6 @@ get_filename_component(SCRIPT_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH) if(NOT DEFINED CPACK_BINARY_GENERATORS) set(CPACK_BINARY_GENERATORS "STGZ TGZ TZ") endif() -if(DEFINED EXTRA_COPY) - set(HAS_EXTRA_COPY 1) -endif() if(NOT DEFINED CMAKE_RELEASE_DIRECTORY) set(CMAKE_RELEASE_DIRECTORY "~/CMakeReleaseDirectory") endif() @@ -55,11 +52,11 @@ message("Creating CMake release ${CMAKE_CREATE_VERSION} on ${HOST} with parallel macro(remote_command comment command) message("${comment}") if(${ARGC} GREATER 2) - message("ssh ${HOST} ${EXTRA_HOP} ${command}") - execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2}) + message("ssh ${HOST} ${command}") + execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2}) else() - message("ssh ${HOST} ${EXTRA_HOP} ${command}") - execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result) + message("ssh ${HOST} ${command}") + execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result) endif() if(${result} GREATER 0) message(FATAL_ERROR "Error running command: ${command}, return value = ${result}") @@ -67,14 +64,15 @@ macro(remote_command comment command) endmacro() if(CMAKE_DOC_TARBALL) - message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:'") + get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME) + string(REPLACE ".tar.gz" "-${SCRIPT_NAME}.tar.gz" CMAKE_DOC_TARBALL_STAGED "${CMAKE_DOC_TARBALL_NAME}") + message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:${CMAKE_DOC_TARBALL_STAGED}'") execute_process(COMMAND - scp ${CMAKE_DOC_TARBALL} ${HOST}: + scp ${CMAKE_DOC_TARBALL} ${HOST}:${CMAKE_DOC_TARBALL_STAGED} RESULT_VARIABLE result) if(${result} GREATER 0) - message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:'") + message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:${CMAKE_DOC_TARBALL_STAGED}'") endif() - get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME) endif() # set this so configure file will work from script mode diff --git a/Utilities/Release/release_cmake.sh.in b/Utilities/Release/release_cmake.sh.in index f41bda8..76fdb3a 100755 --- a/Utilities/Release/release_cmake.sh.in +++ b/Utilities/Release/release_cmake.sh.in @@ -18,7 +18,7 @@ check_exit_value() CMAKE_DOC_TARBALL="" if [ ! -z "@CMAKE_DOC_TARBALL_NAME@" ] ; then CMAKE_DOC_TARBALL=@CMAKE_RELEASE_DIRECTORY@/@CMAKE_DOC_TARBALL_NAME@ - mv "$HOME/@CMAKE_DOC_TARBALL_NAME@" "$CMAKE_DOC_TARBALL" + mv "$HOME/@CMAKE_DOC_TARBALL_STAGED@" "$CMAKE_DOC_TARBALL" check_exit_value $? "mv doc tarball" || exit 1 fi @@ -155,11 +155,6 @@ done -# need to add an extra copy thing here -if [ ! -z "@EXTRA_COPY@" ]; then - @EXTRA_COPY@ - check_exit_value $? "Extra copy step @EXTRA_COPY@" || exit 1 -fi echo "End release" date echo "" diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake index 9bf3523..5f4da8f 100644 --- a/Utilities/Release/upload_release.cmake +++ b/Utilities/Release/upload_release.cmake @@ -1,20 +1,19 @@ set(CTEST_RUN_CURRENT_SCRIPT 0) -if(NOT DEFINED PROJECT_PREFIX) - set(PROJECT_PREFIX cmake-) -endif() if(NOT VERSION) - set(VERSION 2.8) + set(VERSION 3.0) +endif() +if(NOT DEFINED PROJECT_PREFIX) + set(PROJECT_PREFIX cmake-${VERSION}) endif() -set(dir "v${VERSION}") -if("${VERSION}" MATCHES "master") - set(dir "dev") +if(NOT DEFINED DIR) + set(DIR "v${VERSION}") endif() file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*") list(SORT FILES) list(REVERSE FILES) message("${FILES}") set(UPLOAD_LOC - "kitware@www.cmake.org:/projects/FTP/pub/cmake/${dir}") + "kitware@www.cmake.org:/projects/FTP/pub/cmake/${DIR}") set(count 0) foreach(file ${FILES}) if(NOT IS_DIRECTORY ${file}) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index abf04d8..1b918c9 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -172,6 +172,11 @@ IF(NOT CURL_SPECIAL_LIBZ) CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ) ENDIF(NOT CURL_SPECIAL_LIBZ) +# Include the local directories before any others so that we do not end up +# including system curl's include directory first by mistake. +INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR}) + OPTION(CMAKE_USE_OPENSSL "Use OpenSSL code with curl." OFF) MARK_AS_ADVANCED(CMAKE_USE_OPENSSL) IF(CMAKE_USE_OPENSSL) @@ -679,8 +684,6 @@ INCLUDE(CMake/OtherTests.cmake) # The rest of the build -INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR}) -INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR}) OPTION(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" TRUE) IF(CMAKE_BUILD_CURL_SHARED) SET(LIBRARY_TYPE SHARED) diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h index 1a1d32a..83d2c16 100644 --- a/Utilities/cmlibarchive/libarchive/archive.h +++ b/Utilities/cmlibarchive/libarchive/archive.h @@ -54,7 +54,7 @@ /* Get appropriate definitions of standard POSIX-style types. */ /* These should match the types used in 'struct stat' */ -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) # define __LA_INT64_T __int64 # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) # define __LA_SSIZE_T ssize_t diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h index 85ea885..ae6a76e 100644 --- a/Utilities/cmlibarchive/libarchive/archive_entry.h +++ b/Utilities/cmlibarchive/libarchive/archive_entry.h @@ -48,7 +48,7 @@ #endif /* Get a suitable 64-bit integer type. */ -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) # define __LA_INT64_T __int64 #else #include <unistd.h> @@ -63,7 +63,7 @@ #if ARCHIVE_VERSION_NUMBER >= 3999000 /* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */ # define __LA_MODE_T int -#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) +#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__) # define __LA_MODE_T unsigned short #else # define __LA_MODE_T mode_t diff --git a/Utilities/cmlibarchive/libarchive/archive_windows.h b/Utilities/cmlibarchive/libarchive/archive_windows.h index 620810c..1dd61b6 100644 --- a/Utilities/cmlibarchive/libarchive/archive_windows.h +++ b/Utilities/cmlibarchive/libarchive/archive_windows.h @@ -188,6 +188,9 @@ #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* directory */ #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* regular file */ #endif + +#if !defined(__WATCOMC__) + #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* Symbolic link */ #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) /* Socket */ @@ -227,6 +230,8 @@ #define S_IWOTH _S_IWOTH #define S_IROTH _S_IROTH +#endif + #define F_DUPFD 0 /* Duplicate file descriptor. */ #define F_GETFD 1 /* Get file descriptor flags. */ #define F_SETFD 2 /* Set file descriptor flags. */ @@ -329,6 +329,7 @@ fi KWSYS_CXX_SOURCES="\ Directory \ EncodingCXX \ + FStream \ Glob \ RegularExpression \ SystemTools" |