forked from Samsung/ONE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cmake
More file actions
66 lines (59 loc) · 2.4 KB
/
utils.cmake
File metadata and controls
66 lines (59 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# generate sources files by *.def files for soft backend
function(nnc_make_generated_sources DEF_SOURCES OUT_DIR GEN_SOURCES)
set(GEN_OUT "")
foreach(file IN LISTS DEF_SOURCES)
get_filename_component(file_name ${file} NAME_WE)
set(out_file "${OUT_DIR}/${file_name}.generated.h")
list(APPEND GEN_OUT "${out_file}")
add_custom_command(
OUTPUT ${out_file}
COMMAND def2src ${OUT_DIR} ${file}
DEPENDS def2src ${file}
)
endforeach()
set(${GEN_SOURCES} ${GEN_OUT} PARENT_SCOPE)
endfunction()
function(nnc_set_installation_properties TARG)
# TODO when we upgrade our cmake to version 3.8 we'll need to use
# BUILD_RPATH variable instead of CMAKE_BUILD_WITH_INSTALL_RPATH here
# set external RPATHs
set_target_properties(${TARG} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
# use paths from build directoris
set_target_properties(${TARG} PROPERTIES CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# set RPATH to core part of nnc
set_target_properties(${TARG} PROPERTIES INSTALL_RPATH ${NNC_INSTALL_LIB_PATH})
endfunction()
# install nnc libraries
function(nnc_install_library LIB)
install(TARGETS ${LIB} DESTINATION ${NNC_INSTALL_LIB_PATH})
nnc_set_installation_properties(${LIB})
endfunction()
# install nnc executable
function(nnc_install_executable BIN)
install(TARGETS ${BIN} DESTINATION ${NNC_INSTALL_BIN_PATH})
nnc_set_installation_properties(${BIN})
endfunction()
# add nnc library as target
function(nnc_add_library)
add_library(${ARGV})
# to prevent _GLIBCXX17_DEPRECATED warning as error
# target_link_libraries(${ARGV0} PRIVATE nncc_common)
target_link_libraries(${ARGV0} PUBLIC nncc_coverage)
get_target_property(LIBS ${NNC_TARGET_EXECUTABLE} LINK_LIBRARIES)
target_include_directories(${ARGV0} PUBLIC ${NNC_ROOT_SRC_DIR}/include ${NNC_ROOT_BIN_DIR}/include)
if(LIBS MATCHES NOTFOUND)
set(LIBS "")
endif()
list(APPEND LIBS ${ARGV0})
set_target_properties(${NNC_TARGET_EXECUTABLE} PROPERTIES LINK_LIBRARIES "${LIBS}")
endfunction()
# function to add nnc unit test
function(nnc_add_unit_test)
if(ENABLE_TEST)
add_executable(${ARGV})
target_link_libraries(${ARGV0} gtest_main)
add_test(${ARGV0} ${ARGV0})
endif(ENABLE_TEST)
add_dependencies(nnc_unit_tests ${ARGV0})
target_include_directories(${ARGV0} PUBLIC ${NNC_ROOT_SRC_DIR}/include ${NNC_ROOT_BIN_DIR}/include)
endfunction()