diff options
-rw-r--r-- | build_files/cmake/macros.cmake | 43 | ||||
-rw-r--r-- | source/blender/makesdna/intern/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/CMakeLists.txt | 3 | ||||
-rw-r--r-- | source/blenderplayer/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/creator/CMakeLists.txt | 2 |
5 files changed, 50 insertions, 2 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index d29f086069a..5ffd6c4e7f4 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -196,8 +196,33 @@ function(blender_source_group endfunction() +# Support per-target CMake flags +# Read from: CMAKE_C_FLAGS_**** (made upper case) when set. +# +# 'name' should alway match the target name, +# use this macro before add_library or add_executable. +# +# Optionally takes an arg passed to set(), eg PARENT_SCOPE. +macro(add_cc_flags_custom_test + name + ) + + string(TOUPPER ${name} _name_upper) + if(DEFINED CMAKE_C_FLAGS_${_name_upper}) + message(STATUS "Using custom CFLAGS: CMAKE_C_FLAGS_${_name_upper} in \"${CMAKE_CURRENT_SOURCE_DIR}\"") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_name_upper}}" ${ARGV1}) + endif() + if(DEFINED CMAKE_CXX_FLAGS_${_name_upper}) + message(STATUS "Using custom CXXFLAGS: CMAKE_CXX_FLAGS_${_name_upper} in \"${CMAKE_CURRENT_SOURCE_DIR}\"") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_name_upper}}" ${ARGV1}) + endif() + unset(_name_upper) + +endmacro() + + # only MSVC uses SOURCE_GROUP -function(blender_add_lib_nolist +function(blender_add_lib__impl name sources includes @@ -225,6 +250,18 @@ function(blender_add_lib_nolist endfunction() +function(blender_add_lib_nolist + name + sources + includes + includes_sys + ) + + add_cc_flags_custom_test(${name} PARENT_SCOPE) + + blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}") +endfunction() + function(blender_add_lib name sources @@ -232,7 +269,9 @@ function(blender_add_lib includes_sys ) - blender_add_lib_nolist(${name} "${sources}" "${includes}" "${includes_sys}") + add_cc_flags_custom_test(${name} PARENT_SCOPE) + + blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}") set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name}) endfunction() diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index 0bb6e866bf4..8c758c33dc5 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -52,6 +52,8 @@ endif() # SRC_DNA_INC is defined in the parent dir +add_cc_flags_custom_test(makesdna) + add_executable(makesdna ${SRC} ${SRC_DNA_INC}) # Output dna.c diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 31bf0c9389b..7bfac9d0605 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -350,7 +350,10 @@ blender_include_dirs_sys( "${GLEW_INCLUDE_PATH}" ) +add_cc_flags_custom_test(makesrna) + add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC}) + target_link_libraries(makesrna bf_dna) target_link_libraries(makesrna bf_dna_blenlib) diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 206007b8d8b..ca841954b16 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -63,6 +63,8 @@ if(WIN32 AND NOT UNIX) COMPONENT Blenderplayer DESTINATION ".") +add_cc_flags_custom_test(blenderplayer) + elseif(APPLE) add_executable(blenderplayer ${EXETYPE} bad_level_call_stubs/stubs.c) # setup Info.plist diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 4e8dd6f9fd3..d8435284096 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -222,6 +222,8 @@ if(WITH_BUILDINFO) add_dependencies(buildinfoobj buildinfo) endif() +add_cc_flags_custom_test(blender) + # message(STATUS "Configuring blender") if(WITH_PYTHON_MODULE) add_definitions(-DWITH_PYTHON_MODULE) |