1
0
Fork 0
cmake_helpers/external/glib/generate_cppgir.cmake
2023-05-15 09:44:42 +04:00

43 lines
1.5 KiB
CMake

# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
function(generate_cppgir target_name gir)
# cppgir generates all the dependent headers everytime, better to have a global folder
set(gen_dst ${CMAKE_BINARY_DIR}/gen)
file(MAKE_DIRECTORY ${gen_dst})
set(gen_timestamp ${gen_dst}/${target_name}_cppgir.timestamp)
add_custom_command(
OUTPUT
${gen_timestamp}
COMMAND
cppgir
--class
--expected
--ignore
${cmake_helpers_loc}/external/glib/cppgir/data/cppgir.ignore:${cmake_helpers_loc}/external/glib/cppgir/data/cppgir_unix.ignore
--output
${gen_dst}
${gir}
COMMAND
echo 1> ${gen_timestamp}
COMMENT "Generating C++ wrapper for ${gir} (${target_name})"
DEPENDS
cppgir
$<$<PATH:IS_ABSOLUTE,${gir}>:${gir}>
)
generate_target(${target_name} cppgir ${gen_timestamp} "" ${gen_dst})
get_target_property(target_type ${target_name} TYPE)
if (${target_type} STREQUAL "INTERFACE_LIBRARY")
target_link_libraries(${target_name} INTERFACE gi)
target_compile_definitions(${target_name} INTERFACE GI_INLINE GI_OBJECT_NEWV)
else()
target_link_libraries(${target_name} PUBLIC gi)
target_compile_definitions(${target_name} PUBLIC GI_INLINE GI_OBJECT_NEWV)
endif()
endfunction()