|
| 1 | +cmake_minimum_required(VERSION 3.10) |
| 2 | +project(kanzi) |
| 3 | + |
| 4 | +set(CMAKE_CXX_STANDARD 17) |
| 5 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O3 -fomit-frame-pointer -fPIC -DNDEBUG -pedantic -march=native -fno-rtti") |
| 6 | + |
| 7 | +if(CONCURRENCY_DISABLED) |
| 8 | + add_definitions(-DCONCURRENCY_DISABLED) |
| 9 | +endif() |
| 10 | + |
| 11 | +if(MSVC) |
| 12 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
| 13 | +endif() |
| 14 | + |
| 15 | +# Source files |
| 16 | +set(LIB_COMMON_SOURCES |
| 17 | + Global.cpp |
| 18 | + Event.cpp |
| 19 | + entropy/EntropyUtils.cpp |
| 20 | + entropy/HuffmanCommon.cpp |
| 21 | + entropy/CMPredictor.cpp |
| 22 | + entropy/TPAQPredictor.cpp |
| 23 | + transform/AliasCodec.cpp |
| 24 | + transform/BWT.cpp |
| 25 | + transform/BWTS.cpp |
| 26 | + transform/DivSufSort.cpp |
| 27 | + transform/SBRT.cpp |
| 28 | + transform/BWTBlockCodec.cpp |
| 29 | + transform/LZCodec.cpp |
| 30 | + transform/FSDCodec.cpp |
| 31 | + transform/ROLZCodec.cpp |
| 32 | + transform/RLT.cpp |
| 33 | + transform/SRT.cpp |
| 34 | + transform/TextCodec.cpp |
| 35 | + transform/UTFCodec.cpp |
| 36 | + transform/EXECodec.cpp |
| 37 | + transform/ZRLT.cpp |
| 38 | +) |
| 39 | + |
| 40 | +set(LIB_COMP_SOURCES |
| 41 | + api/Compressor.cpp |
| 42 | + bitstream/DebugOutputBitStream.cpp |
| 43 | + bitstream/DefaultOutputBitStream.cpp |
| 44 | + io/CompressedOutputStream.cpp |
| 45 | + entropy/ANSRangeEncoder.cpp |
| 46 | + entropy/BinaryEntropyEncoder.cpp |
| 47 | + entropy/ExpGolombEncoder.cpp |
| 48 | + entropy/FPAQEncoder.cpp |
| 49 | + entropy/HuffmanEncoder.cpp |
| 50 | + entropy/RangeEncoder.cpp |
| 51 | +) |
| 52 | + |
| 53 | +set(LIB_DECOMP_SOURCES |
| 54 | + api/Decompressor.cpp |
| 55 | + bitstream/DebugInputBitStream.cpp |
| 56 | + bitstream/DefaultInputBitStream.cpp |
| 57 | + io/CompressedInputStream.cpp |
| 58 | + entropy/ANSRangeDecoder.cpp |
| 59 | + entropy/BinaryEntropyDecoder.cpp |
| 60 | + entropy/ExpGolombDecoder.cpp |
| 61 | + entropy/FPAQDecoder.cpp |
| 62 | + entropy/HuffmanDecoder.cpp |
| 63 | + entropy/RangeDecoder.cpp |
| 64 | +) |
| 65 | + |
| 66 | +set(TEST_SOURCES |
| 67 | + test/TestEntropyCodec.cpp |
| 68 | + test/TestBWT.cpp |
| 69 | + test/TestCompressedStream.cpp |
| 70 | + test/TestDefaultBitStream.cpp |
| 71 | + test/TestTransforms.cpp |
| 72 | +) |
| 73 | + |
| 74 | +set(APP_SOURCES |
| 75 | + app/Kanzi.cpp |
| 76 | + app/InfoPrinter.cpp |
| 77 | + app/BlockCompressor.cpp |
| 78 | + app/BlockDecompressor.cpp |
| 79 | +) |
| 80 | + |
| 81 | +# Libraries |
| 82 | +add_library(libkanzi STATIC ${LIB_COMMON_SOURCES} ${LIB_COMP_SOURCES} ${LIB_DECOMP_SOURCES}) |
| 83 | +add_library(libkanzi_shared SHARED ${LIB_COMMON_SOURCES} ${LIB_COMP_SOURCES} ${LIB_DECOMP_SOURCES}) |
| 84 | +set_target_properties(libkanzi_shared PROPERTIES OUTPUT_NAME "kanzi") |
| 85 | + |
| 86 | +#add_library(libkanzi_comp STATIC ${LIB_COMP_SOURCES}) |
| 87 | +#add_library(libkanzi_decomp STATIC ${LIB_DECOMP_SOURCES}) |
| 88 | + |
| 89 | +#add_library(libkanzi_comp_shared SHARED ${LIB_COMP_SOURCES}) |
| 90 | +#add_library(libkanzi_decomp_shared SHARED ${LIB_DECOMP_SOURCES}) |
| 91 | + |
| 92 | +# Test executables |
| 93 | +add_executable(testBWT test/TestBWT.cpp) |
| 94 | +target_link_libraries(testBWT libkanzi) |
| 95 | + |
| 96 | +add_executable(testTransforms test/TestTransforms.cpp) |
| 97 | +target_link_libraries(testTransforms libkanzi) |
| 98 | + |
| 99 | +add_executable(testEntropyCodec test/TestEntropyCodec.cpp) |
| 100 | +target_link_libraries(testEntropyCodec libkanzi) |
| 101 | + |
| 102 | +add_executable(testDefaultBitStream test/TestDefaultBitStream.cpp) |
| 103 | +target_link_libraries(testDefaultBitStream libkanzi) |
| 104 | + |
| 105 | +add_executable(testCompressedStream test/TestCompressedStream.cpp) |
| 106 | +target_link_libraries(testCompressedStream libkanzi) |
| 107 | + |
| 108 | +# Main executable |
| 109 | +add_executable(kanzi ${APP_SOURCES}) |
| 110 | +target_link_libraries(kanzi libkanzi) |
| 111 | + |
| 112 | +# Custom target to build all tests |
| 113 | +add_custom_target(test |
| 114 | + DEPENDS testBWT testTransforms testEntropyCodec testDefaultBitStream testCompressedStream |
| 115 | +) |
| 116 | +# Custom target to build static libraries |
| 117 | +add_custom_target(static_lib |
| 118 | + DEPENDS libkanzi #libkanzi_comp libkanzi_decomp |
| 119 | +) |
| 120 | + |
| 121 | +# Custom target to build shared libraries |
| 122 | +add_custom_target(shared_lib |
| 123 | + DEPENDS libkanzi_shared #libkanzi_comp_shared libkanzi_decomp_shared |
| 124 | +) |
| 125 | + |
| 126 | +# Custom target to build all libraries (static and shared) |
| 127 | +add_custom_target(lib |
| 128 | + DEPENDS static_lib shared_lib |
| 129 | +) |
0 commit comments