Michael Wild wrote:
On 29. Oct, 2009, at 11:11 , Tim Just wrote:
Hi,
I'm using CMake 2.8 rc3 on Ubuntu to build a modular and extensible
project. Therefore I have a directory called 'modules' beneath the
project root. In this folder may be an undefined number of subfolders
containing module sources and CMakeLists.txt files. In the
CMakeLists.txt in project root, I try to find out which modules exist
in the modules folder. To do so I'm using find_path:
find_path(MODULE_PATH CMakeLists.txt PATHS modules/* NO_DEFAULT_PATH)
get_filename_component(MODULE_NAME ${MODULE_PATH} NAME)
This works for ONE module, but I want to find ALL modules in the
directory. The number of modules is not known in advance.
Has anyone suggestions how to realize this functionality?
Thanks for your help,
Tim
You should be using something like
FILE(GLOB MODULES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/modules/*")
FOREACH(module ${MODULE_PATHS})
IF(IS_DIRECTORY "${module}")
ADD_SUBDIRECTORY("${module}")
ENDIF()
ENDFOREACH()
HTH
Michael
Hi Michael,
thanks for your fast reply and the code.
Finally I'm using this function:
---
function(find_all_modules)
file(GLOB MODULE_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/modules/*")
foreach(M ${MODULE_PATHS})
if(IS_DIRECTORY "${M}")
get_filename_component(MODULE_NAME "${M}" NAME)
list(APPEND MODULES_ALL ${MODULE_NAME})
message("Found module: ${MODULE_NAME}")
endif()
endforeach()
endfunction(find_all_modules)
---
Best regards,
Tim
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake