CMake project organisation

白昼怎懂夜的黑 提交于 2019-12-11 14:45:59

问题


I have different projects (executables and libraries) that use the same internal libraries. Each project and internal library folder is located in the same base folder.

Let's say I have a shell tool named shelltool1 and shelltool2 that use lib1. They are located in

/path/to/base/shelltool1
/path/to/base/shelltool2
/path/to/base/lib1

Do I build the executable/library in the respective folders and link them in the CMakeLists.txt inside /path/to/base ?

So my idea would be

base: CMakeLists.txt

add_subdirectory(shelltool1)
add_subdirectory(shelltool2)
add_subdirectory(lib1)

target_link_libraries(shelltool1 lib1)
target_link_libraries(shelltool2 lib1)

shelltool1: CMakeLists.txt

add_executable(shelltool1 ${SRC})

shelltool2: CMakeLists.txt

add_executable(shelltool2 ${SRC})

lib1: CMakeLists.txt

add_library(lib1 ${SRC})

Is this sensible, or will I run into troubles?

来源:https://stackoverflow.com/questions/50330271/cmake-project-organisation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!