mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-22 03:41:11 +00:00
Move cmake code to generate a C++ source file from a binary data file into a helper module
This commit is contained in:
parent
3c836c2d0c
commit
761a4c5d3b
3 changed files with 27 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
project(updater)
|
||||
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
|
||||
|
||||
include_directories(external)
|
||||
include_directories(external/TinyThread/source)
|
||||
|
|
21
cmake/modules/GenerateCppResourceFile.cmake
Normal file
21
cmake/modules/GenerateCppResourceFile.cmake
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
# Convert a binary data file into a C++
|
||||
# source file for embedding into an application binary
|
||||
#
|
||||
# Currently only implemented for Unix. Requires the 'xxd'
|
||||
# tool to be installed.
|
||||
#
|
||||
# INPUT_FILE : The name of the binary data file to be converted into a C++
|
||||
# source file.
|
||||
#
|
||||
# CPP_FILE : The path of the C++ source file to be generated.
|
||||
# See the documentation for xxd for information on
|
||||
# the structure of the generated source file.
|
||||
#
|
||||
# INPUT_FILE_TARGET : The name of the target which generates INPUT_FILE
|
||||
#
|
||||
function (generate_cpp_resource_file INPUT_FILE CPP_FILE INPUT_FILE_TARGET)
|
||||
add_custom_command(OUTPUT ${CPP_FILE}
|
||||
COMMAND xxd -i ${INPUT_FILE} ${CPP_FILE}
|
||||
DEPENDS ${INPUT_FILE_TARGET})
|
||||
endfunction()
|
|
@ -2,6 +2,7 @@
|
|||
add_subdirectory(tests)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
include(GenerateCppResourceFile)
|
||||
|
||||
if (UNIX)
|
||||
add_definitions(-Wall -Werror -Wconversion)
|
||||
|
@ -60,13 +61,11 @@ if (ENABLE_GTK)
|
|||
# embed the GTK helper library into the updater binary.
|
||||
# At runtime it will be extracted and loaded if the
|
||||
# GTK libraries are available
|
||||
|
||||
set(GTK_UPDATER_LIB libupdatergtk.so)
|
||||
set(GTK_BIN_FILE ${CMAKE_CURRENT_BINARY_DIR}/libupdatergtk.cpp)
|
||||
add_custom_command(OUTPUT ${GTK_BIN_FILE}
|
||||
COMMAND xxd -i ${GTK_UPDATER_LIB} ${GTK_BIN_FILE}
|
||||
DEPENDS updatergtk)
|
||||
set(SOURCES ${SOURCES} UpdateDialogGtkWrapper.cpp ${GTK_BIN_FILE})
|
||||
set(GTK_BIN_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libupdatergtk.cpp)
|
||||
generate_cpp_resource_file(${GTK_UPDATER_LIB} ${GTK_BIN_CPP_FILE} updatergtk)
|
||||
|
||||
set(SOURCES ${SOURCES} UpdateDialogGtkWrapper.cpp ${GTK_BIN_CPP_FILE})
|
||||
set(HEADERS ${HEADERS} UpdateDialogGtkWrapper.h)
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in a new issue