diff options
66 files changed, 575 insertions, 278 deletions
diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 6b73730..03195cc 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -76,12 +76,12 @@ endif() if(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY) set(CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS> " - "<CMAKE_RANLIB> <TARGET> ") + "<CMAKE_RANLIB> <TARGET>") endif() if(NOT CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE) set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE - "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endif() if(NOT CMAKE_EXECUTABLE_RUNTIME_ASM${ASM_DIALECT}_FLAG) diff --git a/Modules/CMakeASM_MASMInformation.cmake b/Modules/CMakeASM_MASMInformation.cmake index 9f7e934..6d1e174 100644 --- a/Modules/CMakeASM_MASMInformation.cmake +++ b/Modules/CMakeASM_MASMInformation.cmake @@ -8,7 +8,7 @@ set(ASM_DIALECT "_MASM") set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm) -set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /c /Fo <OBJECT> <SOURCE>") +set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /c /Fo <OBJECT> <SOURCE>") # The ASM_MASM compiler id for this compiler is "MSVC", so fill out the runtime library table. set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 1e08bb7..f6d620f 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -161,7 +161,7 @@ if(NOT DEFINED CMAKE_C_ARCHIVE_CREATE) set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_C_ARCHIVE_APPEND) - set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_C_ARCHIVE_FINISH) set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") @@ -170,12 +170,12 @@ endif() # compile a C file into an object file if(NOT CMAKE_C_COMPILE_OBJECT) set(CMAKE_C_COMPILE_OBJECT - "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") + "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") endif() if(NOT CMAKE_C_LINK_EXECUTABLE) set(CMAKE_C_LINK_EXECUTABLE - "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endif() if(NOT CMAKE_EXECUTABLE_RUNTIME_C_FLAG) diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index f31713e..f7eb4a7 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -129,7 +129,7 @@ if(NOT DEFINED CMAKE_CUDA_ARCHIVE_CREATE) set(CMAKE_CUDA_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_CUDA_ARCHIVE_APPEND) - set(CMAKE_CUDA_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_CUDA_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_CUDA_ARCHIVE_FINISH) set(CMAKE_CUDA_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index da7440a..dbb4366 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -258,7 +258,7 @@ if(NOT DEFINED CMAKE_CXX_ARCHIVE_CREATE) set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_CXX_ARCHIVE_APPEND) - set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_CXX_ARCHIVE_FINISH) set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") @@ -267,12 +267,12 @@ endif() # compile a C++ file into an object file if(NOT CMAKE_CXX_COMPILE_OBJECT) set(CMAKE_CXX_COMPILE_OBJECT - "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") + "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") endif() if(NOT CMAKE_CXX_LINK_EXECUTABLE) set(CMAKE_CXX_LINK_EXECUTABLE - "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endif() mark_as_advanced( diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index e80716b..9a4ce63 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -193,7 +193,7 @@ if(NOT DEFINED CMAKE_Fortran_ARCHIVE_CREATE) set(CMAKE_Fortran_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_Fortran_ARCHIVE_APPEND) - set(CMAKE_Fortran_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_Fortran_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_Fortran_ARCHIVE_FINISH) set(CMAKE_Fortran_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") @@ -209,7 +209,7 @@ endif() # link a fortran program if(NOT CMAKE_Fortran_LINK_EXECUTABLE) set(CMAKE_Fortran_LINK_EXECUTABLE - "<CMAKE_Fortran_COMPILER> <CMAKE_Fortran_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_Fortran_COMPILER> <CMAKE_Fortran_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endif() if(CMAKE_Fortran_STANDARD_LIBRARIES_INIT) diff --git a/Modules/CMakeOBJCInformation.cmake b/Modules/CMakeOBJCInformation.cmake index 15a3311..b3da82d 100644 --- a/Modules/CMakeOBJCInformation.cmake +++ b/Modules/CMakeOBJCInformation.cmake @@ -161,7 +161,7 @@ if(NOT DEFINED CMAKE_OBJC_ARCHIVE_CREATE) set(CMAKE_OBJC_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_OBJC_ARCHIVE_APPEND) - set(CMAKE_OBJC_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_OBJC_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_OBJC_ARCHIVE_FINISH) set(CMAKE_OBJC_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") @@ -170,12 +170,12 @@ endif() # compile an Objective-C file into an object file if(NOT CMAKE_OBJC_COMPILE_OBJECT) set(CMAKE_OBJC_COMPILE_OBJECT - "<CMAKE_OBJC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x objective-c -o <OBJECT> -c <SOURCE>") + "<CMAKE_OBJC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x objective-c -o <OBJECT> -c <SOURCE>") endif() if(NOT CMAKE_OBJC_LINK_EXECUTABLE) set(CMAKE_OBJC_LINK_EXECUTABLE - "<CMAKE_OBJC_COMPILER> <FLAGS> <CMAKE_OBJC_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_OBJC_COMPILER> <FLAGS> <CMAKE_OBJC_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endif() if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG) diff --git a/Modules/CMakeOBJCXXInformation.cmake b/Modules/CMakeOBJCXXInformation.cmake index cb349d7..71beb7f 100644 --- a/Modules/CMakeOBJCXXInformation.cmake +++ b/Modules/CMakeOBJCXXInformation.cmake @@ -254,7 +254,7 @@ if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_CREATE) set(CMAKE_OBJCXX_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_APPEND) - set(CMAKE_OBJCXX_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_OBJCXX_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") endif() if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_FINISH) set(CMAKE_OBJCXX_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") @@ -263,12 +263,12 @@ endif() # compile an Objective-C++ file into an object file if(NOT CMAKE_OBJCXX_COMPILE_OBJECT) set(CMAKE_OBJCXX_COMPILE_OBJECT - "<CMAKE_OBJCXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x objective-c++ -o <OBJECT> -c <SOURCE>") + "<CMAKE_OBJCXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x objective-c++ -o <OBJECT> -c <SOURCE>") endif() if(NOT CMAKE_OBJCXX_LINK_EXECUTABLE) set(CMAKE_OBJCXX_LINK_EXECUTABLE - "<CMAKE_OBJCXX_COMPILER> <FLAGS> <CMAKE_OBJCXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_OBJCXX_COMPILER> <FLAGS> <CMAKE_OBJCXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endif() mark_as_advanced( diff --git a/Modules/Compiler/GNU-ASM.cmake b/Modules/Compiler/GNU-ASM.cmake index 4aa680f..3daa57d 100644 --- a/Modules/Compiler/GNU-ASM.cmake +++ b/Modules/Compiler/GNU-ASM.cmake @@ -8,5 +8,5 @@ __compiler_gnu(ASM) if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH STREQUAL "GNU assembler") set(CMAKE_DEPFILE_FLAGS_ASM${ASM_DIALECT} "--MD <DEPFILE>") set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE - "<CMAKE_LINKER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_LINKER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endif() diff --git a/Modules/Compiler/QCC-CXX.cmake b/Modules/Compiler/QCC-CXX.cmake index 0e7314a..42303f4 100644 --- a/Modules/Compiler/QCC-CXX.cmake +++ b/Modules/Compiler/QCC-CXX.cmake @@ -10,6 +10,6 @@ set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> -lang-c++ <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") set(CMAKE_CXX_LINK_EXECUTABLE - "<CMAKE_CXX_COMPILER> -lang-c++ <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_CXX_COMPILER> -lang-c++ <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 6132693..018956b 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -191,8 +191,7 @@ Hints ``Python_FIND_STRATEGY`` This variable defines how lookup will be done. - The ``Python_FIND_STRATEGY`` variable can be set to empty or one of the - following: + The ``Python_FIND_STRATEGY`` variable can be set to one of the following: * ``VERSION``: Try to find the most recent version in all specified locations. @@ -205,8 +204,7 @@ Hints ``Python_FIND_REGISTRY`` On Windows the ``Python_FIND_REGISTRY`` variable determine the order of preference between registry and environment variables. - the ``Python_FIND_REGISTRY`` variable can be set to empty or one of the - following: + the ``Python_FIND_REGISTRY`` variable can be set to one of the following: * ``FIRST``: Try to use registry before environment variables. This is the default. @@ -216,8 +214,8 @@ Hints ``Python_FIND_FRAMEWORK`` On macOS the ``Python_FIND_FRAMEWORK`` variable determine the order of preference between Apple-style and unix-style package components. - This variable can be set to empty or take same values as - :variable:`CMAKE_FIND_FRAMEWORK` variable. + This variable can take same values as :variable:`CMAKE_FIND_FRAMEWORK` + variable. .. note:: @@ -231,8 +229,8 @@ Hints ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment is active (i.e. the ``activate`` script has been evaluated). In this case, it takes precedence over ``Python_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` - variables. The ``Python_FIND_VIRTUALENV`` variable can be set to empty or - one of the following: + variables. The ``Python_FIND_VIRTUALENV`` variable can be set to one of the + following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index a40d7f7..0ca1f56 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -939,15 +939,15 @@ endif() # Compute search signature # This signature will be used to check validity of cached variables on new search -set (_${_PYTHON_PREFIX}_SIGNATURE "${${_PYTHON_PREFIX}_ROOT_DIR}:${${_PYTHON_PREFIX}_FIND_STRATEGY}:${${_PYTHON_PREFIX}_FIND_VIRTUALENV}") +set (_${_PYTHON_PREFIX}_SIGNATURE "${${_PYTHON_PREFIX}_ROOT_DIR}:${_${_PYTHON_PREFIX}_FIND_STRATEGY}:${${_PYTHON_PREFIX}_FIND_VIRTUALENV}") if (NOT WIN32) string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_USE_STATIC_LIBS}:") endif() if (CMAKE_HOST_APPLE) - string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_FIND_FRAMEWORK}") + string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${_${_PYTHON_PREFIX}_FIND_FRAMEWORK}") endif() if (CMAKE_HOST_WIN32) - string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_FIND_REGISTRY}") + string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${_${_PYTHON_PREFIX}_FIND_REGISTRY}") endif() diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 10fe211..15e1ce1 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -140,8 +140,7 @@ Hints ``Python2_FIND_STRATEGY`` This variable defines how lookup will be done. - The ``Python2_FIND_STRATEGY`` variable can be set to empty or one of the - following: + The ``Python2_FIND_STRATEGY`` variable can be set to one of the following: * ``VERSION``: Try to find the most recent version in all specified locations. @@ -154,8 +153,7 @@ Hints ``Python2_FIND_REGISTRY`` On Windows the ``Python2_FIND_REGISTRY`` variable determine the order of preference between registry and environment variables. - the ``Python2_FIND_REGISTRY`` variable can be set to empty or one of the - following: + the ``Python2_FIND_REGISTRY`` variable can be set to one of the following: * ``FIRST``: Try to use registry before environment variables. This is the default. @@ -165,8 +163,8 @@ Hints ``Python2_FIND_FRAMEWORK`` On macOS the ``Python2_FIND_FRAMEWORK`` variable determine the order of preference between Apple-style and unix-style package components. - This variable can be set to empty or take same values as - :variable:`CMAKE_FIND_FRAMEWORK` variable. + This variable can take same values as :variable:`CMAKE_FIND_FRAMEWORK` + variable. .. note:: @@ -180,8 +178,8 @@ Hints ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment is active (i.e. the ``activate`` script has been evaluated). In this case, it takes precedence over ``Python2_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` - variables. The ``Python2_FIND_VIRTUALENV`` variable can be set to empty or - one of the following: + variables. The ``Python2_FIND_VIRTUALENV`` variable can be set to one of the + following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 211f982..8135a1d 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -188,8 +188,7 @@ Hints ``Python3_FIND_STRATEGY`` This variable defines how lookup will be done. - The ``Python3_FIND_STRATEGY`` variable can be set to empty or one of the - following: + The ``Python3_FIND_STRATEGY`` variable can be set to one of the following: * ``VERSION``: Try to find the most recent version in all specified locations. @@ -202,8 +201,7 @@ Hints ``Python3_FIND_REGISTRY`` On Windows the ``Python3_FIND_REGISTRY`` variable determine the order of preference between registry and environment variables. - The ``Python3_FIND_REGISTRY`` variable can be set to empty or one of the - following: + The ``Python3_FIND_REGISTRY`` variable can be set to one of the following: * ``FIRST``: Try to use registry before environment variables. This is the default. @@ -213,8 +211,8 @@ Hints ``Python3_FIND_FRAMEWORK`` On macOS the ``Python3_FIND_FRAMEWORK`` variable determine the order of preference between Apple-style and unix-style package components. - This variable can be set to empty or take same values as - :variable:`CMAKE_FIND_FRAMEWORK` variable. + This variable can take same values as :variable:`CMAKE_FIND_FRAMEWORK` + variable. .. note:: @@ -228,8 +226,8 @@ Hints ``virtualenv`` or ``conda``. It is meaningful only when a virtual environment is active (i.e. the ``activate`` script has been evaluated). In this case, it takes precedence over ``Python3_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` - variables. The ``Python3_FIND_VIRTUALENV`` variable can be set to empty or - one of the following: + variables. The ``Python3_FIND_VIRTUALENV`` variable can be set to one of the + following: * ``FIRST``: The virtual environment is used before any other standard paths to look-up for the interpreter. This is the default. diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 1e010bf..1bdee60 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -22,6 +22,9 @@ standard syntax, e.g. It also determines what the name of the library is. +Virtual environments such as RVM are handled as well, by passing +the argument ``Ruby_FIND_VIRTUALENV`` + Result Variables ^^^^^^^^^^^^^^^^ @@ -49,6 +52,28 @@ Also: ``Ruby_INCLUDE_PATH`` same as Ruby_INCLUDE_DIRS, only provided for compatibility reasons, don't use it + +Hints +^^^^^ + +``Ruby_ROOT_DIR`` + Define the root directory of a Ruby installation. + +``Ruby_FIND_VIRTUALENV`` + This variable defines the handling of virtual environments managed by + ``rvm``. It is meaningful only when a virtual environment + is active (i.e. the ``rvm`` script has been evaluated or at least the + ``MY_RUBY_HOME`` environment variable is set). + The ``Ruby_FIND_VIRTUALENV`` variable can be set to empty or + one of the following: + + * ``FIRST``: The virtual environment is used before any other standard + paths to look-up for the interpreter. This is the default. + * ``ONLY``: Only the virtual environment is used to look-up for the + interpreter. + * ``STANDARD``: The virtual environment is not used to look-up for the + interpreter (assuming it isn't still in the PATH...) + #]=======================================================================] # Backwards compatibility @@ -121,14 +146,115 @@ if(NOT Ruby_FIND_VERSION_EXACT) list(REMOVE_DUPLICATES _Ruby_POSSIBLE_EXECUTABLE_NAMES) endif() +# virtual environments handling (eg RVM) +if (DEFINED ENV{MY_RUBY_HOME}) + if(_Ruby_DEBUG_OUTPUT) + message("My ruby home is defined: $ENV{MY_RUBY_HOME}") + endif() + + if (DEFINED Ruby_FIND_VIRTUALENV) + if (NOT Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$") + message (AUTHOR_WARNING "FindRuby: ${Ruby_FIND_VIRTUALENV}: invalid value for 'Ruby_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead.") + set (_Ruby_FIND_VIRTUALENV "FIRST") + else() + set (_Ruby_FIND_VIRTUALENV ${Ruby_FIND_VIRTUALENV}) + endif() + else() + set (_Ruby_FIND_VIRTUALENV FIRST) + endif() +else() + if (DEFINED Ruby_FIND_VIRTUALENV) + message("Environment variable MY_RUBY_HOME isn't set, defaulting back to Ruby_FIND_VIRTUALENV=STANDARD") + endif() + set (_Ruby_FIND_VIRTUALENV STANDARD) +endif() + if(_Ruby_DEBUG_OUTPUT) message("_Ruby_POSSIBLE_EXECUTABLE_NAMES=${_Ruby_POSSIBLE_EXECUTABLE_NAMES}") + message("_Ruby_FIND_VIRTUALENV=${_Ruby_FIND_VIRTUALENV}") endif() -find_program (Ruby_EXECUTABLE - NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES} - NAMES_PER_DIR - ) +function (_RUBY_VALIDATE_INTERPRETER) + if (NOT Ruby_EXECUTABLE) + return() + endif() + + cmake_parse_arguments (PARSE_ARGV 0 _RVI "EXACT;CHECK_EXISTS" "" "") + if (_RVI_UNPARSED_ARGUMENTS) + set (expected_version ${_RVI_UNPARSED_ARGUMENTS}) + else() + unset (expected_version) + endif() + + if (_RVI_CHECK_EXISTS AND NOT EXISTS "${Ruby_EXECUTABLE}") + # interpreter does not exist anymore + set (_Ruby_Interpreter_REASON_FAILURE "Cannot find the interpreter \"${Ruby_EXECUTABLE}\"") + set_property (CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND") + return() + endif() + + # Check the version it returns + # executable found must have a specific version + execute_process (COMMAND "${Ruby_EXECUTABLE}" -e "puts RUBY_VERSION" + RESULT_VARIABLE result + OUTPUT_VARIABLE version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (result OR (_RVI_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version)) + # interpreter not usable or has wrong major version + if (result) + set (_Ruby_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${Ruby_EXECUTABLE}\"") + else() + set (_Ruby_Interpreter_REASON_FAILURE "Wrong major version for the interpreter \"${Ruby_EXECUTABLE}\"") + endif() + set_property (CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND") + return() + endif() + +endfunction() + +while(1) + # Virtual environments handling + if(_Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + if(_Ruby_DEBUG_OUTPUT) + message("Inside Matches") + endif() + find_program (Ruby_EXECUTABLE + NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES} + NAMES_PER_DIR + PATHS ENV MY_RUBY_HOME + PATH_SUFFIXES bin Scripts + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + + if(_Ruby_DEBUG_OUTPUT) + message("Ruby_EXECUTABLE=${Ruby_EXECUTABLE}") + endif() + + _RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION}}) + if(Ruby_EXECUTABLE) + break() + endif() + if(NOT _Ruby_FIND_VIRTUALENV STREQUAL "ONLY") + break() + endif() + elseif(_Ruby_DEBUG_OUTPUT) + message("_Ruby_FIND_VIRTUALENV doesn't match: ${_Ruby_FIND_VIRTUALENV}") + endif() + + # try using standard paths + find_program (Ruby_EXECUTABLE + NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES} + NAMES_PER_DIR) + _RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION}) + if (Ruby_EXECUTABLE) + break() + endif() + + break() +endwhile() if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR) function(_RUBY_CONFIG_VAR RBVAR OUTVAR) @@ -266,6 +392,8 @@ if(Ruby_VERSION_MAJOR) set(_Ruby_NODOT_VERSION "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}${Ruby_VERSION_PATCH}") endif() +# FIXME: Currently we require both the interpreter and development components to be found +# in order to use either. See issue #20474. find_path(Ruby_INCLUDE_DIR NAMES ruby.h HINTS diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake index 1affcd0..581fde4 100644 --- a/Modules/Platform/Android-Common.cmake +++ b/Modules/Platform/Android-Common.cmake @@ -73,7 +73,7 @@ if(CMAKE_ANDROID_STL_TYPE) macro(__android_stl lang) # FIXME: Add a way to add project-wide language-specific compile-only flags. set(CMAKE_CXX_COMPILE_OBJECT - "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE> -nostdinc++") + "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE> -nostdinc++") string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -nostdlib++") endmacro() else() diff --git a/Modules/Platform/BlueGeneL.cmake b/Modules/Platform/BlueGeneL.cmake index 082e46c..0ed9975 100644 --- a/Modules/Platform/BlueGeneL.cmake +++ b/Modules/Platform/BlueGeneL.cmake @@ -23,18 +23,18 @@ include(Platform/UnixPaths) if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_LINK_EXECUTABLE - "<CMAKE_C_COMPILER> -Wl,-relax <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Wl,-lgcc,-lc -lnss_files -lnss_dns -lresolv") + "<CMAKE_C_COMPILER> -Wl,-relax <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Wl,-lgcc,-lc -lnss_files -lnss_dns -lresolv") else() # when using IBM xlc we probably don't want to link to -lgcc set(CMAKE_C_LINK_EXECUTABLE - "<CMAKE_C_COMPILER> -Wl,-relax <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Wl,-lc -lnss_files -lnss_dns -lresolv") + "<CMAKE_C_COMPILER> -Wl,-relax <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Wl,-lc -lnss_files -lnss_dns -lresolv") endif() if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_LINK_EXECUTABLE - "<CMAKE_CXX_COMPILER> -Wl,-relax <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Wl,-lstdc++,-lgcc,-lc -lnss_files -lnss_dns -lresolv") + "<CMAKE_CXX_COMPILER> -Wl,-relax <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Wl,-lstdc++,-lgcc,-lc -lnss_files -lnss_dns -lresolv") else() # when using the IBM xlC we probably don't want to link to -lgcc set(CMAKE_CXX_LINK_EXECUTABLE - "<CMAKE_CXX_COMPILER> -Wl,-relax <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Wl,-lstdc++,-lc -lnss_files -lnss_dns -lresolv") + "<CMAKE_CXX_COMPILER> -Wl,-relax <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Wl,-lstdc++,-lc -lnss_files -lnss_dns -lresolv") endif() diff --git a/Modules/Platform/BlueGeneP-base.cmake b/Modules/Platform/BlueGeneP-base.cmake index fe95b42..7095dd8 100644 --- a/Modules/Platform/BlueGeneP-base.cmake +++ b/Modules/Platform/BlueGeneP-base.cmake @@ -97,7 +97,7 @@ macro(__BlueGeneP_set_dynamic_flags compiler_id lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty set(BGP_${lang}_DEFAULT_EXE_FLAGS - "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGP_${lang}_DYNAMIC_EXE_FLAGS} ${BGP_${lang}_DEFAULT_EXE_FLAGS}") endmacro() @@ -108,7 +108,7 @@ endmacro() # macro(__BlueGeneP_set_static_flags compiler_id lang) set(BGP_${lang}_DEFAULT_EXE_FLAGS - "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGP_${lang}_DEFAULT_EXE_FLAGS}") endmacro() diff --git a/Modules/Platform/BlueGeneQ-base.cmake b/Modules/Platform/BlueGeneQ-base.cmake index 5e56d8e..94cb0a8 100644 --- a/Modules/Platform/BlueGeneQ-base.cmake +++ b/Modules/Platform/BlueGeneQ-base.cmake @@ -101,7 +101,7 @@ macro(__BlueGeneQ_common_setup compiler_id lang) foreach(dir ${CMAKE_SYSTEM_INCLUDE_PATH}) string(APPEND BGQ_SYSTEM_INCLUDES " -I${dir}") endforeach() - set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") + set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") # @@ -146,7 +146,7 @@ macro(__BlueGeneQ_setup_dynamic compiler_id lang) # For dynamic executables, need to provide special BG/Q arguments. set(BGQ_${lang}_DEFAULT_EXE_FLAGS - "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGQ_${lang}_DYNAMIC_EXE_FLAGS} ${BGQ_${lang}_DEFAULT_EXE_FLAGS}") endmacro() @@ -160,7 +160,7 @@ macro(__BlueGeneQ_setup_static compiler_id lang) # For static executables, use default link settings. set(BGQ_${lang}_DEFAULT_EXE_FLAGS - "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGQ_${lang}_DEFAULT_EXE_FLAGS}") endmacro() diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index ca90712..4fa14ce 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -22,7 +22,7 @@ macro(__cygwin_compiler_gnu lang) set(CMAKE_${lang}_CREATE_SHARED_LIBRARY "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") set(CMAKE_${lang}_LINK_EXECUTABLE - "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") + "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") # No -fPIC on cygwin set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") diff --git a/Modules/Platform/HP-UX-HP-C.cmake b/Modules/Platform/HP-UX-HP-C.cmake index 7610383..57ba2eb 100644 --- a/Modules/Platform/HP-UX-HP-C.cmake +++ b/Modules/Platform/HP-UX-HP-C.cmake @@ -3,4 +3,4 @@ __hpux_compiler_hp(C) set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") -set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> -Aa -Ae <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") +set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> -Aa -Ae <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") diff --git a/Modules/Platform/Linux-como.cmake b/Modules/Platform/Linux-como.cmake index d1550d2..f6db34c 100644 --- a/Modules/Platform/Linux-como.cmake +++ b/Modules/Platform/Linux-como.cmake @@ -11,7 +11,7 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> --prelink_objects <OBJECTS>" - "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") set(CMAKE_SHARED_LIBRARY_C_FLAGS "") diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 87ddfcd..0c366b4 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -55,13 +55,13 @@ macro(__windows_compiler_clang_gnu lang) # Create archiving rules to support large object file lists for static libraries. set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") - set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") set(CMAKE_${lang}_CREATE_SHARED_LIBRARY "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES>") set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) set(CMAKE_${lang}_LINK_EXECUTABLE - "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") + "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") if(NOT "${lang}" STREQUAL "ASM") set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 38a8cf4..a2e3811 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -47,16 +47,12 @@ if("${_help}" MATCHES "GNU ld .* 2\\.1[1-6]") set(__WINDOWS_GNU_LD_RESPONSE 0) endif() -if(NOT CMAKE_GENERATOR_RC AND CMAKE_GENERATOR MATCHES "Unix Makefiles") - set(CMAKE_GENERATOR_RC windres) -endif() - macro(__windows_compiler_gnu lang) if(MSYS OR MINGW) # Create archiving rules to support large object file lists for static libraries. set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") - set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") # Initialize C link type selection flags. These flags are used when @@ -108,7 +104,7 @@ macro(__windows_compiler_gnu lang) set(CMAKE_${lang}_CREATE_SHARED_LIBRARY "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>") set(CMAKE_${lang}_LINK_EXECUTABLE - "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") + "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") list(APPEND CMAKE_${lang}_ABI_FILES "Platform/Windows-GNU-${lang}-ABI") @@ -132,7 +128,7 @@ macro(__windows_compiler_gnu lang) endif() if(NOT CMAKE_RC_COMPILER_INIT AND NOT CMAKE_GENERATOR_RC) - set(CMAKE_RC_COMPILER_INIT windres) + set(CMAKE_RC_COMPILER_INIT ${_CMAKE_TOOLCHAIN_PREFIX}windres) endif() enable_language(RC) diff --git a/Modules/Platform/Windows-df.cmake b/Modules/Platform/Windows-df.cmake index f948914..8b824bc 100644 --- a/Modules/Platform/Windows-df.cmake +++ b/Modules/Platform/Windows-df.cmake @@ -13,7 +13,7 @@ endif() set(CMAKE_Fortran_MODDIR_FLAG "-module:") set(CMAKE_Fortran_CREATE_SHARED_LIBRARY - "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out:<TARGET> /dll <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out:<TARGET> /dll <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") set(CMAKE_Fortran_CREATE_SHARED_MODULE ${CMAKE_Fortran_CREATE_SHARED_LIBRARY}) @@ -22,7 +22,7 @@ set(CMAKE_Fortran_CREATE_STATIC_LIBRARY "lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /o # compile a C++ file into an object file set(CMAKE_Fortran_COMPILE_OBJECT - "<CMAKE_Fortran_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} /object:<OBJECT> <FLAGS> /compile_only <SOURCE>${CMAKE_END_TEMP_FILE}") + "<CMAKE_Fortran_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} /object:<OBJECT> <FLAGS> /compile_only <SOURCE>${CMAKE_END_TEMP_FILE}") set(CMAKE_Fortran_LINK_EXECUTABLE "<CMAKE_Fortran_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> /exe:<TARGET> <OBJECTS> /link <CMAKE_Fortran_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}") diff --git a/Modules/Platform/eCos.cmake b/Modules/Platform/eCos.cmake index e1279ef..25db028 100644 --- a/Modules/Platform/eCos.cmake +++ b/Modules/Platform/eCos.cmake @@ -52,8 +52,8 @@ include_directories(${ECOS_SYSTEM_CONFIG_HEADER_PATH}) add_definitions(-D__ECOS__=1 -D__ECOS=1) # special link commands for eCos executables -set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostdlib -nostartfiles -L${ECOS_LIBTARGET_DIRECTORY} -Ttarget.ld <LINK_LIBRARIES>") -set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostdlib -nostartfiles -L${ECOS_LIBTARGET_DIRECTORY} -Ttarget.ld <LINK_LIBRARIES>") +set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostdlib -nostartfiles -L${ECOS_LIBTARGET_DIRECTORY} -Ttarget.ld <LINK_LIBRARIES>") +set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -nostdlib -nostartfiles -L${ECOS_LIBTARGET_DIRECTORY} -Ttarget.ld <LINK_LIBRARIES>") # eCos doesn't support shared libs set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) diff --git a/Modules/Platform/gas.cmake b/Modules/Platform/gas.cmake index 7c659f2..8484076 100644 --- a/Modules/Platform/gas.cmake +++ b/Modules/Platform/gas.cmake @@ -11,7 +11,7 @@ set(CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY "<CMAKE_RANLIB> <TARGET> ") set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE - "<CMAKE_LINKER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + "<CMAKE_LINKER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") # to be done set(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY) diff --git a/Modules/UseEcos.cmake b/Modules/UseEcos.cmake index 60324b1..83c9b20 100644 --- a/Modules/UseEcos.cmake +++ b/Modules/UseEcos.cmake @@ -185,11 +185,11 @@ macro(ECOS_ADD_EXECUTABLE _exe_NAME ) # when using nmake makefiles, the custom buildtype suppresses the default cl.exe flags # and the rules for creating objects are adjusted for gcc set(CMAKE_BUILD_TYPE CUSTOM_ECOS_BUILD) - set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") + set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") # special link commands for ecos-executables - set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <OBJECTS> -o <TARGET> ${_ecos_EXTRA_LIBS} -nostdlib -nostartfiles -L${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib -Ttarget.ld ${ECOS_LD_MCPU}") - set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <OBJECTS> -o <TARGET> ${_ecos_EXTRA_LIBS} -nostdlib -nostartfiles -L${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib -Ttarget.ld ${ECOS_LD_MCPU}") + set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <OBJECTS> -o <TARGET> ${_ecos_EXTRA_LIBS} -nostdlib -nostartfiles -L${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib -Ttarget.ld ${ECOS_LD_MCPU}") + set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <OBJECTS> -o <TARGET> ${_ecos_EXTRA_LIBS} -nostdlib -nostartfiles -L${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib -Ttarget.ld ${ECOS_LD_MCPU}") # some strict compiler flags set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -fno-rtti -Wctor-dtor-privacy -fno-strict-aliasing -fno-exceptions") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 467abe9..564e647 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1,6 +1,11 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +# To ensure maximum portability across various compilers and platforms +# deactivate any compiler extensions +set(CMAKE_C_EXTENSIONS FALSE) +set(CMAKE_CXX_EXTENSIONS FALSE) + include(CheckIncludeFile) # Check if we can build support for ELF parsing. if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d85832e..73b7771 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 17) -set(CMake_VERSION_PATCH 20200325) +set(CMake_VERSION_PATCH 20200326) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index c0d879a..b4085d5 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -1,5 +1,10 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ +#if defined(__CYGWIN__) +// For S_IWRITE symbol +# define _DEFAULT_SOURCE +#endif + #include "cmWIXFilesSourceWriter.h" #include "cm_sys_stat.h" diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index ee81a7d..9d928b2 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -201,8 +201,7 @@ int main(int argc, char** argv) cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data()); // check if argument is a directory containing CMakeCache.txt - std::string buildFilePath = - cmSystemTools::CollapseFullPath("CMakeCache.txt", filePath.c_str()); + std::string buildFilePath = cmStrCat(filePath, "/CMakeCache.txt"); // check if argument is a CMakeCache.txt file if (cmSystemTools::GetFilenameName(filePath) == "CMakeCache.txt" && @@ -211,8 +210,7 @@ int main(int argc, char** argv) } // check if argument is a directory containing CMakeLists.txt - std::string srcFilePath = - cmSystemTools::CollapseFullPath("CMakeLists.txt", filePath.c_str()); + std::string srcFilePath = cmStrCat(filePath, "/CMakeLists.txt"); if (cmSystemTools::FileExists(buildFilePath.c_str())) { dialog.setBinaryDirectory(QString::fromLocal8Bit( diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index ee89b0d..8789f6e 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -124,13 +124,13 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, } this->CacheMajorVersion = 0; this->CacheMinorVersion = 0; - if (const std::string* cmajor = + if (cmProp cmajor = this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) { unsigned int v = 0; if (sscanf(cmajor->c_str(), "%u", &v) == 1) { this->CacheMajorVersion = v; } - if (const std::string* cminor = + if (cmProp cminor = this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) { if (sscanf(cminor->c_str(), "%u", &v) == 1) { this->CacheMinorVersion = v; @@ -150,8 +150,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, } // check to make sure the cache directory has not // been moved - const std::string* oldDir = - this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR"); + cmProp oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR"); if (internal && oldDir) { std::string currentcwd = path; std::string oldcwd = *oldDir; @@ -159,8 +158,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, currentcwd += "/CMakeCache.txt"; oldcwd += "/CMakeCache.txt"; if (!cmSystemTools::SameFile(oldcwd, currentcwd)) { - const std::string* dir = - this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR"); + cmProp dir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR"); std::ostringstream message; message << "The current CMakeCache.txt directory " << currentcwd << " is different than the directory " << (dir ? *dir : "") @@ -210,7 +208,7 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os, CacheIterator i, cmMessenger* messenger) { for (const char** p = cmCacheManager::PersistentProperties; *p; ++p) { - if (const char* value = i.GetProperty(*p)) { + if (cmProp value = i.GetProperty(*p)) { std::string helpstring = cmStrCat(*p, " property for variable: ", i.GetName()); cmCacheManager::OutputHelpString(os, helpstring); @@ -218,9 +216,9 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os, CacheIterator i, std::string key = cmStrCat(i.GetName(), '-', *p); cmCacheManager::OutputKey(os, key); os << ":INTERNAL="; - cmCacheManager::OutputValue(os, value); + cmCacheManager::OutputValue(os, *value); os << "\n"; - cmCacheManager::OutputNewlineTruncationWarning(os, key, value, + cmCacheManager::OutputNewlineTruncationWarning(os, key, *value, messenger); } } @@ -305,8 +303,8 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger) */ } else if (t != cmStateEnums::INTERNAL) { // Format is key:type=value - if (const char* help = ce.GetProperty("HELPSTRING")) { - cmCacheManager::OutputHelpString(fout, help); + if (cmProp help = ce.GetProperty("HELPSTRING")) { + cmCacheManager::OutputHelpString(fout, *help); } else { cmCacheManager::OutputHelpString(fout, "Missing description"); } @@ -336,8 +334,8 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger) this->WritePropertyEntries(fout, i, messenger); if (t == cmStateEnums::INTERNAL) { // Format is key:type=value - if (const char* help = i.GetProperty("HELPSTRING")) { - cmCacheManager::OutputHelpString(fout, help); + if (cmProp help = i.GetProperty("HELPSTRING")) { + cmCacheManager::OutputHelpString(fout, *help); } cmCacheManager::OutputKey(fout, i.GetName()); fout << ":" << cmState::CacheEntryTypeToString(t) << "="; @@ -508,8 +506,7 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator() return { *this, nullptr }; } -const std::string* cmCacheManager::GetInitializedCacheValue( - const std::string& key) const +cmProp cmCacheManager::GetInitializedCacheValue(const std::string& key) const { auto i = this->Cache.find(key); if (i != this->Cache.end() && i->second.Initialized) { @@ -619,17 +616,15 @@ std::vector<std::string> cmCacheManager::CacheEntry::GetPropertyList() const return this->Properties.GetKeys(); } -const char* cmCacheManager::CacheEntry::GetProperty( - const std::string& prop) const +cmProp cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const { if (prop == "TYPE") { - return cmState::CacheEntryTypeToString(this->Type).c_str(); + return &cmState::CacheEntryTypeToString(this->Type); } if (prop == "VALUE") { - return this->Value.c_str(); + return &this->Value; } - cmProp retVal = this->Properties.GetPropertyValue(prop); - return retVal ? retVal->c_str() : nullptr; + return this->Properties.GetPropertyValue(prop); } void cmCacheManager::CacheEntry::SetProperty(const std::string& prop, @@ -663,7 +658,7 @@ void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop, } } -const char* cmCacheManager::CacheIterator::GetProperty( +cmProp cmCacheManager::CacheIterator::GetProperty( const std::string& prop) const { if (!this->IsAtEnd()) { @@ -692,8 +687,8 @@ void cmCacheManager::CacheIterator::AppendProperty(const std::string& p, bool cmCacheManager::CacheIterator::GetPropertyAsBool( const std::string& prop) const { - if (const char* value = this->GetProperty(prop)) { - return cmIsOn(value); + if (cmProp value = this->GetProperty(prop)) { + return cmIsOn(*value); } return false; } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index d8be991..3db76a9 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -37,7 +37,7 @@ private: cmStateEnums::CacheEntryType Type = cmStateEnums::UNINITIALIZED; cmPropertyMap Properties; std::vector<std::string> GetPropertyList() const; - const char* GetProperty(const std::string&) const; + cmProp GetProperty(const std::string&) const; void SetProperty(const std::string& property, const char* value); void AppendProperty(const std::string& property, const std::string& value, bool asString = false); @@ -54,7 +54,7 @@ public: void Next(); std::string GetName() const { return this->Position->first; } std::vector<std::string> GetPropertyList() const; - const char* GetProperty(const std::string&) const; + cmProp 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); @@ -121,19 +121,19 @@ public: int GetSize() { return static_cast<int>(this->Cache.size()); } //! Get a value from the cache given a key - const std::string* GetInitializedCacheValue(const std::string& key) const; + cmProp GetInitializedCacheValue(const std::string& key) const; - const char* GetCacheEntryValue(const std::string& key) + cmProp GetCacheEntryValue(const std::string& key) { cmCacheManager::CacheIterator it = this->GetCacheIterator(key); if (it.IsAtEnd()) { return nullptr; } - return it.GetValue().c_str(); + return &it.GetValue(); } - const char* GetCacheEntryProperty(std::string const& key, - std::string const& propName) + cmProp GetCacheEntryProperty(std::string const& key, + std::string const& propName) { return this->GetCacheIterator(key).GetProperty(propName); } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index da04396..9c26f61 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -101,29 +101,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, this->SrcFileSignature = true; cmStateEnums::TargetType targetType = cmStateEnums::EXECUTABLE; - const char* tt = - this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE"); - if (!isTryRun && tt && *tt) { - if (strcmp(tt, cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE)) == - 0) { + const std::string* tt = + this->Makefile->GetDef("CMAKE_TRY_COMPILE_TARGET_TYPE"); + if (!isTryRun && tt && !tt->empty()) { + if (*tt == cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE)) { targetType = cmStateEnums::EXECUTABLE; - } else if (strcmp(tt, - cmState::GetTargetTypeName( - cmStateEnums::STATIC_LIBRARY)) == 0) { + } else if (*tt == + cmState::GetTargetTypeName(cmStateEnums::STATIC_LIBRARY)) { targetType = cmStateEnums::STATIC_LIBRARY; } else { this->Makefile->IssueMessage( MessageType::FATAL_ERROR, - std::string("Invalid value '") + tt + - "' for " - "CMAKE_TRY_COMPILE_TARGET_TYPE. Only " - "'" + - cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE) + - "' and " - "'" + - cmState::GetTargetTypeName(cmStateEnums::STATIC_LIBRARY) + - "' " - "are allowed."); + cmStrCat("Invalid value '", *tt, + "' for CMAKE_TRY_COMPILE_TARGET_TYPE. Only '", + cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE), + "' and '", + cmState::GetTargetTypeName(cmStateEnums::STATIC_LIBRARY), + "' are allowed.")); return -1; } } @@ -296,12 +290,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, default: this->Makefile->IssueMessage( MessageType::FATAL_ERROR, - "Only libraries may be used as try_compile or try_run IMPORTED " - "LINK_LIBRARIES. Got " + - std::string(tgt->GetName()) + - " of " - "type " + - cmState::GetTargetTypeName(tgt->GetType()) + "."); + cmStrCat("Only libraries may be used as try_compile or try_run " + "IMPORTED LINK_LIBRARIES. Got ", + tgt->GetName(), " of type ", + cmState::GetTargetTypeName(tgt->GetType()), ".")); return -1; } if (tgt->IsImported()) { diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 8b450d0..4603b13 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2327,12 +2327,9 @@ bool HandleLockCommand(std::vector<std::string> const& args, path += "/cmake.lock"; } - if (!cmsys::SystemTools::FileIsFullPath(path)) { - path = status.GetMakefile().GetCurrentSourceDirectory() + "/" + path; - } - // Unify path (remove '//', '/../', ...) - path = cmSystemTools::CollapseFullPath(path); + path = cmSystemTools::CollapseFullPath( + path, status.GetMakefile().GetCurrentSourceDirectory()); // Create file and directories if needed std::string parentDir = cmSystemTools::GetParentDirectory(path); diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index 64438d5..65b3457 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -7,7 +7,6 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" -#include "cmStringAlgorithms.h" #include "cmSystemTools.h" namespace { @@ -37,14 +36,8 @@ bool cmGetDirectoryPropertyCommand(std::vector<std::string> const& args, "DIRECTORY argument provided without subsequent arguments"); return false; } - std::string sd = *i; - // make sure the start dir is a full path - if (!cmSystemTools::FileIsFullPath(sd)) { - sd = cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', *i); - } - - // The local generators are associated with collapsed paths. - sd = cmSystemTools::CollapseFullPath(sd); + std::string sd = cmSystemTools::CollapseFullPath( + *i, status.GetMakefile().GetCurrentSourceDirectory()); // lookup the makefile from the directory name dir = status.GetMakefile().GetGlobalGenerator()->FindMakefile(sd); diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 947d893..2c3adde 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -256,14 +256,8 @@ bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name, if (!name.empty()) { // Construct the directory name. Interpret relative paths with // respect to the current directory. - std::string dir = name; - if (!cmSystemTools::FileIsFullPath(dir)) { - dir = - cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', name); - } - - // The local generators are associated with collapsed paths. - dir = cmSystemTools::CollapseFullPath(dir); + std::string dir = cmSystemTools::CollapseFullPath( + name, status.GetMakefile().GetCurrentSourceDirectory()); // Lookup the generator. mf = status.GetMakefile().GetGlobalGenerator()->FindMakefile(dir); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d58113c..94483ca 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1009,7 +1009,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand( // Get a stream where to generate things. this->CompileCommandsStream = cm::make_unique<cmGeneratedFileStream>(buildFilePath); - *this->CompileCommandsStream << "["; + *this->CompileCommandsStream << "[\n"; } else { *this->CompileCommandsStream << "," << std::endl; } @@ -1021,7 +1021,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand( } /* clang-format off */ - *this->CompileCommandsStream << "\n{\n" + *this->CompileCommandsStream << "{\n" << R"( "directory": ")" << cmGlobalGenerator::EscapeJSON(buildFileDir) << "\",\n" << R"( "command": ")" diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 7daca74..e213023 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -697,9 +697,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # in target - progCmd << lg.ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(progress.Dir), - cmOutputConverter::SHELL); + progCmd << lg.ConvertToOutputFormat(progress.Dir, + cmOutputConverter::SHELL); // std::set<cmGeneratorTarget const*> emitted; progCmd << " " @@ -711,9 +710,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( { std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 - progCmd << lg.ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(progress.Dir), - cmOutputConverter::SHELL); + progCmd << lg.ConvertToOutputFormat(progress.Dir, + cmOutputConverter::SHELL); progCmd << " 0"; commands.push_back(progCmd.str()); } diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 92258e2..5790e16 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -1,5 +1,15 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ + +#if !defined(_WIN32) && !defined(__sun) +// POSIX APIs are needed +# define _POSIX_C_SOURCE 200809L +#endif +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +// For isascii +# define _XOPEN_SOURCE 700 +#endif + #include "cmLoadCommandCommand.h" #include <csignal> diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a7799b6..e7cc189 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -877,7 +877,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if ((sep[0] != ' ') && !flags.empty() && flags.back() == sep[0]) { flags.back() = ' '; } - return flags; + return cmTrimWhitespace(flags); } void cmLocalGenerator::AddCompileOptions(std::string& flags, @@ -1390,8 +1390,8 @@ void cmLocalGenerator::GetTargetFlags( for (cmSourceFile* sf : sources) { if (sf->GetExtension() == "def") { sharedLibFlags += defFlag; - sharedLibFlags += this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(sf->ResolveFullPath()), SHELL); + sharedLibFlags += + this->ConvertToOutputFormat(sf->ResolveFullPath(), SHELL); sharedLibFlags += " "; } } @@ -2396,7 +2396,9 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, void cmLocalGenerator::AppendFlags(std::string& flags, const std::string& newFlags) const { - if (!newFlags.empty()) { + bool allSpaces = std::all_of(newFlags.begin(), newFlags.end(), cmIsSpace); + + if (!newFlags.empty() && !allSpaces) { if (!flags.empty()) { flags += " "; } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index be1dd0d..1568397 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -144,8 +144,9 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference( bool forceFullPaths) { if (forceFullPaths) { - return this->ConvertToOutputFormat(cmSystemTools::CollapseFullPath(path), - format); + return this->ConvertToOutputFormat( + cmSystemTools::CollapseFullPath(path, this->GetCurrentBinaryDirectory()), + format); } return this->ConvertToOutputFormat( this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), path), diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 63c6680..3191350 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -623,8 +623,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeVariables( this->MaybeConvertWatcomShellCommand(cmSystemTools::GetCMakeCommand()); if (cmakeShellCommand.empty()) { cmakeShellCommand = this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(cmSystemTools::GetCMakeCommand()), - cmOutputConverter::SHELL); + cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL); } /* clang-format off */ @@ -648,16 +647,14 @@ void cmLocalUnixMakefileGenerator3::WriteMakeVariables( << "# The top-level source directory on which CMake was run.\n" << "CMAKE_SOURCE_DIR = " << this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(this->GetSourceDirectory()), - cmOutputConverter::SHELL) + this->GetSourceDirectory(), cmOutputConverter::SHELL) << "\n" << "\n"; makefileStream << "# The top-level build directory on which CMake was run.\n" << "CMAKE_BINARY_DIR = " << this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(this->GetBinaryDirectory()), - cmOutputConverter::SHELL) + this->GetBinaryDirectory(), cmOutputConverter::SHELL) << "\n" << "\n"; /* clang-format on */ @@ -974,7 +971,8 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( // Expand rule variables referenced in the given launcher command. cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = target->GetName().c_str(); - vars.CMTargetType = cmState::GetTargetTypeName(target->GetType()); + vars.CMTargetType = + cmState::GetTargetTypeName(target->GetType()).c_str(); std::string output; const std::vector<std::string>& outputs = ccg.GetOutputs(); if (!outputs.empty()) { @@ -1053,10 +1051,9 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand( cleanfile += filename; } cleanfile += ".cmake"; - std::string cleanfilePath = cmSystemTools::CollapseFullPath(cleanfile); - cmsys::ofstream fout(cleanfilePath.c_str()); + cmsys::ofstream fout(cleanfile.c_str()); if (!fout) { - cmSystemTools::Error("Could not create " + cleanfilePath); + cmSystemTools::Error("Could not create " + cleanfile); } if (!files.empty()) { fout << "file(REMOVE_RECURSE\n"; @@ -1116,10 +1113,9 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( cmStrCat(currentBinaryDir, "/CMakeFiles/cmake_directory_clean.cmake"); // Write clean script { - std::string cleanfilePath = cmSystemTools::CollapseFullPath(cleanfile); - cmsys::ofstream fout(cleanfilePath.c_str()); + cmsys::ofstream fout(cleanfile.c_str()); if (!fout) { - cmSystemTools::Error("Could not create " + cleanfilePath); + cmSystemTools::Error("Could not create " + cleanfile); return; } fout << "file(REMOVE_RECURSE\n"; @@ -1190,9 +1186,8 @@ void cmLocalUnixMakefileGenerator3::AppendEcho( color_name); if (progress) { cmd += "--progress-dir="; - cmd += this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(progress->Dir), - cmOutputConverter::SHELL); + cmd += this->ConvertToOutputFormat(progress->Dir, + cmOutputConverter::SHELL); cmd += " "; cmd += "--progress-num="; cmd += progress->Arg; @@ -1632,15 +1627,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( { std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; - progCmd << this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL); + progCmd << this->ConvertToOutputFormat(progressDir, + cmOutputConverter::SHELL); std::string progressFile = "/CMakeFiles/progress.marks"; std::string progressFileNameFull = this->ConvertToFullPath(progressFile); progCmd << " " - << this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(progressFileNameFull), - cmOutputConverter::SHELL); + << this->ConvertToOutputFormat(progressFileNameFull, + cmOutputConverter::SHELL); commands.push_back(progCmd.str()); } std::string mf2Dir = "CMakeFiles/Makefile2"; @@ -1650,8 +1644,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( { std::ostringstream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 - progCmd << this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL); + progCmd << this->ConvertToOutputFormat(progressDir, + cmOutputConverter::SHELL); progCmd << " 0"; commands.push_back(progCmd.str()); } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 74219b5..51bf3d9 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -225,7 +225,6 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() std::string makefileIn = cmStrCat(this->GetCurrentSourceDirectory(), "/CMakeLists.txt"); - makefileIn = cmSystemTools::CollapseFullPath(makefileIn); if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) { if (file->GetCustomCommand()) { return file; @@ -256,8 +255,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() "--check-stamp-file", stampName }); std::string comment = cmStrCat("Building Custom Rule ", makefileIn); const char* no_working_directory = nullptr; - std::string fullpathStampName = cmSystemTools::CollapseFullPath(stampName); - this->AddCustomCommandToOutput(fullpathStampName, listFiles, makefileIn, + this->AddCustomCommandToOutput(stampName, listFiles, makefileIn, commandLines, comment.c_str(), no_working_directory, true, false); if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) { diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 8d50898..7267976 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -154,8 +154,7 @@ std::string cmLocalVisualStudioGenerator::ConstructScript( script += newline; newline = newline_text; script += "cd "; - script += this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(workingDirectory), SHELL); + script += this->ConvertToOutputFormat(workingDirectory, SHELL); script += check_error; // Change the working drive. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 0471a45..4fe10ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -547,7 +547,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = this->GeneratorTarget->GetName().c_str(); vars.CMTargetType = - cmState::GetTargetTypeName(this->GeneratorTarget->GetType()); + cmState::GetTargetTypeName(this->GeneratorTarget->GetType()).c_str(); vars.Language = linkLanguage.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index d3f3a4f..4434f1d 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -756,7 +756,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( vars.CMTargetName = this->GeneratorTarget->GetName().c_str(); vars.CMTargetType = - cmState::GetTargetTypeName(this->GeneratorTarget->GetType()); + cmState::GetTargetTypeName(this->GeneratorTarget->GetType()).c_str(); vars.Language = linkLanguage.c_str(); vars.AIXExports = aixExports.c_str(); vars.Objects = buildObjs.c_str(); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 451f19e..f0fc34f 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -639,7 +639,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = this->GeneratorTarget->GetName().c_str(); vars.CMTargetType = - cmState::GetTargetTypeName(this->GeneratorTarget->GetType()); + cmState::GetTargetTypeName(this->GeneratorTarget->GetType()).c_str(); vars.Language = lang.c_str(); vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); @@ -716,8 +716,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( // no launcher for CMAKE_EXPORT_COMPILE_COMMANDS rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, compileCommand, vars); - std::string workingDirectory = cmSystemTools::CollapseFullPath( - this->LocalGenerator->GetCurrentBinaryDirectory()); + std::string workingDirectory = + this->LocalGenerator->GetCurrentBinaryDirectory(); compileCommand.replace(compileCommand.find(langFlags), langFlags.size(), this->GetFlags(lang, this->GetConfigName())); std::string langDefines = std::string("$(") + lang + "_DEFINES)"; @@ -1129,8 +1129,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() // translation table for the dependency scanning process. depCmd << "cd " << (this->LocalGenerator->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath( - this->LocalGenerator->GetBinaryDirectory()), + this->LocalGenerator->GetBinaryDirectory(), cmOutputConverter::SHELL)) << " && "; #endif @@ -1146,23 +1145,19 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() depCmd << "$(CMAKE_COMMAND) -E cmake_depends \"" << this->GlobalGenerator->GetName() << "\" " << this->LocalGenerator->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath( - this->LocalGenerator->GetSourceDirectory()), + this->LocalGenerator->GetSourceDirectory(), cmOutputConverter::SHELL) << " " << this->LocalGenerator->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath( - this->LocalGenerator->GetCurrentSourceDirectory()), + this->LocalGenerator->GetCurrentSourceDirectory(), cmOutputConverter::SHELL) << " " << this->LocalGenerator->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath( - this->LocalGenerator->GetBinaryDirectory()), + this->LocalGenerator->GetBinaryDirectory(), cmOutputConverter::SHELL) << " " << this->LocalGenerator->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath( - this->LocalGenerator->GetCurrentBinaryDirectory()), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmOutputConverter::SHELL) << " " << this->LocalGenerator->ConvertToOutputFormat( @@ -1250,8 +1245,10 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile( // Setup implicit dependency scanning. for (auto const& idi : ccg.GetCC().GetImplicitDepends()) { - std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]); - std::string srcFullPath = cmSystemTools::CollapseFullPath(idi.second); + std::string objFullPath = cmSystemTools::CollapseFullPath( + outputs[0], this->LocalGenerator->GetCurrentBinaryDirectory()); + std::string srcFullPath = cmSystemTools::CollapseFullPath( + idi.second, this->LocalGenerator->GetCurrentBinaryDirectory()); this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi.first, objFullPath, srcFullPath); } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 062c46c..9c4ff83 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -156,23 +156,25 @@ const char* cmNinjaNormalTargetGenerator::GetVisibleTypeName() const std::string cmNinjaNormalTargetGenerator::LanguageLinkerRule( const std::string& config) const { - return this->TargetLinkLanguage(config) + "_" + - cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) + - "_LINKER__" + + return cmStrCat( + this->TargetLinkLanguage(config), "_", + cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()), + "_LINKER__", cmGlobalNinjaGenerator::EncodeRuleName( - this->GetGeneratorTarget()->GetName()) + - "_" + config; + this->GetGeneratorTarget()->GetName()), + "_", config); } std::string cmNinjaNormalTargetGenerator::LanguageLinkerDeviceRule( const std::string& config) const { - return this->TargetLinkLanguage(config) + "_" + - cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) + - "_DEVICE_LINKER__" + + return cmStrCat( + this->TargetLinkLanguage(config), "_", + cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()), + "_DEVICE_LINKER__", cmGlobalNinjaGenerator::EncodeRuleName( - this->GetGeneratorTarget()->GetName()) + - "_" + config; + this->GetGeneratorTarget()->GetName()), + "_", config); } struct cmNinjaRemoveNoOpCommands @@ -191,7 +193,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule( cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str(); vars.CMTargetType = - cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()); + cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) + .c_str(); vars.Language = "CUDA"; @@ -282,7 +285,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile, cmNinjaRule rule(std::move(linkRuleName)); cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str(); - vars.CMTargetType = cmState::GetTargetTypeName(targetType); + vars.CMTargetType = cmState::GetTargetTypeName(targetType).c_str(); std::string lang = this->TargetLinkLanguage(config); vars.Language = config.c_str(); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0e1136f..8833fa4 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -495,7 +495,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str(); vars.CMTargetType = - cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()); + cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()).c_str(); vars.Language = lang.c_str(); vars.Source = "$in"; vars.Object = "$out"; diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 5ab1b3a..254131b 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -236,8 +236,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( } if (variable == "CMAKE_COMMAND") { return outputConverter->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(cmSystemTools::GetCMakeCommand()), - cmOutputConverter::SHELL); + cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL); } auto compIt = this->Compilers.find(variable); @@ -334,7 +333,17 @@ void cmRulePlaceholderExpander::ExpandRuleVariables( std::string replace = this->ExpandRuleVariable(outputConverter, var, replaceValues); expandedInput += s.substr(pos, start - pos); + + // Prevent consecutive whitespace in the output if the rule variable + // expands to an empty string. + bool consecutive = replace.empty() && start > 0 && s[start - 1] == ' ' && + end + 1 < s.size() && s[end + 1] == ' '; + if (consecutive) { + expandedInput.pop_back(); + } + expandedInput += replace; + // move to next one start = s.find('<', start + var.size() + 2); pos = end + 1; diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index e7330ef..4dbbbd7 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -235,14 +235,8 @@ bool HandleDirectoryMode(cmExecutionStatus& status, if (!names.empty()) { // Construct the directory name. Interpret relative paths with // respect to the current directory. - std::string dir = *names.begin(); - if (!cmSystemTools::FileIsFullPath(dir)) { - dir = cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', - *names.begin()); - } - - // The local generators are associated with collapsed paths. - dir = cmSystemTools::CollapseFullPath(dir); + std::string dir = cmSystemTools::CollapseFullPath( + *names.begin(), status.GetMakefile().GetCurrentSourceDirectory()); mf = status.GetMakefile().GetGlobalGenerator()->FindMakefile(dir); if (!mf) { diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index cc62952..8350410 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -30,18 +30,6 @@ std::vector<std::string> tokenizePath(const std::string& path) return cmTokenize(path, "\\/"); } -std::string getFullFilePath(const std::string& currentPath, - const std::string& path) -{ - std::string fullPath = path; - - if (!cmSystemTools::FileIsFullPath(path)) { - fullPath = cmStrCat(currentPath, '/', path); - } - - return cmSystemTools::CollapseFullPath(fullPath); -} - std::set<std::string> getSourceGroupFilesPaths( const std::string& root, const std::vector<std::string>& files) { @@ -124,7 +112,8 @@ bool addFilesToItsSourceGroups(const std::string& root, errorMsg = "Could not create source group for file: " + sgFilesPath; return false; } - const std::string fullPath = getFullFilePath(root, sgFilesPath); + const std::string fullPath = + cmSystemTools::CollapseFullPath(sgFilesPath, root); sg->AddGroupFile(fullPath); } } @@ -255,10 +244,8 @@ bool cmSourceGroupCommand(std::vector<std::string> const& args, parsedArguments[kFilesOptionName]; for (auto const& filesArg : filesArguments) { std::string src = filesArg; - if (!cmSystemTools::FileIsFullPath(src)) { - src = cmStrCat(mf.GetCurrentSourceDirectory(), '/', filesArg); - } - src = cmSystemTools::CollapseFullPath(src); + src = + cmSystemTools::CollapseFullPath(src, mf.GetCurrentSourceDirectory()); sg->AddGroupFile(src); } } diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h index 13f7622..55d23c1 100644 --- a/Source/cmStandardLexer.h +++ b/Source/cmStandardLexer.h @@ -3,6 +3,19 @@ #ifndef cmStandardLexer_h #define cmStandardLexer_h +#if !defined(_WIN32) && !defined(__sun) +/* POSIX APIs are needed */ +# define _POSIX_C_SOURCE 200809L +#endif +#if defined(__sun) && defined(__GNUC__) && !defined(__cplusplus) +/* C sources: for fileno and strdup */ +# define _XOPEN_SOURCE 600 +#endif +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +/* For isascii */ +# define _XOPEN_SOURCE 700 +#endif + #include "cmsys/Configure.h" // IWYU pragma: keep /* Disable some warnings. */ diff --git a/Source/cmState.cxx b/Source/cmState.cxx index bc08223..6d95c7a 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -34,30 +34,44 @@ cmState::cmState() cmState::~cmState() = default; -const char* cmState::GetTargetTypeName(cmStateEnums::TargetType targetType) -{ +const std::string& cmState::GetTargetTypeName( + cmStateEnums::TargetType targetType) +{ +#define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP + MAKE_STATIC_PROP(STATIC_LIBRARY); + MAKE_STATIC_PROP(MODULE_LIBRARY); + MAKE_STATIC_PROP(SHARED_LIBRARY); + MAKE_STATIC_PROP(OBJECT_LIBRARY); + MAKE_STATIC_PROP(EXECUTABLE); + MAKE_STATIC_PROP(UTILITY); + MAKE_STATIC_PROP(GLOBAL_TARGET); + MAKE_STATIC_PROP(INTERFACE_LIBRARY); + MAKE_STATIC_PROP(UNKNOWN_LIBRARY); + static const std::string propEmpty; +#undef MAKE_STATIC_PROP + switch (targetType) { case cmStateEnums::STATIC_LIBRARY: - return "STATIC_LIBRARY"; + return propSTATIC_LIBRARY; case cmStateEnums::MODULE_LIBRARY: - return "MODULE_LIBRARY"; + return propMODULE_LIBRARY; case cmStateEnums::SHARED_LIBRARY: - return "SHARED_LIBRARY"; + return propSHARED_LIBRARY; case cmStateEnums::OBJECT_LIBRARY: - return "OBJECT_LIBRARY"; + return propOBJECT_LIBRARY; case cmStateEnums::EXECUTABLE: - return "EXECUTABLE"; + return propEXECUTABLE; case cmStateEnums::UTILITY: - return "UTILITY"; + return propUTILITY; case cmStateEnums::GLOBAL_TARGET: - return "GLOBAL_TARGET"; + return propGLOBAL_TARGET; case cmStateEnums::INTERFACE_LIBRARY: - return "INTERFACE_LIBRARY"; + return propINTERFACE_LIBRARY; case cmStateEnums::UNKNOWN_LIBRARY: - return "UNKNOWN_LIBRARY"; + return propUNKNOWN_LIBRARY; } assert(false && "Unexpected target type"); - return nullptr; + return propEmpty; } static const std::array<std::string, 7> cmCacheEntryTypes = { @@ -199,7 +213,8 @@ const char* cmState::GetCacheEntryProperty(std::string const& key, if (!it.PropertyExists(propertyName)) { return nullptr; } - return it.GetProperty(propertyName); + cmProp retVal = it.GetProperty(propertyName); + return retVal ? retVal->c_str() : nullptr; } bool cmState::GetCacheEntryPropertyAsBool(std::string const& key, diff --git a/Source/cmState.h b/Source/cmState.h index b577a72..89400d6 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -53,7 +53,8 @@ public: CPack, }; - static const char* GetTargetTypeName(cmStateEnums::TargetType targetType); + static const std::string& GetTargetTypeName( + cmStateEnums::TargetType targetType); cmStateSnapshot CreateBaseSnapshot(); cmStateSnapshot CreateBuildsystemDirectorySnapshot( diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index d8cd705..81f76ca 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1,5 +1,15 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ + +#if !defined(_WIN32) && !defined(__sun) +// POSIX APIs are needed +# define _POSIX_C_SOURCE 200809L +#endif +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +// For isascii +# define _XOPEN_SOURCE 700 +#endif + #include "cmSystemTools.h" #include <cmext/algorithm> diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 03f1525..872f02c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1668,7 +1668,7 @@ const char* cmTarget::GetProperty(const std::string& prop) const } // the type property returns what type the target is if (prop == propTYPE) { - return cmState::GetTargetTypeName(this->GetType()); + return cmState::GetTargetTypeName(this->GetType()).c_str(); } if (prop == propINCLUDE_DIRECTORIES) { if (impl->IncludeDirectoriesEntries.empty()) { diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 390fd16..13f73dc 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -1,5 +1,15 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ + +#if !defined(_WIN32) && !defined(__sun) +// POSIX APIs are needed +# define _POSIX_C_SOURCE 200809L +#endif +#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) +// For isascii +# define _XOPEN_SOURCE 700 +#endif + #include "cmTimestamp.h" #include <cstdlib> diff --git a/Tests/FindRuby/CMakeLists.txt b/Tests/FindRuby/CMakeLists.txt index 193cb4f..3f4807c 100644 --- a/Tests/FindRuby/CMakeLists.txt +++ b/Tests/FindRuby/CMakeLists.txt @@ -24,7 +24,7 @@ if(CMake_TEST_FindRuby) --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> ) set_tests_properties(FindRuby.Fail PROPERTIES - PASS_REGULAR_EXPRESSION "Could NOT find Ruby: Found unsuitable version \".*\", but required is.*least \"[0-9]+\\.[0-9]+\\.[0-9]+\" \\(found .*\\)") + PASS_REGULAR_EXPRESSION "Could NOT find Ruby.*(Required is at least version \"[0-9]+\\.[0-9]+\\.[0-9]+\")") # Looks for 1.9.9 EXACTLY, which unlike the "FindRuby" test above will fail on every machine # since this version doesn't exist (ruby goes from 1.9.3 to 2.0.0) @@ -41,4 +41,17 @@ if(CMake_TEST_FindRuby) set_tests_properties(FindRuby.FailExact PROPERTIES PASS_REGULAR_EXPRESSION "Could NOT find Ruby: Found unsuitable version \".*\", but required is.*exact version \"[0-9]+\\.[0-9]+\\.[0-9]+\" \\(found .*\\)") + # RVM specific test + if(CMake_TEST_FindRuby_RVM) + add_test(NAME FindRuby.Rvm COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindRuby/Rvm" + "${CMake_BINARY_DIR}/Tests/FindRuby/Rvm" + ${build_generator_args} + --build-project TestRVM + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) + endif() endif() diff --git a/Tests/FindRuby/Rvm/CMakeLists.txt b/Tests/FindRuby/Rvm/CMakeLists.txt new file mode 100644 index 0000000..545fc94 --- /dev/null +++ b/Tests/FindRuby/Rvm/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.17) +project(TestRVM LANGUAGES NONE) + +include(CTest) + +# To run this test, you need to have at least one RVM ruby installed +# and to ensure that the env variable 'MY_RUBY_HOME' is set to a valid RVM ruby when you run the test +# (which is the case if you have done `rvm use x.y.z`, but could be manually set too) + +# Properly using rvm would require sourcing a shell script, eg `source "$HOME/.rvm/scripts/rvm"` +# Instead, I'll just rely on the env variable MY_RUBY_HOME +set(MY_RUBY_HOME "$ENV{MY_RUBY_HOME}") +if(NOT MY_RUBY_HOME) + message(FATAL_ERROR "Env variable MY_RUBY_HOME should be set to a valid RVM ruby location, or you should call `rvm use x.y.z` before") +endif() +execute_process (COMMAND "${MY_RUBY_HOME}/bin/ruby" -e "puts RUBY_VERSION" + RESULT_VARIABLE result + OUTPUT_VARIABLE RVM_RUBY_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +if (result) + message (FATAL_ERROR "Unable to detect RVM ruby version from `${MY_RUBY_HOME}/bin/ruby`: ${RVM_RUBY_VERSION}") +endif() + +execute_process(COMMAND "${CMAKE_COMMAND}" -E env --unset=MY_RUBY_HOME --unset=PATH + "which" "ruby" + RESULT_VARIABLE result + OUTPUT_VARIABLE SYSTEM_RUBY + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +if (SYSTEM_RUBY MATCHES "^${MY_RUBY_HOME}/.+") + message(FATAL_ERROR "Unable to find system ruby, found ${SYSTEM_RUBY} which is part of MY_RUBY_HOME=${MY_RUBY_HOME}") +endif() + +# Check version of the system ruby executable. +execute_process (COMMAND "${SYSTEM_RUBY}" -e "puts RUBY_VERSION" + RESULT_VARIABLE result + OUTPUT_VARIABLE SYSTEM_RUBY_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +if (result) + message (FATAL_ERROR "Unable to detect system ruby version from '${SYSTEM_RUBY}': ${SYSTEM_RUBY_VERSION}") +endif() + +if(SYSTEM_RUBY_VERSION VERSION_EQUAL RVM_RUBY_VERSION) + message(FATAL_ERROR "Your RVM Ruby Version and your System ruby version are the same (${RVM_RUBY_VERSION}).") +endif() + +message("Found System Ruby (${SYSTEM_RUBY_VERSION}): ${SYSTEM_RUBY}") +message("Found RVM Ruby (${RVM_RUBY_VERSION}): ${MY_RUBY_HOME}/bin/ruby") + +add_test(NAME FindRuby.RvmDefault + COMMAND "${CMAKE_COMMAND}" -E env "MY_RUBY_HOME=${MY_RUBY_HOME}" + "${CMAKE_COMMAND}" "-DRUBY_HOME=${MY_RUBY_HOME}" + -P "${CMAKE_CURRENT_LIST_DIR}/RvmDefault.cmake") + +add_test(NAME FindRuby.RvmOnly + COMMAND "${CMAKE_COMMAND}" -E env --unset=PATH + "MY_RUBY_HOME=${MY_RUBY_HOME}" + "${CMAKE_COMMAND}" "-DRUBY_HOME=${MY_RUBY_HOME}" + "-DRVM_RUBY_VERSION=${RVM_RUBY_VERSION}" "-DSYSTEM_RUBY_VERSION=${SYSTEM_RUBY_VERSION}" + -P "${CMAKE_CURRENT_LIST_DIR}/RvmOnly.cmake") +add_test(NAME FindRuby.UnsetRvmOnly + COMMAND "${CMAKE_COMMAND}" -E env --unset=MY_RUBY_HOME "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" + "${CMAKE_COMMAND}" "-DRVM_RUBY_VERSION=${RVM_RUBY_VERSION}" "-DSYSTEM_RUBY_VERSION=${SYSTEM_RUBY_VERSION}" + -P "${CMAKE_CURRENT_LIST_DIR}/RvmOnly.cmake") + +add_test(NAME FindRuby.RvmStandard + COMMAND "${CMAKE_COMMAND}" -E env "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" + "MY_RUBY_HOME=${MY_RUBY_HOME}" + "${CMAKE_COMMAND}" "-DRUBY_HOME=${MY_RUBY_HOME}" + -P "${CMAKE_CURRENT_LIST_DIR}/RvmStandard.cmake") diff --git a/Tests/FindRuby/Rvm/RvmDefault.cmake b/Tests/FindRuby/Rvm/RvmDefault.cmake new file mode 100644 index 0000000..a66b911 --- /dev/null +++ b/Tests/FindRuby/Rvm/RvmDefault.cmake @@ -0,0 +1,17 @@ +set(CMAKE_FIND_LIBRARY_PREFIXES "") +set(CMAKE_FIND_LIBRARY_SUFFIXES "") + +find_package (Ruby 2.1.1 REQUIRED) +if (NOT RUBY_EXECUTABLE MATCHES "^${RUBY_HOME}/.+") + message (FATAL_ERROR "Failed to use RVM environment: ${RUBY_EXECUTABLE}, ${RUBY_HOME}") +endif() + +find_package (Ruby 2.1 REQUIRED) +if (NOT RUBY_EXECUTABLE MATCHES "^${RUBY_HOME}/.+") + message (FATAL_ERROR "Failed to use RVM environment: ${RUBY_EXECUTABLE}, ${RUBY_HOME}") +endif() + +find_package (Ruby REQUIRED) +if (NOT RUBY_EXECUTABLE MATCHES "^${RUBY_HOME}/.+") + message (FATAL_ERROR "Failed to use RVM environment: ${RUBY_EXECUTABLE}, ${RUBY_HOME}") +endif() diff --git a/Tests/FindRuby/Rvm/RvmOnly.cmake b/Tests/FindRuby/Rvm/RvmOnly.cmake new file mode 100644 index 0000000..3851a7c --- /dev/null +++ b/Tests/FindRuby/Rvm/RvmOnly.cmake @@ -0,0 +1,41 @@ +set(CMAKE_FIND_LIBRARY_PREFIXES "") +set(CMAKE_FIND_LIBRARY_SUFFIXES "") + +set(Ruby_FIND_VIRTUALENV ONLY) + +# Test: FindRuby.RvmOnly +if (RUBY_HOME) + # => Trying to find exactly system ruby using ONLY virtual environment should fail + find_package (Ruby ${SYSTEM_RUBY_VERSION} EXACT QUIET) + if(Ruby_FOUND) + message (FATAL_ERROR "Ruby unexpectedly found.") + endif() + # And should work to find the rvm version + find_package (Ruby ${RVM_RUBY_VERSION} EXACT QUIET) + if(Ruby_FOUND) + message (FATAL_ERROR "Ruby unexpectedly found.") + endif() +endif() + + +# Test: FindRuby.UnsetRvmOnly +if (NOT RUBY_HOME) + + # If ENV{MY_RUBY_HOME} isn't defined, it should default back to "STANDARD" + # At which point: + + # It shouldn't find the RVM ruby + find_package (Ruby ${RVM_RUBY_VERSION} EXACT QUIET) + if(Ruby_FOUND) + message(FATAL_ERROR "Found RVM ruby when expecting system") + endif() + + # it should find the system ruby + find_package (Ruby ${SYSTEM_RUBY_VERSION} EXACT QUIET) + if(NOT Ruby_FOUND) + message (FATAL_ERROR "Ruby not found.") + endif() + if (Ruby_FOUND MATCHES "^${RUBY_HOME}/.+") + message(FATAL_ERROR "Failed to find system ruby") + endif() +endif() diff --git a/Tests/FindRuby/Rvm/RvmStandard.cmake b/Tests/FindRuby/Rvm/RvmStandard.cmake new file mode 100644 index 0000000..26befdb7 --- /dev/null +++ b/Tests/FindRuby/Rvm/RvmStandard.cmake @@ -0,0 +1,9 @@ +set(CMAKE_FIND_LIBRARY_PREFIXES "") +set(CMAKE_FIND_LIBRARY_SUFFIXES "") + +set (Ruby_FIND_VIRTUALENV STANDARD) +find_package (Ruby REQUIRED) + +if (RUBY_EXECUTABLE MATCHES "^${RUBY_HOME}/.+") + message (FATAL_ERROR "RVM ruby unexpectedly found at ${RUBY_EXECUTABLE}, matches ${RUBY_HOME}") +endif() diff --git a/Utilities/std/CMakeLists.txt b/Utilities/std/CMakeLists.txt index 63c0a60..a72abb7 100644 --- a/Utilities/std/CMakeLists.txt +++ b/Utilities/std/CMakeLists.txt @@ -1,4 +1,8 @@ +# To ensure maximum portability across various compilers and platforms +# deactivate any compiler extensions +set(CMAKE_CXX_EXTENSIONS FALSE) + # source files for CMake std library set(SRCS cm/bits/string_view.cxx cm/memory |