Use `MSVC_RUNTIME_LIBRARY` instead of setting compile flags manually
https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html
Clang's GNU driver wouldn't recognize /MT flag when cross-compiling for Windows, let CMake handle compile flags internally instead
@illnyang this is not working as intended on Windows / MSVC . Please verify and try again. The produced Windows plugin should be statically linked in Release build and should have no CRT dependencies.
cmake --build . --config Release
Thanks!
I didn't notice that the minimum required version throughout ida-cmake is 3.12, it needs to be bumped to 3.15 for this property to take effect. I think it's reasonable to do so, that version was released back in 2017 and CMAKE_CXX_STANDARD is set to 17 in all sample addons as well.
sorry, I did not notice you updated the PR. I read quickly and saw you asked for a bump.
Indeed, I tought I did that before. Ok, I pushed to 3.27 ; fair and from last year.
please revert the last change. it is a different topic anyway.
Clang's GNU driver wouldn't recognize /MT flag when cross-compiling for Windows, let CMake handle compile flags internally instead
Can you please tell me how to cross-compile and verify (full steps)? I can test, like I did before, on Windows. So give me some time to make sure on Windows, after bumping the CMake version, after your changes, we still get static linking.
I use the following CMAKE_TOOLCHAIN_FILE:
find_program(LLD_LINK_PATH NAMES lld-link)
if (${LLD_LINK_PATH} STREQUAL "LLD_LINK_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find lld-link")
endif ()
find_program(CLANG_C_PATH NAMES clang)
if (${CLANG_C_PATH} STREQUAL "CLANG_C_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find clang")
endif ()
find_program(CLANG_CXX_PATH NAMES clang++)
if (${CLANG_CXX_PATH} STREQUAL "CLANG_CXX_PATH-NOTFOUND")
message(SEND_ERROR "Unable to find clang++")
endif ()
set(CMAKE_LINKER_TYPE LLD CACHE STRING "")
set(CMAKE_C_COMPILER "${CLANG_C_PATH}" CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER "${CLANG_CXX_PATH}" CACHE FILEPATH "")
I'm not sure whether find_program will find your LLVM installation on Windows, but you can set paths manually if it doesn't.
I verified that it works by opening built DLL in pe-bear: