[CMake] macro withunexpected results
ope
ope-devel at gmx.de
Fri Aug 24 15:24:27 EDT 2007
Alexander Neundorf schrieb:
> On Friday 24 August 2007 15:02, you wrote:
>>>> macro(ADD_SUBDIRECTORIES dirlist)
>>>> set(prefix " + ")
>>>> MESSAGE(STATUS "add_subdirectories: ${ARGN}")
>>>> foreach(subdir ${dirlist})
>>>> MESSAGE(STATUS "${prefix}${subdir}")
>>>> add_subdirectory(${subdir})
>>>> endforeach(subdir ${dirlist})
>>>> endmacro(ADD_SUBDIRECTORIES)
>>>>
>>>> using this gets:
>>>>
>>>> ...
>>>> -- Scanning for sub projects in extra:
>>>> -- Adding est;boost;threadpool
>>>> -- add_subdirectories: boost;threadpool
>>>> -- + est
>>>> ...
>>> The macro has one argument "dirlist" which gets the first argument: est.
>>> The remaining arguments go into ARGN. You are iterating over the first
>>> argument only.
>> Thanks, I changed to:
>>
>> macro(ADD_SUBDIRECTORIES)
>> set(prefix " + ")
>> MESSAGE(STATUS "add_subdirectories: ${ARGN}")
>> foreach(subdir ${ARGN})
>> MESSAGE(STATUS "${prefix}${subdir}")
>> add_subdirectory(${subdir})
>> endforeach(subdir ${ARGN})
>> endmacro(ADD_SUBDIRECTORIES)
>>
>> and got:
>>
>> -- Scanning for sub projects in extra:
>> -- Adding est;boost;threadpool
>> -- add_subdirectories: est;boost;threadpool
>> -- + est
>> -- + boost
>> -- Scanning ...
>>
>> The last is missing, why?
>
>
> This should work, maybe there is something in the CMakeCache.txt or some file
> not saved or ...
macro(ADD_SUBDIRECTORIES)
set(prefix " + ")
MESSAGE(STATUS "add_subdirectories: ${ARGN}")
foreach(subdir ${ARGN})
MESSAGE(STATUS "${prefix}${subdir}")
add_subdirectory(${subdir})
endforeach(subdir ${ARGN})
endmacro(ADD_SUBDIRECTORIES)
gets for:
$ find . -name CMakeLists.txt|sort
./CMakeLists.txt
./extra/boost/CMakeLists.txt
./extra/boost/libs/asio/CMakeLists.txt
./extra/boost/libs/CMakeLists.txt
./extra/boost/libs/md5/CMakeLists.txt
./extra/boost/libs/md5/src/CMakeLists.txt
./extra/boost/libs/system/CMakeLists.txt
./extra/boost/libs/system/src/CMakeLists.txt
./extra/CMakeLists.txt
./extra/est/CMakeLists.txt
./extra/threadpool/CMakeLists.txt
./src/CMakeLists.txt
./src/downloader/CMakeLists.txt
./src/libs/CMakeLists.txt
./src/libs/inet_io/CMakeLists.txt
./src/libs/inet_io/src/CMakeLists.txt
./src/settings/CMakeLists.txt
where the following files contains the macro add_subdirectories()
$ find . -name CMakeLists.txt -exec egrep --with-filename
add_subdirectories {} \;
./src/libs/CMakeLists.txt:add_subdirectories(${SUBLIBS_DIRS})
./src/CMakeLists.txt:add_subdirectories(${SUBPROJECT_DIRS})
./extra/boost/libs/CMakeLists.txt:add_subdirectories(${BOOST_SUBPROJECT_DIRS})
./extra/CMakeLists.txt:add_subdirectories(${EXTRA_PROJECT_DIRS})
and inside build dir:
$ rm -rf * && cmake ..
...
-- Scanning for sub projects in extra:
-- add_subdirectories: est;boost;threadpool
-- + est
-- + boost
-- Scanning for sub projects in extra/boost/libs:
-- add_subdirectories: md5;asio;system
-- + md5
-- + asio
-- + system
-- + threadpool
-- Scanning for sub projects in src:
-- add_subdirectories: libs;downloader;settings
-- + libs
-- Scanning for sub projects in src/libs:
-- add_subdirectories: inet_io
-- + inet_io
-- + downloader
-- + settings
-- Configuring done
...
That is confusing, isn't it?
Thanks,
Olaf
More information about the CMake
mailing list