Skip to content

Commit

Permalink
Locate mc.exe at configuration time (#4623)
Browse files Browse the repository at this point in the history
The `find_program()` command is now executed during the configuration
phase to locate `mc.exe` in predefined locations. This approach allows
the CMake toolchain to influence the search without modifying the `%PATH%`.

If user sets CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=FALSE, then
honor it and fail at configuration time if not found. Otherwise
expect %PATH% to contain mc.exe at build time, which is the case
when VS generator is used.
  • Loading branch information
redbaron authored Oct 24, 2024
1 parent f2bbbc1 commit 637b164
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,21 @@ if(WIN32)
# Generate the MsQuicEtw header file.
file(MAKE_DIRECTORY ${QUIC_BUILD_DIR}/inc)

if(NOT DEFINED CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OR CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH)
find_program(MC_EXE NAMES mc.exe)
if(MC_EXE MATCHES "NOTFOUND")
# If not found, then VS project generator will set %PATH% env var to WinSDK bin directory
set(MC_EXE "mc.exe" CACHE STRING "mc.exe from %PATH%" FORCE)
endif()
else()
find_program(MC_EXE NAMES mc.exe REQUIRED)
endif()

add_custom_command(
OUTPUT ${QUIC_BUILD_DIR}/inc/MsQuicEtw.h
OUTPUT ${QUIC_BUILD_DIR}/inc/MsQuicEtw.rc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest/MsQuicEtw.man
COMMAND mc.exe -um -h ${QUIC_BUILD_DIR}/inc -r ${QUIC_BUILD_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest/MsQuicEtw.man)
COMMAND "${MC_EXE}" -um -h ${QUIC_BUILD_DIR}/inc -r ${QUIC_BUILD_DIR}/inc ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest/MsQuicEtw.man)
add_custom_target(MsQuicEtw_HeaderBuild
DEPENDS ${QUIC_BUILD_DIR}/inc/MsQuicEtw.h)

Expand Down

0 comments on commit 637b164

Please sign in to comment.