1616
1717cmake_minimum_required ( VERSION 3.14 )
1818
19- project ( scl VERSION 1.1.1 DESCRIPTION "Secure Computation Library" )
19+ project ( scl VERSION 2.0.0 DESCRIPTION "Secure Computation Library" )
2020
2121if (NOT CMAKE_BUILD_TYPE )
2222 set (CMAKE_BUILD_TYPE Release)
2323endif ()
2424
25+ option (WITH_EC "Include support for elliptic curves (requires GMP)" ON )
26+
2527message (STATUS "CMAKE_BUILD_TYPE=" ${CMAKE_BUILD_TYPE} )
28+ message (STATUS "WITH_EC=" ${WITH_EC} )
29+
30+ if (WITH_EC MATCHES ON )
31+ find_library (GMP gmp libgmp REQUIRED)
32+ endif ()
2633
2734set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR} " )
2835set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -pedantic -Werror -std=gnu++17" )
@@ -44,6 +51,13 @@ set(SCL_SOURCE_FILES
4451 src/scl/net/discovery/server.cc
4552 src/scl/net/discovery/client.cc)
4653
54+ if (WITH_EC MATCHES ON )
55+ set (SCL_SOURCE_FILES ${SCL_SOURCE_FILES}
56+ src/scl/math/secp256k1_field.cc
57+ src/scl/math/secp256k1_curve.cc
58+ src/scl/math/number.cc)
59+ endif ()
60+
4761set (SCL_HEADERS "${CMAKE_SOURCE_DIR} /include" )
4862
4963include_directories (${SCL_HEADERS} )
@@ -65,7 +79,7 @@ if(CMAKE_BUILD_TYPE MATCHES "Release")
6579 FILES_MATCHING PATTERN "*.h" )
6680
6781endif ()
68-
82+
6983if (CMAKE_BUILD_TYPE MATCHES "Debug" )
7084
7185 set (SCL_TEST_SOURCE_FILES
@@ -97,29 +111,40 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug")
97111
98112 test /scl/p/test_simple.cc)
99113
100- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0" )
101- find_package (Catch2 REQUIRED)
102- include (CTest)
103- include (Catch)
104- include (${CMAKE_SOURCE_DIR} /cmake/CodeCoverage.cmake)
105-
106- # Tests that check bounds for reading/writing are sped up considerably by
107- # lowering said bounds.
108- add_compile_definitions (MAX_VEC_READ_SIZE=1024)
109- add_compile_definitions (MAX_MAT_READ_SIZE=1024)
110- add_compile_definitions (SCL_TEST_DATA_DIR="${CMAKE_SOURCE_DIR} /test/data/" )
111-
112- add_executable (scl_test ${SCL_SOURCE_FILES} ${SCL_TEST_SOURCE_FILES} )
113- target_link_libraries (scl_test Catch2::Catch2 pthread)
114- catch_discover_tests(scl_test)
115-
116- append_coverage_compiler_flags()
117-
118- # Tell lcov to ignore system STL headers in order to make the coverage
119- # output more precise.
120- setup_target_for_coverage_lcov(
121- NAME coverage
122- EXECUTABLE scl_test
123- EXCLUDE "/usr/include/*" "test/*" "/usr/lib/*" "/usr/local/*" )
114+ if (WITH_EC MATCHES ON )
115+ set (SCL_TEST_SOURCE_FILES ${SCL_TEST_SOURCE_FILES}
116+ test /scl/math/test_secp256k1.cc
117+ test /scl/math/test_number.cc)
118+ add_compile_definitions (SCL_ENABLE_EC_TESTS)
119+ endif ()
120+
121+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0" )
122+ find_package (Catch2 REQUIRED)
123+ include (CTest)
124+ include (Catch)
125+ include (${CMAKE_SOURCE_DIR} /cmake/CodeCoverage.cmake)
126+
127+ # Lower the max size of Vec/Mat reads to speed up tests
128+ add_compile_definitions (MAX_VEC_READ_SIZE=1024)
129+ add_compile_definitions (MAX_MAT_READ_SIZE=1024)
130+ add_compile_definitions (SCL_TEST_DATA_DIR="${CMAKE_SOURCE_DIR} /test/data/" )
131+
132+ add_executable (scl_test ${SCL_SOURCE_FILES} ${SCL_TEST_SOURCE_FILES} )
133+ target_link_libraries (scl_test Catch2::Catch2 pthread)
134+
135+ if (WITH_EC MATCHES ON )
136+ target_link_libraries (scl_test ${GMP} )
137+ endif ()
138+
139+ catch_discover_tests(scl_test)
140+
141+ append_coverage_compiler_flags()
142+
143+ # Tell lcov to ignore system STL headers in order to make the coverage
144+ # output more precise.
145+ setup_target_for_coverage_lcov(
146+ NAME coverage
147+ EXECUTABLE scl_test
148+ EXCLUDE "/usr/include/*" "test/*" "/usr/lib/*" "/usr/local/*" )
124149
125150endif ()
0 commit comments