2 ################################################################################################
3 # Helper function to get all list items that begin with given prefix
5 # caffe_get_items_with_prefix(<prefix> <list_variable> <output_variable>)
6 function(caffe_get_items_with_prefix prefix list_variable output_variable)
8 foreach(__e ${${list_variable}})
9 if(__e MATCHES "^${prefix}.*")
10 list(APPEND __result ${__e})
13 set(${output_variable} ${__result} PARENT_SCOPE)
16 ################################################################################################
17 # Function for generation Caffe build- and install- tree export config files
19 # caffe_generate_export_configs()
20 function(caffe_generate_export_configs)
21 set(install_cmake_suffix "share/Caffe")
31 # ---[ Configure build-tree CaffeConfig.cmake file ]---
33 configure_file("cmake/Templates/CaffeConfig.cmake.in" "${PROJECT_BINARY_DIR}/CaffeConfig.cmake" @ONLY)
35 # Add targets to the build-tree export set
36 export(TARGETS caffe proto FILE "${PROJECT_BINARY_DIR}/CaffeTargets.cmake")
39 # ---[ Configure install-tree CaffeConfig.cmake file ]---
41 configure_file("cmake/Templates/CaffeConfig.cmake.in" "${PROJECT_BINARY_DIR}/cmake/CaffeConfig.cmake" @ONLY)
43 # Install the CaffeConfig.cmake and export set to use with install-tree
44 install(FILES "${PROJECT_BINARY_DIR}/cmake/CaffeConfig.cmake" DESTINATION ${install_cmake_suffix})
45 install(EXPORT CaffeTargets DESTINATION ${install_cmake_suffix})
47 # ---[ Configure and install version file ]---
49 # TODO: Lines below are commented because Caffe doesn't declare its version in headers.
50 # When the declarations are added, modify `caffe_extract_caffe_version()` macro and uncomment
52 # configure_file(cmake/Templates/CaffeConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/CaffeConfigVersion.cmake" @ONLY)
53 # install(FILES "${PROJECT_BINARY_DIR}/CaffeConfigVersion.cmake" DESTINATION ${install_cmake_suffix})