Thursday 15 August 2013

c++ - How to do CMake modules -


I try to learn C ++ with Ccm. I have done a project, and runs cm, it compiles, it works, it is good, okay now I started a new project in which i want to use some classes for the first time. I have tried to read some source code and I have understood that I need to create a module, which I can read from the application. Then it will be my store:

  / / cmake / modules / network / software / sw1 / software / sw2   

both projects sw1 and sw2 module Netowrk . The folder cmake should contain the FindNetwork.cmake file, and sw1 , sw2 and network should be CMakeList.txt should be .

But .. I messed with include_directories and other cmake obscurities ..

Does anyone tell me a good overview that the normal module How to easily organize a repository with the dependent software? "post-text" itemprop = "text">

will provide some examples for you

Things to do in terms of how you are looking at project / infrastructure Too much confusing is the best.

  • A module is a library (hence see your network module as a library)
  • To include the library, you link it to and The header file can also be available along with it.

    In Semicom, this is the two command target_link_libraries and respectively include_directories

    it may be a project structure keeping in mind For example, for example CmakeLists

      / network / include (API here) / network / src / sw1 / src / sw2 / src   

    Txt file: (place in the root wall of the project)

      cmake_minimum_required (VERSION 2.7) // add_subdirectory (sw1) add_subdirectory (sw2) add_subdirectory in your preferred project (myproject) / network directory In   

    you will have it ($ {MYPROJECT_SOURCE_DIR} / include the network) link_directories ($ {MYPROJECT_BINARY_DIR} / network) ) Sw_dirs ($ { MYPROJECT_SOURCE_DIR} /). (Sw1prog sw1.cc sw11.cc etc.) target_link_libraries (sw1prog network)

    sw2 dir

      network / include) link_directories ($ {MYPROJECT_BINARY_DIR} / Network) add_executable (sw2prog sw2.cc sw21.cc etc.) target_link_libraries (sw2prog network)   

    This is a very simple version of what is required for you, to make it Removes the need for a FindXXModule.cmake file and you can undoubtedly create using the library. I think this is the best mechanism for you, if you want to create a FindXModule.cmake, then I can suggest that when you actually install your LIBOS on the machine and be able to find others If you want to, either a mechanism for linking to each other libraries for multiple projects

    I hope this is a little helpful, please note that some examples in this And your cmake --help is your friend

  • No comments:

    Post a Comment