Skip to content

Commit

Permalink
Add workaround to always build manif python bindings with clang-cl
Browse files Browse the repository at this point in the history
  • Loading branch information
traversaro committed Sep 5, 2024
1 parent 950214f commit 93dc14b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion cmake/Buildmanif.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@

include(YCMEPHelper)

# Workaround for https://github.com/artivis/manif/issues/311, if use use python bindings
# on Windows with MSVC we need to specify somehow the use of clang-cl
set(manif_CMAKE_GENERATOR_YCM_ARGS "")
set(manif_CLANG_CL_CMAKE_ARGS "")
if(ROBOTOLOGY_USES_PYTHON AND MSVC)
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
# If Visual Studio is used, we specify the use of ClangCL via the CMake Generator Toolset option
list(APPEND manif_CMAKE_GENERATOR_YCM_ARGS CMAKE_GENERATOR "${CMAKE_GENERATOR}")
list(APPEND manif_CMAKE_GENERATOR_YCM_ARGS CMAKE_GENERATOR_TOOLSET "ClangCL")
else()
# Otherwise, we specify the use of clang-cl via CMAKE_C_COMPILER and CMAKE_CXX_COMPILER versions
message(STATUS "VS: $ENV{VSINSTALLDIR} VC: $ENV{VCINSTALLDIR}")
if($ENV{VCINSTALLDIR} STREQUAL "")
message(FATAL_ERROR "Building robotology-superbuild with CMAKE_GENERATOR=${CMAKE_GENERATOR} and ROBOTOLOGY_USES_PYTHON is enabled, but no VCINSTALLDIR env variable defined.")
endif()
set(CANDIDATE_CLANG_CL_LOCATION $ENV{VCINSTALLDIR}\\Tools\\Llvm\\x64\\bin\\clang-cl.exe)
if(NOT EXISTS ${CANDIDATE_CLANG_CL_LOCATION})
message(FATAL_ERROR "Building robotology-superbuild on Windows ROBOTOLOGY_USES_PYTHON is enabled requires the 'C++ Clang Compiler for Windows' and 'C++ Clang-cl for vXYZ build tools' components of Visual Studio, but ${CANDIDATE_CLANG_CL_LOCATION} was not found. Please install the required components and try again.")
endif()
list(APPEND manif_CLANG_CL_CMAKE_ARGS "-DCMAKE_C_COMPILER=${CANDIDATE_CLANG_CL_LOCATION}")
list(APPEND manif_CLANG_CL_CMAKE_ARGS "-DCMAKE_CXX_COMPILER=${CANDIDATE_CLANG_CL_LOCATION}")
endif()
endif()

# We pass CMAKE_CXX_STANDARD=17 as we encountered problems when using -march=native
# and mixing libraries compiled with C++11 and C++17, see
# https://github.com/artivis/manif/issues/274
Expand All @@ -13,7 +37,8 @@ ycm_ep_helper(manif TYPE GIT
TAG master
COMPONENT external
FOLDER src
CMAKE_ARGS -DCMAKE_CXX_STANDARD=17 -DBUILD_TESTING:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=${ROBOTOLOGY_USES_PYTHON} -DMANIFPY_PKGDIR:PATH=${YCM_EP_INSTALL_DIR}/${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR})
${manif_CMAKE_GENERATOR_YCM_ARGS}
CMAKE_ARGS -DCMAKE_CXX_STANDARD=17 -DBUILD_TESTING:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=${ROBOTOLOGY_USES_PYTHON} -DMANIFPY_PKGDIR:PATH=${YCM_EP_INSTALL_DIR}/${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR} ${manif_CLANG_CL_CMAKE_ARGS})

set(manif_CONDA_PKG_NAME manif)
set(manif_CONDA_PKG_CONDA_FORGE_OVERRIDE ON)
Expand Down
2 changes: 1 addition & 1 deletion releases/latest.releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repositories:
YCM:
type: git
url: https://github.com/robotology/ycm.git
version: v0.16.7
version: v0.16.8
YARP:
type: git
url: https://github.com/robotology/yarp.git
Expand Down

0 comments on commit 93dc14b

Please sign in to comment.