Loading CMakeLists.txt +8 −1 Original line number Diff line number Diff line cmake_minimum_required(VERSION 3.20) set(_MCP2221A_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "MCP2221A library directory") # Function to copy the MCP2221 DLL to the target directory after build function(copy_runtime_dll target) if(WIN32) set(_dll_path "${_MCP2221A_CMAKE_DIR}/MCP2221_DLL/unmanaged/dll/mcp2221_dll_um_x64.dll") # Make sure backslashes are converted to forward slashes for Windows file(TO_CMAKE_PATH "${_dll_path}" _dll_path_normalized) add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/MCP2221_DLL/unmanaged/dll/mcp2221_dll_um_x64.dll" "${_dll_path_normalized}" $<TARGET_FILE_DIR:${target}> COMMENT "Copying MCP2221 DLL to output directory" ) Loading tests/CMakeLists.txt +4 −2 Original line number Diff line number Diff line Loading @@ -12,5 +12,7 @@ add_executable(i2c_scan i2c_scan.cpp) target_link_libraries(i2c_scan PRIVATE mcp2221a) copy_runtime_dll(i2c_scan) if (UNIX) add_executable(hid_test hid_test.cpp) target_link_libraries(hid_test PRIVATE mcp2221a) endif() No newline at end of file Loading
CMakeLists.txt +8 −1 Original line number Diff line number Diff line cmake_minimum_required(VERSION 3.20) set(_MCP2221A_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "MCP2221A library directory") # Function to copy the MCP2221 DLL to the target directory after build function(copy_runtime_dll target) if(WIN32) set(_dll_path "${_MCP2221A_CMAKE_DIR}/MCP2221_DLL/unmanaged/dll/mcp2221_dll_um_x64.dll") # Make sure backslashes are converted to forward slashes for Windows file(TO_CMAKE_PATH "${_dll_path}" _dll_path_normalized) add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/MCP2221_DLL/unmanaged/dll/mcp2221_dll_um_x64.dll" "${_dll_path_normalized}" $<TARGET_FILE_DIR:${target}> COMMENT "Copying MCP2221 DLL to output directory" ) Loading
tests/CMakeLists.txt +4 −2 Original line number Diff line number Diff line Loading @@ -12,5 +12,7 @@ add_executable(i2c_scan i2c_scan.cpp) target_link_libraries(i2c_scan PRIVATE mcp2221a) copy_runtime_dll(i2c_scan) if (UNIX) add_executable(hid_test hid_test.cpp) target_link_libraries(hid_test PRIVATE mcp2221a) endif() No newline at end of file