Commit: 66dee44088e9d46cffb4731faf1e76fda3396b10 Author: Campbell Barton Date: Thu Jan 19 17:07:23 2023 +1100 Branches: master https://developer.blender.org/rB66dee44088e9d46cffb4731faf1e76fda3396b10
CMake: quiet references to undeclared variable warnings These warnings can reveal errors in logic, so quiet them by checking if the features are enabled before using variables or by assigning empty strings in some cases. - Check CMAKE_THREAD_LIBS_INIT is set before use as CMake docs note that this may be left unset if it's not needed. - Remove BOOST/OPENVDB/VULKAN references when disable. - Define INC_SYS even when empty. - Remove PNG_INC from freetype (not defined anywhere). =================================================================== M CMakeLists.txt M build_files/cmake/Modules/FindOptiX.cmake M build_files/cmake/Modules/FindPythonLibsUnix.cmake M build_files/cmake/macros.cmake M build_files/cmake/platform/platform_unix.cmake M extern/mantaflow/CMakeLists.txt M intern/cycles/cmake/macros.cmake M intern/cycles/graph/CMakeLists.txt M intern/cycles/integrator/CMakeLists.txt M intern/cycles/session/CMakeLists.txt M intern/guardedalloc/CMakeLists.txt M source/blender/blendthumb/CMakeLists.txt M source/blender/blenkernel/CMakeLists.txt M source/blender/compositor/realtime_compositor/CMakeLists.txt M source/blender/draw/CMakeLists.txt M source/blender/editors/animation/CMakeLists.txt M source/blender/editors/armature/CMakeLists.txt M source/blender/editors/curve/CMakeLists.txt M source/blender/editors/gizmo_library/CMakeLists.txt M source/blender/editors/gpencil/CMakeLists.txt M source/blender/editors/interface/CMakeLists.txt M source/blender/editors/mask/CMakeLists.txt M source/blender/editors/object/CMakeLists.txt M source/blender/editors/physics/CMakeLists.txt M source/blender/editors/screen/CMakeLists.txt M source/blender/editors/sound/CMakeLists.txt M source/blender/editors/space_action/CMakeLists.txt M source/blender/editors/space_buttons/CMakeLists.txt M source/blender/editors/space_clip/CMakeLists.txt M source/blender/editors/space_console/CMakeLists.txt M source/blender/editors/space_file/CMakeLists.txt M source/blender/editors/space_graph/CMakeLists.txt M source/blender/editors/space_image/CMakeLists.txt M source/blender/editors/space_info/CMakeLists.txt M source/blender/editors/space_nla/CMakeLists.txt M source/blender/editors/space_outliner/CMakeLists.txt M source/blender/editors/space_script/CMakeLists.txt M source/blender/editors/space_sequencer/CMakeLists.txt M source/blender/editors/space_spreadsheet/CMakeLists.txt M source/blender/editors/space_statusbar/CMakeLists.txt M source/blender/editors/space_text/CMakeLists.txt M source/blender/editors/space_topbar/CMakeLists.txt M source/blender/editors/space_view3d/CMakeLists.txt M source/blender/editors/transform/CMakeLists.txt M source/blender/editors/undo/CMakeLists.txt M source/blender/editors/util/CMakeLists.txt M source/blender/editors/uvedit/CMakeLists.txt M source/blender/freestyle/CMakeLists.txt M source/blender/gpu/CMakeLists.txt M source/blender/imbuf/intern/oiio/CMakeLists.txt M source/blender/io/alembic/CMakeLists.txt M source/blender/io/gpencil/CMakeLists.txt M source/blender/makesdna/intern/CMakeLists.txt M source/blender/makesrna/intern/CMakeLists.txt M source/blender/nodes/composite/CMakeLists.txt M source/blender/nodes/function/CMakeLists.txt M source/blender/nodes/texture/CMakeLists.txt M source/blender/render/CMakeLists.txt M source/blender/sequencer/CMakeLists.txt M source/blender/windowmanager/CMakeLists.txt M tests/CMakeLists.txt M tests/python/CMakeLists.txt =================================================================== diff --git a/CMakeLists.txt b/CMakeLists.txt index 252b2d13450..2acae1d7b26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -993,6 +993,8 @@ set(PLATFORM_LINKLIBS "") # - CMAKE_EXE_LINKER_FLAGS_DEBUG set(PLATFORM_LINKFLAGS "") set(PLATFORM_LINKFLAGS_DEBUG "") +set(PLATFORM_LINKFLAGS_RELEASE "") +set(PLATFORM_LINKFLAGS_EXECUTABLE "") if(NOT CMAKE_BUILD_TYPE MATCHES "Release") if(WITH_COMPILER_ASAN) diff --git a/build_files/cmake/Modules/FindOptiX.cmake b/build_files/cmake/Modules/FindOptiX.cmake index bb671ed6495..f6838f0583f 100644 --- a/build_files/cmake/Modules/FindOptiX.cmake +++ b/build_files/cmake/Modules/FindOptiX.cmake @@ -17,9 +17,13 @@ ENDIF() SET(_optix_SEARCH_DIRS ${OPTIX_ROOT_DIR} - "$ENV{PROGRAMDATA}/NVIDIA Corporation/OptiX SDK 7.3.0" ) +# TODO: Which environment uses this? +if(DEFINED ENV{PROGRAMDATA}) + list(APPEND _optix_SEARCH_DIRS "$ENV{PROGRAMDATA}/NVIDIA Corporation/OptiX SDK 7.3.0") +endif() + FIND_PATH(OPTIX_INCLUDE_DIR NAMES optix.h diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake index b222ed85a4f..5d40a4f1277 100644 --- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake +++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake @@ -67,6 +67,8 @@ ENDIF() STRING(REPLACE "." "" PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) +SET(_PYTHON_ABI_FLAGS "") + SET(_python_SEARCH_DIRS ${PYTHON_ROOT_DIR} "$ENV{HOME}/py${PYTHON_VERSION_NO_DOTS}" diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 1b440c7aaed..44081ee5d81 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -550,7 +550,9 @@ function(setup_platform_linker_libs endif() if(WIN32 AND NOT UNIX) - target_link_libraries(${target} ${PTHREADS_LIBRARIES}) + if(DEFINED PTHREADS_LIBRARIES) + target_link_libraries(${target} ${PTHREADS_LIBRARIES}) + endif() endif() # target_link_libraries(${target} ${PLATFORM_LINKLIBS} ${CMAKE_DL_LIBS}) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 787d0f87002..4f84fe262f5 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -430,10 +430,13 @@ if(WITH_OPENIMAGEIO) ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} - ${BOOST_LIBRARIES} ) + set(OPENIMAGEIO_DEFINITIONS "") + if(WITH_BOOST) + list(APPEND OPENIMAGEIO_LIBRARIES "${BOOST_LIBRARIES}") + endif() if(WITH_IMAGE_TIFF) list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}") endif() @@ -451,7 +454,7 @@ add_bundled_libraries(openimageio/lib) if(WITH_OPENCOLORIO) find_package_wrapper(OpenColorIO 2.0.0) - set(OPENCOLORIO_DEFINITIONS) + set(OPENCOLORIO_DEFINITIONS "") set_and_warn_library_found("OpenColorIO" OPENCOLORIO_FOUND WITH_OPENCOLORIO) endif() add_bundled_libraries(opencolorio/lib) @@ -551,9 +554,14 @@ else() endif() find_package(Threads REQUIRED) -list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT}) -# used by other platforms -set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) +# `FindThreads` documentation notes that this may be empty +# with the system libraries provide threading functionality. +if(CMAKE_THREAD_LIBS_INIT) + list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT}) + # used by other platforms + set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) +endif() + if(CMAKE_DL_LIBS) list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS}) diff --git a/extern/mantaflow/CMakeLists.txt b/extern/mantaflow/CMakeLists.txt index 06767e9af1e..2c503071184 100644 --- a/extern/mantaflow/CMakeLists.txt +++ b/extern/mantaflow/CMakeLists.txt @@ -13,10 +13,12 @@ endif() # Exporting functions from the blender binary gives linker warnings on Apple arm64 systems. # Silence them here. -if(APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")) - if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - string(APPEND CMAKE_C_FLAGS " -fvisibility=hidden") - string(APPEND CMAKE_CXX_FLAGS " -fvisibility=hidden") +if(APPLE) + if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64") + if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + string(APPEND CMAKE_C_FLAGS " -fvisibility=hidden") + string(APPEND CMAKE_CXX_FLAGS " -fvisibility=hidden") + endif() endif() endif() @@ -261,9 +263,11 @@ set(LIB blender_add_lib(extern_mantaflow "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") -# The VDB libs above are only added to as INTERFACE libs by blender_add_lib, -# meaning extern_mantaflow itself actually does not have a dependency on the -# openvdb libraries, and CMAKE is free to link the vdb libs before -# extern_mantaflow causing linker errors on linux. By explicitly declaring -# a dependency here, cmake will do the right thing. -target_link_libraries(extern_mantaflow PRIVATE ${OPENVDB_LIBRARIES}) +if(WITH_OPENVDB) + # The VDB libs above are only added to as INTERFACE libs by blender_add_lib, + # meaning extern_mantaflow itself actually does not have a dependency on the + # openvdb libraries, and CMAKE is free to link the vdb libs before + # extern_mantaflow causing linker errors on linux. By explicitly declaring + # a dependency here, cmake will do the right thing. + target_link_libraries(extern_mantaflow PRIVATE ${OPENVDB_LIBRARIES}) +endif() diff --git a/intern/cycles/cmake/macros.cmake b/intern/cycles/cmake/macros.cmake index d1a929f2b35..0753e8cc592 100644 --- a/intern/cycles/cmake/macros.cmake +++ b/intern/cycles/cmake/macros.cmake @@ -111,8 +111,10 @@ macro(cycles_external_libraries_append libraries) endif() if(WITH_OPENIMAGEDENOISE) list(APPEND ${libraries} ${OPENIMAGEDENOISE_LIBRARIES}) - if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64") - list(APPEND ${libraries} "-framework Accelerate") + if(APPLE) + if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64") + list(APPEND ${libraries} "-framework Accelerate") + endif() endif() endif() if(WITH_ALEMBIC) @@ -136,7 +138,15 @@ macro(cycles_external_libraries_append libraries) ${PYTHON_LIBRARIES} ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS} - ${PTHREADS_LIBRARIES} + ) + + if(DEFINED PTHREADS_LIBRARIES) + list(APPEND ${libraries} + ${PTHREADS_LIBRARIES} + ) + endif() + + list(APPEND ${libraries} ${PLATFORM_LINKLIBS} ) diff --git a/intern/cycles/graph/CMakeLists.txt b/intern/cycles/graph/CMakeLists.txt index ca4f996ed5d..d183b77c6ab 100644 --- a/intern/cycles/graph/CMakeLists.txt +++ b/intern/cycles/graph/CMakeLists.txt @@ -5,6 +5,9 @@ set(INC .. ) +set(INC_SYS +) + set(SRC node.cpp node_type.cpp diff --git a/intern/cycles/integrator/CMakeLists.txt b/intern/cycles/integrator/CMakeLists.txt index 9869a8744a3..0559a3e9401 100644 --- a/intern/cycles/integrator/CMakeLists.txt +++ b/intern/cycles/integrator/CMakeLists.txt @@ -5,6 +5,9 @@ set(INC .. ) +set(INC_SYS +) + set(SRC adaptive_sampling.cpp denoiser.cpp diff --git a/intern/cycles/session/CMakeLists.txt b/intern/cycles/session/CMakeLists.txt index 4f3a0a99ee1..9f4b4e3cc36 100644 --- a/intern/cycles/session/CMakeLists.txt +++ b/intern/cycles/session/CMakeLists.txt @@ -5,6 +5,9 @@ set(INC .. ) +set(INC_SYS +) + set(SRC buffers.cpp denoising.cpp diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt index 5d766d8543d..63310f858b1 100644 --- a/intern/guardedalloc/CMakeLists.txt +++ b/intern/guardedalloc/CMakeLists.txt @@ -41,10 +41,11 @@ if(WIN32 AND NOT UNIX) list(APPEND INC_SYS ${PTHREADS_INC} ) - - list(APPEND LIB - ${PTHREADS_LIBRARIES} - ) + if(DEFINED PTHREADS_LIBRARIES) + list(APPEND LIB + ${PTHREADS_LIBRARIES} + ) + endif() endif() # Jemalloc 5.0.0+ needs extra configuration. diff --git a/source/blender/blendthumb/CMakeLists.txt b/source/blender/blendthumb/CMakeLists.txt index 6160d225d45..5a5bc20fed7 100644 --- a/source/blender/blendthumb/CMakeLists.txt +++ b/source/blender/blendthumb/CMakeLists.txt @@ -50,5 +50,7 @@ else() add_executable(blender-thumbnailer ${SRC} ${SRC_CMD}) setup_platform_linker_flags(blender-thumbnailer) target_link_libraries(blender-thumbnailer bf_blenlib) - target_link_libraries(blender-thumbnailer ${PTHREADS_LIBRARIES}) + if(DEFINED PTHREADS_LIBRARIES) + target_link_libraries(blender-thumbnailer ${PTHREADS_LIBRARIES}) + endif() endif() diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 15c44589291..8a3c6877787 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -559,15 +559,16 @@ if(WIN32) endif() if(WITH_AUDASPACE) - add_definitions(-DWITH_AUDASPACE) - list(APPEND INC_SYS ${AUDASPACE_C_INCLUDE_DIRS} ) - list(APPEND LIB - ${AUDASPACE_C_LIBRARIES} - ${AUDASPACE_PY_LIBRARIES} - ) + if(WITH_SYSTEM_AUDASPACE) + list(APPEND LIB + ${AUDASPACE_C_LIBRARIES} + ${AUDASPACE_PY_LIBRARIES} + ) + endif() + add_definitions(-DWITH_AUDASPACE) endif() if(WITH_BULLET) diff --git a/source/blender/compositor/realtime_compositor/CMakeLists.txt b/source/blender/compositor/realtime_compositor/CMakeLists.txt index f9739972690..38e5c6be88c 100644 --- a/source/blender/compositor/realtime_compositor/CMakeLists.txt +++ b/source/blender/compositor/realtime_compositor/CMakeLists.txt @@ -16,6 +16,8 @@ set(INC ../../../../intern/guardedalloc ) +set(INC_SYS +) set(SRC intern/compile_state.cc diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 2c4d2b65ea5..2ced6f2d1bf 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -35,7 +35,6 @@ set(INC # dna_type_offsets.h ${CMAKE_CURRENT_BINARY_DIR}/../makesdna/intern - ${OPENSUBDIV_INCLUDE_DIRS} ) set(SRC @@ -724,6 +723,12 @@ if(WITH_DRAW_DEBUG) add_definitions(-DWITH_DRAW_DEBUG) endif() +if(WITH_OPENSUBDIV) + list(APPEND INC_SYS + ${OPENSUBDIV_INCLUDE_DIRS} + ) +endif() + if(WITH_MOD_FLUID) list(APPEND INC ../../../intern/mantaflow/extern diff -- @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs