以下のようなディレクトリ構造のC++プロジェクトがあります。
server/
code/
BASE/
Thread/
Log/
Memory/
Net/
cmake/
CMakeList.txt
BASE/
CMakeList.txt
Net/
CMakeList.txt
ここに /cmake/CMakeList.txt の一部があります:
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
SET(dirlist ${dirlist} ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
add_subdirectory(Base)
次に、/cmake/Base/CMakeList.txt でマクロを使用します。
SET(SUBDIR, "")
SUBDIRLIST(SUBDIRS, ${BASE_SRC_DIR})
message("SUBDIRS : " ${SUBDIRS})
出力: サブディレクトリ:
出力で ${dirlist} をチェックします。出力はマクロの値であり、期待されるディレクトリ リストを取得しますが、SET(${result} ${dirlist}) の後に message("result " ${result}) が発生すると、期待される出力を取得できません。 、私の CMakeLists.txt の何が問題になっていますか?