# -*- mode: cmake -*- # @HEADER # ***************************************************************************** # TriBITS: Tribal Build, Integrate, and Test System # # Copyright 2013-2016 NTESS and the TriBITS contributors. # SPDX-License-Identifier: BSD-3-Clause # ***************************************************************************** # @HEADER # # Modified version from MSTK which was originally based on Amanzi open # source code https://software.lanl.gov/ascem/trac) # parse_library_list( # DEBUG # OPT # GENERAL ) # CMake module include(CMakeParseArguments) function(parse_library_list) # Macro: _print_usage macro(_print_usage) message("PARSE_LIBRARY_LIST \n" " FOUND \n" " DEBUG \n" " OPT \n" " GENERAL \n" "lib_list string to parse\n" "FOUND flag to indicate if keywords were found\n" "DEBUG variable containing debug libraries\n" "OPT variable containing optimized libraries\n" "GENERAL variable containing debug libraries\n") endmacro() # Read in args cmake_parse_arguments(PARSE_ARGS "" "FOUND;DEBUG;OPT;GENERAL" "" ${ARGN}) set(_parse_list "${PARSE_ARGS_UNPARSED_ARGUMENTS}") if ( (NOT PARSE_ARGS_FOUND) OR (NOT PARSE_ARGS_DEBUG) OR (NOT PARSE_ARGS_OPT) OR (NOT PARSE_ARGS_GENERAL) OR (NOT _parse_list ) ) _print_usage() message(FATAL_ERROR "Invalid arguments") endif() # Now split the list set(_debug_libs "") set(_opt_libs "") set(_gen_libs "") foreach( item ${_parse_list} ) if( ${item} MATCHES debug OR ${item} MATCHES optimized OR ${item} MATCHES general ) if( ${item} STREQUAL "debug" ) set( mylist "_debug_libs" ) elseif( ${item} STREQUAL "optimized" ) set( mylist "_opt_libs" ) elseif( ${item} STREQUAL "general" ) set( mylist "_gen_libs" ) endif() else() list( APPEND ${mylist} ${item} ) endif() endforeach() # Now set output variables set(${PARSE_ARGS_DEBUG} "${_debug_libs}" PARENT_SCOPE) set(${PARSE_ARGS_OPT} "${_opt_libs}" PARENT_SCOPE) set(${PARSE_ARGS_GENERAL} "${_gen_libs}" PARENT_SCOPE) # If any of the lib lists are defined set flag to TRUE if ( (_debug_libs) OR (_opt_libs) OR (_gen_libs) ) set(${PARSE_ARGS_FOUND} TRUE PARENT_SCOPE) else() set(${PARSE_ARGS_FOUND} FALSE PARENT_SCOPE) endif() endfunction()