From a9af9341b9b1f7f693505c7227bcd638edcf39a8 Mon Sep 17 00:00:00 2001 From: Josef Wienerroither Date: Mon, 8 Dec 2025 14:43:46 +0100 Subject: [PATCH] chore: update ifcmax cmakelists --- src/ifcmax/CMakeLists.txt | 107 +++++++++++++++++++++++++++++++------- src/ifcmax/IfcMax.rc | Bin 0 -> 4088 bytes src/ifcmax/resource.h | 23 ++++++++ 3 files changed, 111 insertions(+), 19 deletions(-) create mode 100644 src/ifcmax/IfcMax.rc create mode 100644 src/ifcmax/resource.h diff --git a/src/ifcmax/CMakeLists.txt b/src/ifcmax/CMakeLists.txt index d306758b67..2d451e7eab 100644 --- a/src/ifcmax/CMakeLists.txt +++ b/src/ifcmax/CMakeLists.txt @@ -18,9 +18,20 @@ ################################################################################ # check for 3ds Max SDK -foreach(max_year RANGE 2014 2030) - set(max_sdk "$ENV{ADSK_3DSMAX_SDK_${max_year}}") +set(valid_max_years 2027 2026 2025 2024 2023 2022 2021 2020 2019 2018 2017) +# might be dangerous to use tools 143 for all max versions +set(max_toolset_versions_143 "2017" "2018" "2019" "2020" "2021" "2022" "2023" "2024" "2025" "2026" "2027" ) +# set(max_toolset_versions_143 "2025" "2026" "2027" ) +# set(max_toolset_versions_142 "2022" "2023" "2024" ) +# set(max_toolset_versions_141 "2020" "2021" ) +# set(max_toolset_versions_140 "2017" "2018" "2019" ) +# set(max_toolset_versions_110 "2015" "2016" ) +# set(max_toolset_versions_100 "2013" "2014" ) +# set(max_toolset_versions_90 "2010" "2011" "2012" ) + +foreach(max_year ${valid_max_years}) + set(max_sdk "$ENV{ADSK_3DSMAX_SDK_${max_year}}") if(NOT "${max_sdk}" STREQUAL "") message(STATUS "Autodesk 3ds Max SDK ${max_year} found at ${max_sdk}") list(APPEND FOUND_MAX_YEARS ${max_year}) @@ -29,22 +40,41 @@ foreach(max_year RANGE 2014 2030) endif() endforeach() +message(STATUS) + if(HAS_MAX) - # build libraray for each found 3ds Max SDK + # set depenency include and link directoris outside of MaxSDK loop + include_directories(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS} ${ICU_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ) + link_directories(${LINK_DIRECTORIES} ${IfcOpenShell_BINARY_DIR} ${OCC_LIBRARY_DIR} ${OPENCOLLADA_LIBRARY_DIR} ${ICU_LIBRARY_DIR} ${Boost_LIBRARY_DIRS} ) + + # Specify individual source files + set(MAX_SOURCES + IfcMax.h + IfcMax.cpp + IfcMax.rc + resource.h + # IfcHelper.h + # IfcHelper.cpp + # MaxUtils.h + # MaxUtils.cpp + ) + + # build library for each found 3ds Max SDK foreach(max_year max_sdk IN ZIP_LISTS FOUND_MAX_YEARS FOUND_MAX_SDKS) - message(STATUS "Building IFCMax library for Autodesk 3ds Max SDK ${max_year}") + # skip 3ds Max versions that do not match the vs toolset + if( NOT ${max_year} IN_LIST max_toolset_versions_${MSVC_TOOLSET_VERSION} ) + continue() + endif() - include_directories(${INCLUDE_DIRECTORIES} ${OPENCOLLADA_INCLUDE_DIRS} ${ICU_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} ${max_sdk}/include - ) + message(STATUS "Adding build target: IFCMax for 3ds Max SDK ${max_year}, Tier: ${BUILD_TIER_NAME}") - # All recent versions of 3ds Max (2014 and newer) are 64-bit only so assume lib/x64 directory - link_directories(${LINK_DIRECTORIES} ${IfcOpenShell_BINARY_DIR} ${OPENCOLLADA_LIBRARY_DIR} - ${ICU_LIBRARY_DIR} ${Boost_LIBRARY_DIRS} ${max_sdk}/lib/x64/Release - ) - - add_library(IfcMax_${max_year} SHARED IfcMax.h IfcMax.cpp) + add_library(IfcMax_${max_year} SHARED ${MAX_SOURCES}) + + target_include_directories(IfcMax_${max_year} PRIVATE ${max_sdk}/include) + + # All recent versions of 3ds Max (2014 and newer) are 64-bit only so assume lib/x64 directory + target_link_directories(IfcMax_${max_year} PRIVATE ${max_sdk}/lib/x64/Release) # TODO: find the minimal subset of 3dsmax libraries to reference target_link_libraries(IfcMax_${max_year} ${IFCOPENSHELL_LIBRARIES} @@ -63,8 +93,6 @@ if(HAS_MAX) maxnet.lib Maxscrpt.lib maxutil.lib - MenuMan.lib - menus.lib mesh.lib MNMath.lib Paramblk2.lib @@ -73,14 +101,55 @@ if(HAS_MAX) RenderUtil.lib tessint.lib viewfile.lib - zlibdll.lib - ${OpenCASCADE_LIBRARIES} - ) + ${OPENCASCADE_LIBRARIES} + ) + + # Note: libraries build by same major vs toolset versions are binary compatible. so v14x builds can be intermixed + # Older Max versions using v110 or older require dependencies being build using the according toolset version ( most likely ) + if( ${max_year} IN_LIST max_toolset_versions_143 ) + set_target_properties( IfcMax_${max_year} PROPERTIES VS_PLATFORM_TOOLSET v143) + elseif( ${max_year} IN_LIST max_toolset_versions_142 ) + set_target_properties( IfcMax_${max_year} PROPERTIES VS_PLATFORM_TOOLSET v142) + elseif( ${max_year} IN_LIST max_toolset_versions_141 ) + set_target_properties( IfcMax_${max_year} PROPERTIES VS_PLATFORM_TOOLSET v141) + elseif( ${max_year} IN_LIST max_toolset_versions_140 ) + set_target_properties( IfcMax_${max_year} PROPERTIES VS_PLATFORM_TOOLSET v140) + elseif( ${max_year} IN_LIST max_toolset_versions_110 ) + set_target_properties( IfcMax_${max_year} PROPERTIES VS_PLATFORM_TOOLSET v110) + elseif( ${max_year} IN_LIST max_toolset_versions_100 ) + set_target_properties( IfcMax_${max_year} PROPERTIES VS_PLATFORM_TOOLSET v100) + elseif( ${max_year} IN_LIST max_toolset_versions_90 ) + set_target_properties( IfcMax_${max_year} PROPERTIES VS_PLATFORM_TOOLSET v90) + endif() + # prevent minmax macro clashes occuring with ifcOpenShell v0.8 + target_compile_definitions(IfcMax_${max_year} PRIVATE NOMINMAX) + + # fix 3ds Max 2020 SDK's "/permissive-" flag incompatibility / disables C++ language conformance mode + if( ${max_year} EQUAL 2020 ) + set_source_files_properties( "IfcMax.cpp" PROPERTIES COMPILE_FLAGS "/permissive") + endif() + + # C++17 required for 3ds Max SDK 2025 and higher + if( ${max_year} GREATER_EQUAL 2025 ) + set_target_properties(IfcMax_${max_year} PROPERTIES CXX_STANDARD 17) + endif() + set_target_properties(IfcMax_${max_year} PROPERTIES SUFFIX ".dli") + + if(BUILD_TIER_NAME) + target_compile_definitions(IfcMax_${max_year} PRIVATE BUILD_${BUILD_TIER_NAME}_TIER) + + string(TOLOWER "${BUILD_TIER_NAME}" BUILD_TIER_lower) + if(BUILD_TIER_lower STREQUAL "free") + set_target_properties(IfcMax_${max_year} PROPERTIES OUTPUT_NAME "IfcMax_Free_${max_year}") + endif() + endif() + + install(TARGETS IfcMax_${max_year} RUNTIME DESTINATION ${BINDIR}) - install(TARGETS IfcMax_${max_year}) endforeach() + message(STATUS) else() message(STATUS "Autodesk 3ds Max SDK not found, is required to build IFCMax.") endif() diff --git a/src/ifcmax/IfcMax.rc b/src/ifcmax/IfcMax.rc new file mode 100644 index 0000000000000000000000000000000000000000..b6ed3491783ad0a8d6310a9b35b6dae49f29bfaa GIT binary patch literal 4088 zcmdUyT~8B16o${WiT`0OHxLB`qqnAAO0AUAumv?CX^^&9Qw!;~F(&?Y^?7GI&~|qb ziWh4p+nGH(Gw16)AN~Dn+qNyRLmSwIjqS=}p1w_>okELkYUeiOEwty1z%H$4Bc3tz z33C_Pm|5qhtS(pwyy>=qU9)G)p4t<*Y`b|4>WHsHc6Z(0QtJGceX)|;t&?kRU*Db6 z-DPW8WNkaKJ*(T1b?n%xQ1@6jtzn;_MEo9F1xkap=PwzGH@tLy4y=Y}y` z{U=yQc4(vZM}F&Q9ipe~QH8$Cv+R+-`{28?Z*p$Y{>8JHmncEU6k7>Nee_-p8{YE% z-eS#Ox&ZHvh`%A8iorl&>-c=cn~%eYRT7o4ZDgPzo{Oo0v)8kQ*y?g)+4ezI5>pZJ zb3$~5aPEMv21ED$WCXb<+uU&shC7^Ua(=^cZ9r{8Jz=gnoO(*Kug2YVV)dQ9;O>Zh z6)4G>by6KZcDSmsD!Z7i-hsF} zc#6mjiuDTXDsQ2?p~ZPs^X83(W#kIICgn( z3}xNk^B&J?!Uy#5^;9)f`BD{hOlDd{+I^(!z*YT*D(!00ZE|uS?mdROEJ+e0)fM_Z zUUp^BBP49QjGb>^$)4D6AKvn9o-O1PW%IkerTbKer|2T={BT;TClpmx$!i$G?VMfm zPn^TGOongIH0i*}5~)IYC-TUE-iOVQkJ;Z=mHxLbmL6ByHUw zA#{~gb-aNNdYg~8TP&nwsfA9mnmYN1b6U1m30wB?fFf83QC>+R_qMO~xE##I_1hWm z#fp@lm;X(tG@m1jwf6bf&#JL~7ioEYaJnuPOQU&dd>!)hWB(DUPq_OZk+