Changeset View
Changeset View
Standalone View
Standalone View
build_files/cmake/macros.cmake
| Show First 20 Lines • Show All 1,169 Lines • ▼ Show 20 Lines | |||||
| macro(without_system_libs_begin) | 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}") | set(CMAKE_IGNORE_PATH "${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES};${CMAKE_SYSTEM_INCLUDE_PATH};${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES};${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}") | ||||
| endmacro() | endmacro() | ||||
| macro(without_system_libs_end) | macro(without_system_libs_end) | ||||
| unset(CMAKE_IGNORE_PATH) | unset(CMAKE_IGNORE_PATH) | ||||
| endmacro() | endmacro() | ||||
| # creates a name.so which can be imported as a python module. | |||||
| macro(blender_add_python_module | |||||
| name | |||||
| sources | |||||
| includes | |||||
| includes_sys | |||||
| ) | |||||
| set(_target_name py_capi_module_${name}) | |||||
| blender_include_dirs("${includes}") | |||||
| blender_include_dirs_sys("${includes_sys}") | |||||
| add_library(${_target_name} MODULE "${sources}") | |||||
| get_filename_component(_folder_dir ${CMAKE_CURRENT_SOURCE_DIR} PATH) | |||||
| set_target_properties( | |||||
| ${_target_name} | |||||
| PROPERTIES | |||||
| PREFIX "" | |||||
| OUTPUT_NAME ${name} | |||||
| DEBUG_POSTFIX _d | |||||
| LIBRARY_OUTPUT_DIRECTORY "${_folder_dir}" | |||||
| LIBRARY_OUTPUT_DIRECTORY_DEBUG "${_folder_dir}" | |||||
| LIBRARY_OUTPUT_DIRECTORY_RELEASE "${_folder_dir}" | |||||
| LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${_folder_dir}" | |||||
| LINKER_LANGUAGE C | |||||
| ) | |||||
| if(WIN32) | |||||
| # python modules use this | |||||
| set_target_properties( | |||||
| ${_target_name} | |||||
| PROPERTIES | |||||
| SUFFIX ".pyd" | |||||
| ) | |||||
| endif() | |||||
| # link | |||||
| target_link_libraries(${_target_name} ${PYTHON_LINKFLAGS}) | |||||
| target_link_libraries(${_target_name} ${PYTHON_LIBRARIES}) | |||||
| # ----------------------------------------------------------------------------- | |||||
| # Remove on installation | |||||
| string(REPLACE ${CMAKE_SOURCE_DIR}/release/scripts/ "" _exclude_dir "${CMAKE_CURRENT_SOURCE_DIR}") | |||||
| set_property(GLOBAL APPEND_STRING PROPERTY ADDON_CPYTHON_SOURCES "|${_exclude_dir}") | |||||
| unset(_target_name) | |||||
| unset(_folder_dir) | |||||
| unset(_exclude_dir) | |||||
| endmacro(blender_add_python_module) | |||||
campbellbarton: `module` is too generic, suggest `cpython_module_` or `py_capi_module_` prefix. | |||||
Done Inline ActionsThis 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. campbellbarton: This should take `SRC, INC, INC_SYS` arguments, since its possible the module has own includes. | |||||
Done Inline ActionsCan't PYTHON_LIBPATH be used here? campbellbarton: Can't `PYTHON_LIBPATH` be used here? | |||||
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… | |||||
Done Inline ActionsUse if(NOT DEFINED ...) campbellbarton: Use `if(NOT DEFINED ...)` | |||||
module is too generic, suggest cpython_module_ or py_capi_module_ prefix.