11#[=============================================================================[
22# FindMC
33
4- Find Windows compatible message compiler (mc.exe or windmc) command-line tool.
4+ Finds Windows compatible message compiler (mc.exe or windmc) command-line tool:
5+
6+ ```cmake
7+ find_package(MC [...])
8+ ```
59
610Message compiler is installed on Windows as part of the Visual Studio or Windows
711SDK. When cross-compiling for Windows, there is also a compatible alternative by
@@ -16,9 +20,9 @@ https://sourceware.org/binutils/docs/binutils.html#windmc.
1620
1721* `MC_EXECUTABLE` - Path to the message compiler if found.
1822
19- ## Functions provided by this module
23+ ## Commands
2024
21- Module exposes the following function :
25+ This module provides the following command :
2226
2327```cmake
2428mc_target(
@@ -33,20 +37,23 @@ mc_target(
3337```
3438
3539* `NAME` - Target name.
36- * `INPUT` - Input message file to compile.
40+ * `INPUT` - Input message file to compile. Relative path is interpreted as being
41+ relative to the current source directory.
3742* `HEADER_DIR` - Set the export directory for headers, otherwise current binary
3843 directory will be used.
39- * `RC_DIR` - Set the export directory for rc files.
44+ * `RC_DIR` - Set the export directory for rc files, otherwise current binary
45+ directory will be used.
4046* `XDBG_DIR` - Where to create the .dbg C include file that maps message IDs to
4147 their symbolic name.
4248* `OPTIONS` - A list of additional options to pass to message compiler tool.
4349* `DEPENDS` - Optional list of dependent files to recompile message file.
4450
45- ## Usage
51+ ## Examples
4652
4753```cmake
4854# CMakeLists.txt
4955find_package(MC)
56+ mc_target(...)
5057```
5158#]=============================================================================]
5259
@@ -137,11 +144,12 @@ endblock()
137144
138145set (_reason "" )
139146
140- if (NOT MC_EXECUTABLE OR NOT EXISTS ${MC_EXECUTABLE} )
141- string (APPEND _reason "Message compiler command-line tool (mc) not found. " )
142- else ()
143- # If MC_EXECUTABLE was found or was set by the user and path exists.
147+ # Check whether MC_EXECUTABLE exists.
148+ if (EXISTS "${MC_EXECUTABLE} " )
144149 set (_mc_exists TRUE )
150+ else ()
151+ set (_mc_exists FALSE )
152+ string (APPEND _reason "Message compiler command-line tool (mc) not found. " )
145153endif ()
146154
147155mark_as_advanced (MC_EXECUTABLE)
@@ -190,6 +198,13 @@ function(mc_target)
190198 return ()
191199 endif ()
192200
201+ cmake_path(
202+ ABSOLUTE_PATH
203+ parsed_INPUT
204+ BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
205+ NORMALIZE
206+ )
207+
193208 # Set default header export directory if empty.
194209 if (NOT parsed_HEADER_DIR)
195210 set (parsed_HEADER_DIR ${CMAKE_CURRENT_BINARY_DIR} )
0 commit comments