Debian Codegraph @

cmake/tribits/common_tpls/utils/ParseLibraryList.cmake

raw
1 # -*- mode: cmake -*-
2 # @HEADER
3 # *****************************************************************************
4 # TriBITS: Tribal Build, Integrate, and Test System
5 #
6 # Copyright 2013-2016 NTESS and the TriBITS contributors.
7 # SPDX-License-Identifier: BSD-3-Clause
8 # *****************************************************************************
9 # @HEADER
10 #
11 # Modified version from MSTK which was originally based on Amanzi open
12 # source code https://software.lanl.gov/ascem/trac)
13 # parse_library_list( <lib_list>
14 # DEBUG <out_debug_list>
15 # OPT <out_opt_list>
16 # GENERAL <out_gen_list> )
17
18 # CMake module
19 include(CMakeParseArguments)
20
21 function(parse_library_list)
22
23 # Macro: _print_usage
24 macro(_print_usage)
25 message("PARSE_LIBRARY_LIST <lib_list>\n"
26 " FOUND <out_flag>\n"
27 " DEBUG <out_debug_list>\n"
28 " OPT <out_opt_list>\n"
29 " GENERAL <out_gen_list>\n"
30 "lib_list string to parse\n"
31 "FOUND flag to indicate if keywords were found\n"
32 "DEBUG variable containing debug libraries\n"
33 "OPT variable containing optimized libraries\n"
34 "GENERAL variable containing debug libraries\n")
35
36 endmacro()
37
38 # Read in args
39 cmake_parse_arguments(PARSE_ARGS "" "FOUND;DEBUG;OPT;GENERAL" "" ${ARGN})
40 set(_parse_list "${PARSE_ARGS_UNPARSED_ARGUMENTS}")
41 if ( (NOT PARSE_ARGS_FOUND) OR
42 (NOT PARSE_ARGS_DEBUG) OR
43 (NOT PARSE_ARGS_OPT) OR
44 (NOT PARSE_ARGS_GENERAL) OR
45 (NOT _parse_list )
46 )
47 _print_usage()
48 message(FATAL_ERROR "Invalid arguments")
49 endif()
50
51 # Now split the list
52 set(_debug_libs "")
53 set(_opt_libs "")
54 set(_gen_libs "")
55 foreach( item ${_parse_list} )
56 if( ${item} MATCHES debug OR
57 ${item} MATCHES optimized OR
58 ${item} MATCHES general )
59
60 if( ${item} STREQUAL "debug" )
61 set( mylist "_debug_libs" )
62 elseif( ${item} STREQUAL "optimized" )
63 set( mylist "_opt_libs" )
64 elseif( ${item} STREQUAL "general" )
65 set( mylist "_gen_libs" )
66 endif()
67 else()
68 list( APPEND ${mylist} ${item} )
69 endif()
70 endforeach()
71
72
73 # Now set output variables
74 set(${PARSE_ARGS_DEBUG} "${_debug_libs}" PARENT_SCOPE)
75 set(${PARSE_ARGS_OPT} "${_opt_libs}" PARENT_SCOPE)
76 set(${PARSE_ARGS_GENERAL} "${_gen_libs}" PARENT_SCOPE)
77
78 # If any of the lib lists are defined set flag to TRUE
79 if ( (_debug_libs) OR (_opt_libs) OR (_gen_libs) )
80 set(${PARSE_ARGS_FOUND} TRUE PARENT_SCOPE)
81 else()
82 set(${PARSE_ARGS_FOUND} FALSE PARENT_SCOPE)
83 endif()
84
85 endfunction()
86