Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CMakeRC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ set(_version 2.0.0)
cmake_minimum_required(VERSION 3.12)
include(CMakeParseArguments)

# Enable use of CODEGEN keyword in add_custom_command() calls if available
if(POLICY CMP0171)
cmake_policy(SET CMP0171 NEW)
endif()

if(COMMAND cmrc_add_resource_library)
if(NOT DEFINED _CMRC_VERSION OR NOT (_version STREQUAL _CMRC_VERSION))
message(WARNING "More than one CMakeRC version has been included in this project.")
Expand Down Expand Up @@ -487,10 +492,16 @@ function(cmrc_add_resource_library name)
string(REPLACE "\n " "\n" cpp_content "${cpp_content}")
file(GENERATE OUTPUT "${lib_tmp_cpp}" CONTENT "${cpp_content}")
get_filename_component(libcpp "${libdir}/lib.cpp" ABSOLUTE)
if(POLICY CMP0171)
set(maybe_CODEGEN CODEGEN)
else()
set(maybe_CODEGEN "")
endif()
add_custom_command(OUTPUT "${libcpp}"
DEPENDS "${lib_tmp_cpp}" "${cmrc_hpp}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${lib_tmp_cpp}" "${libcpp}"
COMMENT "Generating ${name} resource loader"
${maybe_CODEGEN}
)
# Generate the actual static library. Each source file is just a single file
# with a character array compiled in containing the contents of the
Expand Down Expand Up @@ -619,6 +630,11 @@ function(cmrc_add_resources name)
endfunction()

function(_cmrc_generate_intermediate_cpp lib_ns symbol outfile infile)
if(POLICY CMP0171)
set(maybe_CODEGEN CODEGEN)
else()
set(maybe_CODEGEN "")
endif()
add_custom_command(
# This is the file we will generate
OUTPUT "${outfile}"
Expand All @@ -633,6 +649,7 @@ function(_cmrc_generate_intermediate_cpp lib_ns symbol outfile infile)
"-DOUTPUT_FILE=${outfile}"
-P "${_CMRC_SCRIPT}"
COMMENT "Generating intermediate file for ${infile}"
${maybe_CODEGEN}
)
endfunction()

Expand Down