mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-24 09:23:27 +00:00
The deps superbuild passes the Visual Studio generator and platform to every sub-build but not the toolset, so build_win.bat -d -l without -x compiled every dependency with cl even though the superbuild had been configured with -T ClangCL; CMake replaces the forwarded CMAKE_<LANG>_COMPILER with whatever the toolset ran. The recipes that adapt to clang-cl then disagreed with what had been built, and wxInspector told FindwxWidgets to look in lib/clang_x64_lib while the cl-built wxWidgets had installed into lib/vc_x64_lib: Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS core base aui propgrid) Forward CMAKE_GENERATOR_TOOLSET as well, so the dependencies compile with clang-cl under MSBuild the way they already do under Ninja. Four of them need more than that: - OpenSSL always builds with cl, and MSBuild runs its nmake steps in the project's toolset environment, where ClangCL puts clang's include directory first and cl trips over clang's stdint.h. The project gets the default toolset. - Boost.Container's dlmalloc needs -Wno-incompatible-pointer-types under clang. boost_container links as C++, and the Visual Studio generator writes only the link language's flags into the project, so its C file never saw CMAKE_C_FLAGS. Under that generator the option goes through the C++ flags as well, with the defaults kept. - Draco's tools and NLopt's testopt compile sources their own static library also contains. MSBuild lists libraries before objects and lld-link resolves archive members as each input arrives, so the library's copy is pulled in before the executable's own object and the link fails on duplicate symbols; link.exe defers the search and Ninja lists the objects first. Nothing uses those executables, so they get /FORCE:MULTIPLE there. The Ninja path is unchanged: the generated configure commands of all 29 dependencies are identical before and after. OCCT's arm64 override to cl still applies under Ninja but not under the Visual Studio generator, where the toolset wins; that combination never built and is left for a follow-up.
86 lines
2.8 KiB
CMake
86 lines
2.8 KiB
CMake
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
|
if (MSVC_VERSION EQUAL 1800)
|
|
# 1800 = VS 12.0 (v120 toolset)
|
|
set(DEP_VS_VER "12")
|
|
set(DEP_BOOST_TOOLSET "msvc-12.0")
|
|
elseif (MSVC_VERSION EQUAL 1900)
|
|
# 1900 = VS 14.0 (v140 toolset)
|
|
set(DEP_VS_VER "14")
|
|
set(DEP_BOOST_TOOLSET "msvc-14.0")
|
|
elseif (MSVC_VERSION LESS 1920)
|
|
# 1910-1919 = VS 15.0 (v141 toolset)
|
|
set(DEP_VS_VER "15")
|
|
set(DEP_BOOST_TOOLSET "msvc-14.1")
|
|
elseif (MSVC_VERSION LESS 1930)
|
|
# 1920-1929 = VS 16.0 (v142 toolset)
|
|
set(DEP_VS_VER "16")
|
|
set(DEP_BOOST_TOOLSET "msvc-14.2")
|
|
elseif (MSVC_VERSION LESS 1950)
|
|
# 1930-1949 = VS 17.0 (v143 toolset)
|
|
set(DEP_VS_VER "17")
|
|
set(DEP_BOOST_TOOLSET "msvc-14.3")
|
|
elseif (MSVC_VERSION LESS 1960)
|
|
# 1950-1959 = VS 18.0 (v145 toolset)
|
|
set(DEP_VS_VER "18")
|
|
set(DEP_BOOST_TOOLSET "msvc-14.5")
|
|
else ()
|
|
message(FATAL_ERROR "Unsupported MSVC version")
|
|
endif ()
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
|
set(DEP_BOOST_TOOLSET "clang-win")
|
|
endif ()
|
|
|
|
set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER}")
|
|
if ("${DEPS_ARCH}" STREQUAL "x86")
|
|
set(DEP_PLATFORM "Win32")
|
|
elseif ("${DEPS_ARCH}" STREQUAL "x64")
|
|
set(DEP_PLATFORM "x64")
|
|
elseif ("${DEPS_ARCH}" STREQUAL "arm64")
|
|
set(DEP_PLATFORM "ARM64")
|
|
else ()
|
|
message(FATAL_ERROR "Unsupported OS architecture: ${DEPS_ARCH}")
|
|
endif ()
|
|
|
|
# Draco's tools and NLopt's testopt compile sources that are also in their
|
|
# static library. MSBuild passes the library before the objects and lld-link
|
|
# resolves as it goes, so the library's copy wins and the object then reads as
|
|
# a duplicate. Nothing uses those executables, so let lld keep the first one.
|
|
set(DEP_LLD_FORCE_MULTIPLE "")
|
|
if (CMAKE_GENERATOR MATCHES "Visual Studio" AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
set(DEP_LLD_FORCE_MULTIPLE "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} /FORCE:MULTIPLE")
|
|
endif ()
|
|
|
|
if (${DEP_DEBUG})
|
|
set(DEP_BOOST_DEBUG "debug")
|
|
else ()
|
|
set(DEP_BOOST_DEBUG "")
|
|
endif ()
|
|
|
|
macro(add_debug_dep _dep)
|
|
if (${DEP_DEBUG})
|
|
ExternalProject_Get_Property(${_dep} BINARY_DIR)
|
|
ExternalProject_Add_Step(${_dep} build_debug
|
|
DEPENDEES build
|
|
DEPENDERS install
|
|
COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
|
|
WORKING_DIRECTORY "${BINARY_DIR}"
|
|
)
|
|
endif ()
|
|
endmacro()
|
|
|
|
if ("${DEPS_ARCH}" STREQUAL "x86")
|
|
set(DEP_WXWIDGETS_TARGET "")
|
|
set(DEP_WXWIDGETS_LIBDIR "vc_lib")
|
|
elseif ("${DEPS_ARCH}" STREQUAL "x64")
|
|
set(DEP_WXWIDGETS_TARGET "TARGET_CPU=X64")
|
|
set(DEP_WXWIDGETS_LIBDIR "vc_x64_lib")
|
|
elseif ("${DEPS_ARCH}" STREQUAL "arm64")
|
|
set(DEP_WXWIDGETS_TARGET "TARGET_CPU=ARM64")
|
|
set(DEP_WXWIDGETS_LIBDIR "vc_arm64_lib")
|
|
else ()
|
|
message(FATAL_ERROR "Unsupported OS architecture: ${DEPS_ARCH}")
|
|
endif ()
|
|
|
|
find_package(Git REQUIRED)
|