Changeset View
Standalone View
CMakeLists.txt
| Show First 20 Lines • Show All 564 Lines • ▼ Show 20 Lines | else() | ||||
| COMPILER_ASAN_LIBRARY asan ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES} | COMPILER_ASAN_LIBRARY asan ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES} | ||||
| ) | ) | ||||
| endif() | endif() | ||||
| mark_as_advanced(COMPILER_ASAN_LIBRARY) | mark_as_advanced(COMPILER_ASAN_LIBRARY) | ||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") | |||||
| option(WITH_COMPILER_SHORT_FILE_MACRO "Make paths in macros like __FILE__ relative to top level source and build directories." ON) | |||||
campbellbarton: This can be marked as advanced. | |||||
Not Done Inline ActionsWITH_* are often used for Blender features (FFMPEG, FLUID... etc). For tweaking compiler flags I'd prefer to group this with other compiler flags. It could be called WITH_COMPILER_MACRO_REL_PATHS ? campbellbarton: `WITH_*` are often used for Blender features (FFMPEG, FLUID... etc). For tweaking compiler… | |||||
| mark_as_advanced(WITH_COMPILER_SHORT_FILE_MACRO) | |||||
| endif() | |||||
| if(WIN32) | if(WIN32) | ||||
| # Use hardcoded paths or find_package to find externals | # Use hardcoded paths or find_package to find externals | ||||
| option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF) | option(WITH_WINDOWS_FIND_MODULES "Use find_package to locate libraries" OFF) | ||||
| mark_as_advanced(WITH_WINDOWS_FIND_MODULES) | mark_as_advanced(WITH_WINDOWS_FIND_MODULES) | ||||
| option(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS "Organize the visual studio projects according to source folder structure." ON) | option(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS "Organize the visual studio projects according to source folder structure." ON) | ||||
| mark_as_advanced(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS) | mark_as_advanced(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS) | ||||
| ▲ Show 20 Lines • Show All 1,069 Lines • ▼ Show 20 Lines | |||||
| endif() | endif() | ||||
| if(UNIX AND NOT APPLE) | if(UNIX AND NOT APPLE) | ||||
| if(NOT WITH_CXX11_ABI) | if(NOT WITH_CXX11_ABI) | ||||
| set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") | set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") | ||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| if(WITH_COMPILER_SHORT_FILE_MACRO) | |||||
Not Done Inline ActionsLogic in this block seems a bit odd. I find this easier to follow, where turning off the feature is an exception instead of the body of the first check. if(WITH_MACRO_REL_PATHS)
# Use '-fmacro-prefix-map' for Clang and GCC (MSVC doesn't support this).
if((CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.4) OR
(CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0))
if(APPLE AND XCODE AND ${XCODE_VERSION} VERSION_LESS 11.0)
message(WARNING
"-fmacro-prefix-map flag is not supported by Clang shipped with Xcode-${XCODE_VERSION}."
)
set(WITH_MACRO_REL_PATHS OFF)
endif()
if(WITH_MACRO_REL_PATHS)
set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} \
-fmacro-prefix-map=\"${CMAKE_SOURCE_DIR}/\"=\"\" \
-fmacro-prefix-map=\"${CMAKE_BINARY_DIR}/\"=\"\"")
endif()
endif()
endif()campbellbarton: Logic in this block seems a bit odd.
I find this easier to follow, where turning off the… | |||||
| # Use '-fmacro-prefix-map' for Clang and GCC (MSVC doesn't support this). | |||||
Not Done Inline ActionsI would make this logic purely depend on the compiler version, not Xcode version. (CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.4) OR (CMAKE_C_COMPILER_ID EQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0) OR (CMAKE_C_COMPILER_ID EQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0) Also, it's inconsistent that for Xcode it shows a warning message when unsupported, while for Linux it silently ignores. You might as well check the compiler versions earlier and if not supported, simply don't expose the option. brecht: I would make this logic purely depend on the compiler version, not Xcode version.
```… | |||||
Not Done Inline ActionsFrom an earlier version of this patch the issue seems to be XCode not properly handling the paths. (as in - it breaks some XCode features, while the compiler works). if(XCODE AND ${XCODE_VERSION} VERSION_LESS 11.0)
message_first_run(WARNING "Some actions under Product menu like assembling or preprocessing"
" individual files may not work due to -ffile-prefix-map.")
endif()I don't have strong opinions on this, It just seemed like the kind of thing developers could spend a long time looking into only to realize they they missed this this message, so disabling makes more sense so as not to trip developers up. campbellbarton: From an earlier version of this patch the issue seems to be XCode not properly handling the… | |||||
Not Done Inline ActionsTo clarify, that would happen in a case where Xcode say 10.2 is being used with a new toolchain containing llvm clang 10 or 11 or 12 etc. ankitm: To clarify, that would happen in a case where Xcode say 10.2 is being used with a new toolchain… | |||||
| if((CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.4) OR | |||||
| (CMAKE_C_COMPILER_ID EQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0) OR | |||||
| (CMAKE_C_COMPILER_ID EQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0) | |||||
| ) | |||||
| if(XCODE AND ${XCODE_VERSION} VERSION_LESS 11.0) | |||||
Not Done Inline ActionsI'd prefer if(APPLE) wrap the entire block, it means non-apple devs can ignore the contents entirely and avoids changes to the if-check impacting other platforms. campbellbarton: I'd prefer `if(APPLE)` wrap the entire block, it means non-apple devs can ignore the contents… | |||||
| message_first_run(WARNING | |||||
| "-fmacro-prefix-map flag is NOT supported by Clang shipped with Xcode-${XCODE_VERSION}." | |||||
| " Some Xcode functionality may fail to work. Consider disabling WITH_COMPILER_SHORT_FILE_MACRO." | |||||
| ) | |||||
| endif() | |||||
Not Done Inline ActionsOn Linux this is giving me an error. CMake Error at CMakeLists.txt:1671 (if):
if given arguments:
"XCODE" "AND" "VERSION_LESS" "12.0"
Unknown arguments specifiedCheck APPLE before the version of xcode. if(APPLE) if((DEFINED XCODE) AND ...) endif() endif() Then there is the issue of this being disabled or not, suggest to disable so developers don't loose time investigating broken features, since we can't rely on them to see this message, but I'm not an XCode user. campbellbarton: On Linux this is giving me an error.
```
CMake Error at CMakeLists.txt:1671 (if):
if given… | |||||
| set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} \ | |||||
| -fmacro-prefix-map=\"${CMAKE_SOURCE_DIR}/\"=\"\" \ | |||||
| -fmacro-prefix-map=\"${CMAKE_BINARY_DIR}/\"=\"\"") | |||||
| else() | |||||
| message_first_run(WARNING | |||||
| "-fmacro-prefix-map flag is NOT supported by ${CMAKE_C_COMPILER_ID} version-${CMAKE_C_COMPILER_VERSION}." | |||||
| " Disabling WITH_COMPILER_SHORT_FILE_MACRO." | |||||
| ) | |||||
| set(WITH_COMPILER_SHORT_FILE_MACRO OFF) | |||||
| endif() | |||||
| endif() | |||||
| # Include warnings first, so its possible to disable them with user defined flags | # Include warnings first, so its possible to disable them with user defined flags | ||||
| # eg: -Wno-uninitialized | # eg: -Wno-uninitialized | ||||
| set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}") | set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}") | ||||
| set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}") | set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}") | ||||
| # defined above, platform specific but shared names | # defined above, platform specific but shared names | ||||
| mark_as_advanced( | mark_as_advanced( | ||||
| CYCLES_OSL | CYCLES_OSL | ||||
| ▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines | |||||
This can be marked as advanced.