@@ -77,6 +77,7 @@ endfunction()
7777_VALIDATE_ENV_V_(LIB)
7878_VALIDATE_ENV_V_(INCLUDE )
7979
80+ # compilers/linkers
8081set (CMAKE_C_COMPILER "${MSVC_TOOLSET_DIR} /bin/Host${ARCH} /${ARCH} /cl.exe" CACHE FILEPATH "" )
8182set (CMAKE_CXX_COMPILER "${MSVC_TOOLSET_DIR} /bin/Host${ARCH} /${ARCH} /cl.exe" CACHE FILEPATH "" )
8283set (CMAKE_ASM_COMPILER "${MSVC_TOOLSET_DIR} /bin/Host${ARCH} /${ARCH} /cl.exe" CACHE FILEPATH "" )
@@ -111,4 +112,46 @@ if(EXISTS "${HINT}")
111112endif ()
112113endmacro ()
113114
114- _REQUEST_EXTENSION_(DIASDK_INCLUDE_DIR "${VS_INSTANCE_LOCATION} /DIA SDK/include" )
115+ _REQUEST_EXTENSION_(DIASDK_INCLUDE_DIR "${VS_INSTANCE_LOCATION} /DIA SDK/include" )
116+
117+ # redists
118+ function (_REQUEST_REDIST_MODULES BASE OUTPUT )
119+ if (NOT EXISTS "${BASE} " )
120+ message (FATAL_ERROR "Internal error, base \" ${BASE} \" for redist module search directories doesn't exist - is your build tools installation corrupted?" )
121+ endif ()
122+
123+ file (GLOB_RECURSE _MODULES LIST_DIRECTORIES false "${BASE} /*.dll" )
124+
125+ set (_DIRS)
126+ foreach (f IN LISTS _MODULES)
127+ get_filename_component (d "${f} " DIRECTORY )
128+ list (APPEND _DIRS "${d} " )
129+ endforeach ()
130+
131+ list (REMOVE_DUPLICATES _DIRS)
132+
133+ set (${OUTPUT} "${_DIRS} " )
134+
135+ if (NOT ${OUTPUT} )
136+ message (FATAL_ERROR "Internal error, no redist module search directories found (CRTs) - is your build tools installation corrupted?" )
137+ endif ()
138+
139+ set (${OUTPUT} "${${OUTPUT} }" PARENT_SCOPE)
140+ endfunction ()
141+
142+ cmake_path(GET MSVC_TOOLSET_DIR FILENAME MSVC_VERSION )
143+ cmake_path(CONVERT "${VS_INSTANCE_LOCATION} /VC/Redist/MSVC/${MSVC_VERSION} " TO_CMAKE_PATH_LIST MSVC_REDIST_BASE NORMALIZE)
144+ _REQUEST_REDIST_MODULES("${MSVC_REDIST_BASE} /${ARCH} " RELEASE_REDISTS)
145+ _REQUEST_REDIST_MODULES("${MSVC_REDIST_BASE} /debug_nonredist/${ARCH} " DEBUG_REDISTS)
146+ set (MSVC_REDIST_MODULE_DIRECTORIES "${RELEASE_REDISTS} ;${DEBUG_REDISTS} " CACHE FILEPATH "MSVC Redist module search directories" )
147+
148+ # launchers
149+ if (WIN32 )
150+ set (SHELL_LAUNCHER "cmd /C" )
151+ else ()
152+ set (SHELL_LAUNCHER "sh -c" )
153+ endif ()
154+
155+ set_property (GLOBAL PROPERTY RULE_LAUNCH_CUSTOM
156+ "${CMAKE_COMMAND} -E env --modify PATH=path_list_prepend:${MSVC_REDIST_MODULE_DIRECTORIES} -- ${SHELL_LAUNCHER} "
157+ )
0 commit comments