|
| 1 | +# SCL --- Secure Computation Library |
| 2 | +# Copyright (C) 2022 Anders Dalskov |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU Affero General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU Affero General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU Affero General Public License |
| 15 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +cmake_minimum_required( VERSION 3.14 ) |
| 18 | + |
| 19 | +project( scl VERSION 1.0.0 DESCRIPTION "Secure Computation Library" ) |
| 20 | + |
| 21 | +if(NOT CMAKE_BUILD_TYPE) |
| 22 | + set(CMAKE_BUILD_TYPE Release) |
| 23 | +endif() |
| 24 | + |
| 25 | +message(STATUS "CMAKE_BUILD_TYPE=" ${CMAKE_BUILD_TYPE}) |
| 26 | + |
| 27 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}") |
| 28 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -pedantic -Werror -std=gnu++17") |
| 29 | + |
| 30 | +set(SCL_SOURCE_FILES |
| 31 | + src/scl/prg.cc |
| 32 | + src/scl/hash.cc |
| 33 | + |
| 34 | + src/scl/math/str.cc |
| 35 | + src/scl/math/mersenne61.cc |
| 36 | + src/scl/math/mersenne127.cc |
| 37 | + |
| 38 | + src/scl/net/config.cc |
| 39 | + src/scl/net/mem_channel.cc |
| 40 | + src/scl/net/tcp_channel.cc |
| 41 | + src/scl/net/threaded_sender.cc |
| 42 | + src/scl/net/tcp_utils.cc |
| 43 | + src/scl/net/network.cc |
| 44 | + src/scl/net/discovery/server.cc |
| 45 | + src/scl/net/discovery/client.cc) |
| 46 | + |
| 47 | +set(SCL_HEADERS "${CMAKE_SOURCE_DIR}/include") |
| 48 | + |
| 49 | +include_directories(${SCL_HEADERS}) |
| 50 | + |
| 51 | +if(CMAKE_BUILD_TYPE MATCHES "Release") |
| 52 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") |
| 53 | + add_library(scl SHARED ${SCL_SOURCE_FILES}) |
| 54 | + |
| 55 | + set_target_properties(scl PROPERTIES VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) |
| 56 | + |
| 57 | + message(STATUS "CMAKE_INSTALL_PREFIX=" ${CMAKE_INSTALL_PREFIX}) |
| 58 | + |
| 59 | + install(TARGETS scl |
| 60 | + ARCHIVE DESTINATION lib |
| 61 | + LIBRARY DESTINATION lib) |
| 62 | + |
| 63 | + install(DIRECTORY "${SCL_HEADERS}/" |
| 64 | + DESTINATION include |
| 65 | + FILES_MATCHING PATTERN "*.h") |
| 66 | + |
| 67 | +endif() |
| 68 | + |
| 69 | +if(CMAKE_BUILD_TYPE MATCHES "Debug") |
| 70 | + |
| 71 | + set(SCL_TEST_SOURCE_FILES |
| 72 | + test/scl/main.cc |
| 73 | + |
| 74 | + test/scl/test_hash.cc |
| 75 | + test/scl/test_prg.cc |
| 76 | + |
| 77 | + test/scl/math/test_mersenne61.cc |
| 78 | + test/scl/math/test_mersenne127.cc |
| 79 | + test/scl/math/test_vec.cc |
| 80 | + test/scl/math/test_mat.cc |
| 81 | + test/scl/math/test_la.cc |
| 82 | + test/scl/math/test_ff.cc |
| 83 | + test/scl/math/test_z2k.cc |
| 84 | + |
| 85 | + test/scl/ss/test_additive.cc |
| 86 | + test/scl/ss/test_poly.cc |
| 87 | + test/scl/ss/test_shamir.cc |
| 88 | + |
| 89 | + test/scl/net/util.cc |
| 90 | + test/scl/net/test_config.cc |
| 91 | + test/scl/net/test_mem_channel.cc |
| 92 | + test/scl/net/test_tcp_channel.cc |
| 93 | + test/scl/net/test_threaded_sender.cc |
| 94 | + test/scl/net/test_network.cc |
| 95 | + test/scl/net/test_discover.cc |
| 96 | + |
| 97 | + test/scl/p/test_simple.cc) |
| 98 | + |
| 99 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0") |
| 100 | + find_package(Catch2 REQUIRED) |
| 101 | + include(CTest) |
| 102 | + include(Catch) |
| 103 | + include(${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake) |
| 104 | + |
| 105 | + # Tests that check bounds for reading/writing are sped up considerably by |
| 106 | + # lowering said bounds. |
| 107 | + add_compile_definitions(MAX_VEC_READ_SIZE=1024) |
| 108 | + add_compile_definitions(MAX_MAT_READ_SIZE=1024) |
| 109 | + add_compile_definitions(SCL_TEST_DATA_DIR="${CMAKE_SOURCE_DIR}/test/data/") |
| 110 | + |
| 111 | + add_executable(scl_test ${SCL_SOURCE_FILES} ${SCL_TEST_SOURCE_FILES}) |
| 112 | + target_link_libraries(scl_test Catch2::Catch2 pthread) |
| 113 | + catch_discover_tests(scl_test) |
| 114 | + |
| 115 | + append_coverage_compiler_flags() |
| 116 | + |
| 117 | + # Tell lcov to ignore system STL headers in order to make the coverage |
| 118 | + # output more precise. |
| 119 | + setup_target_for_coverage_lcov( |
| 120 | + NAME coverage |
| 121 | + EXECUTABLE scl_test |
| 122 | + EXCLUDE "/usr/include/*" "test/*" "/usr/lib/*" "/usr/local/*") |
| 123 | + |
| 124 | +endif() |
0 commit comments