diff --git a/CMakeLists.txt b/CMakeLists.txt index ab7f932a128..7f41d455fa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1559,8 +1559,10 @@ if(WITH_OPENMP) if(NOT WITH_OPENMP_STATIC) string(APPEND CMAKE_C_FLAGS " ${OpenMP_C_FLAGS}") string(APPEND CMAKE_CXX_FLAGS " ${OpenMP_CXX_FLAGS}") - string(APPEND CMAKE_EXE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}") - string(APPEND CMAKE_MODULE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}") + if(DEFINED OpenMP_LINKER_FLAGS) + string(APPEND CMAKE_EXE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}") + string(APPEND CMAKE_MODULE_LINKER_FLAGS " ${OpenMP_LINKER_FLAGS}") + endif() else() # Typically avoid adding flags as defines but we can't # pass OpenMP flags to the linker for static builds, meaning diff --git a/build_files/cmake/Modules/FindHIP.cmake b/build_files/cmake/Modules/FindHIP.cmake index 1f93b211573..a3b7ee56f2c 100644 --- a/build_files/cmake/Modules/FindHIP.cmake +++ b/build_files/cmake/Modules/FindHIP.cmake @@ -7,16 +7,18 @@ # HIP_VERSION, the HIP compiler version # HIP_FOUND, if the HIP toolkit is found. +if(NOT (DEFINED HIP_ROOT_DIR)) + set(HIP_ROOT_DIR "") +endif() + # If `HIP_ROOT_DIR` was defined in the environment, use it. -if(DEFINED HIP_ROOT_DIR AND HIP_ROOT_DIR) +if(HIP_ROOT_DIR) # Pass. elseif(DEFINED ENV{HIP_ROOT_DIR}) set(HIP_ROOT_DIR $ENV{HIP_ROOT_DIR}) elseif(DEFINED ENV{HIP_PATH}) # Built-in environment variable from SDK. set(HIP_ROOT_DIR $ENV{HIP_PATH}) -else() - set(HIP_ROOT_DIR "") endif() set(_hip_SEARCH_DIRS diff --git a/build_files/cmake/Modules/FindHIPRT.cmake b/build_files/cmake/Modules/FindHIPRT.cmake index 60f97203f5e..600f695d110 100644 --- a/build_files/cmake/Modules/FindHIPRT.cmake +++ b/build_files/cmake/Modules/FindHIPRT.cmake @@ -7,16 +7,18 @@ # HIPRT_BITCODE, bitcode file with ray-tracing functionality # HIPRT_FOUND, if SDK found +if(NOT (DEFINED HIPRT_ROOT_DIR)) + set(HIPRT_ROOT_DIR "") +endif() + # If `HIPRT_ROOT_DIR` was defined in the environment, use it. -if(DEFINED HIPRT_ROOT_DIR AND HIPRT_ROOT_DIR) +if(HIPRT_ROOT_DIR) # Pass. elseif(DEFINED ENV{HIPRT_ROOT_DIR}) set(HIPRT_ROOT_DIR $ENV{HIPRT_ROOT_DIR}) elseif(DEFINED ENV{HIP_PATH}) # Built-in environment variable from SDK. set(HIPRT_ROOT_DIR $ENV{HIP_PATH}) -else() - set(HIPRT_ROOT_DIR "") endif() set(_hiprt_SEARCH_DIRS diff --git a/build_files/cmake/Modules/FindOptiX.cmake b/build_files/cmake/Modules/FindOptiX.cmake index 97e1c18e242..40a59099cc9 100644 --- a/build_files/cmake/Modules/FindOptiX.cmake +++ b/build_files/cmake/Modules/FindOptiX.cmake @@ -11,13 +11,15 @@ # This can also be an environment variable. # OPTIX_FOUND, If false, do not try to use OptiX. +if(NOT (DEFINED OPTIX_ROOT_DIR)) + set(OPTIX_ROOT_DIR "") +endif() + # If `OPTIX_ROOT_DIR` was defined in the environment, use it. -if(DEFINED OPTIX_ROOT_DIR AND OPTIX_ROOT_DIR) +if(OPTIX_ROOT_DIR) # Pass. elseif(DEFINED ENV{OPTIX_ROOT_DIR}) set(OPTIX_ROOT_DIR $ENV{OPTIX_ROOT_DIR}) -else() - set(OPTIX_ROOT_DIR "") endif() set(_optix_SEARCH_DIRS diff --git a/build_files/cmake/Modules/FindSYCL.cmake b/build_files/cmake/Modules/FindSYCL.cmake index 8911aab1140..806bdebfdf9 100644 --- a/build_files/cmake/Modules/FindSYCL.cmake +++ b/build_files/cmake/Modules/FindSYCL.cmake @@ -12,12 +12,14 @@ # This can also be an environment variable. # SYCL_FOUND, If false, then don't try to use SYCL. -if(DEFINED SYCL_ROOT_DIR AND SYCL_ROOT_DIR) +if(NOT (DEFINED SYCL_ROOT_DIR)) + set(SYCL_ROOT_DIR "") +endif() + +if(SYCL_ROOT_DIR) # Pass. elseif(DEFINED ENV{SYCL_ROOT_DIR} AND NOT $ENV{SYCL_ROOT_DIR} STREQUAL "") set(SYCL_ROOT_DIR $ENV{SYCL_ROOT_DIR}) -else() - set(SYCL_ROOT_DIR "") endif() set(_sycl_search_dirs diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 199e671a1fd..b8fd4589295 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -37,19 +37,21 @@ else() unset(LIBDIR_GLIBC228_ABI) endif() - if(NOT (EXISTS ${LIBDIR})) - if(WITH_STRICT_BUILD_OPTIONS) - message(SEND_ERROR - "Unable to find LIBDIR: ${LIBDIR}. " - "WITH_LIBS_PRECOMPILED needs to be able to find the LIBDIR for the precompiled libraries." - ) - else() - message(STATUS - "Unable to find LIBDIR: ${LIBDIR}. system libraries may be used " - "(disable WITH_LIBS_PRECOMPILED to suppress this message)." - ) + if(DEFINED LIBDIR) + if(NOT (EXISTS ${LIBDIR})) + if(WITH_STRICT_BUILD_OPTIONS) + message(SEND_ERROR + "Unable to find LIBDIR: ${LIBDIR}. " + "WITH_LIBS_PRECOMPILED needs to be able to find the LIBDIR for the precompiled libraries." + ) + else() + message(STATUS + "Unable to find LIBDIR: ${LIBDIR}. system libraries may be used " + "(disable WITH_LIBS_PRECOMPILED to suppress this message)." + ) + endif() + unset(LIBDIR) endif() - unset(LIBDIR) set(WITH_LIBS_PRECOMPILED OFF) endif() endif() @@ -136,7 +138,11 @@ if(DEFINED tiff_DIR) endif() if(WITH_VULKAN_BACKEND) - if((DEFINED LIBDIR) AND (EXISTS "${LIBDIR}/vulkan") AND (EXISTS "${LIBDIR}/shaderc")) + if(DEFINED LIBDIR) + # If these are missing, something went wrong (outdated LIBDIR?). + if(NOT ((EXISTS "${LIBDIR}/vulkan") AND (EXISTS "${LIBDIR}/shaderc"))) + message(FATAL_ERROR "${LIBDIR}/vulkan & ${LIBDIR}/shaderc are missing!") + endif() if(NOT DEFINED VULKAN_ROOT_DIR) set(VULKAN_ROOT_DIR ${LIBDIR}/vulkan) endif() @@ -361,9 +367,11 @@ if(WITH_INPUT_NDOF) endif() if(WITH_CYCLES AND WITH_CYCLES_OSL) - set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") - if(EXISTS ${CYCLES_OSL} AND NOT OSL_ROOT) - set(OSL_ROOT ${CYCLES_OSL}) + if(DEFINED LIBDIR) + set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") + if(EXISTS ${CYCLES_OSL} AND NOT OSL_ROOT) + set(OSL_ROOT ${CYCLES_OSL}) + endif() endif() find_package_wrapper(OSL) set_and_warn_library_found("OSL" OSL_FOUND WITH_CYCLES_OSL) @@ -382,7 +390,7 @@ if(WITH_CYCLES AND WITH_CYCLES_OSL) endif() add_bundled_libraries(osl/lib) -if(WITH_CYCLES AND WITH_CYCLES_DEVICE_ONEAPI) +if(WITH_CYCLES AND WITH_CYCLES_DEVICE_ONEAPI AND DEFINED LIBDIR) set(CYCLES_LEVEL_ZERO ${LIBDIR}/level-zero CACHE PATH "Path to Level Zero installation") mark_as_advanced(CYCLES_LEVEL_ZERO) if(EXISTS ${CYCLES_LEVEL_ZERO} AND NOT LEVEL_ZERO_ROOT_DIR) @@ -509,7 +517,9 @@ if(WITH_PUGIXML) endif() if(WITH_IMAGE_WEBP) - set(WEBP_ROOT_DIR ${LIBDIR}/webp) + if(DEFINED LIBDIR) + set(WEBP_ROOT_DIR ${LIBDIR}/webp) + endif() find_package_wrapper(WebP) set_and_warn_library_found("WebP" WEBP_FOUND WITH_IMAGE_WEBP) endif() @@ -712,10 +722,11 @@ if(WITH_GHOST_WAYLAND) # When dynamically linked WAYLAND is used and `${LIBDIR}/wayland` is present, # there is no need to search for the libraries as they are not needed for building. # Only the headers are needed which can reference the known paths. - if((DEFINED LIBDIR) AND (EXISTS "${LIBDIR}/wayland" AND WITH_GHOST_WAYLAND_DYNLOAD)) - set(_use_system_wayland OFF) - else() - set(_use_system_wayland ON) + set(_use_system_wayland ON) + if(DEFINED LIBDIR) + if(EXISTS "${LIBDIR}/wayland" AND WITH_GHOST_WAYLAND_DYNLOAD) + set(_use_system_wayland OFF) + endif() endif() if(_use_system_wayland) @@ -784,8 +795,11 @@ if(WITH_GHOST_WAYLAND) add_definitions(-DWITH_GHOST_WAYLAND_LIBDECOR) endif() - if((DEFINED LIBDIR) AND (EXISTS "${LIBDIR}/wayland/bin/wayland-scanner")) + if(DEFINED LIBDIR) set(WAYLAND_SCANNER "${LIBDIR}/wayland/bin/wayland-scanner") + if(NOT (EXISTS "${WAYLAND_SCANNER}")) + message(FATAL_ERROR "${WAYLAND_SCANNER} is missing!") + endif() else() pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner) endif() @@ -1124,4 +1138,8 @@ if(PLATFORM_BUNDLED_LIBRARIES) set(PLATFORM_ENV_BUILD "LD_LIBRARY_PATH=\"${_library_paths}:$LD_LIBRARY_PATH\"") set(PLATFORM_ENV_INSTALL "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX_WITH_CONFIG}/lib/;$LD_LIBRARY_PATH") unset(_library_paths) +else() + # Quiet unused variable warnings, unfortunately this can't be empty. + set(PLATFORM_ENV_BUILD "_DUMMY_ENV_VAR_=1") + set(PLATFORM_ENV_INSTALL "_DUMMY_ENV_VAR_=1") endif() diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt index 28bf3deb25c..26c77b19c55 100644 --- a/source/blender/io/usd/CMakeLists.txt +++ b/source/blender/io/usd/CMakeLists.txt @@ -19,7 +19,7 @@ add_definitions(-DBOOST_ALL_NO_LIB) # Clang as well works around the issue. if(UNIX AND NOT APPLE) if(CMAKE_C_COMPILER_ID MATCHES "Clang") - if(EXISTS ${LIBDIR}) + if(DEFINED LIBDIR) add_definitions(-DARCH_HAS_GNU_STL_EXTENSIONS) endif() endif() diff --git a/source/blender/render/hydra/CMakeLists.txt b/source/blender/render/hydra/CMakeLists.txt index ed9f3f3b027..9b1622f19ad 100644 --- a/source/blender/render/hydra/CMakeLists.txt +++ b/source/blender/render/hydra/CMakeLists.txt @@ -19,7 +19,7 @@ add_definitions(-DBOOST_ALL_NO_LIB) # Clang as well works around the issue. if(UNIX AND NOT APPLE) if(CMAKE_C_COMPILER_ID MATCHES "Clang") - if(EXISTS ${LIBDIR}) + if(DEFINED LIBDIR) add_definitions(-DARCH_HAS_GNU_STL_EXTENSIONS) endif() endif() diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 3242e2e00d3..13ed1176b00 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -906,8 +906,10 @@ file(REMOVE ${CMAKE_BINARY_DIR}/bin/lib/libglapi.so.0.0.0)\n # Install to the same directory as the source, so debian-like # distros are happy with their policy. set(_suffix "site-packages") - if(${PYTHON_USD_PATH} MATCHES "dist-packages") - set(_suffix "dist-packages") + if(0) # TODO: `PYTHON_USD_PATH` isn't defined anywhere. + if(${PYTHON_USD_PATH} MATCHES "dist-packages") + set(_suffix "dist-packages") + endif() endif() install( DIRECTORY ${USD_LIBRARY_DIR}/python/