项目建成后
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()