Skip to content

Commit 2f4104c

Browse files
Jeffrey HurchallaJeffrey Hurchalla
authored andcommitted
update CMakeLists cmake_minimum_required to allow a policy up to 4.03 (the most recent CMake version I've verified works), and remove the CMakeLists.txt option to build/run dependencies' tests
1 parent 5c5b6bf commit 2f4104c

File tree

5 files changed

+18
-46
lines changed

5 files changed

+18
-46
lines changed

CMakeLists.txt

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ if(TARGET hurchalla_factoring)
77
return()
88
endif()
99

10-
cmake_minimum_required(VERSION 3.14)
10+
# later versions are probably fine, but are untested
11+
cmake_minimum_required(VERSION 3.14...4.03)
1112

1213
project(hurchalla_factoring VERSION 1.0.0 LANGUAGES CXX)
1314

@@ -19,29 +20,17 @@ endif()
1920

2021

2122
# TODO: this section seems slightly messy for detecting/setting up testing
22-
# --------------------
23-
option(TEST_HURCHALLA_LIBS
24-
"Build the tests for all Hurchalla library projects."
25-
OFF)
26-
23+
#
2724
# if this is the top level CMakeLists.txt, add testing options, and enable
2825
# testing when testing options have been set to ON.
2926
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
3027
option(TEST_HURCHALLA_FACTORING
3128
"Build the tests for the Hurchalla modular arithmetic library project."
3229
ON)
33-
if(TEST_HURCHALLA_FACTORING OR TEST_HURCHALLA_LIBS)
30+
if(TEST_HURCHALLA_FACTORING)
3431
enable_testing()
3532
# include(CTest)
3633
endif()
37-
elseif(TEST_HURCHALLA_LIBS)
38-
# If TEST_HURCHALLA_LIBS is set to ON, enable_testing() should have been
39-
# called either directly or indirectly by the top level project. (Note that
40-
# if a project calls include(CTest), the included CTest.cmake defines a
41-
# BUILT_TESTING option and calls enable_testing if BUILD_TESTING is ON.)
42-
if (NOT CMAKE_TESTING_ENABLED)
43-
message(FATAL_ERROR "Fatal error: TEST_HURCHALLA_LIBS was set, but enable_testing() was never called")
44-
endif()
4534
endif()
4635

4736

@@ -170,11 +159,9 @@ target_link_libraries(hurchalla_factoring
170159

171160
# if this is the top level CMakeLists.txt
172161
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
173-
if(TEST_HURCHALLA_FACTORING OR TEST_HURCHALLA_LIBS)
162+
if(TEST_HURCHALLA_FACTORING)
174163
add_subdirectory(test)
175164
endif()
176-
elseif(TEST_HURCHALLA_LIBS)
177-
add_subdirectory(test)
178165
endif()
179166

180167

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Alt text](images/epr.jpg?raw=true "Elliptic curve, and rho cycle")
44

5-
EPR is a high performance, easy to use factoring and primality checking C++ library (header-only) for any integer up to 128 bits in size. At the time of this writing, EPR provides the fastest factoring functions known for 64 bit integers (i.e. types int64_t and uint64_t). Note that for good performance you *must* ensure that the standard macro NDEBUG is defined when compiling - see [How to use the library](#how-to-use-the-library).
5+
EPR is a high performance, easy to use factoring and primality checking C++ library (header-only, written in C++17) for any integer up to 128 bits in size. At the time of this writing, EPR provides the fastest factoring functions known for 64 bit integers (i.e. types int64_t and uint64_t). Note that for good performance you *must* ensure that the standard macro NDEBUG is defined when compiling - see [How to use the library](#how-to-use-the-library).
66

77
The name EPR is an abbreviation of Ecm and Pollard-Rho, since those are the two main algorithms this library uses for factoring. It's also a play on [Einstein-Podolsky-Rosen](https://en.wikipedia.org/wiki/EPR_paradox) for fun ([for now](https://en.wikipedia.org/wiki/Shor%27s_algorithm)).
88

@@ -14,9 +14,11 @@ The goal for EPR was to create a correct and easy to use library with extremely
1414

1515
## Requirements
1616

17-
The EPR library requires compiler support for C++17 (if you are not using CMake, you may need to specify the option *-std="c++17"* when compiling). Compilers that are confirmed to build the library without warnings or errors on x86 include clang6, clang10, clang18, gcc7, gcc10, gcc13, intel compiler 19, and Microsoft Visual C++ 2017, 2019, 2022. The library is intended for use on all architectures (e.g. x86/64, ARM, RISC-V, Power), but has been tested only on x86/x64.
17+
The EPR library requires compiler support for C++17. If you are not using CMake, you may need to specify the option *-std="c++17"* when compiling. Any C++ version higher than C++17 is also fine.
1818

19-
For good performance you absolutely *must* ensure that the standard macro NDEBUG (see <cassert>) is defined when compiling.
19+
For good performance you absolutely *must* ensure that the standard macro NDEBUG (see <cassert>) is defined when compiling.
20+
21+
Compilers that are confirmed to build this library without warnings or errors on Ubuntu linux (x64) include clang6, clang10, clang18, gcc7, gcc10, gcc13, and intel compiler 19. On Windows, Microsoft Visual C++ 2017, 2019, 2022 are all confirmed to build it without warnings or errors. On MacOS, clang16 and gcc14 are confirmed to build it without warnings or errors. The library is intended for use on all architectures (e.g. x86/64, ARM, RISC-V), but has so far been tested only with x86, x64 (Windows and Ubuntu), and ARM64 (MacOS).
2022

2123
## Status
2224

benchmark/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if(TARGET bench_hurchalla_factoring)
88
return()
99
endif()
1010

11-
cmake_minimum_required(VERSION 3.14)
11+
# later versions are probably fine, but are untested
12+
cmake_minimum_required(VERSION 3.14...4.03)
1213

1314

1415
#set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests)

build_tests.sh

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# This is a working convenience script for invoking the testing builds and then
1313
# running the tests.
1414
# The syntax is
15-
# ./build_tests [-c<compiler_name>] [-j<num_jobs>] [-r] [-a] [-u] [-t] [-m<Release|Debug|Profile>] [-l<standard_library_name>]
15+
# ./build_tests [-c<compiler_name>] [-j<num_jobs>] [-r] [-a] [-u] [-m<Release|Debug|Profile>] [-l<standard_library_name>]
1616
#
1717
# -c allows you to select the compiler, rather than using the default.
1818
# -j specifies the number of jobs (typically threads) that you want the compiler
@@ -26,8 +26,6 @@
2626
# -u specifies that you want to compile the code using all available inline asm
2727
# routines, so that the tests will cover all of them (this is not expected to
2828
# result in the fastest binaries).
29-
# -t specifies to compile tests for all Hurchalla libraries, as well as for this
30-
# repository. Without -t, only tests for this repository will be compiled.
3129
# -m allows you to choose between Release, Debug, and Profile(Release with
3230
# debug symbols) build configurations, rather than using the default.
3331
# -l allows you to choose between either libstdc++ or libc++ when using clang.
@@ -177,12 +175,12 @@ if [ "${BASH_VERSINFO:-0}" -lt 4 ]; then
177175
exit 1
178176
fi
179177

180-
while getopts ":m:l:c:j:h-:raut" opt; do
178+
while getopts ":m:l:c:j:h-:rau" opt; do
181179
case $opt in
182180
h)
183181
;&
184182
-)
185-
echo "Usage: build_tests [-c<compiler_name>] [-j<num_jobs>] [-r] [-a] [-u] [-t] [-m<Release|Debug|Profile>] [-l<standard_library_name>]" >&2
183+
echo "Usage: build_tests [-c<compiler_name>] [-j<num_jobs>] [-r] [-a] [-u] [-m<Release|Debug|Profile>] [-l<standard_library_name>]" >&2
186184
exit 1
187185
;;
188186
c)
@@ -206,10 +204,6 @@ while getopts ":m:l:c:j:h-:raut" opt; do
206204
u)
207205
use_all_inline_asm="-DHURCHALLA_ALLOW_INLINE_ASM_ALL=1"
208206
;;
209-
t)
210-
test_all_hurchalla_libs="-DTEST_HURCHALLA_LIBS=ON"
211-
run_all_hurchalla_tests=true
212-
;;
213207
\?)
214208
echo "Invalid option: -$OPTARG" >&2
215209
exit 1
@@ -533,7 +527,6 @@ if [ "${mode,,}" = "release" ]; then
533527
mkdir -p $build_dir
534528
cmake -S. -B./$build_dir -DTEST_HURCHALLA_FACTORING=ON \
535529
-DBENCH_HURCHALLA_FACTORING=ON \
536-
$test_all_hurchalla_libs \
537530
-DCMAKE_BUILD_TYPE=Release \
538531
-DCMAKE_CXX_FLAGS="$cpp_standard $cpp_stdlib \
539532
$use_inline_asm $use_all_inline_asm \
@@ -548,7 +541,6 @@ elif [ "${mode,,}" = "debug" ]; then
548541
build_dir=build/debug_$compiler_name$compiler_version
549542
mkdir -p $build_dir
550543
cmake -S. -B./$build_dir -DTEST_HURCHALLA_FACTORING=ON \
551-
$test_all_hurchalla_libs \
552544
-DCMAKE_BUILD_TYPE=Debug \
553545
-DCMAKE_EXE_LINKER_FLAGS="$clang_ubsan_link_flags" \
554546
-DCMAKE_CXX_FLAGS="$cpp_standard $cpp_stdlib \
@@ -565,7 +557,6 @@ elif [ "${mode,,}" = "profile" ]; then
565557
build_dir=build/profile_$compiler_name$compiler_version
566558
mkdir -p $build_dir
567559
cmake -S. -B./$build_dir -DTEST_HURCHALLA_FACTORING=ON \
568-
$test_all_hurchalla_libs \
569560
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
570561
-DCMAKE_EXE_LINKER_FLAGS="-ldl" \
571562
-DCMAKE_CXX_FLAGS="$cpp_standard $cpp_stdlib \
@@ -582,21 +573,11 @@ fi
582573

583574

584575
# -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
585-
# cmake -S. -B./build_tmp -DCMAKE_CXX_FLAGS="-std=c++17" -DTEST_HURCHALLA_LIBS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=icpc -DCMAKE_C_COMPILER=icc
576+
# cmake -S. -B./build_tmp -DCMAKE_CXX_FLAGS="-std=c++17" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=icpc -DCMAKE_C_COMPILER=icc
586577
# cmake --build ./build_tmp --config Debug
587578

588579

589580
if [ "$run_tests" = true ]; then
590-
if [ "$run_all_hurchalla_tests" = true ]; then
591-
./$build_dir/test_ndebug_programming_by_contract --gtest_break_on_failure
592-
exit_on_failure
593-
./$build_dir/test_programming_by_contract --gtest_break_on_failure
594-
exit_on_failure
595-
./$build_dir/test_hurchalla_util --gtest_break_on_failure
596-
exit_on_failure
597-
./$build_dir/test_hurchalla_modular_arithmetic --gtest_break_on_failure
598-
exit_on_failure
599-
fi
600581
./$build_dir/test_hurchalla_factoring --gtest_break_on_failure
601582
exit_on_failure
602583
fi

test/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if(TARGET test_hurchalla_factoring)
88
return()
99
endif()
1010

11-
cmake_minimum_required(VERSION 3.14)
11+
# later versions are probably fine, but are untested
12+
cmake_minimum_required(VERSION 3.14...4.03)
1213

1314

1415
include(FetchGoogleTest.cmake)

0 commit comments

Comments
 (0)