Changeset View
Changeset View
Standalone View
Standalone View
build_files/cmake/platform/platform_win32.cmake
| Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
| endmacro() | endmacro() | ||||
| add_definitions(-DWIN32) | add_definitions(-DWIN32) | ||||
| # Needed, otherwise system encoding causes utf-8 encoding to fail in some cases (C4819) | # Needed, otherwise system encoding causes utf-8 encoding to fail in some cases (C4819) | ||||
| add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>") | add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>") | ||||
| add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>") | add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>") | ||||
| # Minimum MSVC Version | |||||
| if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) | |||||
| if(MSVC_VERSION EQUAL 1800) | |||||
| set(_min_ver "18.0.31101") | |||||
| if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver}) | |||||
| message(FATAL_ERROR | |||||
| "Visual Studio 2013 (Update 4, ${_min_ver}) required, " | |||||
| "found (${CMAKE_CXX_COMPILER_VERSION})") | |||||
| endif() | |||||
| endif() | |||||
| if(MSVC_VERSION EQUAL 1900) | |||||
| set(_min_ver "19.0.24210") | |||||
| if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver}) | |||||
| message(FATAL_ERROR | |||||
| "Visual Studio 2015 (Update 3, ${_min_ver}) required, " | |||||
| "found (${CMAKE_CXX_COMPILER_VERSION})") | |||||
| endif() | |||||
| endif() | |||||
| endif() | |||||
| unset(_min_ver) | |||||
| # needed for some MSVC installations | # needed for some MSVC installations | ||||
| # 4099 : PDB 'filename' was not found with 'object/library' | # 4099 : PDB 'filename' was not found with 'object/library' | ||||
| string(APPEND CMAKE_EXE_LINKER_FLAGS " /SAFESEH:NO /ignore:4099") | string(APPEND CMAKE_EXE_LINKER_FLAGS " /SAFESEH:NO /ignore:4099") | ||||
| string(APPEND CMAKE_SHARED_LINKER_FLAGS " /SAFESEH:NO /ignore:4099") | string(APPEND CMAKE_SHARED_LINKER_FLAGS " /SAFESEH:NO /ignore:4099") | ||||
| string(APPEND CMAKE_MODULE_LINKER_FLAGS " /SAFESEH:NO /ignore:4099") | string(APPEND CMAKE_MODULE_LINKER_FLAGS " /SAFESEH:NO /ignore:4099") | ||||
| list(APPEND PLATFORM_LINKLIBS | list(APPEND PLATFORM_LINKLIBS | ||||
| ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 Comctl32 version | ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 Comctl32 version | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28.29828) | ||||
| string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " /INCREMENTAL:NO") | string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " /INCREMENTAL:NO") | ||||
| else() | else() | ||||
| message("-- ASAN not supported on MSVC ${CMAKE_CXX_COMPILER_VERSION}") | message("-- ASAN not supported on MSVC ${CMAKE_CXX_COMPILER_VERSION}") | ||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| # C++ standards conformace (/permissive-) is available on msvc 15.5 (1912) and up | # C++ standards conformace (/permissive-) is available on msvc 15.5 (1912) and up | ||||
| if(MSVC_VERSION GREATER 1911 AND NOT MSVC_CLANG) | if(NOT MSVC_CLANG) | ||||
| string(APPEND CMAKE_CXX_FLAGS " /permissive-") | string(APPEND CMAKE_CXX_FLAGS " /permissive-") | ||||
| # Two-phase name lookup does not place nicely with OpenMP yet, so disable for now | # Two-phase name lookup does not place nicely with OpenMP yet, so disable for now | ||||
| string(APPEND CMAKE_CXX_FLAGS " /Zc:twoPhase-") | string(APPEND CMAKE_CXX_FLAGS " /Zc:twoPhase-") | ||||
| endif() | endif() | ||||
| if(WITH_WINDOWS_SCCACHE AND CMAKE_VS_MSBUILD_COMMAND) | if(WITH_WINDOWS_SCCACHE AND CMAKE_VS_MSBUILD_COMMAND) | ||||
| message(WARNING "Disabling sccache, sccache is not supported with msbuild") | message(WARNING "Disabling sccache, sccache is not supported with msbuild") | ||||
| set(WITH_WINDOWS_SCCACHE OFF) | set(WITH_WINDOWS_SCCACHE OFF) | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
| string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " /MD ${PDB_INFO_OVERRIDE_FLAGS}") | string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " /MD ${PDB_INFO_OVERRIDE_FLAGS}") | ||||
| string(APPEND CMAKE_C_FLAGS_MINSIZEREL " /MD ${PDB_INFO_OVERRIDE_FLAGS}") | string(APPEND CMAKE_C_FLAGS_MINSIZEREL " /MD ${PDB_INFO_OVERRIDE_FLAGS}") | ||||
| string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " /MD ${SYMBOL_FORMAT_RELEASE}") | string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " /MD ${SYMBOL_FORMAT_RELEASE}") | ||||
| string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " /MD ${SYMBOL_FORMAT_RELEASE}") | string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " /MD ${SYMBOL_FORMAT_RELEASE}") | ||||
| unset(SYMBOL_FORMAT) | unset(SYMBOL_FORMAT) | ||||
| unset(SYMBOL_FORMAT_RELEASE) | unset(SYMBOL_FORMAT_RELEASE) | ||||
| # JMC is available on msvc 15.8 (1915) and up | # JMC is available on msvc 15.8 (1915) and up | ||||
| if(MSVC_VERSION GREATER 1914 AND NOT MSVC_CLANG) | if(NOT MSVC_CLANG) | ||||
| string(APPEND CMAKE_CXX_FLAGS_DEBUG " /JMC") | string(APPEND CMAKE_CXX_FLAGS_DEBUG " /JMC") | ||||
| endif() | endif() | ||||
| string(APPEND PLATFORM_LINKFLAGS " /SUBSYSTEM:CONSOLE /STACK:2097152") | string(APPEND PLATFORM_LINKFLAGS " /SUBSYSTEM:CONSOLE /STACK:2097152") | ||||
| set(PLATFORM_LINKFLAGS_RELEASE "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib") | set(PLATFORM_LINKFLAGS_RELEASE "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib") | ||||
| string(APPEND PLATFORM_LINKFLAGS_DEBUG " /IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib") | string(APPEND PLATFORM_LINKFLAGS_DEBUG " /IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcmtd.lib") | ||||
| # Ignore meaningless for us linker warnings. | # Ignore meaningless for us linker warnings. | ||||
| Show All 16 Lines | else() | ||||
| message(FATAL_ERROR "32 bit compiler detected, blender no longer provides pre-build libraries for 32 bit windows, please set the LIBDIR cmake variable to your own library folder") | message(FATAL_ERROR "32 bit compiler detected, blender no longer provides pre-build libraries for 32 bit windows, please set the LIBDIR cmake variable to your own library folder") | ||||
| endif() | endif() | ||||
| if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.30.30423) | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.30.30423) | ||||
| message(STATUS "Visual Studio 2022 detected.") | message(STATUS "Visual Studio 2022 detected.") | ||||
| set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15) | set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15) | ||||
| elseif(MSVC_VERSION GREATER 1919) | elseif(MSVC_VERSION GREATER 1919) | ||||
| message(STATUS "Visual Studio 2019 detected.") | message(STATUS "Visual Studio 2019 detected.") | ||||
| set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15) | set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15) | ||||
| elseif(MSVC_VERSION GREATER 1909) | |||||
| message(STATUS "Visual Studio 2017 detected.") | |||||
| set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc15) | |||||
| endif() | endif() | ||||
| else() | else() | ||||
| message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") | message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}") | ||||
| endif() | endif() | ||||
| if(NOT EXISTS "${LIBDIR}/") | if(NOT EXISTS "${LIBDIR}/") | ||||
| message(FATAL_ERROR "\n\nWindows requires pre-compiled libs at: '${LIBDIR}'. Please run `make update` in the blender source folder to obtain them.") | message(FATAL_ERROR "\n\nWindows requires pre-compiled libs at: '${LIBDIR}'. Please run `make update` in the blender source folder to obtain them.") | ||||
| endif() | endif() | ||||
| include(platform_old_libs_update) | include(platform_old_libs_update) | ||||
| if(CMAKE_GENERATOR MATCHES "^Visual Studio.+" AND # Only supported in the VS IDE | # Only supported in the VS IDE & Clang Tidy needs to be on. | ||||
| MSVC_VERSION GREATER_EQUAL 1924 AND # Supported for 16.4+ | if(CMAKE_GENERATOR MATCHES "^Visual Studio.+" AND WITH_CLANG_TIDY) | ||||
| WITH_CLANG_TIDY # And Clang Tidy needs to be on | |||||
| ) | |||||
| set(CMAKE_VS_GLOBALS | set(CMAKE_VS_GLOBALS | ||||
| "RunCodeAnalysis=false" | "RunCodeAnalysis=false" | ||||
| "EnableMicrosoftCodeAnalysis=false" | "EnableMicrosoftCodeAnalysis=false" | ||||
| "EnableClangTidyCodeAnalysis=true" | "EnableClangTidyCodeAnalysis=true" | ||||
| ) | ) | ||||
| set(VS_CLANG_TIDY ON) | set(VS_CLANG_TIDY ON) | ||||
| endif() | endif() | ||||
| # Mark libdir as system headers with a lower warn level, to resolve some warnings | # Mark libdir as system headers with a lower warn level, to resolve some warnings | ||||
| # that we have very little control over | # that we have very little control over | ||||
| if(MSVC_VERSION GREATER_EQUAL 1914 AND # Available with 15.7+ | if(NOT MSVC_CLANG AND # But not for clang | ||||
| NOT MSVC_CLANG AND # But not for clang | |||||
| NOT WITH_WINDOWS_SCCACHE AND # And not when sccache is enabled | NOT WITH_WINDOWS_SCCACHE AND # And not when sccache is enabled | ||||
| NOT VS_CLANG_TIDY) # Clang-tidy does not like these options | NOT VS_CLANG_TIDY) # Clang-tidy does not like these options | ||||
| add_compile_options(/experimental:external /external:templates- /external:I "${LIBDIR}" /external:W0) | add_compile_options(/experimental:external /external:templates- /external:I "${LIBDIR}" /external:W0) | ||||
| endif() | endif() | ||||
| # Add each of our libraries to our cmake_prefix_path so find_package() could work | # Add each of our libraries to our cmake_prefix_path so find_package() could work | ||||
| file(GLOB children RELATIVE ${LIBDIR} ${LIBDIR}/*) | file(GLOB children RELATIVE ${LIBDIR} ${LIBDIR}/*) | ||||
| foreach(child ${children}) | foreach(child ${children}) | ||||
| ▲ Show 20 Lines • Show All 680 Lines • Show Last 20 Lines | |||||