Переименуйте существующий файл с помощью команды установки CMake - PullRequest
0 голосов
/ 22 сентября 2018

После сборки проекта есть файл tensorflowd.dll (установленный CMake), который я хотел бы переименовать в файл tensorflow.dll на дополнительном этапе установки CMake.Можно ли просто переименовать файл (не устанавливая его как часть той же команды?)

или должен ли я выполнить переименование как часть установки файла tensorflowd.dllсам?

install_lib макрос упоминается в комментариях:

#general macro suitable for small libs where you don't want to pick and choose which dlls get installed
#separates all dlls into two lists and if debug versions are present it uses that or if it's not
# it uses the release ones instead
function(INSTALL_LIB libname)

    if(NOT "${${libname}_FOUND}" STREQUAL "TRUE")
        message("Library ${libname} is not present and cannot be installed.")
        return()
    endif()


    FILELIST(files "${${libname}_BINARY_DIRS}")


    #filter out non dll files
    foreach(file ${files})

        string(REGEX MATCH "^.*.dll$" result ${file})

        if(NOT result STREQUAL "")
            list(APPEND dll_files ${file})
        endif()

    endforeach()

    #message("${files}")

    #find if it has debug or is it only release dll that is present..
    foreach(file ${dll_files})

        string(REGEX MATCH "^.*d\\.dll$" result ${file})

        if(result STREQUAL "")
            list(APPEND optimized_libs ${file})
        else()          
            list(APPEND debug_libs ${file})
        endif()

        #workaround for edge case with libs ending with 'd' and debug versions with 'dd'
        #upon detecting XXXdd.lib the coresponding XXXd.lib must be already in optimized_libs
        #so take it from there and place it into correct list.
        string(REGEX REPLACE "^(.*d)d\\.lib$" "\\1" dd_result ${file})
            #message("${filename} ${dd_result}")

        if(NOT dd_result STREQUAL "" AND NOT ${dd_result} STREQUAL ${file})
            #message("${filename} ${dd_result}")
            list(REMOVE_ITEM debug_libs "${dd_result}.dll")
            list(APPEND optimized_libs "${dd_result}.dll")
        endif()

        set(dd_result "")
        set(result "")

    endforeach()

    list(LENGTH debug_libs debug_length)
    list(LENGTH optimized_libs optimized_length)

    #If there are debug version but their count is not on par with release version, raise a red flag.
    if(NOT "${debug_length}" EQUAL "${optimized_length}" AND "${debug_length}" GREATER 0)
        message(WARNING "Counts of debug and optimized dlls of library ${libname} are different from each other..")
    endif()

    if("${debug_length}" GREATER 0)   

        foreach(item ${debug_libs})
            install(FILES ${${libname}_BINARY_DIRS}/${item} DESTINATION Debug           CONFIGURATIONS Debug)
        endforeach()

        foreach(item ${optimized_libs})
            install(FILES ${${libname}_BINARY_DIRS}/${item} DESTINATION RelWithDebInfo  CONFIGURATIONS RelWithDebInfo)
            install(FILES ${${libname}_BINARY_DIRS}/${item} DESTINATION Release         CONFIGURATIONS Release) 
        endforeach()

    else()

        foreach(item ${optimized_libs})
            install(FILES ${${libname}_BINARY_DIRS}/${item} DESTINATION Debug           CONFIGURATIONS Debug)
            install(FILES ${${libname}_BINARY_DIRS}/${item} DESTINATION RelWithDebInfo  CONFIGURATIONS RelWithDebInfo)
            install(FILES ${${libname}_BINARY_DIRS}/${item} DESTINATION Release         CONFIGURATIONS Release) 
        endforeach()

    endif()
endfunction()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...