lxqt-globalkeys-packaging/cmake/create_portable_headers.cmake
Andrew Lee (李健秋) 512032c43f
Adding upstream version 0.9.0.
Signed-off-by: Andrew Lee (李健秋) <ajqlee@debian.org>
2015-08-12 03:27:51 +08:00

31 lines
1004 B
CMake

# Creates portable headers; e.g.:
# Creates XdgAction from xdgaction.h
# XdgAction contents:
# #include "xdgaction.h"
#
# Use:
# set(PUBLIC_CLASSES MyClass YourClass)
# create_portable_headers(PORTABLE_HEADERS ${PUBLIC_CLASSES})
# PORTABLE_HEADER is an return value that contains the full name of the
# generated headers.
function(create_portable_headers outfiles)
set(options)
set(oneValueArgs NAMESPACE)
set(multiValueArgs FILENAMES)
cmake_parse_arguments(_CREATE_PORTABLE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(prefix ${_CREATE_PORTABLE_HEADERS_NAMESPACE})
set(class_list ${_CREATE_PORTABLE_HEADERS_FILENAMES})
foreach(f ${class_list})
string(TOLOWER "${f}.h" _filename)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${f}
"#include \"../${_filename}\"")
list(APPEND ${outfiles} ${CMAKE_CURRENT_BINARY_DIR}/${f})
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()