Skip to content

Tweaks to build the whole project on Windows with CMake/MSVC 19 in 2026 - #305

Open
twdragon wants to merge 3 commits into
Beckhoff:masterfrom
twdragon:master
Open

Tweaks to build the whole project on Windows with CMake/MSVC 19 in 2026#305
twdragon wants to merge 3 commits into
Beckhoff:masterfrom
twdragon:master

Conversation

@twdragon

Copy link
Copy Markdown
  • Fixed the PLC port definitions mistakenly left in the BSD section in the test program
  • Added CMake tweaks to successfully build the project on Windows natively using git/MSVC/PowerShell
  • Implemented TcAdsDll_ROOT CMake variable to let the build system catch the libraries from non-standard locations. Tested on non-native installation in Windows 10.0.19045 and SDK 10.0.26100.0

twdragon added 2 commits July 30, 2026 16:55
    - Fixed the PLC port definitions mistakenly left in the BSD section
      in the test program
    - Added CMake tweaks to successfully build the project on Windows natively
      using git/MSVC/PowerShell
    - Implemented TcAdsDll_ROOT CMake variable to let the build system catch
      the libraries from non-standard locations. Tested on non-native
      installation in Windows 10.0.19045 and SDK 10.0.26100.0
@juarezr-mvtec

juarezr-mvtec commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Hello, I am not the maintainer, but I authored the FindTcAdsDll.cmake file that you are editing. I suggest that you should keep the support for finding TcAdsDll in old TwinCAT versions ? The way you are doing it is correct but will only work for the newest versions.
So instead of changing the variable value just try make it an array :
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(TcAdsDll_IMPLIB_DIR "${TcAdsDll_ROOT_DIR}/Lib/x64" "${TcAdsDll_ROOT_DIR}/x64/lib")
set(TcAdsDll_DLL_DIR "${TcAdsDll_ROOT_DIR}/x64" "${TcAdsDll_ROOT_DIR}/../../Common64")
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(TcAdsDll_IMPLIB_DIR "${TcAdsDll_ROOT_DIR}/Lib")
set(TcAdsDll_DLL_DIR "${TcAdsDll_ROOT_DIR}" "${TcAdsDll_ROOT_DIR}/../../Common32")
endif()

The find_library and find_file PATHS argument take an array anyways.

Additionally, since the default location is no longer C:/TwinCAT/.. in the new version so we can probably change it to something like this:

if (WIN32 AND NOT DEFINED TcAdsDll_ROOT)
# Typical install locations on Windows
set(_TcAdsDll_PATH "$ENV{SystemDrive}/TwinCAT/AdsApi/TcAdsDll")
if( NOT EXISTS ${_TcAdsDll_PATH})
# New TwinCAT 3.5+ default location
set(_TcAdsDll_PATH "$ENV{ProgramFiles(x86)}/Beckhoff/TwinCAT/AdsApi/TcAdsDll")
endif()
else ()

Try them out, tell me if it works.

@twdragon

twdragon commented Aug 6, 2026

Copy link
Copy Markdown
Author

@juarezr-mvtec thanks for the suggestion! Unfortunately, direct introduction of array-like path lists did not work, so I used separate variables.

@twdragon

twdragon commented Aug 6, 2026

Copy link
Copy Markdown
Author

@juarezr-mvtec I will also try to fix the Linux pipeline, but I cannot promise to do it now, so likely it will be a separate PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants