diff options
-rw-r--r-- | Modules/FindMPI.cmake | 289 | ||||
-rw-r--r-- | Modules/FindPerlLibs.cmake | 212 | ||||
-rw-r--r-- | Modules/InstallRequiredSystemLibraries.cmake | 22 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmGraphVizWriter.cxx | 41 | ||||
-rw-r--r-- | Source/cmGraphVizWriter.h | 1 | ||||
-rw-r--r-- | Source/cmIDEOptions.cxx | 15 | ||||
-rw-r--r-- | Source/cmIDEOptions.h | 8 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 4 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.cxx | 7 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 13 | ||||
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 35 |
13 files changed, 333 insertions, 324 deletions
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 4d9444a..db14a89 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -602,9 +602,6 @@ function (_MPI_interrogate_compiler lang) if(MPI_DIRECT_LIB_NAMES_WORK) set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}") endif() - if(MPI_${LANG}_EXTRA_LIB_NAMES) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}") - endif() # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to # link it in that case. -lpthread is covered by the normal library treatment on the other hand. @@ -617,6 +614,16 @@ function (_MPI_interrogate_compiler lang) endif() endif() + if(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) + list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS}") + endif() + if(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) + list(APPEND MPI_COMPILE_OPTIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_OPTIONS}") + endif() + if(MPI_${LANG}_EXTRA_LIB_NAMES) + list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}") + endif() + # If we found MPI, set up all of the appropriate cache entries if(NOT MPI_${LANG}_COMPILE_OPTIONS) set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE) @@ -825,33 +832,43 @@ endfunction() macro(_MPI_assemble_libraries LANG) set(MPI_${LANG}_LIBRARIES "") - foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) - endforeach() + # Only for libraries do we need to check whether the compiler's linking stage is separate. + if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT) + foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) + list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) + endforeach() + endif() endmacro() macro(_MPI_assemble_include_dirs LANG) - set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") - if("${LANG}" MATCHES "(C|CXX)") - if(MPI_${LANG}_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - else() # Fortran - if(MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") + if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + set(MPI_${LANG}_INCLUDE_DIRS "") + else() + set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") + if("${LANG}" MATCHES "(C|CXX)") + if(MPI_${LANG}_HEADER_DIR) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") + endif() + else() # Fortran + if(MPI_${LANG}_F77_HEADER_DIR) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") + endif() + if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") + endif() endif() - if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") + if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}") + endforeach() endif() endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(mpiadditionalinclude IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${mpiadditionalinclude}_INCLUDE_DIR}") - endforeach() - endif() endmacro() function(_MPI_split_include_dirs LANG) + if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + return() + endif() # Backwards compatibility: Search INCLUDE_PATH if given. if(MPI_${LANG}_INCLUDE_PATH) list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") @@ -887,6 +904,13 @@ function(_MPI_split_include_dirs LANG) endif() mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) endif() + # Remove duplicates and default system directories from the list. + if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + foreach(MPI_IMPLICIT_INC_DIR IN LISTS CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) + list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR}) + endforeach() + endif() set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) endfunction() @@ -1016,7 +1040,7 @@ elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") # FreeBSD ships mpich under the normal system paths - but available openmpi implementations # will be found in /usr/local/mpi/<name> - MPI_search_mpi_prefix_folder("/usr/local/mpi/") + MPI_search_mpi_prefix_folder("/usr/local/mpi") endif() # Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for. @@ -1052,51 +1076,54 @@ mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXE # # Once we find the new variables, we translate them back into their old # equivalents below. -foreach (LANG IN ITEMS C CXX) - # Old input variables. - set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) - - # Set new vars based on their old equivalents, if the new versions are not already set. - foreach (var ${_MPI_OLD_INPUT_VARS}) - if (NOT MPI_${LANG}_${var} AND MPI_${var}) - set(MPI_${LANG}_${var} "${MPI_${var}}") - endif() - endforeach() - - # Chop the old compile flags into options and definitions - if(MPI_${LANG}_COMPILE_FLAGS) - unset(MPI_${LANG}_COMPILE_OPTIONS) - unset(MPI_${LANG}_COMPILE_DEFINITIONS) - separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") - foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) - if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") - list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") - else() - list(APPEND MPI_${LANG}_COMPILE_FLAGS "${_MPI_FLAG}") +if(NOT MPI_IGNORE_LEGACY_VARIABLES) + foreach (LANG IN ITEMS C CXX) + # Old input variables. + set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) + + # Set new vars based on their old equivalents, if the new versions are not already set. + foreach (var ${_MPI_OLD_INPUT_VARS}) + if (NOT MPI_${LANG}_${var} AND MPI_${var}) + set(MPI_${LANG}_${var} "${MPI_${var}}") endif() endforeach() - unset(MPI_SEPARATE_FLAGS) - endif() - # If a list of libraries was given, we'll split it into new-style cache variables - unset(MPI_${LANG}_EXTRA_LIB_NAMES) - if(NOT MPI_${LANG}_LIB_NAMES) - foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) - if(_MPI_LIB) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) - get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) - list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endif() - endforeach() - endif() -endforeach() + # Chop the old compile flags into options and definitions + + unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS) + unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS) + if(MPI_${LANG}_COMPILE_FLAGS) + separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") + foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) + if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") + list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") + else() + list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}") + endif() + endforeach() + unset(MPI_SEPARATE_FLAGS) + endif() + + # If a list of libraries was given, we'll split it into new-style cache variables + unset(MPI_${LANG}_EXTRA_LIB_NAMES) + if(NOT MPI_${LANG}_LIB_NAMES) + foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) + if(_MPI_LIB) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) + get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) + get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) + list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" + HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endif() + endforeach() + endif() + endforeach() +endif() #============================================================================= unset(MPI_VERSION) @@ -1105,6 +1132,11 @@ unset(MPI_VERSION_MINOR) unset(_MPI_MIN_VERSION) +# If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. +if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) + set(MPI_SKIP_COMPILER_WRAPPER TRUE) +endif() + # This loop finds the compilers and sends them off for interrogation. foreach(LANG IN ITEMS C CXX Fortran) if(CMAKE_${LANG}_COMPILER_LOADED) @@ -1126,6 +1158,8 @@ foreach(LANG IN ITEMS C CXX Fortran) mark_as_advanced(MPI_CXX_SKIP_MPICXX) endif() if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS))) + set(MPI_${LANG}_TRIED_IMPLICIT FALSE) + set(MPI_${LANG}_WORKS_IMPLICIT FALSE) if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI) # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g. # Cray PrgEnv. @@ -1135,80 +1169,90 @@ foreach(LANG IN ITEMS C CXX Fortran) # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it. if(MPI_${LANG}_WORKS) set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) + set(MPI_${LANG}_WORKS_IMPLICIT TRUE) endif() + set(MPI_${LANG}_TRIED_IMPLICIT TRUE) endif() - # If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. - if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) - set(MPI_SKIP_COMPILER_WRAPPER TRUE) - endif() - if(NOT MPI_SKIP_COMPILER_WRAPPER) - if(MPI_${LANG}_COMPILER) - # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. - if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") - # Get rid of our default list of names and just search for the name the user wants. - set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") - unset(MPI_${LANG}_COMPILER CACHE) + if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS) + set(MPI_${LANG}_WRAPPER_FOUND FALSE) + set(MPI_PINNED_COMPILER FALSE) + + if(NOT MPI_SKIP_COMPILER_WRAPPER) + if(MPI_${LANG}_COMPILER) + # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. + if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") + # Get rid of our default list of names and just search for the name the user wants. + set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") + unset(MPI_${LANG}_COMPILER CACHE) + endif() + # If the user specifies a compiler, we don't want to try to search libraries either. + set(MPI_PINNED_COMPILER TRUE) + endif() + + # If we have an MPI base directory, we'll try all compiler names in that one first. + # This should prevent mixing different MPI environments + if(_MPI_BASE_DIR) + find_program(MPI_${LANG}_COMPILER + NAMES ${_MPI_${LANG}_COMPILER_NAMES} + PATH_SUFFIXES bin sbin + HINTS ${_MPI_BASE_DIR} + NO_DEFAULT_PATH + DOC "MPI compiler for ${LANG}" + ) endif() - # If the user specifies a compiler, we don't want to try to search libraries either. - set(MPI_PINNED_COMPILER TRUE) - else() - set(MPI_PINNED_COMPILER FALSE) - endif() - # If we have an MPI base directory, we'll try all compiler names in that one first. - # This should prevent mixing different MPI environments - if(_MPI_BASE_DIR) + # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), + # we shall try searching in the default paths. find_program(MPI_${LANG}_COMPILER NAMES ${_MPI_${LANG}_COMPILER_NAMES} PATH_SUFFIXES bin sbin - HINTS ${_MPI_BASE_DIR} - NO_DEFAULT_PATH DOC "MPI compiler for ${LANG}" ) - endif() - # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), - # we shall try searching in the default paths. - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - DOC "MPI compiler for ${LANG}" - ) - - if(MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) - set(MPI_SKIP_GUESSING TRUE) - elseif(MPI_${LANG}_COMPILER) - _MPI_interrogate_compiler(${LANG}) - else() - set(MPI_${LANG}_WRAPPER_FOUND FALSE) + if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}") + set(MPI_PINNED_COMPILER TRUE) + + # If we haven't made the implicit compiler test yet, perform it now. + if(NOT MPI_${LANG}_TRIED_IMPLICIT) + _MPI_create_imported_target(${LANG}) + _MPI_check_lang_works(${LANG}) + endif() + + # Should the MPI compiler not work implicitly for MPI, still interrogate it. + # Otherwise, MPI compilers for which CMake has separate linking stages, e.g. Intel MPI on Windows where link.exe is being used + # directly during linkage instead of CMAKE_<LANG>_COMPILER will not work. + if(NOT MPI_${LANG}_WORKS) + set(MPI_${LANG}_WORKS_IMPLICIT FALSE) + _MPI_interrogate_compiler(${LANG}) + else() + set(MPI_${LANG}_WORKS_IMPLICIT TRUE) + endif() + elseif(MPI_${LANG}_COMPILER) + _MPI_interrogate_compiler(${LANG}) + endif() endif() - else() - set(MPI_${LANG}_WRAPPER_FOUND FALSE) - set(MPI_PINNED_COMPILER FALSE) - endif() - if(NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) - # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the - # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. - if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) - set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) - set(MPI_${LANG}_WRAPPER_FOUND TRUE) - elseif(NOT MPI_SKIP_GUESSING) - _MPI_guess_settings(${LANG}) + if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) + # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the + # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. + if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) + set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) + set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") + set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) + set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) + else() + _MPI_guess_settings(${LANG}) + endif() endif() endif() endif() _MPI_split_include_dirs(${LANG}) - if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) - _MPI_assemble_include_dirs(${LANG}) - _MPI_assemble_libraries(${LANG}) - endif() + _MPI_assemble_include_dirs(${LANG}) + _MPI_assemble_libraries(${LANG}) + _MPI_adjust_compile_definitions(${LANG}) # We always create imported targets even if they're empty _MPI_create_imported_target(${LANG}) @@ -1222,7 +1266,9 @@ foreach(LANG IN ITEMS C CXX Fortran) set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" ) set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories") set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" ) - set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) + set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) + endif() mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER) @@ -1453,6 +1499,7 @@ if (MPI_NUMLIBS GREATER 1) else() set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND") endif() +set(MPI_IGNORE_LEGACY_VARIABLES TRUE) #============================================================================= # unset these vars to cleanup namespace diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake index e01e75e..0b902e7 100644 --- a/Modules/FindPerlLibs.cmake +++ b/Modules/FindPerlLibs.cmake @@ -32,193 +32,94 @@ # # :: # -# PERL_SITESEARCH = path to the sitesearch install dir -# PERL_SITELIB = path to the sitelib install directory -# PERL_VENDORARCH = path to the vendor arch install directory -# PERL_VENDORLIB = path to the vendor lib install directory -# PERL_ARCHLIB = path to the arch lib install directory -# PERL_PRIVLIB = path to the priv lib install directory +# PERL_SITESEARCH = path to the sitesearch install dir (-V:installsitesearch) +# PERL_SITEARCH = path to the sitelib install directory (-V:installsitearch) +# PERL_SITELIB = path to the sitelib install directory (-V:installsitelib) +# PERL_VENDORARCH = path to the vendor arch install directory (-V:installvendorarch) +# PERL_VENDORLIB = path to the vendor lib install directory (-V:installvendorlib) +# PERL_ARCHLIB = path to the core arch lib install directory (-V:archlib) +# PERL_PRIVLIB = path to the core priv lib install directory (-V:privlib) +# PERL_UPDATE_ARCHLIB = path to the update arch lib install directory (-V:installarchlib) +# PERL_UPDATE_PRIVLIB = path to the update priv lib install directory (-V:installprivlib) # PERL_EXTRA_C_FLAGS = Compilation flags used to build perl # find the perl executable include(${CMAKE_CURRENT_LIST_DIR}/FindPerl.cmake) if (PERL_EXECUTABLE) - ### PERL_PREFIX - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:prefix - OUTPUT_VARIABLE - PERL_PREFIX_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_PREFIX_RESULT_VARIABLE - ) - if (NOT PERL_PREFIX_RESULT_VARIABLE) - string(REGEX REPLACE "prefix='([^']+)'.*" "\\1" PERL_PREFIX ${PERL_PREFIX_OUTPUT_VARIABLE}) - endif () + function (perl_get_info _pgi_info tag) + cmake_parse_arguments(_PGI "IS_PATH" "" "" ${ARGN}) - ### PERL_ARCHNAME - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:archname - OUTPUT_VARIABLE - PERL_ARCHNAME_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_ARCHNAME_RESULT_VARIABLE - ) - if (NOT PERL_ARCHNAME_RESULT_VARIABLE) - string(REGEX REPLACE "archname='([^']+)'.*" "\\1" PERL_ARCHNAME ${PERL_ARCHNAME_OUTPUT_VARIABLE}) - endif () + set (${_pgi_info} NOTFOUND PARENT_SCOPE) + + execute_process(COMMAND "${PERL_EXECUTABLE}" -V:${tag} + OUTPUT_VARIABLE result + RESULT_VARIABLE status) + + if (NOT status) + string(REGEX REPLACE "${tag}='([^']*)'.*" "\\1" result "${result}") + if (_PGI_IS_PATH) + file(TO_CMAKE_PATH "${result}" result) + endif() + set (${_pgi_info} "${result}" PARENT_SCOPE) + endif () + endfunction() + ### PERL_PREFIX + perl_get_info(PERL_PREFIX prefix IS_PATH) + ### PERL_ARCHNAME + perl_get_info(PERL_ARCHNAME archname) ### PERL_EXTRA_C_FLAGS - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:cppflags - OUTPUT_VARIABLE - PERL_CPPFLAGS_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_CPPFLAGS_RESULT_VARIABLE - ) - if (NOT PERL_CPPFLAGS_RESULT_VARIABLE) - string(REGEX REPLACE "cppflags='([^']+)'.*" "\\1" PERL_EXTRA_C_FLAGS ${PERL_CPPFLAGS_OUTPUT_VARIABLE}) - endif () + perl_get_info(PERL_EXTRA_C_FLAGS cppflags) ### PERL_SITESEARCH - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:installsitesearch - OUTPUT_VARIABLE - PERL_SITESEARCH_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_SITESEARCH_RESULT_VARIABLE - ) - if (NOT PERL_SITESEARCH_RESULT_VARIABLE) - string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_SITESEARCH ${PERL_SITESEARCH_OUTPUT_VARIABLE}) - file(TO_CMAKE_PATH "${PERL_SITESEARCH}" PERL_SITESEARCH) - endif () + perl_get_info(PERL_SITESEARCH installsitesearch IS_PATH) + + ### PERL_SITEARCH + perl_get_info(PERL_SITEARCH installsitearch IS_PATH) ### PERL_SITELIB - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:installsitelib - OUTPUT_VARIABLE - PERL_SITELIB_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_SITELIB_RESULT_VARIABLE - ) - if (NOT PERL_SITELIB_RESULT_VARIABLE) - string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_SITELIB ${PERL_SITELIB_OUTPUT_VARIABLE}) - file(TO_CMAKE_PATH "${PERL_SITELIB}" PERL_SITELIB) - endif () + perl_get_info(PERL_SITELIB installsitelib IS_PATH) ### PERL_VENDORARCH - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:installvendorarch - OUTPUT_VARIABLE - PERL_VENDORARCH_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_VENDORARCH_RESULT_VARIABLE - ) - if (NOT PERL_VENDORARCH_RESULT_VARIABLE) - string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_VENDORARCH ${PERL_VENDORARCH_OUTPUT_VARIABLE}) - file(TO_CMAKE_PATH "${PERL_VENDORARCH}" PERL_VENDORARCH) - endif () + perl_get_info(PERL_VENDORARCH installvendorarch IS_PATH) ### PERL_VENDORLIB - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:installvendorlib - OUTPUT_VARIABLE - PERL_VENDORLIB_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_VENDORLIB_RESULT_VARIABLE - ) - if (NOT PERL_VENDORLIB_RESULT_VARIABLE) - string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_VENDORLIB ${PERL_VENDORLIB_OUTPUT_VARIABLE}) - file(TO_CMAKE_PATH "${PERL_VENDORLIB}" PERL_VENDORLIB) - endif () - - macro(perl_adjust_darwin_lib_variable varname) - string( TOUPPER PERL_${varname} FINDPERL_VARNAME ) - string( TOLOWER install${varname} PERL_VARNAME ) - - if (NOT PERL_MINUSV_OUTPUT_VARIABLE) - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V - OUTPUT_VARIABLE - PERL_MINUSV_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_MINUSV_RESULT_VARIABLE - ) - endif() - - if (NOT PERL_MINUSV_RESULT_VARIABLE) - string(REGEX MATCH "(${PERL_VARNAME}.*points? to the Updates directory)" - PERL_NEEDS_ADJUSTMENT ${PERL_MINUSV_OUTPUT_VARIABLE}) - - if (PERL_NEEDS_ADJUSTMENT) - string(REGEX REPLACE "(.*)/Updates/" "/System/\\1/" ${FINDPERL_VARNAME} ${${FINDPERL_VARNAME}}) - endif () - - endif () - endmacro() + perl_get_info(PERL_VENDORLIB installvendorlib IS_PATH) ### PERL_ARCHLIB - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:installarchlib - OUTPUT_VARIABLE - PERL_ARCHLIB_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_ARCHLIB_RESULT_VARIABLE - ) - if (NOT PERL_ARCHLIB_RESULT_VARIABLE) - string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_ARCHLIB ${PERL_ARCHLIB_OUTPUT_VARIABLE}) - perl_adjust_darwin_lib_variable( ARCHLIB ) - file(TO_CMAKE_PATH "${PERL_ARCHLIB}" PERL_ARCHLIB) - endif () + perl_get_info(PERL_ARCHLIB archlib IS_PATH) ### PERL_PRIVLIB - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:installprivlib - OUTPUT_VARIABLE - PERL_PRIVLIB_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_PRIVLIB_RESULT_VARIABLE - ) - if (NOT PERL_PRIVLIB_RESULT_VARIABLE) - string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_PRIVLIB ${PERL_PRIVLIB_OUTPUT_VARIABLE}) - perl_adjust_darwin_lib_variable( PRIVLIB ) - file(TO_CMAKE_PATH "${PERL_PRIVLIB}" PERL_PRIVLIB) - endif () + perl_get_info(PERL_PRIVLIB privlib IS_PATH) + + ### PERL_UPDATE_ARCHLIB + perl_get_info(PERL_UPDATE_ARCHLIB installarchlib IS_PATH) + + ### PERL_UPDATE_PRIVLIB + perl_get_info(PERL_UPDATE_PRIVLIB installprivlib IS_PATH) ### PERL_POSSIBLE_LIBRARY_NAMES - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:libperl - OUTPUT_VARIABLE - PERL_LIBRARY_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_LIBRARY_RESULT_VARIABLE - ) - if (NOT PERL_LIBRARY_RESULT_VARIABLE) - string(REGEX REPLACE "libperl='([^']+)'.*" "\\1" PERL_POSSIBLE_LIBRARY_NAMES ${PERL_LIBRARY_OUTPUT_VARIABLE}) - else () + perl_get_info(PERL_POSSIBLE_LIBRARY_NAMES libperl) + if (NOT PERL_POSSIBLE_LIBRARY_NAMES) set(PERL_POSSIBLE_LIBRARY_NAMES perl${PERL_VERSION_STRING} perl) - endif () + endif() + if (CMAKE_SYSTEM_NAME MATCHES "MSYS|CYGWIN") + # on MSYS and CYGWIN environments, current perl -V:libperl gives shared library name + # rather than the import library. So, extends possible library names + list (APPEND PERL_POSSIBLE_LIBRARY_NAMES perl) + endif() ### PERL_INCLUDE_PATH find_path(PERL_INCLUDE_PATH NAMES perl.h PATHS - ${PERL_ARCHLIB}/CORE + "${PERL_UPDATE_ARCHLIB}/CORE" + "${PERL_ARCHLIB}/CORE" /usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE /usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE /usr/lib/perl5/${PERL_VERSION_STRING}/CORE @@ -230,7 +131,8 @@ if (PERL_EXECUTABLE) NAMES ${PERL_POSSIBLE_LIBRARY_NAMES} PATHS - ${PERL_ARCHLIB}/CORE + "${PERL_UPDATE_ARCHLIB}/CORE" + "${PERL_ARCHLIB}/CORE" /usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE /usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE /usr/lib/perl5/${PERL_VERSION_STRING}/CORE diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 38e0861..797f9e4 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -56,10 +56,13 @@ # Specify the :command:`install(PROGRAMS)` command ``COMPONENT`` # option. If not specified, no such option will be used. +cmake_policy(PUSH) +cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced + set(_IRSL_HAVE_Intel FALSE) set(_IRSL_HAVE_MSVC FALSE) foreach(LANG IN ITEMS C CXX Fortran) - if(CMAKE_${LANG}_COMPILER_ID STREQUAL Intel) + if("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "Intel") if(NOT _IRSL_HAVE_Intel) get_filename_component(_Intel_basedir "${CMAKE_${LANG}_COMPILER}" PATH) if(CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -81,7 +84,7 @@ foreach(LANG IN ITEMS C CXX Fortran) endif() set(_IRSL_HAVE_Intel TRUE) endif() - elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL MSVC) + elseif("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "MSVC") set(_IRSL_HAVE_MSVC TRUE) endif() endforeach() @@ -600,11 +603,14 @@ if(_IRSL_HAVE_Intel) if(_Intel_compiler_ver VERSION_LESS 18) list(APPEND __install_dirs "${_Intel_redistdir}/irml" "${_Intel_redistdir}/irml_c") endif() - foreach(__Intel_lib IN ITEMS cilkrts20.dll libchkp.dll libgfxoffload.dll libioffload_host.dll libirngmd.dll + foreach(__Intel_lib IN ITEMS cilkrts20.dll libchkp.dll libioffload_host.dll libirngmd.dll libmmd.dll libmmdd.dll libmpx.dll liboffload.dll svml_dispmd.dll) list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}") endforeach() + if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel) + list(APPEND __install_libs "${_Intel_redistdir}/libgfxoffload.dll") + endif() if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel) foreach(__Intel_lib IN ITEMS ifdlg100.dll libicaf.dll libifcoremd.dll libifcoremdd.dll libifcorert.dll libifcorertd.dll libifportmd.dll) @@ -637,10 +643,10 @@ if(_IRSL_HAVE_Intel) endforeach() endif() if(_Intel_compiler_ver VERSION_GREATER_EQUAL 15) - foreach(__Intel_lib IN ITEMS libgfxoffload.so libistrconv.so) - - list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}") - endforeach() + list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.so") + if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel) + list(APPEND __install_libs "${_Intel_redistdir}/libgfxoffload.so") + endif() endif() if(_Intel_compiler_ver VERSION_GREATER_EQUAL 16) foreach(__Intel_lib IN ITEMS libioffload_host.so libioffload_host.so.5 libioffload_target.so libioffload_target.so.5 libmpx.so offload_main) @@ -743,3 +749,5 @@ if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) ) endif() endif() + +cmake_policy(POP) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a28378a..3556f94 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 10) -set(CMake_VERSION_PATCH 20171212) +set(CMake_VERSION_PATCH 20171214) #set(CMake_VERSION_RC 1) diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index dd2993d..e684f5e 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -29,6 +29,22 @@ enum LinkLibraryScopeType const char* const GRAPHVIZ_PRIVATE_EDEGE_STYLE = "dashed"; const char* const GRAPHVIZ_INTERFACE_EDEGE_STYLE = "dotted"; +std::string getLinkLibraryStyle(const LinkLibraryScopeType& type) +{ + std::string style; + switch (type) { + case LLT_SCOPE_PRIVATE: + style = "[style = " + std::string(GRAPHVIZ_PRIVATE_EDEGE_STYLE) + "]"; + break; + case LLT_SCOPE_INTERFACE: + style = "[style = " + std::string(GRAPHVIZ_INTERFACE_EDEGE_STYLE) + "]"; + break; + default: + break; + } + return style; +} + const char* getShapeForTarget(const cmGeneratorTarget* target) { if (!target) { @@ -132,6 +148,7 @@ cmGraphVizWriter::cmGraphVizWriter( , GenerateForStaticLibs(true) , GenerateForSharedLibs(true) , GenerateForModuleLibs(true) + , GenerateForInterface(true) , GenerateForExternals(true) , GeneratePerTarget(true) , GenerateDependers(true) @@ -192,6 +209,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, __set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS"); __set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS"); __set_bool_if_set(this->GenerateForModuleLibs, "GRAPHVIZ_MODULE_LIBS"); + __set_bool_if_set(this->GenerateForInterface, "GRAPHVIZ_INTERFACE"); __set_bool_if_set(this->GenerateForExternals, "GRAPHVIZ_EXTERNAL_LIBS"); __set_bool_if_set(this->GeneratePerTarget, "GRAPHVIZ_GENERATE_PER_TARGET"); __set_bool_if_set(this->GenerateDependers, "GRAPHVIZ_GENERATE_DEPENDERS"); @@ -379,16 +397,7 @@ void cmGraphVizWriter::WriteConnections( str << " \"" << myNodeName << "\" -> \"" << libNameIt->second << "\""; - switch (llit.second) { - case LLT_SCOPE_PRIVATE: - str << "[style = " << GRAPHVIZ_PRIVATE_EDEGE_STYLE << "]"; - break; - case LLT_SCOPE_INTERFACE: - str << "[style = " << GRAPHVIZ_INTERFACE_EDEGE_STYLE << "]"; - break; - default: - break; - } + str << getLinkLibraryStyle(llit.second); str << " // " << targetName << " -> " << libName << std::endl; this->WriteConnections(libName, insertedNodes, insertedConnections, str); @@ -429,12 +438,11 @@ void cmGraphVizWriter::WriteDependerConnections( // Now we have a target, check whether it links against targetName. // If so, draw a connection, and then continue with dependers on that one. - const cmTarget::LinkLibraryVectorType* ll = - &(tptr.second->Target->GetOriginalLinkLibraries()); + std::map<std::string, LinkLibraryScopeType> ll = + getScopedLinkLibrariesFromTarget(tptr.second->Target); - for (auto const& llit : *ll) { - std::string libName = llit.first; - if (libName == targetName) { + for (auto const& llit : ll) { + if (llit.first == targetName) { // So this target links against targetName. std::map<std::string, std::string>::const_iterator dependerNodeNameIt = this->TargetNamesNodes.find(tptr.first); @@ -452,6 +460,7 @@ void cmGraphVizWriter::WriteDependerConnections( str << " \"" << dependerNodeNameIt->second << "\" -> \"" << myNodeName << "\""; str << " // " << targetName << " -> " << tptr.first << std::endl; + str << getLinkLibraryStyle(llit.second); this->WriteDependerConnections(tptr.first, insertedNodes, insertedConnections, str); } @@ -572,6 +581,8 @@ bool cmGraphVizWriter::GenerateForTargetType( return this->GenerateForSharedLibs; case cmStateEnums::MODULE_LIBRARY: return this->GenerateForModuleLibs; + case cmStateEnums::INTERFACE_LIBRARY: + return this->GenerateForInterface; default: break; } diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 824999b..ac20da9 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -79,6 +79,7 @@ protected: bool GenerateForStaticLibs; bool GenerateForSharedLibs; bool GenerateForModuleLibs; + bool GenerateForInterface; bool GenerateForExternals; bool GeneratePerTarget; bool GenerateDependers; diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 5e872d2..4b59f44 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -155,12 +155,12 @@ std::vector<std::string> const& cmIDEOptions::GetDefines() const return this->Defines; } -void cmIDEOptions::AddFlag(const char* flag, const char* value) +void cmIDEOptions::AddFlag(std::string const& flag, std::string const& value) { this->FlagMap[flag] = value; } -void cmIDEOptions::AddFlag(const char* flag, +void cmIDEOptions::AddFlag(std::string const& flag, std::vector<std::string> const& value) { this->FlagMap[flag] = value; @@ -185,7 +185,7 @@ void cmIDEOptions::AppendFlagString(std::string const& flag, this->FlagMap[flag].append_with_space(value); } -void cmIDEOptions::RemoveFlag(const char* flag) +void cmIDEOptions::RemoveFlag(std::string const& flag) { this->FlagMap.erase(flag); } @@ -195,12 +195,13 @@ bool cmIDEOptions::HasFlag(std::string const& flag) const return this->FlagMap.find(flag) != this->FlagMap.end(); } -const char* cmIDEOptions::GetFlag(const char* flag) +const char* cmIDEOptions::GetFlag(std::string const& flag) const { // This method works only for single-valued flags! - std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(flag); - if (i != this->FlagMap.end() && i->second.size() == 1) { + std::map<std::string, FlagValue>::const_iterator i = + this->FlagMap.find(flag); + if (i != this->FlagMap.cend() && i->second.size() == 1) { return i->second[0].c_str(); } - return 0; + return nullptr; } diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index af03128..ded92ca 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -26,15 +26,15 @@ public: void AddDefines(const std::vector<std::string>& defines); std::vector<std::string> const& GetDefines() const; - void AddFlag(const char* flag, const char* value); - void AddFlag(const char* flag, std::vector<std::string> const& value); + void AddFlag(std::string const& flag, std::string const& value); + void AddFlag(std::string const& flag, std::vector<std::string> const& value); void AppendFlag(std::string const& flag, std::string const& value); void AppendFlag(std::string const& flag, std::vector<std::string> const& value); void AppendFlagString(std::string const& flag, std::string const& value); - void RemoveFlag(const char* flag); + void RemoveFlag(std::string const& flag); bool HasFlag(std::string const& flag) const; - const char* GetFlag(const char* flag); + const char* GetFlag(std::string const& flag) const; protected: // create a map of xml tags to the values they should have in the output diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 53966cd..47e6d7d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -701,7 +701,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( Options targetOptions(this, t, table, gg->ExtraFlagTable); targetOptions.FixExceptionHandlingDefault(); std::string asmLocation = configName + "/"; - targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); + targetOptions.AddFlag("AssemblerListingLocation", asmLocation); targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); @@ -1007,7 +1007,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (mdi && !mdi->DefFile.empty()) { std::string defFile = this->ConvertToOutputFormat(mdi->DefFile, cmOutputConverter::SHELL); - linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); + linkOptions.AddFlag("ModuleDefinitionFile", defFile); } switch (target->GetType()) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8589a96..fd2f899 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2448,7 +2448,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.FixExceptionHandlingDefault(); clOptions.AddFlag("PrecompiledHeader", "NotUsing"); std::string asmLocation = configName + "/"; - clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); + clOptions.AddFlag("AssemblerListingLocation", asmLocation); } } clOptions.Parse(flags.c_str()); @@ -3315,8 +3315,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( imLib += "/"; imLib += targetNameImport; - linkOptions.AddFlag("ImportLibrary", imLib.c_str()); - linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); + linkOptions.AddFlag("ImportLibrary", imLib); + linkOptions.AddFlag("ProgramDataBaseFile", pdb); // A Windows Runtime component uses internal .NET metadata, // so does not have an import library. @@ -3337,7 +3337,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib"); } } else if (this->NsightTegra) { - linkOptions.AddFlag("SoName", targetNameSO.c_str()); + linkOptions.AddFlag("SoName", targetNameSO); } linkOptions.Parse(flags.c_str()); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index b1686be..4f3d737 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -258,7 +258,7 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() void cmVisualStudioGeneratorOptions::FixManifestUACFlags() { - static const char* ENABLE_UAC = "EnableUAC"; + static std::string const ENABLE_UAC = "EnableUAC"; if (!HasFlag(ENABLE_UAC)) { return; } @@ -304,8 +304,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags() continue; } - AddFlag(uacMap[keyValue[0]].c_str(), - uacExecuteLevelMap[keyValue[1]].c_str()); + AddFlag(uacMap[keyValue[0]], uacExecuteLevelMap[keyValue[1]]); continue; } @@ -314,7 +313,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags() // unknown uiAccess value continue; } - AddFlag(uacMap[keyValue[0]].c_str(), keyValue[1].c_str()); + AddFlag(uacMap[keyValue[0]], keyValue[1]); continue; } diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 50aa857..649f30b 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -4234,11 +4234,16 @@ bool SystemTools::IsSubDirectory(const std::string& cSubdir, std::string dir = cDir; SystemTools::ConvertToUnixSlashes(subdir); SystemTools::ConvertToUnixSlashes(dir); - if (subdir.size() > dir.size() && subdir[dir.size()] == '/') { - std::string s = subdir.substr(0, dir.size()); - return SystemTools::ComparePath(s, dir); + if (subdir.size() <= dir.size() || dir.empty()) { + return false; } - return false; + bool isRootPath = *dir.rbegin() == '/'; // like "/" or "C:/" + size_t expectedSlashPosition = isRootPath ? dir.size() - 1u : dir.size(); + if (subdir[expectedSlashPosition] != '/') { + return false; + } + std::string s = subdir.substr(0, dir.size()); + return SystemTools::ComparePath(s, dir); } void SystemTools::Delay(unsigned int msec) diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 3b694c9..a6af9cc 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -813,6 +813,39 @@ static bool CheckFind() return res; } +static bool CheckIsSubDirectory() +{ + bool res = true; + + if (kwsys::SystemTools::IsSubDirectory("/foo", "/") == false) { + std::cerr << "Problem with IsSubDirectory (root - unix): " << std::endl; + res = false; + } + if (kwsys::SystemTools::IsSubDirectory("c:/foo", "c:/") == false) { + std::cerr << "Problem with IsSubDirectory (root - dos): " << std::endl; + res = false; + } + if (kwsys::SystemTools::IsSubDirectory("/foo/bar", "/foo") == false) { + std::cerr << "Problem with IsSubDirectory (deep): " << std::endl; + res = false; + } + if (kwsys::SystemTools::IsSubDirectory("/foo", "/foo") == true) { + std::cerr << "Problem with IsSubDirectory (identity): " << std::endl; + res = false; + } + if (kwsys::SystemTools::IsSubDirectory("/fooo", "/foo") == true) { + std::cerr << "Problem with IsSubDirectory (substring): " << std::endl; + res = false; + } + if (kwsys::SystemTools::IsSubDirectory("/foo/", "/foo") == true) { + std::cerr << "Problem with IsSubDirectory (prepended slash): " + << std::endl; + res = false; + } + + return res; +} + static bool CheckGetLineFromStream() { const std::string fileWithFiveCharsOnFirstLine(TEST_SYSTEMTOOLS_SOURCE_DIR @@ -897,6 +930,8 @@ int testSystemTools(int, char* []) res &= CheckFind(); + res &= CheckIsSubDirectory(); + res &= CheckGetLineFromStream(); res &= CheckGetFilenameName(); |