[Bf-blender-cvs] [4ac4d0b7969] temp-T97352-3d-texturing-seam-bleeding-b2: Build: fix gtest build flags affecting actual library

Brecht Van Lommel noreply at git.blender.org
Tue Sep 20 10:32:14 CEST 2022


Commit: 4ac4d0b796985db3661f5f29ca15568db4ca36a1
Author: Brecht Van Lommel
Date:   Sun Sep 18 07:41:13 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB4ac4d0b796985db3661f5f29ca15568db4ca36a1

Build: fix gtest build flags affecting actual library

Switch to target_ functions to avoid this.

===================================================================

M	CMakeLists.txt
M	build_files/cmake/Modules/GTestTesting.cmake
M	build_files/cmake/macros.cmake
M	build_files/cmake/platform/platform_apple.cmake
M	build_files/cmake/platform/platform_win32.cmake
M	intern/guardedalloc/CMakeLists.txt
M	intern/opensubdiv/CMakeLists.txt
M	source/blender/blenlib/CMakeLists.txt
M	source/blender/blenlib/tests/performance/CMakeLists.txt
M	source/blender/blentranslation/msgfmt/CMakeLists.txt
M	source/blender/editors/space_view3d/CMakeLists.txt
M	source/blender/makesdna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/creator/CMakeLists.txt

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 359968ca525..ed2aa4de78e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1097,7 +1097,7 @@ if(WITH_CPU_SIMD)
   if(SUPPORT_NEON_BUILD)
     # Neon
     if(SSE2NEON_FOUND)
-      blender_include_dirs_sys("${SSE2NEON_INCLUDE_DIRS}")
+      include_directories(SYSTEM "${SSE2NEON_INCLUDE_DIRS}")
       add_definitions(-DWITH_SSE2NEON)
     endif()
   else()
diff --git a/build_files/cmake/Modules/GTestTesting.cmake b/build_files/cmake/Modules/GTestTesting.cmake
index 92ce403d5f3..5ffd158361e 100644
--- a/build_files/cmake/Modules/GTestTesting.cmake
+++ b/build_files/cmake/Modules/GTestTesting.cmake
@@ -40,12 +40,10 @@ macro(BLENDER_SRC_GTEST_EX)
       set(MANIFEST "${CMAKE_BINARY_DIR}/tests.exe.manifest")
     endif()
 
-    add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
-    add_definitions(${GFLAGS_DEFINES})
-    add_definitions(${GLOG_DEFINES})
-
     add_executable(${TARGET_NAME} ${ARG_SRC} ${MANIFEST})
     setup_platform_linker_flags(${TARGET_NAME})
+    target_compile_definitions(${TARGET_NAME} PRIVATE ${GFLAGS_DEFINES})
+    target_compile_definitions(${TARGET_NAME} PRIVATE ${GLOG_DEFINES})
     target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}")
     target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}")
     target_link_libraries(${TARGET_NAME} ${ARG_EXTRA_LIBS} ${PLATFORM_LINKLIBS})
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index d271d8f216f..b197cd01bbb 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -134,12 +134,11 @@ endfunction()
 
 # Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
 # use it instead of include_directories()
-function(blender_include_dirs
-  includes
-  )
+function(absolute_include_dirs
+  includes_absolute)
 
   set(_ALL_INCS "")
-  foreach(_INC ${ARGV})
+  foreach(_INC ${ARGN})
     get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
     list(APPEND _ALL_INCS ${_ABS_INC})
     # for checking for invalid includes, disable for regular use
@@ -147,22 +146,24 @@ function(blender_include_dirs
     #   message(FATAL_ERROR "Include not found: ${_ABS_INC}/")
     # endif()
   endforeach()
-  include_directories(${_ALL_INCS})
+
+  set(${includes_absolute} ${_ALL_INCS} PARENT_SCOPE)
 endfunction()
 
-function(blender_include_dirs_sys
-  includes
+function(blender_target_include_dirs
+  name
   )
 
-  set(_ALL_INCS "")
-  foreach(_INC ${ARGV})
-    get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
-    list(APPEND _ALL_INCS ${_ABS_INC})
-    # if(NOT EXISTS "${_ABS_INC}/")
-    #   message(FATAL_ERROR "Include not found: ${_ABS_INC}/")
-    # endif()
-  endforeach()
-  include_directories(SYSTEM ${_ALL_INCS})
+  absolute_include_dirs(_ALL_INCS ${ARGN})
+  target_include_directories(${name} PRIVATE ${_ALL_INCS})
+endfunction()
+
+function(blender_target_include_dirs_sys
+  name
+  )
+
+  absolute_include_dirs(_ALL_INCS ${ARGN})
+  target_include_directories(${name} SYSTEM PRIVATE ${_ALL_INCS})
 endfunction()
 
 # Set include paths for header files included with "*.h" syntax.
@@ -268,13 +269,11 @@ function(blender_add_lib__impl
 
   # message(STATUS "Configuring library ${name}")
 
-  # include_directories(${includes})
-  # include_directories(SYSTEM ${includes_sys})
-  blender_include_dirs("${includes}")
-  blender_include_dirs_sys("${includes_sys}")
-
   add_library(${name} ${sources})
 
+  blender_target_include_dirs(${name} ${includes})
+  blender_target_include_dirs_sys(${name} ${includes_sys})
+
   # On Windows certain libraries have two sets of binaries: one for debug builds and one for
   # release builds. The root of this requirement goes into ABI, I believe, but that's outside
   # of a scope of this comment.
@@ -434,12 +433,12 @@ function(blender_add_test_lib
     ${CMAKE_SOURCE_DIR}/extern/gtest/include
     ${CMAKE_SOURCE_DIR}/extern/gmock/include
   )
-  add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
-  add_definitions(${GFLAGS_DEFINES})
-  add_definitions(${GLOG_DEFINES})
 
   blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}")
 
+  target_compile_definitions(${name} PRIVATE ${GFLAGS_DEFINES})
+  target_compile_definitions(${name} PRIVATE ${GLOG_DEFINES})
+
   set_property(GLOBAL APPEND PROPERTY BLENDER_TEST_LIBS ${name})
 
   blender_add_test_suite(
@@ -469,9 +468,6 @@ function(blender_add_test_executable
   ## Otherwise external projects will produce warnings that we cannot fix.
   remove_strict_flags()
 
-  include_directories(${includes})
-  include_directories(${includes_sys})
-
   BLENDER_SRC_GTEST_EX(
     NAME ${name}
     SRC "${sources}"
@@ -479,6 +475,9 @@ function(blender_add_test_executable
     SKIP_ADD_TEST
   )
 
+  blender_target_include_dirs(${name}_test ${includes})
+  blender_target_include_dirs_sys(${name}_test ${includes_sys})
+
   blender_add_test_suite(
     TARGET ${name}_test
     SUITE_NAME ${name}
@@ -513,6 +512,11 @@ function(setup_platform_linker_flags
   set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " ${PLATFORM_LINKFLAGS}")
   set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " ${PLATFORM_LINKFLAGS_RELEASE}")
   set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG " ${PLATFORM_LINKFLAGS_DEBUG}")
+
+  get_target_property(target_type ${target} TYPE)
+  if (target_type STREQUAL "EXECUTABLE")
+    set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " ${PLATFORM_LINKFLAGS_EXECUTABLE}")
+  endif()
 endfunction()
 
 # Platform specific libraries for targets.
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index f2a8bd42a3e..27fcaf823e8 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -352,10 +352,6 @@ endif()
 
 if(WITH_CYCLES AND WITH_CYCLES_EMBREE)
   find_package(Embree 3.8.0 REQUIRED)
-  # Increase stack size for Embree, only works for executables.
-  if(NOT WITH_PYTHON_MODULE)
-    string(APPEND PLATFORM_LINKFLAGS " -Wl,-stack_size,0x100000")
-  endif()
 
   # Embree static library linking can mix up SSE and AVX symbols, causing
   # crashes on macOS systems with older CPUs that don't have AVX. Using
@@ -475,6 +471,9 @@ string(APPEND PLATFORM_LINKFLAGS
 string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++")
 string(APPEND PLATFORM_LINKFLAGS " -stdlib=libc++")
 
+# Make stack size more similar to Embree, required for Embree.
+string(APPEND PLATFORM_LINKFLAGS_EXECUTABLE " -Wl,-stack_size,0x100000")
+
 # Suppress ranlib "has no symbols" warnings (workaround for T48250)
 set(CMAKE_C_ARCHIVE_CREATE   "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
 set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index dd5d04d7c92..7d7efb83b8e 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -767,7 +767,7 @@ if(WITH_TBB)
 endif()
 
 # used in many places so include globally, like OpenGL
-blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
+include_directories(SYSTEM "${PTHREADS_INCLUDE_DIRS}")
 
 set(WINTAB_INC ${LIBDIR}/wintab/include)
 
diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt
index 89fdf367037..0d16879adb5 100644
--- a/intern/guardedalloc/CMakeLists.txt
+++ b/intern/guardedalloc/CMakeLists.txt
@@ -7,6 +7,7 @@ endif()
 
 set(INC
   .
+  ..
   ../atomic
 )
 
diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
index 596534fc82c..7df1a94bbd8 100644
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -110,7 +110,6 @@ if(WITH_GTESTS AND WITH_OPENSUBDIV)
 
   add_definitions(${GFLAGS_DEFINES})
   add_definitions(${GLOG_DEFINES})
-  add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
 
   blender_add_test_executable(opensubdiv_mesh_topology_test "internal/topology/mesh_topology_test.cc" "${INC}" "${INC_SYS}" "${LIB};bf_intern_opensubdiv")
 endif()
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index 205bd45b87c..cc3b3730f4a 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -7,6 +7,7 @@ endif()
 
 set(INC
   .
+  ..
   # ../blenkernel  # don't add this back!
   ../makesdna
   ../../../intern/atomic
diff --git a/source/blender/blenlib/tests/performance/CMakeLists.txt b/source/blender/blenlib/tests/performance/CMakeLists.txt
index c4f03255a11..2e4fcd4516c 100644
--- a/source/blender/blenlib/tests/performance/CMakeLists.txt
+++ b/source/blender/blenlib/tests/performance/CMakeLists.txt
@@ -4,6 +4,10 @@
 set(INC
   .
   ..
+  ../..
+  ../../../makesdna
+  ../../../../../intern/guardedalloc
+  ../../../../../intern/atomic
 )
 
 include_directories(${INC})
diff --git a/source/blender/blentranslation/msgfmt/CMakeLists.txt b/source/blender/blentranslation/msgfmt/CMakeLists.txt
index 7b95bf210d7..dce3f0014f0 100644
--- a/source/blender/blentranslation/msgfmt/CMakeLists.txt
+++ b/source/blender/blentranslation/msgfmt/CMakeLists.txt
@@ -4,7 +4,7 @@
 # -----------------------------------------------------------------------------
 # Build msgfmt executable
 
-blender_include_dirs(
+set(INC
   ../../../../intern/guardedalloc
   ../../blenlib
 )
@@ -13,21 +13,20 @@ set(SRC
   msgfmt.c
 )
 
+set(LIB
+  bf_blenlib
+  bf_intern_guardedalloc
+  ${ZLIB_LIBRARIES}
+  ${PLATFORM_LINKLIBS})
+
 add_cc_flags_custom_test(msgfmt)
 
 if(WIN32)
   string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " /nodefaultlib:MSVCRT.lib")
+  list(APPEND LIB bf_intern_utfconv)
 endif()
 
 add_executable(msgfmt ${SRC})
 setup_platform_linker_flags(msgfmt)
-
-target_link_libraries(msgfmt bf_blenlib)
-target_link_libraries(msgfmt bf_intern_guardedalloc)
-
-if(WIN32)
-  target_link_libraries(msgfmt bf_intern_utfconv)
-endif()
-
-target_link_libraries(msgfmt ${ZLIB_LIBRARIES})
-target_link_libraries(msgfmt ${PLATFORM_LINKLIBS})
+blender_target_include_dirs(msgfmt ${INC})
+target_link_libraries(msgfmt ${LIB})
diff --git a/s

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list