forked from aldebaran/libqi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qimodule-config.cmake
52 lines (46 loc) · 1.49 KB
/
qimodule-config.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
##
## Author(s):
## - Cedric GESTES <[email protected]>
##
## Copyright (C) 2014 Aldebaran Robotics
##
#!
# create a qi module
#
# it's the normal qi_create_lib except that:
# - if the name is separated by point, it automatically add SUBFOLDERs to qi_create_lib
# naoqi.foo.bar -> SUBFOLDER naoqi/foo/
# - a file is created to state that the module is a c++ module
# sdk/share/qi/naoqi.foo.bar.mod
# - the created library is always SHARED
# - a depends on libqi is added
#
function(qi_create_module name)
set(_namelist)
string(FIND "${name}" "." _idx REVERSE)
string(SUBSTRING "${name}" "0" "${_idx}" _pkgname)
#only libname
if (_idx EQUAL -1)
set(_pkgname "")
set(_libname "${name}")
else() #pkg + lib name
math(EXPR _idxlib "${_idx} + 1")
string(SUBSTRING "${name}" "${_idxlib}" "-1" _libname)
endif()
string(REPLACE "." "/" _pkgpathname "${_pkgname}")
qi_info("Module: ${name}")
#TODO: check for SUBFOLDER spec already provided... FAIL in that case..
qi_create_lib("${name}" SHARED ${ARGN} SUBFOLDER "${_pkgpathname}" NO_LOG)
qi_use_lib("${name}" qi)
set_target_properties("${name}" PROPERTIES OUTPUT_NAME "${_libname}")
set(_modfilename "${name}.mod")
file(WRITE "${QI_SDK_DIR}/${QI_SDK_SHARE}/qi/module/${_modfilename}" "cpp\n")
cmake_parse_arguments(ARG
"NO_INSTALL"
""
""
${ARGN})
if (NOT ARG_NO_INSTALL)
qi_install_data("${QI_SDK_DIR}/${QI_SDK_SHARE}/qi/module/${_modfilename}" SUBFOLDER "qi/module")
endif()
endfunction()