Here is the folder struct. We run cmake in 'folder_cmake' and we hope to use something in 'my_folder'.
/folder_top/folder_level1/folder_cmake
/folder_top/my_folder
SET(my_variable ${CMAKE_CURRENT_SOURCE_DIR}/../../my_folder)
${CMAKE_CURRENT_SOURCE_DIR} is CMAKE internal variable which save the full path of 'folder_cmake'.
in sub folder:
list(APPEND MY_SRCS "a.c" "b.c") list(APPEND MY_INCS "a.h" "b.h") set(MY_SRCS ${MY_SRCS} TOPPARENT) set(MY_INCS ${MY_INCS} TOPPARENT)Then you can use MY_SRCS and MY_INCS at the top folder. Will provide example later.