CMake: how best to build multiple (optional) subprojects?

后端 未结 6 2077
说谎
说谎 2021-02-18 16:23

Imagine an overall project with several components:

  • basic
  • io
  • web
  • app-a
  • app-b
  • app-c

Now, let\'s say web

6条回答
  •  自闭症患者
    2021-02-18 17:03

    My first thought was to use the CMake import/export target feature.

    Have a CMakeLists.txt for basic, io and web and one CMakeLists.txt that references those. You could then use the CMake export feature to export those targets and the application projects could then import the CMake targets.

    When you build the library project first the application projects should be able to find the compiled libraries automatically (without the libraries having to be installed to /usr/local/lib) otherwise one can always set up the proper CMake variable to indicate the correct directory.

    When doing it this way a make in the application project won't do a make in the library project, you would have to take care of this yourself.

提交回复
热议问题