Build: fix gtest build flags affecting actual library
Switch to target_ functions to avoid this.
This commit is contained in:
parent
6bf5cc62e0
commit
0ffd288fab
@ -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()
|
||||
|
@ -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})
|
||||
|
@ -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.
|
||||
|
@ -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>")
|
||||
|
@ -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)
|
||||
|
||||
|
@ -7,6 +7,7 @@ endif()
|
||||
|
||||
set(INC
|
||||
.
|
||||
..
|
||||
../atomic
|
||||
)
|
||||
|
||||
|
@ -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()
|
||||
|
@ -7,6 +7,7 @@ endif()
|
||||
|
||||
set(INC
|
||||
.
|
||||
..
|
||||
# ../blenkernel # don't add this back!
|
||||
../makesdna
|
||||
../../../intern/atomic
|
||||
|
@ -4,6 +4,10 @@
|
||||
set(INC
|
||||
.
|
||||
..
|
||||
../..
|
||||
../../../makesdna
|
||||
../../../../../intern/guardedalloc
|
||||
../../../../../intern/atomic
|
||||
)
|
||||
|
||||
include_directories(${INC})
|
||||
|
@ -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})
|
||||
|
@ -75,7 +75,7 @@ set(LIB
|
||||
)
|
||||
|
||||
if(WITH_PYTHON)
|
||||
blender_include_dirs(../../python)
|
||||
list(APPEND INC ../../python)
|
||||
add_definitions(-DWITH_PYTHON)
|
||||
endif()
|
||||
|
||||
|
@ -3,6 +3,22 @@
|
||||
|
||||
# message(STATUS "Configuring makesdna")
|
||||
|
||||
set(INC
|
||||
..
|
||||
../../blenlib
|
||||
../../imbuf
|
||||
../../../../intern/atomic
|
||||
../../../../intern/guardedalloc
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
|
||||
)
|
||||
|
||||
set(LIB
|
||||
)
|
||||
|
||||
add_definitions(-DWITH_DNA_GHASH)
|
||||
|
||||
# Needed for `mallocn.c`.
|
||||
@ -10,14 +26,6 @@ if(HAVE_MALLOC_STATS_H)
|
||||
add_definitions(-DHAVE_MALLOC_STATS_H)
|
||||
endif()
|
||||
|
||||
blender_include_dirs(
|
||||
../../../../intern/atomic
|
||||
../../../../intern/guardedalloc
|
||||
../../blenlib
|
||||
../../imbuf
|
||||
..
|
||||
)
|
||||
|
||||
set(dna_header_include_file "${CMAKE_CURRENT_BINARY_DIR}/dna_includes_all.h")
|
||||
set(dna_header_string_file "${CMAKE_CURRENT_BINARY_DIR}/dna_includes_as_strings.h")
|
||||
|
||||
@ -57,6 +65,8 @@ add_cc_flags_custom_test(makesdna)
|
||||
|
||||
add_executable(makesdna ${SRC} ${SRC_DNA_INC})
|
||||
setup_platform_linker_flags(makesdna)
|
||||
blender_target_include_dirs(makesdna ${INC})
|
||||
blender_target_include_dirs_sys(makesdna ${INC_SYS})
|
||||
|
||||
if(WIN32 AND NOT UNIX)
|
||||
target_link_libraries(makesdna ${PTHREADS_LIBRARIES})
|
||||
@ -80,14 +90,6 @@ add_custom_command(
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build bf_dna library
|
||||
set(INC
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
|
||||
)
|
||||
|
||||
set(SRC
|
||||
dna_defaults.c
|
||||
dna_genfile.c
|
||||
@ -101,9 +103,6 @@ set(SRC
|
||||
dna_utils.h
|
||||
)
|
||||
|
||||
set(LIB
|
||||
)
|
||||
|
||||
set_source_files_properties(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dna.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dna_type_offsets.h
|
||||
@ -117,7 +116,10 @@ blender_add_lib(bf_dna "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|
||||
# -----------------------------------------------------------------------------
|
||||
# Build bf_dna_blenlib library
|
||||
set(INC
|
||||
|
||||
../../blenlib
|
||||
../../makesdna
|
||||
../../../../intern/atomic
|
||||
../../../../intern/guardedalloc
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
|
@ -185,10 +185,33 @@ set(SRC
|
||||
)
|
||||
|
||||
set(INC
|
||||
../../../../intern/clog
|
||||
|
||||
# Needed for defaults forward declarations.
|
||||
.
|
||||
..
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blenloader
|
||||
../../blentranslation
|
||||
../../bmesh
|
||||
../../depsgraph
|
||||
../../draw
|
||||
../../gpu
|
||||
../../ikplugin
|
||||
../../imbuf
|
||||
../../makesdna
|
||||
../../modifiers
|
||||
../../nodes/
|
||||
../../sequencer
|
||||
../../simulation
|
||||
../../windowmanager
|
||||
../../editors/include
|
||||
../../render
|
||||
../../../../intern/clog
|
||||
../../../../intern/cycles/blender
|
||||
../../../../intern/atomic
|
||||
../../../../intern/guardedalloc
|
||||
../../../../intern/memutil
|
||||
../../../../intern/mantaflow/extern
|
||||
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
|
||||
|
||||
@ -369,38 +392,12 @@ if(WITH_GMP)
|
||||
endif()
|
||||
|
||||
# Build makesrna executable
|
||||
blender_include_dirs(
|
||||
.
|
||||
..
|
||||
../../blenfont
|
||||
../../blenkernel
|
||||
../../blenlib
|
||||
../../blentranslation
|
||||
../../bmesh
|
||||
../../depsgraph
|
||||
../../draw
|
||||
../../gpu
|
||||
../../ikplugin
|
||||
../../imbuf
|
||||
../../makesdna
|
||||
../../modifiers
|
||||
../../nodes/
|
||||
../../sequencer
|
||||
../../simulation
|
||||
../../windowmanager
|
||||
../../editors/include
|
||||
../../render
|
||||
../../../../intern/cycles/blender
|
||||
../../../../intern/atomic
|
||||
../../../../intern/guardedalloc
|
||||
../../../../intern/memutil
|
||||
../../../../intern/mantaflow/extern
|
||||
)
|
||||
|
||||
add_cc_flags_custom_test(makesrna)
|
||||
|
||||
add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC})
|
||||
setup_platform_linker_flags(makesrna)
|
||||
blender_target_include_dirs(makesrna ${INC})
|
||||
blender_target_include_dirs_sys(makesrna ${INC_SYS})
|
||||
|
||||
target_link_libraries(makesrna bf_dna)
|
||||
target_link_libraries(makesrna bf_dna_blenlib)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright 2006 Blender Foundation. All rights reserved.
|
||||
|
||||
blender_include_dirs(
|
||||
set(INC
|
||||
../../intern/clog
|
||||
../../intern/guardedalloc
|
||||
../blender/blenkernel
|
||||
@ -35,17 +35,17 @@ if(WITH_TBB)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
blender_include_dirs(../../intern/utfconv)
|
||||
list(APPEND INC ../../intern/utfconv)
|
||||
endif()
|
||||
|
||||
if(WITH_LIBMV)
|
||||
blender_include_dirs(../../intern/libmv)
|
||||
list(APPEND INC ../../intern/libmv)
|
||||
add_definitions(-DWITH_LIBMV)
|
||||
endif()
|
||||
|
||||
if(WITH_CYCLES)
|
||||
if(WITH_CYCLES_LOGGING)
|
||||
blender_include_dirs(../../intern/cycles/blender)
|
||||
list(APPEND INC ../../intern/cycles/blender)
|
||||
add_definitions(-DWITH_CYCLES_LOGGING)
|
||||
endif()
|
||||
endif()
|
||||
@ -55,7 +55,7 @@ if(WITH_CODEC_FFMPEG)
|
||||
endif()
|
||||
|
||||
if(WITH_TBB)
|
||||
blender_include_dirs(${TBB_INCLUDE_DIRS})
|
||||
list(APPEND INC ${TBB_INCLUDE_DIRS})
|
||||
if(WIN32)
|
||||
# For `pragma` that links `tbbmalloc_proxy.lib`.
|
||||
link_directories(${LIBDIR}/tbb/lib)
|
||||
@ -64,7 +64,7 @@ endif()
|
||||
|
||||
|
||||
if(WITH_PYTHON)
|
||||
blender_include_dirs(../blender/python)
|
||||
list(APPEND INC ../blender/python)
|
||||
add_definitions(-DWITH_PYTHON)
|
||||
|
||||
if(WITH_PYTHON_SECURITY)
|
||||
@ -78,19 +78,19 @@ endif()
|
||||
|
||||
if(WITH_SDL)
|
||||
if(WITH_SDL_DYNLOAD)
|
||||
blender_include_dirs(../../extern/sdlew/include)
|
||||
list(APPEND INC ../../extern/sdlew/include)
|
||||
add_definitions(-DWITH_SDL_DYNLOAD)
|
||||
endif()
|
||||
add_definitions(-DWITH_SDL)
|
||||
endif()
|
||||
|
||||
if(WITH_BINRELOC)
|
||||
blender_include_dirs(${BINRELOC_INCLUDE_DIRS})
|
||||
list(APPEND INC ${BINRELOC_INCLUDE_DIRS})
|
||||
add_definitions(-DWITH_BINRELOC)
|
||||
endif()
|
||||
|
||||
if(WITH_FREESTYLE)
|
||||
blender_include_dirs(../blender/freestyle)
|
||||
list(APPEND INC ../blender/freestyle)
|
||||
add_definitions(-DWITH_FREESTYLE)
|
||||
endif()
|
||||
|
||||
@ -99,7 +99,7 @@ if(WITH_XR_OPENXR)
|
||||
endif()
|
||||
|
||||
if(WITH_GMP)
|
||||
blender_include_dirs(${GMP_INCLUDE_DIRS})
|
||||
list(APPEND INC ${GMP_INCLUDE_DIRS})
|
||||
add_definitions(-DWITH_GMP)
|
||||
endif()
|
||||
|
||||
@ -1285,6 +1285,7 @@ if(DEFINED PLATFORM_SYMBOLS_MAP)
|
||||
set_target_properties(blender PROPERTIES LINK_DEPENDS ${PLATFORM_SYMBOLS_MAP})
|
||||
endif()
|
||||
|
||||
blender_target_include_dirs(blender ${INC})
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# USD registry.
|
||||
|
Loading…
Reference in New Issue
Block a user