|
|
@@ -182,7 +182,9 @@ function(add_component_library target_name)
|
|
|
endfunction(add_component_library)
|
|
|
|
|
|
#
|
|
|
-# Function: add_metalib(target [source1 source2] [INIT initfunc [initheader.h]]
|
|
|
+# Function: add_metalib(target [source1 source2]
|
|
|
+# [INCLUDE header1.h ...]
|
|
|
+# [INIT initfunc [initheader.h] [EXPORT type name expr]]
|
|
|
# [COMPONENTS component1 ...])
|
|
|
#
|
|
|
# This is add_library, but for metalibs.
|
|
|
@@ -191,28 +193,72 @@ endfunction(add_component_library)
|
|
|
# autogenerated by this function) that calls the underlying component libs'
|
|
|
# init functions.
|
|
|
#
|
|
|
+# The EXPORT keyword exports the expression `expr`, which yields a value of
|
|
|
+# type `type`, as the undecorated (extern "C") symbol `name`
|
|
|
+#
|
|
|
+# The INCLUDE keyword allows the init file to pull in additional headers, which
|
|
|
+# may be useful for EXPORT.
|
|
|
+#
|
|
|
function(add_metalib target_name)
|
|
|
set(components_keyword OFF)
|
|
|
set(init_keyword 0)
|
|
|
set(init_func)
|
|
|
set(init_header "${target_name}.h")
|
|
|
+ set(export_keyword 0)
|
|
|
+ set(export_declarations)
|
|
|
+ set(export_definitions)
|
|
|
+ set(component_init_headers)
|
|
|
set(components)
|
|
|
set(sources)
|
|
|
foreach(arg ${ARGN})
|
|
|
if(arg STREQUAL "COMPONENTS")
|
|
|
set(components_keyword ON)
|
|
|
+ set(include_keyword OFF)
|
|
|
+ set(init_keyword 0)
|
|
|
+ set(export_keyword 0)
|
|
|
+ elseif(arg STREQUAL "INCLUDE")
|
|
|
+ set(include_keyword ON)
|
|
|
+ set(components_keyword OFF)
|
|
|
set(init_keyword 0)
|
|
|
+ set(export_keyword 0)
|
|
|
elseif(arg STREQUAL "INIT")
|
|
|
set(init_keyword 2)
|
|
|
set(components_keyword OFF)
|
|
|
+ set(include_keyword OFF)
|
|
|
+ set(export_keyword 0)
|
|
|
+ elseif(arg STREQUAL "EXPORT")
|
|
|
+ if(NOT init_func)
|
|
|
+ message(FATAL_ERROR "EXPORT cannot be used before INIT")
|
|
|
+ endif()
|
|
|
+ set(export_keyword 3)
|
|
|
+ set(components_keyword OFF)
|
|
|
+ set(include_keyword OFF)
|
|
|
+ set(init_keyword 0)
|
|
|
elseif(components_keyword)
|
|
|
list(APPEND components "${arg}")
|
|
|
+ elseif(include_keyword)
|
|
|
+ set(component_init_headers
|
|
|
+ "${component_init_headers}#include \"${arg}\"\n")
|
|
|
elseif(init_keyword EQUAL 2)
|
|
|
set(init_func "${arg}")
|
|
|
set(init_keyword 1)
|
|
|
elseif(init_keyword EQUAL 1)
|
|
|
set(init_header "${arg}")
|
|
|
set(init_keyword 0)
|
|
|
+ elseif(export_keyword EQUAL 3)
|
|
|
+ set(_export_type "${arg}")
|
|
|
+ set(export_keyword 2)
|
|
|
+ elseif(export_keyword EQUAL 2)
|
|
|
+ set(_export_name "${arg}")
|
|
|
+ set(export_keyword 1)
|
|
|
+ elseif(export_keyword EQUAL 1)
|
|
|
+ set(export_declarations
|
|
|
+ "${export_declarations}\nextern \"C\" IMPORT_CLASS ${_export_type} ${_export_name}();")
|
|
|
+ set(export_definitions
|
|
|
+ "${export_definitions}\nextern \"C\" EXPORT_CLASS ${_export_type} ${_export_name}() { return ${arg}; }")
|
|
|
+ unset(_export_type)
|
|
|
+ unset(_export_name)
|
|
|
+ set(export_keyword 0)
|
|
|
else()
|
|
|
list(APPEND sources "${arg}")
|
|
|
endif()
|
|
|
@@ -226,7 +272,6 @@ function(add_metalib target_name)
|
|
|
set(includes)
|
|
|
set(libs)
|
|
|
set(component_init_funcs "")
|
|
|
- set(component_init_headers "")
|
|
|
foreach(component ${components})
|
|
|
if(NOT TARGET "${component}")
|
|
|
message(FATAL_ERROR
|