yys

Maya插件开发,(多多练习英文吧~)

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
[Realxtend/Naali0.4]How to modify cmake files when you add a new Module

--------------------------------------------------
Contents
--------------------------------------------------
1.how to add dependence to an existing module
2.how to add a new module
A.how to write configure_mydep0()

--------------------------------------------------
1.how to add dependence to an existing module
--------------------------------------------------
1.1
do the steps in section A( how to write configure_mydep0() )

1.2
open NaaliRoot\CMakeLists.txt, and add configure_mydep0() into the configure_***() section.
For example, it would be like this:
# Find needed external libraries, abort on error
configure_boost()
...
configure_mydep0()  #<----- add a new line like this

1.3
open EXIST_MODULE/CMakeLists.txt, add use_package(...) to Inlcude section and link_package(...) to Linking section.
For example, it would be like this:
# Includes
use_package (BOOST)
...
use_package (MYDEP0)  #<----- add a new line like this

# Linking
link_package (BOOST)
...
link_package (MYDEP0)  #<----- add a new line like this

--------------------------------------------------
2.how to add a new module
--------------------------------------------------
(suppose the new module name is MyModule(located at NaaliRoot\MyModule), and it depends on MyDep0,MyDep1)
2.1
follow the steps in section A,and write the function configure_mydep0()
follow the steps in section A,and write the function configure_mydep1()

2.2
open NaaliRoot\CMakLists.txt, and add the following line.
configure_mydep0()
configure_mydep1()
For example, it would be like this:
configure_boost()
...
configure_qtpropertybrowser()
configure_mydep0() #<----- add a new line like this
configure_mydep1() #<----- add a new line like this

2.3
open NaaliRoot\CMakeBuildConfig.txt, and add the following line at the end of the file.
add_subdirectory(MyModule)


2.4
(we use NaaliRoot\AvatarModule\CMakeLists.txt as the template.)
copy NaaliRoot\AvatarModule\CMakeLists.txt to NaaliRoot\MyModule\CMakeLists.txt,
and open NaaliRoot\MyModule\CMakeLists.txt,

2.4.1
change init_target (AvatarModule OUTPUT modules/core)
to init_target (HapticModule OUTPUT modules/core)

2.4.2
change add_definitions (-DAV_MODULE_EXPORTS)
to add_definitions (-DHAPTIC_MODULE_EXPORTS)

2.4.3
add the following in Inlcude section. e.g.
use_package (BOOST)
...
use_package (MYMODULE)   #<----- add a new line like this

2.4.4
add the following in Linking section. e.g.
link_package (BOOST)
...
link_package (MYMODULE)   #<----- add a new line like this



--------------------------------------------------
A.how to write configure_mydep0()
--------------------------------------------------
A.1
If you have a new dependence(say it MyDep0), put it to NaaliDepsSVN\MyDep0.
and if it contains the following direcores:
   NaaliDepsSVN\MyDep0\include
   NaaliDepsSVN\MyDep0\lib
goto section A.2,
else goto section A.3

A.2
(suppose MyDep0\lib constains the following directories and files:
   NaaliDepsSVN\MyDep0\include
   NaaliDepsSVN\MyDep0\lib
   NaaliDepsSVN\MyDep0\lib\lib0.lib
   NaaliDepsSVN\MyDep0\lib\lib1.lib
)
open NaaliRoot/CMakeModules/ConfigurePackages.cmake, and add the following function:
[code]
macro (configure_mydep0)
    sagase_configure_package(MYDEP0
        NAMES mydep0
        COMPONENTS lib0 lib1
        PREFIXES ${ENV_NAALI_DEP_PATH}/MyDep0)

    if (MSVC)
        set (MYDEP0_INCLUDE_DIRS ${MYDEP0_INCLUDE_DIRS} ${ENV_NAALI_DEP_PATH}/MyDep0/include)
    endif()

    sagase_configure_report (MYDEP0)
endmacro (configure_mydep0)
[/code]

A.3
(suppose MyDep0\ constains the following sub-directories and files:
   NaaliDepsSVN\MyDep0\submodule0\include\
   NaaliDepsSVN\MyDep0\submodule0\lib\
   NaaliDepsSVN\MyDep0\submodule0\lib\sm0_lib0.lib
   NaaliDepsSVN\MyDep0\submodule0\lib\sm0_lib1.lib
   NaaliDepsSVN\MyDep0\submodule1\include\
   NaaliDepsSVN\MyDep0\submodule1\lib\
   NaaliDepsSVN\MyDep0\submodule1\lib\sm1_lib0.lib
   NaaliDepsSVN\MyDep0\submodule1\lib\sm1_lib1.lib
)
open NaaliRoot/CMakeModules/ConfigurePackages.cmake, and add the following function:
[code]
macro (configure_mydep0)
    sagase_configure_package(MYDEP0
        NAMES mydep0
        COMPONENTS sm0_lib0 sm0_lib1 sm1_lib0 sm1_lib1
        PREFIXES ${ENV_NAALI_DEP_PATH}/MyDep0)

    if (MSVC)
        include_directories(${ENV_NAALI_DEP_PATH}/MyDep0/submodule0/include)
        include_directories(${ENV_NAALI_DEP_PATH}/MyDep0/submodule1/include)
        link_directories(${ENV_NAALI_DEP_PATH}/MyDep0/submodule0/lib)
        link_directories(${ENV_NAALI_DEP_PATH}/MyDep0/submodule1/lib)
    endif()

    sagase_configure_report (MYDEP0)
endmacro (configure_mydep0)
[/code]
--------------------------------------------------

posted on 2011-06-15 11:21  yys  阅读(409)  评论(0编辑  收藏  举报