Skip to content

Instantly share code, notes, and snippets.

@melak47
Created September 28, 2019 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melak47/f7d83046c6d57b338d633468d078f5b1 to your computer and use it in GitHub Desktop.
Save melak47/f7d83046c6d57b338d633468d078f5b1 to your computer and use it in GitHub Desktop.
example
cmake_minimum_required(VERSION 3.15)
project(example CXX)
find_program(CMAKE_MC_COMPILER mc.exe DOC "WinSDK message compiler")
if(NOT CMAKE_MC_COMPILER)
message(FATAL_ERROR "mc.exe was not found")
else()
message(STATUS "mc.exe found at: ${CMAKE_MC_COMPILER}")
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/example.rc ${CMAKE_CURRENT_BINARY_DIR}/example.hpp ${CMAKE_CURRENT_BINARY_DIR}/example_MSG00001.bin
COMMAND ${CMAKE_MC_COMPILER} -b -e hpp -h ${CMAKE_CURRENT_BINARY_DIR} -r ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/example.mc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/example.mc
)
# create a resource-only DLL
add_library(example MODULE ${CMAKE_CURRENT_BINARY_DIR}/example.rc)
set_target_properties(example PROPERTIES LINKER_LANGUAGE CXX)
target_link_options(example PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/noentry>)
SeverityNames=(
Success=0x0:STATUS_SEVERITY_SUCCESS
Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
Warning=0x2:STATUS_SEVERITY_WARNING
Error=0x3:STATUS_SEVERITY_ERROR
)
FacilityNames=(
System=0x0:FACILITY_SYSTEM
Example=0x1:FACILITY_EXAMPLE
)
MessageIdTypedef=DWORD
MessageId=0x100
Severity=Error
Facility=Example
SymbolicName=MSG_EXAMPLE_ERROR
Language=English
Example error occurred.
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment