-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
28 lines (24 loc) · 1.06 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
cmake_minimum_required(VERSION 3.5)
project(EmbedResource)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
function(embed_resources out_var)
set(result)
foreach(in_f ${ARGN})
file(RELATIVE_PATH src_f ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/${in_f}")
set(out_f "${PROJECT_BINARY_DIR}/${in_f}.c")
get_filename_component(out_f_dir "${out_f}" DIRECTORY)
add_custom_command(OUTPUT ${out_f}
COMMAND ${CMAKE_COMMAND} -E make_directory "${out_f_dir}"
COMMAND embed-resource "${out_f}" "${src_f}"
DEPENDS "${in_f}" embed-resource
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building binary file for embedding ${out_f}"
VERBATIM)
list(APPEND result "${out_f}")
endforeach()
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
add_executable(embed-resource embedresource.cpp Resource.h)
target_link_libraries(embed-resource)
set(EMBED_RES_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)