Changeset View
Changeset View
Standalone View
Standalone View
build_files/cmake/macros.cmake
| Show First 20 Lines • Show All 1,572 Lines • ▼ Show 20 Lines | else() | ||||
| add_custom_command(TARGET ${target} | add_custom_command(TARGET ${target} | ||||
| POST_BUILD | POST_BUILD | ||||
| COMMAND ${SIGNTOOL_EXE} sign /f ${WINDOWS_CODESIGN_PFX} ${CODESIGNPASSWORD} $<TARGET_FILE:${target}> | COMMAND ${SIGNTOOL_EXE} sign /f ${WINDOWS_CODESIGN_PFX} ${CODESIGNPASSWORD} $<TARGET_FILE:${target}> | ||||
| VERBATIM | VERBATIM | ||||
| ) | ) | ||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| endmacro() | endmacro() | ||||
| # creates a name.so which can be imported as a python module. | |||||
| macro(blender_add_python_module | |||||
| name | |||||
| local_dir | |||||
| sources | |||||
campbellbarton: This should take `SRC, INC, INC_SYS` arguments, since its possible the module has own includes. | |||||
| includes | |||||
| includes_sys | |||||
Done Inline Actionsmodule is too generic, suggest cpython_module_ or py_capi_module_ prefix. campbellbarton: `module` is too generic, suggest `cpython_module_` or `py_capi_module_` prefix. | |||||
| ) | |||||
| set(target_name py_capi_module_${name}) | |||||
| blender_include_dirs("${includes}") | |||||
| blender_include_dirs_sys("${includes_sys}") | |||||
| add_library(${target_name} MODULE "${sources}") | |||||
| set_target_properties( | |||||
| ${target_name} | |||||
| PROPERTIES | |||||
| PREFIX "" | |||||
Done Inline ActionsCan't PYTHON_LIBPATH be used here? campbellbarton: Can't `PYTHON_LIBPATH` be used here? | |||||
| OUTPUT_NAME ${name} | |||||
| DEBUG_POSTFIX _d | |||||
| LINKER_LANGUAGE C | |||||
| COMPILE_OPTIONS "/Z7" #embeds debugging info directly into the generated object files (PDB) | |||||
| ) | |||||
| if(WIN32) | |||||
| # python modules use this | |||||
| set_target_properties( | |||||
| ${target_name} | |||||
| PROPERTIES | |||||
| SUFFIX ".pyd" | |||||
| ) | |||||
| endif() | |||||
| # link | |||||
| target_link_libraries(${target_name} ${PYTHON_LINKFLAGS}) | |||||
| if(WIN32 AND NOT UNIX) | |||||
| file_list_suffix(PYTHON_LIBRARIES_DEBUG "${PYTHON_LIBRARIES}" "_d") | |||||
| target_link_libraries_debug(${target_name} "${PYTHON_LIBRARIES_DEBUG}") | |||||
| target_link_libraries_optimized(${target_name} "${PYTHON_LIBRARIES}") | |||||
| unset(PYTHON_LIBRARIES_DEBUG) | |||||
| else() | |||||
| target_link_libraries(${target_name} ${PYTHON_LIBRARIES}) | |||||
| endif() | |||||
| # ----------------------------------------------------------------------------- | |||||
| # installation | |||||
| string(REPLACE ${CMAKE_SOURCE_DIR}/release/scripts/ "" EXCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | |||||
Done Inline ActionsTypically you dont need to do this kind of manipulation for installation. Check how this is done elsewhere. campbellbarton: Typically you dont need to do this kind of manipulation for installation.
It's also error prone… | |||||
| get_filename_component( | |||||
| INSTALL_DIR | |||||
| "${CMAKE_INSTALL_PREFIX}/${BLENDER_VERSION}/scripts/${EXCLUDE_DIR}" | |||||
| DIRECTORY | |||||
| ) | |||||
| install( | |||||
| TARGETS ${target_name} | |||||
Done Inline ActionsUse if(NOT DEFINED ...) campbellbarton: Use `if(NOT DEFINED ...)` | |||||
| LIBRARY | |||||
| DESTINATION "${INSTALL_DIR}/${local_dir}" | |||||
| ) | |||||
| set_property(GLOBAL APPEND_STRING PROPERTY PYTHON_MODULE_EXCLUDE "|${EXCLUDE_DIR}") | |||||
| endmacro(blender_add_python_module) | |||||
This should take SRC, INC, INC_SYS arguments, since its possible the module has own includes.
The macro can include ${PYTHON_INCLUDE_DIRS}, ${PYTHON_INC} too.