CMakeLists.txt: Cleanup MODULE_LIST usage

Removed redundant usage of MODULE_LIST and SUBDIRS variables.
Treat utilities and interfaces directories the same (add both if not
added when using MODULE_LIST).

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2017-07-13 10:31:39 -07:00
parent f4da94a06e
commit 5a1f27a92d

View File

@ -796,28 +796,34 @@ set(UPM_TARGETS_NODEJS "" CACHE INTERNAL "List of NodeJs target names")
set(UPM_TARGETS_PYTHON2 "" CACHE INTERNAL "List of Python2 target names") set(UPM_TARGETS_PYTHON2 "" CACHE INTERNAL "List of Python2 target names")
set(UPM_TARGETS_PYTHON3 "" CACHE INTERNAL "List of Python3 target names") set(UPM_TARGETS_PYTHON3 "" CACHE INTERNAL "List of Python3 target names")
# Add subdirectories from MODULE_LIST if defined # MODULE_LIST can be specified on the CMake command line to specify
# Example -DMODULE_LIST="dfrph;rotaryencoder" # a list of directories under src to include in the build.
if (MODULE_LIST) # MODULE_LIST is optional.
set(SUBDIRS ${MODULE_LIST}) # If MODULE_LIST is provided, only add the directories specified
# Add interfaces directory # If MODULE_LIST is NOT provided, add all subdirectories under src
set(SUBDIRS ${SUBDIRS} interfaces) # Example (-DMODULE_LIST="dfrph;rotaryencoder")
else() if (NOT MODULE_LIST)
# Otherwise, add all subdirectories # If no module list, add all subdirectories
subdirlist(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}) subdirlist(MODULE_LIST ${CMAKE_CURRENT_SOURCE_DIR})
endif() endif()
# If the SUBDIRS list does NOT include the utilities directory, add it since # If the module list does NOT include the utilities directory, prepend it since
# most sensor library targets depend on utilities # most sensor library targets depend on utilities
if (NOT "${SUBDIRS}" MATCHES utilities) if (NOT "${MODULE_LIST}" MATCHES ";utilities;")
add_subdirectory(${CMAKE_SOURCE_DIR}/src/utilities) set(MODULE_LIST "utilities;${MODULE_LIST}")
endif() endif()
# Iterate over each directory in SUBDIRS # If the module list does NOT include the interfaces directory, prepend it since
foreach(subdir ${SUBDIRS}) # some sensor library targets depend on interfaces
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/CMakeLists.txt) if (NOT "${MODULE_LIST}" MATCHES ";interfaces;")
add_subdirectory(${subdir}) set(MODULE_LIST "interfaces;${MODULE_LIST}")
endif() endif()
# Iterate over each directory in MODULE_LIST
foreach(subdir ${MODULE_LIST})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/CMakeLists.txt)
add_subdirectory(${subdir})
endif()
endforeach() endforeach()
# Print stats for all targets # Print stats for all targets