CMAKE: moved GNA var setting to proper place; removed find_package when build python...
[platform/upstream/dldt.git] / cmake / debug.cmake
1 # Copyright (C) 2018-2019 Intel Corporation
2 # SPDX-License-Identifier: Apache-2.0
3 #
4
5 function (debug_message)
6     if (VERBOSE_BUILD)
7         message(${ARGV})
8     endif()
9 endfunction()
10
11 function(clean_message type)
12   string (REPLACE ";" "" output_string "${ARGN}")
13   execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${output_string}")
14   if(${ARGV0} STREQUAL "FATAL_ERROR")
15     message (FATAL_ERROR)
16   endif()  
17 endfunction()
18
19 file(REMOVE ${CMAKE_BINARY_DIR}/ld_library_rpath_64.txt)
20
21 # log relative path to shared library that has to be used in LD_LIBRARY_PATH
22 function (log_rpath_remove_top component component_remove_top lib lib_remove_top)
23   
24   set(top_lib_dir ${${component}})
25   set(lib_dir ${lib})
26
27 #  debug_message(STATUS "LIB-IN=${lib} ")
28 #  debug_message(STATUS "TOPLIB-IN=${top_lib_dir} ")
29   get_filename_component(top_lib_dir ${${component}} DIRECTORY)
30
31   if (${component_remove_top} AND ${component})
32   else()
33     get_filename_component(add_name ${${component}} NAME)
34     set(top_lib_dir "${top_lib_dir}/${add_name}")
35   endif()
36   if (${lib_remove_top} AND lib)
37     get_filename_component(lib_dir ${lib} DIRECTORY)
38   endif()
39
40   string (REPLACE "//" "/" top_lib_dir "${top_lib_dir}")
41   string (REPLACE "//" "/" lib_dir "${lib_dir}")
42
43   string (REPLACE "\\\\" "/" top_lib_dir "${top_lib_dir}")
44   string (REPLACE "\\\\" "/" lib_dir "${lib_dir}")
45
46 #  debug_message(STATUS "LIB-OUT=${lib_dir}")
47 #  debug_message(STATUS "TOPLIB-OUT=${top_lib_dir}")
48
49   if (WIN32)
50     string (TOLOWER "${top_lib_dir}" top_lib_dir)
51     string (TOLOWER "${lib_dir}" lib_dir)
52   endif()
53
54   string (REPLACE "${top_lib_dir}" "" component_dir "${lib_dir}")
55
56   set(RPATH_INFO "${component}=${component_dir}")
57   debug_message(STATUS "LD_LIBRARY_RPATH: ${RPATH_INFO}")
58   file(APPEND ${CMAKE_BINARY_DIR}/ld_library_rpath_64.txt "${RPATH_INFO}\n")
59 endfunction()
60
61 function (log_rpath_from_dir component lib_dir)
62   log_rpath_remove_top("${component}" TRUE "${lib_dir}" FALSE)
63 endfunction()
64
65 function (log_rpath component lib_path)
66   log_rpath_remove_top(${component} TRUE ${lib_path} TRUE)
67 endfunction()
68
69 # Just wrapping of the original message() function to make this macro known during IE build.
70 # This macro is redefined (with additional checks) within the InferenceEngineConfig.cmake file.
71 macro(ext_message TRACE_LEVEL)
72     message(${TRACE_LEVEL} "${ARGN}")
73 endmacro()