| 1 | get_filename_component(PRISMA_JNI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE) |
| 2 | set(PRISMA_SOURCE_DIR "${PRISMA_JNI_DIR}/third_party/libprisma") |
| 3 | if(NOT EXISTS "${PRISMA_SOURCE_DIR}/libprisma/SyntaxHighlighter.cpp") |
| 4 | message(FATAL_ERROR "Initialize TMessagesProj/jni/third_party/libprisma") |
| 5 | endif() |
| 6 |
| 7 | set(BOOST_REGEX_SOURCE_DIR "${PRISMA_JNI_DIR}/third_party/boost-regex") |
| 8 | if(NOT EXISTS "${BOOST_REGEX_SOURCE_DIR}/include/boost/regex.hpp") |
| 9 | message(FATAL_ERROR "Initialize TMessagesProj/jni/third_party/boost-regex") |
| 10 | endif() |
| 11 |
| 12 | # Build against full source overrides without changing the submodule checkout. |
| 13 | set(PRISMA_CORE_DIR "${CMAKE_CURRENT_BINARY_DIR}/source") |
| 14 | file(MAKE_DIRECTORY "${PRISMA_CORE_DIR}") |
| 15 | foreach(source IN ITEMS Highlight.cpp Highlight.h LanguageTree.cpp LanguageTree.h |
| 16 | SyntaxHighlighter.cpp SyntaxHighlighter.h TokenList.cpp TokenList.h UnicodeEscapes.h) |
| 17 | configure_file("${PRISMA_SOURCE_DIR}/libprisma/${source}" |
| 18 | "${PRISMA_CORE_DIR}/${source}" COPYONLY) |
| 19 | endforeach() |
| 20 | foreach(source IN ITEMS Highlight.cpp Highlight.h SyntaxHighlighter.cpp SyntaxHighlighter.h) |
| 21 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libprisma/${source}" |
| 22 | "${PRISMA_CORE_DIR}/${source}" COPYONLY) |
| 23 | endforeach() |
| 24 |
| 25 | add_library(prisma STATIC |
| 26 | "${PRISMA_CORE_DIR}/Highlight.cpp" |
| 27 | "${PRISMA_CORE_DIR}/LanguageTree.cpp" |
| 28 | "${PRISMA_CORE_DIR}/SyntaxHighlighter.cpp" |
| 29 | "${PRISMA_CORE_DIR}/TokenList.cpp") |
| 30 | set_target_properties(prisma PROPERTIES POSITION_INDEPENDENT_CODE ON) |
| 31 | target_compile_features(prisma PUBLIC cxx_std_17) |
| 32 | # BudgetedPosition is twice the size of a pointer, which makes a saved state up to half as big |
| 33 | # again, and Boost's limit is on the blocks they fill: the limit in characters stays where it was. |
| 34 | target_compile_definitions(prisma PRIVATE BOOST_REGEX_STANDALONE NDEBUG BOOST_REGEX_MAX_BLOCKS=1536) |
| 35 | target_include_directories(prisma PUBLIC |
| 36 | "${PRISMA_CORE_DIR}" |
| 37 | "${BOOST_REGEX_SOURCE_DIR}/include") |
| 38 | # Highlighting has a time limit, so its speed must not depend on the build type: |
| 39 | # -O0 is 4-5 times slower and -Oz 20-30% slower than -O2. |
| 40 | target_compile_options(prisma PRIVATE |
| 41 | -O2 -fexceptions -frtti -fvisibility=hidden -fvisibility-inlines-hidden |
| 42 | -include "${CMAKE_CURRENT_SOURCE_DIR}/bridge/PrismaIncludes.h") |
| 43 |