Update release_notes.md
[platform/upstream/caffeonacl.git] / cmake / ConfigGen.cmake
1
2 ################################################################################################
3 # Helper function to get all list items that begin with given prefix
4 # Usage:
5 #   caffe_get_items_with_prefix(<prefix> <list_variable> <output_variable>)
6 function(caffe_get_items_with_prefix prefix list_variable output_variable)
7   set(__result "")
8   foreach(__e ${${list_variable}})
9     if(__e MATCHES "^${prefix}.*")
10       list(APPEND __result ${__e})
11     endif()
12   endforeach()
13   set(${output_variable} ${__result} PARENT_SCOPE)
14 endfunction()
15
16 ################################################################################################
17 # Function for generation Caffe build- and install- tree export config files
18 # Usage:
19 #  caffe_generate_export_configs()
20 function(caffe_generate_export_configs)
21   set(install_cmake_suffix "share/Caffe")
22
23   if(NOT HAVE_CUDA)
24     set(HAVE_CUDA FALSE)
25   endif()
26
27   if(NOT HAVE_CUDNN)
28     set(HAVE_CUDNN FALSE)
29   endif()
30
31   # ---[ Configure build-tree CaffeConfig.cmake file ]---
32
33   configure_file("cmake/Templates/CaffeConfig.cmake.in" "${PROJECT_BINARY_DIR}/CaffeConfig.cmake" @ONLY)
34
35   # Add targets to the build-tree export set
36   export(TARGETS caffe proto FILE "${PROJECT_BINARY_DIR}/CaffeTargets.cmake")
37   export(PACKAGE Caffe)
38
39   # ---[ Configure install-tree CaffeConfig.cmake file ]---
40
41   configure_file("cmake/Templates/CaffeConfig.cmake.in" "${PROJECT_BINARY_DIR}/cmake/CaffeConfig.cmake" @ONLY)
42
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})
46
47   # ---[ Configure and install version file ]---
48
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
51
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})
54 endfunction()
55
56