this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1356 from zhaofengli/pyc-optional

cmake: Make Python 2 bytecode pre-compilation optional

authored by

Ariel Abreu and committed by
GitHub
410e2151 8d744680

+24 -1
+21 -1
CMakeLists.txt
··· 30 30 31 31 option(DARLING_NO_CCACHE "Disable ccache usage" OFF) 32 32 33 - find_package(Python2 REQUIRED COMPONENTS Interpreter) 34 33 find_program(CCACHE_PROGRAM ccache) 35 34 if(CCACHE_PROGRAM AND NOT DARLING_NO_CCACHE) 36 35 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") ··· 109 108 option(ENABLE_TESTS "Install in-prefix unit tests" OFF) 110 109 option(REGENERATE_SDK "Regenerate Header Files For Open Source SDK" OFF) 111 110 option(ADDITIONAL_PACKAGES "Include additional pacakges not included by default in a standard macOS installation" OFF) 111 + 112 + set(COMPILE_PY2_BYTECODE AUTO CACHE STRING "Pre-compile bytecode for Python 2 packages") 113 + set_property(CACHE COMPILE_PY2_BYTECODE PROPERTY STRINGS AUTO ON OFF) 114 + 115 + string(TOLOWER "${COMPILE_PY2_BYTECODE}" COMPILE_PY2_BYTECODE) 116 + 117 + if (COMPILE_PY2_BYTECODE STREQUAL "auto") 118 + find_package(Python2 QUIET COMPONENTS Interpreter) 119 + 120 + if (Python2_Interpreter_FOUND) 121 + set(COMPILE_PY2_BYTECODE ON) 122 + message("Found Python 2; enabling pre-compilation of Python bytecode") 123 + else() 124 + set(COMPILE_PY2_BYTECODE OFF) 125 + message("Python 2 not available; bytecode compilation is disabled") 126 + endif (Python2_Interpreter_FOUND) 127 + endif (COMPILE_PY2_BYTECODE STREQUAL "auto") 128 + 129 + if (COMPILE_PY2_BYTECODE) 130 + find_package(Python2 REQUIRED COMPONENTS Interpreter) 131 + endif (COMPILE_PY2_BYTECODE) 112 132 113 133 set(ENABLE_METAL AUTO CACHE STRING "Build Darling with Metal support") 114 134 set_property(CACHE ENABLE_METAL PROPERTY STRINGS AUTO ON OFF)
+3
cmake/pyc.cmake
··· 4 4 cmake_parse_arguments(PYC "" "DESTINATION" "SOURCES" ${ARGN}) 5 5 set(generated_files "") 6 6 7 + if (COMPILE_PY2_BYTECODE) 7 8 foreach(pyfile ${PYC_SOURCES}) 8 9 STRING(REGEX REPLACE "^${CMAKE_CURRENT_SOURCE_DIR}" "" pyfile_rel ${pyfile}) 9 10 ··· 23 24 endforeach(pyfile) 24 25 25 26 add_custom_target("${target_name}" ALL DEPENDS ${generated_files}) 27 + 28 + endif (COMPILE_PY2_BYTECODE) 26 29 endfunction(pyc) 27 30