That can be done with include
, here's some simple example:
Content of A/CMakeLists.txt
function(foo)
message(STATUS "heya")
endfunction()
Content of B/CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
include(${CMAKE_CURRENT_SOURCE_DIR}/../A/CMakeLists.txt)
foo()
Now, including another CMakeLists.txt will also run everything in that file, so you may want to avoid doing that if there are targets in B/CMakeLists.txt
If you can modify your code, it would be better to define your functions in a "top level" CMakeLists.txt before calling add_subdirectory
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…