Modifications to build C++ with Visual Studio 2026 and the v145 toolset. (#9359)

* Modifications to build C++ with Visual Studio 2026 and the v145 toolset.

* Fixes linker settings for rocksdb for Debug and Release builds

* module is a C++ 20 keyword. Explicitly stating namespace allows cpp20 projects to build against the library

* Fixes crash when initializing an object with the initialize function when some of the attributes are empty, {}, or omitted, std::nullopt

* cleanup for vs2026 v145 toolset per @aothms review

* Fixes bug, IfcCurveSegment.setStartLength was setSegmentLength in alignment_helper.cpp

* Bumps boost to 1.92
This commit is contained in:
Richard Brice
2026-08-26 09:10:41 -07:00
committed by GitHub
parent 05e5a375f5
commit 05ba93ab61
7 changed files with 133 additions and 53 deletions
+38 -20
View File
@@ -178,26 +178,31 @@ if((BUILD_CONVERT OR BUILD_GEOMSERVER OR BUILD_IFCPYTHON) AND(NOT BUILD_IFCGEOM)
set(BUILD_IFCGEOM ON)
endif()
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "`ccache` is found, using it as a compiler launcher.")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}")
if(MSVC)
# By default Visual Studio generators will use /Zi which is not compatible
# with ccache, so tell Visual Studio to use /Z7 instead.
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
# Not needed for Ninja.
if(CMAKE_GENERATOR MATCHES "Visual Studio")
file(COPY_FILE
${CCACHE_FOUND} ${CMAKE_BINARY_DIR}/cl.exe
ONLY_IF_DIFFERENT)
set(CMAKE_VS_GLOBALS
"CLToolExe=cl.exe"
"CLToolPath=${CMAKE_BINARY_DIR}"
"UseMultiToolTask=true"
)
option(USE_CCACHE "Use ccache as a compiler launcher if it is found" OFF)
if(USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "`ccache` is found, using it as a compiler launcher.")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}")
if(MSVC)
# By default Visual Studio generators will use /Zi which is not compatible
# with ccache, so tell Visual Studio to use /Z7 instead.
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
# Not needed for Ninja.
if(CMAKE_GENERATOR MATCHES "Visual Studio")
file(COPY_FILE
${CCACHE_FOUND} ${CMAKE_BINARY_DIR}/cl.exe
ONLY_IF_DIFFERENT)
set(CMAKE_VS_GLOBALS
"CLToolExe=cl.exe"
"CLToolPath=${CMAKE_BINARY_DIR}"
"UseMultiToolTask=true"
)
endif()
endif()
endif()
else()
message(STATUS "ccache usage disabled via USE_CCACHE=OFF")
endif()
if(MSVC AND MSVC_PARALLEL_BUILD)
@@ -311,12 +316,25 @@ if (WITH_ROCKSDB)
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_ROCKSDB)
# See https://github.com/facebook/rocksdb/issues/981.
if(TARGET RocksDB::rocksdb)
target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE RocksDB::rocksdb)
set(IFCOPENSHELL_ROCKSDB_IMPORTED_TARGET RocksDB::rocksdb)
elseif(TARGET RocksDB::rocksdb-shared)
target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE RocksDB::rocksdb-shared)
set(IFCOPENSHELL_ROCKSDB_IMPORTED_TARGET RocksDB::rocksdb-shared)
else()
message(FATAL_ERROR "RocksDB found but neither RocksDB::rocksdb nor RocksDB::rocksdb-shared target exists")
endif()
# Our win/build-deps.cmd builds RocksDB separately per Debug/Release config into the
# same install prefix, so the imported target only ever has DEBUG and RELEASE listed in
# IMPORTED_CONFIGURATIONS. On a multi-config generator (Visual Studio), CMake maps any
# unmatched build config to the *first* entry of that list, which happens to be DEBUG
# (RocksDBTargets-debug.cmake sorts before RocksDBTargets-release.cmake). Without an
# explicit mapping, RelWithDebInfo and MinSizeRel builds would end up linking the
# /MDd-flavored rocksdb_d.lib into an /MD (NDEBUG) binary, causing a CRT/runtime-library
# mismatch that depends on nothing but that alphabetical ordering.
set_target_properties(${IFCOPENSHELL_ROCKSDB_IMPORTED_TARGET} PROPERTIES
MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE
MAP_IMPORTED_CONFIG_MINSIZEREL RELEASE
)
target_link_libraries(IFCOPENSHELL_RocksDB INTERFACE ${IFCOPENSHELL_ROCKSDB_IMPORTED_TARGET})
if (WITH_ZSTD)
# @todo do we actually need the zstd include dir or rather just pass