-
Notifications
You must be signed in to change notification settings - Fork 24
/
utils.cmake
61 lines (44 loc) · 2.35 KB
/
utils.cmake
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
macro(copy_dependency deps target)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
get_target_property( DEP_SHARED_LIB_PATH ${deps} IMPORTED_LOCATION_RELEASE )
else()
get_target_property( DEP_SHARED_LIB_PATH ${deps} IMPORTED_LOCATION_DEBUG )
endif()
if (NOT "${DEP_SHARED_LIB_PATH}" STREQUAL "DEP_SHARED_LIB_PATH-NOTFOUND")
# Copy the shared lib file
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${DEP_SHARED_LIB_PATH} $<TARGET_FILE_DIR:${target}>)
# Add to install
install(FILES ${DEP_SHARED_LIB_PATH} TYPE BIN)
endif()
endmacro()
function(get_linux_lsb_release_information)
find_program(LSB_RELEASE_EXEC lsb_release)
if(NOT LSB_RELEASE_EXEC)
message("Could not detect lsb_release executable, can not gather required information. Use of default information (ID : Linux / Version : Unknown / Codename : Unknown")
set(LSB_RELEASE_ID_SHORT "Linux" PARENT_SCOPE)
set(LSB_RELEASE_VERSION_SHORT "Unknown" PARENT_SCOPE)
set(LSB_RELEASE_CODENAME_SHORT "Unknown" PARENT_SCOPE)
else()
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --id OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --release OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${LSB_RELEASE_EXEC}" --short --codename OUTPUT_VARIABLE LSB_RELEASE_CODENAME_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LSB_RELEASE_ID_SHORT "${LSB_RELEASE_ID_SHORT}" PARENT_SCOPE)
set(LSB_RELEASE_VERSION_SHORT "${LSB_RELEASE_VERSION_SHORT}" PARENT_SCOPE)
set(LSB_RELEASE_CODENAME_SHORT "${LSB_RELEASE_CODENAME_SHORT}" PARENT_SCOPE)
endif()
endfunction()
function(find_python_module module)
set(Python3_FIND_REGISTRY "LAST")
find_package(Python3 COMPONENTS Interpreter)
if(Python3_Interpreter_FOUND)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "import ${module}"
RESULT_VARIABLE EXIT_CODE
OUTPUT_QUIET
ERROR_QUIET
)
if (${EXIT_CODE} EQUAL 0)
set(PYTHON_MODULE_${module}_FOUND "true" PARENT_SCOPE)
endif()
endif()
endfunction()