Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2022-10-05 18:46:18 +0300
committerRay Molenkamp <github@lazydodo.com>2022-10-05 18:46:18 +0300
commit42736e0b3f85dc248186dd6dc5349a99addc8c84 (patch)
treed0768a91d8ebfb50642034fdf8437199a5e420b7 /build_files/cmake/macros.cmake
parent42ce93a2cbc28836d22b7fa47e99aa3df76e1acc (diff)
parentb47a234f98dd7e6e0b53ad96b5b4d278635874d8 (diff)
Merge remote-tracking branch 'origin/master' into tmp-vfx-platform-2023
Diffstat (limited to 'build_files/cmake/macros.cmake')
-rw-r--r--build_files/cmake/macros.cmake88
1 files changed, 42 insertions, 46 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index ea14e5c0730..e067fc0f2c2 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.
@@ -382,7 +381,7 @@ function(blender_add_test_suite)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Figure out the release dir, as some tests need files from there.
- GET_BLENDER_TEST_INSTALL_DIR(TEST_INSTALL_DIR)
+ get_blender_test_install_dir(TEST_INSTALL_DIR)
if(APPLE)
set(_test_release_dir ${TEST_INSTALL_DIR}/Blender.app/Contents/Resources/${BLENDER_VERSION})
else()
@@ -427,21 +426,21 @@ function(blender_add_test_lib
# This duplicates logic that's also in GTestTesting.cmake, macro BLENDER_SRC_GTEST_EX.
# TODO(Sybren): deduplicate after the general approach in D7649 has been approved.
- LIST(APPEND includes
+ list(APPEND includes
${CMAKE_SOURCE_DIR}/tests/gtests
)
- LIST(APPEND includes_sys
+ list(APPEND includes_sys
${GLOG_INCLUDE_DIRS}
${GFLAGS_INCLUDE_DIRS}
${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(
@@ -471,16 +470,16 @@ 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(
+ blender_src_gtest_ex(
NAME ${name}
SRC "${sources}"
EXTRA_LIBS "${library_deps}"
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}
@@ -515,6 +514,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.
@@ -762,7 +766,7 @@ function(ADD_CHECK_C_COMPILER_FLAG
include(CheckCCompilerFlag)
- CHECK_C_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
+ check_c_compiler_flag("${_FLAG}" "${_CACHE_VAR}")
if(${_CACHE_VAR})
# message(STATUS "Using CFLAG: ${_FLAG}")
set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}" PARENT_SCOPE)
@@ -779,7 +783,7 @@ function(ADD_CHECK_CXX_COMPILER_FLAG
include(CheckCXXCompilerFlag)
- CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
+ check_cxx_compiler_flag("${_FLAG}" "${_CACHE_VAR}")
if(${_CACHE_VAR})
# message(STATUS "Using CXXFLAG: ${_FLAG}")
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}" PARENT_SCOPE)
@@ -797,9 +801,11 @@ function(get_blender_version)
# - BLENDER_VERSION_PATCH
# - BLENDER_VERSION_CYCLE (alpha, beta, rc, release)
- # So cmake depends on BKE_blender.h, beware of inf-loops!
- CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h
- ${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender_version.h.done)
+ # So CMAKE depends on `BKE_blender.h`, beware of infinite-loops!
+ configure_file(
+ ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h
+ ${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender_version.h.done
+ )
file(STRINGS ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender_version.h _contents REGEX "^#define[ \t]+BLENDER_.*$")
@@ -1186,8 +1192,6 @@ macro(openmp_delayload
if(WITH_OPENMP)
if(MSVC_CLANG)
set(OPENMP_DLL_NAME "libomp")
- elseif(MSVC_VERSION EQUAL 1800)
- set(OPENMP_DLL_NAME "vcomp120")
else()
set(OPENMP_DLL_NAME "vcomp140")
endif()
@@ -1210,18 +1214,10 @@ endmacro()
macro(without_system_libs_begin)
set(CMAKE_IGNORE_PATH "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES};${CMAKE_SYSTEM_INCLUDE_PATH};${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES};${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
- if(APPLE)
- # Avoid searching for headers in frameworks (like Mono), and libraries in LIBDIR.
- set(CMAKE_FIND_FRAMEWORK NEVER)
- endif()
endmacro()
macro(without_system_libs_end)
unset(CMAKE_IGNORE_PATH)
- if(APPLE)
- # FIRST is the default.
- set(CMAKE_FIND_FRAMEWORK FIRST)
- endif()
endmacro()
# Utility to gather and install precompiled shared libraries.