Mercurial > minori
comparison dep/utf8proc/CMakeLists.txt @ 343:1faa72660932
*: transfer back to cmake from autotools
autotools just made lots of things more complicated than
they should have and many things broke (i.e. translations)
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Thu, 20 Jun 2024 05:56:06 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 342:adb79bdde329 | 343:1faa72660932 |
|---|---|
| 1 cmake_minimum_required (VERSION 3.0.0) | |
| 2 | |
| 3 include (utils.cmake) | |
| 4 | |
| 5 disallow_intree_builds() | |
| 6 | |
| 7 if (POLICY CMP0048) | |
| 8 cmake_policy (SET CMP0048 NEW) | |
| 9 endif () | |
| 10 project (utf8proc VERSION 2.9.0 LANGUAGES C) | |
| 11 | |
| 12 # This is the ABI version number, which may differ from the | |
| 13 # API version number (defined in utf8proc.h and above). | |
| 14 # Be sure to also update these in Makefile and MANIFEST! | |
| 15 set(SO_MAJOR 3) | |
| 16 set(SO_MINOR 0) | |
| 17 set(SO_PATCH 0) | |
| 18 | |
| 19 option(UTF8PROC_INSTALL "Enable installation of utf8proc" On) | |
| 20 option(UTF8PROC_ENABLE_TESTING "Enable testing of utf8proc" Off) | |
| 21 option(LIB_FUZZING_ENGINE "Fuzzing engine to link against" Off) | |
| 22 | |
| 23 add_library (utf8proc | |
| 24 utf8proc.c | |
| 25 utf8proc.h | |
| 26 ) | |
| 27 | |
| 28 # expose header path, for when this is part of a larger cmake project | |
| 29 target_include_directories(utf8proc PUBLIC .) | |
| 30 | |
| 31 if (BUILD_SHARED_LIBS) | |
| 32 # Building shared library | |
| 33 else() | |
| 34 # Building static library | |
| 35 target_compile_definitions(utf8proc PUBLIC "UTF8PROC_STATIC") | |
| 36 if (MSVC) | |
| 37 set_target_properties(utf8proc PROPERTIES OUTPUT_NAME "utf8proc_static") | |
| 38 endif() | |
| 39 endif() | |
| 40 | |
| 41 target_compile_definitions(utf8proc PRIVATE "UTF8PROC_EXPORTS") | |
| 42 | |
| 43 if (NOT MSVC) | |
| 44 set_target_properties( | |
| 45 utf8proc PROPERTIES | |
| 46 COMPILE_FLAGS "-O2 -std=c99 -pedantic -Wall" | |
| 47 ) | |
| 48 endif () | |
| 49 | |
| 50 set_target_properties (utf8proc PROPERTIES | |
| 51 POSITION_INDEPENDENT_CODE ON | |
| 52 VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}" | |
| 53 SOVERSION ${SO_MAJOR} | |
| 54 ) | |
| 55 | |
| 56 if (UTF8PROC_INSTALL) | |
| 57 include(GNUInstallDirs) | |
| 58 install(FILES utf8proc.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") | |
| 59 install(TARGETS utf8proc | |
| 60 ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | |
| 61 LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" | |
| 62 RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" | |
| 63 ) | |
| 64 configure_file(libutf8proc.pc.cmakein libutf8proc.pc @ONLY) | |
| 65 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libutf8proc.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") | |
| 66 endif() | |
| 67 | |
| 68 if(UTF8PROC_ENABLE_TESTING) | |
| 69 enable_testing() | |
| 70 file(MAKE_DIRECTORY data) | |
| 71 set(UNICODE_VERSION 15.1.0) | |
| 72 file(DOWNLOAD https://www.unicode.org/Public/${UNICODE_VERSION}/ucd/NormalizationTest.txt ${CMAKE_BINARY_DIR}/data/NormalizationTest.txt SHOW_PROGRESS) | |
| 73 file(DOWNLOAD https://www.unicode.org/Public/${UNICODE_VERSION}/ucd/auxiliary/GraphemeBreakTest.txt ${CMAKE_BINARY_DIR}/data/GraphemeBreakTest.txt SHOW_PROGRESS) | |
| 74 add_executable(case test/tests.h test/tests.c utf8proc.h test/case.c) | |
| 75 target_link_libraries(case utf8proc) | |
| 76 add_executable(custom test/tests.h test/tests.c utf8proc.h test/custom.c) | |
| 77 target_link_libraries(custom utf8proc) | |
| 78 add_executable(iterate test/tests.h test/tests.c utf8proc.h test/iterate.c) | |
| 79 target_link_libraries(iterate utf8proc) | |
| 80 add_executable(misc test/tests.h test/tests.c utf8proc.h test/misc.c) | |
| 81 target_link_libraries(misc utf8proc) | |
| 82 add_executable(printproperty test/tests.h test/tests.c utf8proc.h test/printproperty.c) | |
| 83 target_link_libraries(printproperty utf8proc) | |
| 84 add_executable(valid test/tests.h test/tests.c utf8proc.h test/valid.c) | |
| 85 target_link_libraries(valid utf8proc) | |
| 86 add_test(utf8proc.testcase case) | |
| 87 add_test(utf8proc.testcustom custom) | |
| 88 add_test(utf8proc.testiterate iterate) | |
| 89 add_test(utf8proc.testmisc misc) | |
| 90 add_test(utf8proc.testprintproperty printproperty) | |
| 91 add_test(utf8proc.testvalid valid) | |
| 92 | |
| 93 if (NOT WIN32) | |
| 94 # no wcwidth function on Windows | |
| 95 add_executable(charwidth test/tests.h test/tests.c utf8proc.h test/charwidth.c) | |
| 96 target_link_libraries(charwidth utf8proc) | |
| 97 add_test(utf8proc.testcharwidth charwidth) | |
| 98 endif() | |
| 99 add_executable(graphemetest test/tests.h test/tests.c utf8proc.h test/graphemetest.c) | |
| 100 target_link_libraries(graphemetest utf8proc) | |
| 101 add_executable(normtest test/tests.h test/tests.c utf8proc.h test/normtest.c) | |
| 102 target_link_libraries(normtest utf8proc) | |
| 103 add_test(utf8proc.testgraphemetest graphemetest data/GraphemeBreakTest.txt) | |
| 104 add_test(utf8proc.testnormtest normtest data/NormalizationTest.txt) | |
| 105 | |
| 106 if(LIB_FUZZING_ENGINE) | |
| 107 add_executable(fuzzer utf8proc.h test/fuzzer.c) | |
| 108 target_link_libraries(fuzzer ${LIB_FUZZING_ENGINE} utf8proc) | |
| 109 else() | |
| 110 add_executable(fuzzer utf8proc.h test/fuzz_main.c test/fuzzer.c) | |
| 111 target_link_libraries(fuzzer utf8proc) | |
| 112 endif() | |
| 113 endif() |
