inference_lib.cmake 17.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

L
Luo Tao 已提交
15
# make package for paddle fluid shared and static library
16 17
set(PADDLE_INSTALL_DIR "${CMAKE_BINARY_DIR}/paddle_install_dir" CACHE STRING
  "A path setting paddle shared and static libraries")
18

19 20
set(PADDLE_INFERENCE_INSTALL_DIR "${CMAKE_BINARY_DIR}/paddle_inference_install_dir" CACHE STRING
  "A path setting paddle inference shared and static libraries")
21
  
22 23
# At present, the size of static lib in Windows is very large,
# so we need to crop the library size.
24
if(WIN32)
25
    #todo: remove the option 
26
    option(WITH_STATIC_LIB "Compile demo with static/shared library, default use dynamic."   OFF)
27
    if(NOT PYTHON_EXECUTABLE)
28
        FIND_PACKAGE(PythonInterp REQUIRED)
29 30 31
    endif()
endif()

32
set(COPY_SCRIPT_DIR ${PADDLE_SOURCE_DIR}/cmake)
L
Luo Tao 已提交
33 34 35
function(copy TARGET)
    set(options "")
    set(oneValueArgs "")
36
    set(multiValueArgs SRCS DSTS)
L
Luo Tao 已提交
37 38 39 40
    cmake_parse_arguments(copy_lib "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    list(LENGTH copy_lib_SRCS copy_lib_SRCS_len)
    list(LENGTH copy_lib_DSTS copy_lib_DSTS_len)
41
    if (NOT ${copy_lib_SRCS_len} EQUAL ${copy_lib_DSTS_len})
L
Luo Tao 已提交
42
        message(FATAL_ERROR "${TARGET} source numbers are not equal to destination numbers")
43
    endif ()
L
Luo Tao 已提交
44
    math(EXPR len "${copy_lib_SRCS_len} - 1")
45
    foreach (index RANGE ${len})
L
Luo Tao 已提交
46 47
        list(GET copy_lib_SRCS ${index} src)
        list(GET copy_lib_DSTS ${index} dst)
48 49 50 51 52 53
        if (WIN32)   #windows
            file(TO_NATIVE_PATH ${src} native_src)
            file(TO_NATIVE_PATH ${dst} native_dst)
            add_custom_command(TARGET ${TARGET} POST_BUILD
                    COMMAND ${PYTHON_EXECUTABLE} ${COPY_SCRIPT_DIR}/copyfile.py ${native_src} ${native_dst})
        else (WIN32) #not windows
54
            add_custom_command(TARGET ${TARGET} POST_BUILD
55 56 57 58 59
                    COMMAND mkdir -p "${dst}"
                    COMMAND cp -r "${src}" "${dst}"
                    COMMENT "copying ${src} -> ${dst}")
        endif (WIN32) # not windows
    endforeach ()
L
Luo Tao 已提交
60 61
endfunction()

62 63 64 65 66 67
function(copy_part_of_thrid_party TARGET DST) 
    if(${CBLAS_PROVIDER} STREQUAL MKLML)
        set(dst_dir "${DST}/third_party/install/mklml")
        if(WIN32)
            copy(${TARGET}
                    SRCS ${MKLML_LIB} ${MKLML_IOMP_LIB} ${MKLML_SHARED_LIB}
68
                    ${MKLML_SHARED_IOMP_LIB} ${MKLML_INC_DIR}
69
                    DSTS ${dst_dir}/lib ${dst_dir}/lib ${dst_dir}/lib
70
                    ${dst_dir}/lib ${dst_dir})
71 72 73 74
        else()
            copy(${TARGET}
                    SRCS ${MKLML_LIB} ${MKLML_IOMP_LIB} ${MKLML_INC_DIR}
                    DSTS ${dst_dir}/lib ${dst_dir}/lib ${dst_dir})
75 76 77 78 79 80
            if(WITH_STRIP)
                    add_custom_command(TARGET ${TARGET} POST_BUILD
                            COMMAND strip -s ${dst_dir}/lib/libiomp5.so
                            COMMAND strip -s ${dst_dir}/lib/libmklml_intel.so
                            COMMENT "striping libiomp5.so\nstriping libmklml_intel.so")
            endif()
81 82 83
        endif()
    elseif(${CBLAS_PROVIDER} STREQUAL EXTERN_OPENBLAS)
        set(dst_dir "${DST}/third_party/install/openblas")
84 85 86 87 88
	if(WIN32)
            copy(${TARGET}
                    SRCS ${CBLAS_INSTALL_DIR}/lib ${OPENBLAS_SHARED_LIB} ${CBLAS_INSTALL_DIR}/include
                    DSTS ${dst_dir} ${dst_dir}/lib ${dst_dir})
	else()
89 90 91
            copy(${TARGET}
                    SRCS ${CBLAS_INSTALL_DIR}/lib ${CBLAS_INSTALL_DIR}/include
                    DSTS ${dst_dir} ${dst_dir})
92
	endif()
93 94 95 96 97 98
    endif()

    if(WITH_MKLDNN)
        set(dst_dir "${DST}/third_party/install/mkldnn")
        if(WIN32)
            copy(${TARGET}
A
Adam 已提交
99
                    SRCS ${MKLDNN_INC_DIR} ${MKLDNN_SHARED_LIB}  ${MKLDNN_LIB}
100 101 102
                    DSTS ${dst_dir} ${dst_dir}/lib ${dst_dir}/lib)
        else()
            copy(${TARGET}
103 104 105 106 107 108 109 110 111 112 113
                    SRCS ${MKLDNN_INC_DIR} ${MKLDNN_SHARED_LIB}
                    DSTS ${dst_dir} ${dst_dir}/lib)
            if(WITH_STRIP)
                    add_custom_command(TARGET ${TARGET} POST_BUILD
                            COMMAND strip -s ${dst_dir}/lib/libmkldnn.so.0
                            COMMENT "striping libmkldnn.so.0")
            endif()
            add_custom_command(TARGET ${TARGET} POST_BUILD
                    COMMAND ${CMAKE_COMMAND} -E create_symlink libmkldnn.so.0 ${dst_dir}/lib/libdnnl.so.1
                    COMMAND ${CMAKE_COMMAND} -E create_symlink libmkldnn.so.0 ${dst_dir}/lib/libdnnl.so.2
                    COMMENT "Make a symbol link of libmkldnn.so.0")
114 115 116 117 118 119 120 121 122 123 124 125
        endif()
    endif()

    set(dst_dir "${DST}/third_party/install/gflags")
    copy(${TARGET}
            SRCS ${GFLAGS_INCLUDE_DIR} ${GFLAGS_LIBRARIES}
            DSTS ${dst_dir} ${dst_dir}/lib)

    set(dst_dir "${DST}/third_party/install/glog")
    copy(${TARGET}
            SRCS ${GLOG_INCLUDE_DIR} ${GLOG_LIBRARIES}
            DSTS ${dst_dir} ${dst_dir}/lib)
126

S
Steffy-zxf 已提交
127 128 129 130 131
    set(dst_dir "${DST}/third_party/install/utf8proc")
    copy(${TARGET}
            SRCS ${UTF8PROC_INSTALL_DIR}/include ${UTF8PROC_LIBRARIES}
            DSTS ${dst_dir} ${dst_dir}/lib)

132
    if (WITH_CRYPTO)
M
MRXLT 已提交
133 134
        set(dst_dir "${DST}/third_party/install/cryptopp")
        copy(${TARGET}
135 136 137
            SRCS ${CRYPTOPP_INCLUDE_DIR} ${CRYPTOPP_LIBRARIES}
            DSTS ${dst_dir} ${dst_dir}/lib)
    endif()
M
MRXLT 已提交
138

139 140 141 142
    set(dst_dir "${DST}/third_party/install/xxhash")
    copy(${TARGET}
        SRCS ${XXHASH_INCLUDE_DIR} ${XXHASH_LIBRARIES}
        DSTS ${dst_dir} ${dst_dir}/lib)    
143

144 145 146 147 148 149 150
    if (NOT PROTOBUF_FOUND OR WIN32)
        set(dst_dir "${DST}/third_party/install/protobuf")
        copy(${TARGET}
                SRCS ${PROTOBUF_INCLUDE_DIR} ${PROTOBUF_LIBRARY}
                DSTS ${dst_dir} ${dst_dir}/lib)
    endif ()

151 152 153
    if (LITE_BINARY_DIR)
        set(dst_dir "${DST}/third_party/install/lite")
        copy(${TARGET}
W
Wilber 已提交
154
                SRCS ${LITE_BINARY_DIR}/${LITE_OUTPUT_BIN_DIR}/*
155 156
                DSTS ${dst_dir})
    endif()
157 158
endfunction()

159
# inference library for only inference
160
set(inference_lib_deps third_party paddle_inference paddle_inference_c paddle_inference_shared paddle_inference_c_shared)
161
add_custom_target(inference_lib_dist DEPENDS ${inference_lib_deps})
162

163

164
set(dst_dir "${PADDLE_INFERENCE_INSTALL_DIR}/third_party/threadpool")
165 166 167 168
copy(inference_lib_dist
        SRCS ${THREADPOOL_INCLUDE_DIR}/ThreadPool.h
        DSTS ${dst_dir})

169
# GPU must copy externalErrorMsg.pb
170
IF(WITH_GPU)
171 172 173 174
    set(dst_dir "${PADDLE_INFERENCE_INSTALL_DIR}/third_party/externalError/data")
    copy(inference_lib_dist
            SRCS ${externalError_INCLUDE_DIR}
            DSTS ${dst_dir})
175
ENDIF()
176

177 178 179 180 181 182 183
IF(WITH_XPU)
    set(dst_dir "${PADDLE_INFERENCE_INSTALL_DIR}/third_party/install/xpu")
    copy(inference_lib_dist
        SRCS ${XPU_INC_DIR} ${XPU_LIB_DIR}
        DSTS ${dst_dir} ${dst_dir})
ENDIF()

184
# CMakeCache Info
185
copy(inference_lib_dist
186
        SRCS ${CMAKE_CURRENT_BINARY_DIR}/CMakeCache.txt
187
        DSTS ${PADDLE_INFERENCE_INSTALL_DIR})
188

189
copy_part_of_thrid_party(inference_lib_dist ${PADDLE_INFERENCE_INSTALL_DIR})
190

191
set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid")
P
peizhilin 已提交
192
if(WIN32)
193
    if(WITH_STATIC_LIB)
194 195
        set(paddle_inference_lib $<TARGET_FILE_DIR:paddle_inference>/libpaddle_inference.lib
                             $<TARGET_FILE_DIR:paddle_inference>/paddle_inference.*)
196
    else()
197 198
        set(paddle_inference_lib $<TARGET_FILE_DIR:paddle_inference_shared>/paddle_inference.dll
                             $<TARGET_FILE_DIR:paddle_inference_shared>/paddle_inference.lib)
199
    endif()
200
    copy(inference_lib_dist
201
            SRCS  ${src_dir}/inference/api/paddle_*.h ${paddle_inference_lib}
202 203
            DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib
            ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib)
P
peizhilin 已提交
204
else(WIN32)
205
    set(paddle_inference_lib ${PADDLE_BINARY_DIR}/paddle/fluid/inference/libpaddle_inference.*)
206
    copy(inference_lib_dist
207
                SRCS  ${src_dir}/inference/api/paddle_*.h ${paddle_inference_lib}
208
                DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib)
209
endif(WIN32)
210

211 212
copy(inference_lib_dist
        SRCS  ${CMAKE_BINARY_DIR}/paddle/fluid/framework/framework.pb.h
213
        DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/internal)
M
MRXLT 已提交
214
copy(inference_lib_dist
M
MRXLT 已提交
215
        SRCS  ${PADDLE_SOURCE_DIR}/paddle/fluid/framework/io/crypto/cipher.h
216
        DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/crypto/)
M
MRXLT 已提交
217
include_directories(${CMAKE_BINARY_DIR}/../paddle/fluid/framework/io)
218

219
# copy api headers for pten & custom op
220
copy(inference_lib_dist
C
Chen Weihang 已提交
221
        SRCS  ${PADDLE_SOURCE_DIR}/paddle/pten/api/ext/*.h
222 223
        DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/pten/api/ext/)
copy(inference_lib_dist
C
Chen Weihang 已提交
224
        SRCS  ${PADDLE_SOURCE_DIR}/paddle/pten/api/include/*.h
225 226 227 228 229
        DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/pten/api/include/)
copy(inference_lib_dist
        SRCS  ${PADDLE_SOURCE_DIR}/paddle/pten/api/all.h
        DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/pten/api/)
copy(inference_lib_dist
C
Chen Weihang 已提交
230
        SRCS  ${PADDLE_SOURCE_DIR}/paddle/pten/common/*.h
231 232 233 234 235 236 237
              ${PADDLE_SOURCE_DIR}/paddle/fluid/platform/bfloat16.h
              ${PADDLE_SOURCE_DIR}/paddle/fluid/platform/complex.h
              ${PADDLE_SOURCE_DIR}/paddle/fluid/platform/float16.h
        DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/pten/common/
              ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/pten/common/
              ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/pten/common/
              ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/pten/common/)
238 239
copy(inference_lib_dist
        SRCS  ${PADDLE_SOURCE_DIR}/paddle/utils/any.h
240 241 242
        DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/utils/)
copy(inference_lib_dist
        SRCS  ${PADDLE_SOURCE_DIR}/paddle/extension.h
243
        DSTS  ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/include/experimental/)
244

245 246 247
# the header file of pten is copied to the experimental directory,
# the include path of pten needs to be changed to adapt to inference api path
add_custom_command(TARGET inference_lib_dist POST_BUILD
248
        COMMAND ${CMAKE_COMMAND} -P "${PADDLE_SOURCE_DIR}/cmake/pten_header.cmake"
249
        COMMENT "Change pten header include path to adapt to inference api path")
250

251
# CAPI inference library for only inference
252 253 254
set(PADDLE_INFERENCE_C_INSTALL_DIR "${CMAKE_BINARY_DIR}/paddle_inference_c_install_dir" CACHE STRING
"A path setting CAPI paddle inference shared")
copy_part_of_thrid_party(inference_lib_dist ${PADDLE_INFERENCE_C_INSTALL_DIR})
255 256

set(src_dir "${PADDLE_SOURCE_DIR}/paddle/fluid")
257
if(WIN32)
258
  set(paddle_inference_c_lib $<TARGET_FILE_DIR:paddle_inference_c>/paddle_inference_c.*)
259
else(WIN32)
260
  set(paddle_inference_c_lib ${PADDLE_BINARY_DIR}/paddle/fluid/inference/capi_exp/libpaddle_inference_c.*)
261
endif(WIN32)
262

263
copy(inference_lib_dist
264
      SRCS  ${src_dir}/inference/capi_exp/pd_*.h  ${paddle_inference_c_lib}
265
      DSTS  ${PADDLE_INFERENCE_C_INSTALL_DIR}/paddle/include ${PADDLE_INFERENCE_C_INSTALL_DIR}/paddle/lib)
266

267 268 269 270 271 272 273
if(WITH_STRIP AND NOT WIN32)
        add_custom_command(TARGET inference_lib_dist POST_BUILD
                COMMAND strip -s ${PADDLE_INFERENCE_C_INSTALL_DIR}/paddle/lib/libpaddle_inference_c.so
                COMMAND strip -s ${PADDLE_INFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.so
                COMMENT "striping libpaddle_inference_c.so\nstriping libpaddle_inference.so")
endif()

274 275 276 277
# fluid library for both train and inference
set(fluid_lib_deps inference_lib_dist)
add_custom_target(fluid_lib_dist ALL DEPENDS ${fluid_lib_deps})

278
set(dst_dir "${PADDLE_INSTALL_DIR}/paddle/fluid")
279
set(module "inference")
280
if(WIN32)
281
        copy(fluid_lib_dist
282
                SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/api/paddle_*.h ${paddle_inference_lib}
283 284
                DSTS ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module}
                )
285
        else()
286
        copy(fluid_lib_dist
287
                SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/api/paddle_*.h ${paddle_inference_lib}
288 289 290
                DSTS ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} 
                )
endif()
291 292

set(module "framework")
293
set(framework_lib_deps framework_proto data_feed_proto trainer_desc_proto)
294 295
add_dependencies(fluid_lib_dist ${framework_lib_deps})
copy(fluid_lib_dist
296 297 298 299 300 301 302 303 304
        SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/details/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/framework/trainer_desc.pb.h ${PADDLE_BINARY_DIR}/paddle/fluid/framework/framework.pb.h ${PADDLE_BINARY_DIR}/paddle/fluid/framework/data_feed.pb.h ${src_dir}/${module}/ir/memory_optimize_pass/*.h
        ${src_dir}/${module}/ir/*.h ${src_dir}/${module}/fleet/*.h
        DSTS ${dst_dir}/${module} ${dst_dir}/${module}/details ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module} ${dst_dir}/${module}/ir/memory_optimize_pass ${dst_dir}/${module}/ir ${dst_dir}/${module}/fleet)

set(module "operators")
copy(fluid_lib_dist
        SRCS ${src_dir}/${module}/reader/blocking_queue.h
        DSTS ${dst_dir}/${module}/reader/
        )
305 306 307 308 309

set(module "memory")
copy(fluid_lib_dist
        SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/detail/*.h ${src_dir}/${module}/allocation/*.h
        DSTS ${dst_dir}/${module} ${dst_dir}/${module}/detail ${dst_dir}/${module}/allocation
P
peizhilin 已提交
310
        )
Y
Yan Chunwei 已提交
311

L
Luo Tao 已提交
312
set(module "platform")
313 314
set(platform_lib_deps profiler_proto error_codes_proto)
if(WITH_GPU)
315
  set(platform_lib_deps ${platform_lib_deps} external_error_proto)
316 317
endif(WITH_GPU)

318 319
add_dependencies(fluid_lib_dist ${platform_lib_deps})
copy(fluid_lib_dist
320 321
        SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/dynload/*.h ${src_dir}/${module}/details/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/platform/*.pb.h
        DSTS ${dst_dir}/${module} ${dst_dir}/${module}/dynload ${dst_dir}/${module}/details ${dst_dir}/${module}
322
        )
L
Luo Tao 已提交
323

L
Luo Tao 已提交
324
set(module "string")
325
copy(fluid_lib_dist
326 327 328
        SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/tinyformat/*.h
        DSTS ${dst_dir}/${module} ${dst_dir}/${module}/tinyformat
        )
L
Luo Tao 已提交
329

330 331 332 333 334 335
set(module "imperative")
copy(fluid_lib_dist
        SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/jit/*.h 
        DSTS ${dst_dir}/${module} ${dst_dir}/${module}/jit
        )

336
set(module "pybind")
337
copy(fluid_lib_dist
338 339 340
        SRCS ${CMAKE_CURRENT_BINARY_DIR}/paddle/fluid/${module}/pybind.h
        DSTS ${dst_dir}/${module}
        )
341

342
set(dst_dir "${PADDLE_INSTALL_DIR}/third_party/eigen3")
343 344 345 346
copy(inference_lib_dist
        SRCS ${EIGEN_INCLUDE_DIR}/Eigen/Core ${EIGEN_INCLUDE_DIR}/Eigen/src ${EIGEN_INCLUDE_DIR}/unsupported/Eigen
        DSTS ${dst_dir}/Eigen ${dst_dir}/Eigen ${dst_dir}/unsupported)

347
set(dst_dir "${PADDLE_INSTALL_DIR}/third_party/boost")
348 349 350 351
copy(inference_lib_dist
        SRCS ${BOOST_INCLUDE_DIR}/boost
        DSTS ${dst_dir})

352
set(dst_dir "${PADDLE_INSTALL_DIR}/third_party/dlpack")
353 354 355 356
copy(inference_lib_dist
        SRCS ${DLPACK_INCLUDE_DIR}/dlpack
        DSTS ${dst_dir})

357
set(dst_dir "${PADDLE_INSTALL_DIR}/third_party/install/zlib")
358 359 360 361
copy(inference_lib_dist
        SRCS ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARIES}
        DSTS ${dst_dir} ${dst_dir}/lib)

362

363
# CMakeCache Info
364
copy(fluid_lib_dist
365 366
        SRCS ${PADDLE_INFERENCE_INSTALL_DIR}/third_party ${CMAKE_CURRENT_BINARY_DIR}/CMakeCache.txt
        DSTS ${PADDLE_INSTALL_DIR} ${PADDLE_INSTALL_DIR}
367
        )
T
Tao Luo 已提交
368

369
# paddle fluid version
T
Tao Luo 已提交
370
function(version version_file)
371 372 373 374 375 376 377 378
    execute_process(
            COMMAND ${GIT_EXECUTABLE} log --pretty=format:%H -1
            WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
            OUTPUT_VARIABLE PADDLE_GIT_COMMIT)
    file(WRITE ${version_file}
            "GIT COMMIT ID: ${PADDLE_GIT_COMMIT}\n"
            "WITH_MKL: ${WITH_MKL}\n"
            "WITH_MKLDNN: ${WITH_MKLDNN}\n"
379
            "WITH_GPU: ${WITH_GPU}\n"
380 381 382
            "WITH_ROCM: ${WITH_ROCM}\n"
            "WITH_ASCEND_CL: ${WITH_ASCEND_CL}\n"
            "WITH_ASCEND_CXX11: ${WITH_ASCEND_CXX11}\n")
383
    if(WITH_GPU)
384 385
        file(APPEND ${version_file}
                "CUDA version: ${CUDA_VERSION}\n"
386
                "CUDNN version: v${CUDNN_MAJOR_VERSION}.${CUDNN_MINOR_VERSION}\n")
387
    endif()
388 389 390 391 392
    if(WITH_ROCM)
        file(APPEND ${version_file}
                "HIP version: ${HIP_VERSION}\n"
                "MIOpen version: v${MIOPEN_MAJOR_VERSION}.${MIOPEN_MINOR_VERSION}\n")
    endif()
393 394 395 396 397
    if(WITH_ASCEND_CL)
        file(APPEND ${version_file}
                "Ascend Toolkit version: ${ASCEND_TOOLKIT_VERSION}\n"
                "Ascend Driver version: ${ASCEND_DRIVER_VERSION}\n")
    endif()
398
    file(APPEND ${version_file} "CXX compiler version: ${CMAKE_CXX_COMPILER_VERSION}\n")
399 400
    if(TENSORRT_FOUND)
        file(APPEND ${version_file}
401
                "WITH_TENSORRT: ${TENSORRT_FOUND}\n" "TensorRT version: v${TENSORRT_MAJOR_VERSION}.${TENSORRT_MINOR_VERSION}.${TENSORRT_PATCH_VERSION}.${TENSORRT_BUILD_VERSION}\n")
402
    endif()
403
    if(WITH_LITE)
W
Wilber 已提交
404
        file(APPEND ${version_file} "WITH_LITE: ${WITH_LITE}\n" "LITE_GIT_TAG: ${LITE_GIT_TAG}\n")
405
    endif()
406
    
T
Tao Luo 已提交
407
endfunction()
408 409 410
version(${PADDLE_INSTALL_DIR}/version.txt)
version(${PADDLE_INFERENCE_INSTALL_DIR}/version.txt)
version(${PADDLE_INFERENCE_C_INSTALL_DIR}/version.txt)