From fdc56da20599641383f3ed6c5d8fabf5bb03a4a7 Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Mon, 14 May 2018 18:15:44 +0200 Subject: [PATCH 01/11] Convert `Makefile`s to `cmake` Converted `Makefile`s to `CMakeLists.txt` to add cross-platform support. Closes #43. --- .gitignore | 20 ++ CMakeLists.txt | 45 +++++ Makefile | 39 ---- README.md | 47 +++-- sample/.gitignore | 39 ---- sample/CMakeLists.txt | 17 ++ sample/Makefile | 47 ----- test-high/.gitignore | 75 ------- test-high/CMakeLists.txt | 84 ++++++++ test-high/Makefile | 191 ------------------ test-high/check-pcg128_once_insecure.cpp | 5 - .../check-pcg128_oneseq_once_insecure.cpp | 5 - test-high/check-pcg16_once_insecure.cpp | 5 - .../check-pcg16_oneseq_once_insecure.cpp | 5 - test-high/check-pcg32.cpp | 5 - test-high/check-pcg32_c1024.cpp | 5 - test-high/check-pcg32_c1024_fast.cpp | 5 - test-high/check-pcg32_c64.cpp | 5 - test-high/check-pcg32_c64_fast.cpp | 5 - test-high/check-pcg32_c64_oneseq.cpp | 5 - test-high/check-pcg32_fast.cpp | 5 - test-high/check-pcg32_k1024.cpp | 5 - test-high/check-pcg32_k1024_fast.cpp | 5 - test-high/check-pcg32_k16384.cpp | 5 - test-high/check-pcg32_k16384_fast.cpp | 5 - test-high/check-pcg32_k2.cpp | 5 - test-high/check-pcg32_k2_fast.cpp | 5 - test-high/check-pcg32_k64.cpp | 5 - test-high/check-pcg32_k64_fast.cpp | 5 - test-high/check-pcg32_k64_oneseq.cpp | 5 - test-high/check-pcg32_once_insecure.cpp | 5 - test-high/check-pcg32_oneseq.cpp | 5 - .../check-pcg32_oneseq_once_insecure.cpp | 5 - test-high/check-pcg32_unique.cpp | 5 - test-high/check-pcg64.cpp | 5 - test-high/check-pcg64_c1024.cpp | 6 - test-high/check-pcg64_c1024_fast.cpp | 6 - test-high/check-pcg64_c32.cpp | 6 - test-high/check-pcg64_c32_fast.cpp | 6 - test-high/check-pcg64_c32_oneseq.cpp | 6 - test-high/check-pcg64_fast.cpp | 5 - test-high/check-pcg64_k1024.cpp | 6 - test-high/check-pcg64_k1024_fast.cpp | 6 - test-high/check-pcg64_k32.cpp | 6 - test-high/check-pcg64_k32_fast.cpp | 6 - test-high/check-pcg64_k32_oneseq.cpp | 6 - test-high/check-pcg64_once_insecure.cpp | 5 - test-high/check-pcg64_oneseq.cpp | 5 - .../check-pcg64_oneseq_once_insecure.cpp | 5 - test-high/check-pcg64_unique.cpp | 5 - test-high/check-pcg8_once_insecure.cpp | 5 - test-high/check-pcg8_oneseq_once_insecure.cpp | 5 - test-high/expected/.gitignore | 2 - test-high/run-test.cmake | 31 +++ test-high/run-tests.sh | 98 --------- 55 files changed, 230 insertions(+), 725 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 sample/.gitignore create mode 100644 sample/CMakeLists.txt delete mode 100644 sample/Makefile delete mode 100644 test-high/.gitignore create mode 100644 test-high/CMakeLists.txt delete mode 100644 test-high/Makefile delete mode 100644 test-high/check-pcg128_once_insecure.cpp delete mode 100644 test-high/check-pcg128_oneseq_once_insecure.cpp delete mode 100644 test-high/check-pcg16_once_insecure.cpp delete mode 100644 test-high/check-pcg16_oneseq_once_insecure.cpp delete mode 100644 test-high/check-pcg32.cpp delete mode 100644 test-high/check-pcg32_c1024.cpp delete mode 100644 test-high/check-pcg32_c1024_fast.cpp delete mode 100644 test-high/check-pcg32_c64.cpp delete mode 100644 test-high/check-pcg32_c64_fast.cpp delete mode 100644 test-high/check-pcg32_c64_oneseq.cpp delete mode 100644 test-high/check-pcg32_fast.cpp delete mode 100644 test-high/check-pcg32_k1024.cpp delete mode 100644 test-high/check-pcg32_k1024_fast.cpp delete mode 100644 test-high/check-pcg32_k16384.cpp delete mode 100644 test-high/check-pcg32_k16384_fast.cpp delete mode 100644 test-high/check-pcg32_k2.cpp delete mode 100644 test-high/check-pcg32_k2_fast.cpp delete mode 100644 test-high/check-pcg32_k64.cpp delete mode 100644 test-high/check-pcg32_k64_fast.cpp delete mode 100644 test-high/check-pcg32_k64_oneseq.cpp delete mode 100644 test-high/check-pcg32_once_insecure.cpp delete mode 100644 test-high/check-pcg32_oneseq.cpp delete mode 100644 test-high/check-pcg32_oneseq_once_insecure.cpp delete mode 100644 test-high/check-pcg32_unique.cpp delete mode 100644 test-high/check-pcg64.cpp delete mode 100644 test-high/check-pcg64_c1024.cpp delete mode 100644 test-high/check-pcg64_c1024_fast.cpp delete mode 100644 test-high/check-pcg64_c32.cpp delete mode 100644 test-high/check-pcg64_c32_fast.cpp delete mode 100644 test-high/check-pcg64_c32_oneseq.cpp delete mode 100644 test-high/check-pcg64_fast.cpp delete mode 100644 test-high/check-pcg64_k1024.cpp delete mode 100644 test-high/check-pcg64_k1024_fast.cpp delete mode 100644 test-high/check-pcg64_k32.cpp delete mode 100644 test-high/check-pcg64_k32_fast.cpp delete mode 100644 test-high/check-pcg64_k32_oneseq.cpp delete mode 100644 test-high/check-pcg64_once_insecure.cpp delete mode 100644 test-high/check-pcg64_oneseq.cpp delete mode 100644 test-high/check-pcg64_oneseq_once_insecure.cpp delete mode 100644 test-high/check-pcg64_unique.cpp delete mode 100644 test-high/check-pcg8_once_insecure.cpp delete mode 100644 test-high/check-pcg8_oneseq_once_insecure.cpp delete mode 100644 test-high/expected/.gitignore create mode 100644 test-high/run-test.cmake delete mode 100755 test-high/run-tests.sh diff --git a/.gitignore b/.gitignore index 9f598fd..b08260e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,23 @@ *.app # Actual Project Executables + +# Created by https://www.gitignore.io/api/cmake + +### CMake ### +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +build + + +# End of https://www.gitignore.io/api/cmake + +# Expected test results +!test-high/expected/*.out diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1d1be34 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.1.3) + +project( + PCG + VERSION 0.98.1 + LANGUAGES CXX +) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_library(headers INTERFACE) +target_include_directories( + headers INTERFACE + $ + $ +) +install( + TARGETS headers + EXPORT pcg +) +install( + EXPORT pcg + DESTINATION share/cmake/pcg + NAMESPACE pcg:: + FILE pcg-config.cmake +) +install( + DIRECTORY include/ + DESTINATION include + FILES_MATCHING PATTERN "*.hpp" +) + +set(BUILD_SAMPLES ON CACHE BOOL "Build sample programs.") + +if (BUILD_SAMPLES) + add_subdirectory(sample) +endif() + +set(TEST_PCG ON CACHE BOOL "Run the unit tests.") + +if (TEST_PCG) + enable_testing() + add_subdirectory(test-high) +endif() diff --git a/Makefile b/Makefile deleted file mode 100644 index dda965c..0000000 --- a/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# -# PCG Random Number Generation for C++. -# -# Copyright 2014-2017 Melissa O'Neill , -# and the PCG Project contributors. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) -# -# Licensed under the Apache License, Version 2.0 (provided in -# LICENSE-APACHE.txt and at http://www.apache.org/licenses/LICENSE-2.0) -# or under the MIT license (provided in LICENSE-MIT.txt and at -# http://opensource.org/licenses/MIT), at your option. This file may not -# be copied, modified, or distributed except according to those terms. -# -# Distributed on an "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, either -# express or implied. See your chosen license for details. -# -# For additional information about the PCG random number generation scheme, -# visit http://www.pcg-random.org/. -# - -all: - cd test-high; $(MAKE) - cd sample; $(MAKE) - -PREFIX = /usr/local - -install: all - install -d $(DESTDIR)$(PREFIX)/include - install -m 0644 include/*.hpp $(DESTDIR)$(PREFIX)/include - -test: all - cd test-high; $(MAKE) test - -clean: - cd test-high; $(MAKE) clean - cd sample; $(MAKE) clean - - diff --git a/README.md b/README.md index c6e579c..d08b60c 100644 --- a/README.md +++ b/README.md @@ -27,19 +27,38 @@ self explanatory. ## Building The code is written in C++11, as an include-only library (i.e., there is -nothing you need to build). There are some provided demo programs and tests -however. On a Unix-style system (e.g., Linux, Mac OS X) you should be able -to just type - - make - -To build the demo programs. - -## Testing - -Run - - make test +nothing you need to build). + +There are some provided demo programs and tests however. We also provide a +[cmake](https://cmake.org/)-based building and testing functionality. If you +do not have `cmake` installed on your system, you can +[download](https://cmake.org/download/) the latest version. Once installed, you +can run + +```bash +mkdir build +cd build +cmake ../ +cmake --build . +cmake --build . --target test +cmake --build . --target install +``` + +Above, `cmake` creates necessary files inside the `build` folder, builds the +demo programs (`BUILD_SAMPLES=ON`), creates tests (`TEST_PCG=ON`), and finally +installs the header files to the `include` folder in the default system path. + +You can append `-DVARIABLE=VALUE` to `cmake` to change the default behaviour. +For instance, if you are only interested in installing the header files to the +`install` folder inside the current path, simply run + +```bash +mkdir build install +cd build +cmake -DBUILD_SAMPLES=OFF -DTEST_PCG=OFF -DCMAKE_INSTALL_PREFIX=../install ../ +cmake --build . +cmake --build . --target install +``` ## Directory Structure @@ -48,5 +67,5 @@ The directories are arranged as follows: * `include` -- contains `pcg_random.hpp` and supporting include files * `test-high` -- test code for the high-level API where the functions have shorter, less scary-looking names. -* `sample` -- sample code, some similar to the code in `test-high` but more +* `sample` -- sample code, some similar to the code in `test-high` but more human readable, some other examples too diff --git a/sample/.gitignore b/sample/.gitignore deleted file mode 100644 index fc83ecc..0000000 --- a/sample/.gitignore +++ /dev/null @@ -1,39 +0,0 @@ -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Debug Information -*.dSYM - -# Executables -*.exe -*.out -*.app - -# Actual Project Executables -pcg-demo -codebook -cppref-sample -make-partytrick -spew -use-partytrick diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt new file mode 100644 index 0000000..a81d4f7 --- /dev/null +++ b/sample/CMakeLists.txt @@ -0,0 +1,17 @@ +add_executable(codebook codebook.cpp) +target_link_libraries(codebook PRIVATE headers) + +add_executable(cppref-sample cppref-sample.cpp) +target_link_libraries(cppref-sample PRIVATE headers) + +add_executable(make-partytrick make-partytrick.cpp) +target_link_libraries(make-partytrick PRIVATE headers) + +add_executable(pcg-demo pcg-demo.cpp) +target_link_libraries(pcg-demo PRIVATE headers) + +add_executable(spew spew.cpp) +target_link_libraries(spew PRIVATE headers) + +add_executable(use-partytrick use-partytrick.cpp) +target_link_libraries(use-partytrick PRIVATE headers) diff --git a/sample/Makefile b/sample/Makefile deleted file mode 100644 index c016be0..0000000 --- a/sample/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# PCG Random Number Generation for C++. -# -# Copyright 2014-2017 Melissa O'Neill , -# and the PCG Project contributors. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) -# -# Licensed under the Apache License, Version 2.0 (provided in -# LICENSE-APACHE.txt and at http://www.apache.org/licenses/LICENSE-2.0) -# or under the MIT license (provided in LICENSE-MIT.txt and at -# http://opensource.org/licenses/MIT), at your option. This file may not -# be copied, modified, or distributed except according to those terms. -# -# Distributed on an "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, either -# express or implied. See your chosen license for details. -# -# For additional information about the PCG random number generation scheme, -# visit http://www.pcg-random.org/. -# - -TARGETS = pcg-demo codebook cppref-sample make-partytrick -BINARYOUT_TARGETS = spew use-partytrick - -CPPFLAGS += -I../include -CXXFLAGS += -std=c++11 -O2 -CC = $(CXX) # Cheat so that linking uses the C++ compiler - -all: $(TARGETS) - -posix-binaryoutput: spew use-partytrick - -clean: - rm -f *.o $(TARGETS) $(BINARYOUT_TARGETS) - -codebook.o: codebook.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -cppref-sample.o: cppref-sample.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -make-partytrick.o: make-partytrick.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -pcg-demo.o: pcg-demo.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -spew.o: spew.cpp ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -use-partytrick.o: use-partytrick.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp diff --git a/test-high/.gitignore b/test-high/.gitignore deleted file mode 100644 index 9878f4a..0000000 --- a/test-high/.gitignore +++ /dev/null @@ -1,75 +0,0 @@ -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Debug Information -*.dSYM - -# Executables -*.exe -*.out -*.app - -# Actual Project Executables -check-pcg8_once_insecure -check-pcg8_oneseq_once_insecure -check-pcg16_once_insecure -check-pcg16_oneseq_once_insecure -check-pcg32 -check-pcg32_c1024 -check-pcg32_c1024_fast -check-pcg32_c64 -check-pcg32_c64_fast -check-pcg32_c64_oneseq -check-pcg32_fast -check-pcg32_k1024 -check-pcg32_k1024_fast -check-pcg32_k16384 -check-pcg32_k16384_fast -check-pcg32_k2 -check-pcg32_k2_fast -check-pcg32_k64 -check-pcg32_k64_fast -check-pcg32_k64_oneseq -check-pcg32_once_insecure -check-pcg32_oneseq -check-pcg32_oneseq_once_insecure -check-pcg32_unique -check-pcg64 -check-pcg64_c1024 -check-pcg64_c1024_fast -check-pcg64_c32 -check-pcg64_c32_fast -check-pcg64_c32_oneseq -check-pcg64_fast -check-pcg64_k1024 -check-pcg64_k1024_fast -check-pcg64_k32 -check-pcg64_k32_fast -check-pcg64_k32_oneseq -check-pcg64_once_insecure -check-pcg64_oneseq -check-pcg64_oneseq_once_insecure -check-pcg64_unique -check-pcg128_once_insecure -check-pcg128_oneseq_once_insecure diff --git a/test-high/CMakeLists.txt b/test-high/CMakeLists.txt new file mode 100644 index 0000000..eb4f851 --- /dev/null +++ b/test-high/CMakeLists.txt @@ -0,0 +1,84 @@ +function(define_test source rng two_arg_init) + add_executable(${rng} ${source}) + if(${ARGC} EQUAL 3) + target_compile_definitions( + ${rng} + PRIVATE RNG=${rng} TWO_ARG_INIT=${two_arg_init} + ) + elseif(${ARGC} EQUAL 4) + target_compile_definitions( + ${rng} + PRIVATE RNG=${rng} TWO_ARG_INIT=${two_arg_init} AWKWARD_128BIT_CODE=${ARGV3} + ) + endif() + target_link_libraries(${rng} PRIVATE headers) + + add_test( + NAME check-${rng} + COMMAND ${CMAKE_COMMAND} + -DRNG=${rng} + -DEXECUTABLE=${CMAKE_CURRENT_BINARY_DIR}/${rng} + -DEXPECTED=${CMAKE_CURRENT_SOURCE_DIR}/expected/check-${rng}.out + -P ${CMAKE_CURRENT_SOURCE_DIR}/run-test.cmake + ) +endfunction(define_test) + +set( + test_programs + "pcg-test.cpp pcg8_once_insecure 1" + "pcg-test.cpp pcg8_oneseq_once_insecure 0" + "pcg-test.cpp pcg16_once_insecure 1" + "pcg-test.cpp pcg16_oneseq_once_insecure 0" + "pcg-test-noadvance.cpp pcg32_c64_fast 0" + "pcg-test-noadvance.cpp pcg32_c64_oneseq 0" + "pcg-test-noadvance.cpp pcg32_c64 1" + "pcg-test-noadvance.cpp pcg32_c1024_fast 0" + "pcg-test-noadvance.cpp pcg32_c1024 1" + "pcg-test.cpp pcg32_fast 0" + "pcg-test.cpp pcg32_k2_fast 0" + "pcg-test.cpp pcg32_k2 1" + "pcg-test.cpp pcg32_k64_fast 0" + "pcg-test.cpp pcg32_k64_oneseq 0" + "pcg-test.cpp pcg32_k64 1" + "pcg-test.cpp pcg32_k1024_fast 0" + "pcg-test.cpp pcg32_k1024 1" + "pcg-test.cpp pcg32_k16384_fast 0" + "pcg-test.cpp pcg32_k16384 1" + "pcg-test.cpp pcg32_once_insecure 1" + "pcg-test.cpp pcg32_oneseq_once_insecure 0" + "pcg-test.cpp pcg32_oneseq 0" + "pcg-test-noadvance.cpp pcg32_unique 0" + "pcg-test.cpp pcg32 1" + "pcg-test-noadvance.cpp pcg64_c32_fast 0 1" + "pcg-test-noadvance.cpp pcg64_c32_oneseq 0 1" + "pcg-test-noadvance.cpp pcg64_c32 1 1" + "pcg-test-noadvance.cpp pcg64_c1024_fast 0 1" + "pcg-test-noadvance.cpp pcg64_c1024 1 1" + "pcg-test.cpp pcg64_fast 0" + "pcg-test.cpp pcg64_k32_fast 0 1" + "pcg-test.cpp pcg64_k32_oneseq 0 1" + "pcg-test.cpp pcg64_k32 1 1" + "pcg-test.cpp pcg64_k1024_fast 0 1" + "pcg-test.cpp pcg64_k1024 1 1" + "pcg-test.cpp pcg64_once_insecure 1" + "pcg-test.cpp pcg64_oneseq_once_insecure 0" + "pcg-test.cpp pcg64_oneseq 0" + "pcg-test-noadvance.cpp pcg64_unique 0" + "pcg-test.cpp pcg64 1" + "pcg-test.cpp pcg128_once_insecure 1" + "pcg-test.cpp pcg128_oneseq_once_insecure 0" +) + +foreach(test IN LISTS test_programs) + if(${test} MATCHES "(.+)[ ](.+)[ ](.+)[ ](.+)") + define_test(${CMAKE_MATCH_1} ${CMAKE_MATCH_2} ${CMAKE_MATCH_3} ${CMAKE_MATCH_4}) + elseif(${test} MATCHES "(.+)[ ](.+)[ ](.+)") + define_test(${CMAKE_MATCH_1} ${CMAKE_MATCH_2} ${CMAKE_MATCH_3}) + endif() +endforeach() + +# pcg32_unique and pcg64_unique are failing in the old run-tests.sh (/dev/null'ed) +set_property( + TEST check-pcg32_unique check-pcg64_unique + PROPERTY WILL_FAIL TRUE +) diff --git a/test-high/Makefile b/test-high/Makefile deleted file mode 100644 index e50dc35..0000000 --- a/test-high/Makefile +++ /dev/null @@ -1,191 +0,0 @@ -# -# PCG Random Number Generation for C++. -# -# Copyright 2014-2017 Melissa O'Neill , -# and the PCG Project contributors. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) -# -# Licensed under the Apache License, Version 2.0 (provided in -# LICENSE-APACHE.txt and at http://www.apache.org/licenses/LICENSE-2.0) -# or under the MIT license (provided in LICENSE-MIT.txt and at -# http://opensource.org/licenses/MIT), at your option. This file may not -# be copied, modified, or distributed except according to those terms. -# -# Distributed on an "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, either -# express or implied. See your chosen license for details. -# -# For additional information about the PCG random number generation scheme, -# visit http://www.pcg-random.org/. -# - -TARGETS = \ - check-pcg8_once_insecure check-pcg8_oneseq_once_insecure \ - check-pcg16_once_insecure check-pcg16_oneseq_once_insecure check-pcg32 \ - check-pcg32_c1024 check-pcg32_c1024_fast check-pcg32_c64 \ - check-pcg32_c64_fast check-pcg32_c64_oneseq check-pcg32_fast \ - check-pcg32_k1024 check-pcg32_k1024_fast check-pcg32_k16384 \ - check-pcg32_k16384_fast check-pcg32_k2 check-pcg32_k2_fast \ - check-pcg32_k64 check-pcg32_k64_fast check-pcg32_k64_oneseq \ - check-pcg32_once_insecure check-pcg32_oneseq \ - check-pcg32_oneseq_once_insecure check-pcg32_unique check-pcg64 \ - check-pcg64_c1024 check-pcg64_c1024_fast check-pcg64_c32 \ - check-pcg64_c32_fast check-pcg64_c32_oneseq check-pcg64_fast \ - check-pcg64_k1024 check-pcg64_k1024_fast check-pcg64_k32 \ - check-pcg64_k32_fast check-pcg64_k32_oneseq check-pcg64_once_insecure \ - check-pcg64_oneseq check-pcg64_oneseq_once_insecure check-pcg64_unique \ - check-pcg128_once_insecure check-pcg128_oneseq_once_insecure - -# special flags for some compilers -CPPFLAGS_clang++ += \ - -Weverything \ - -Wno-unknown-warning-option \ - -Wno-c++98-compat \ - -Wno-c++98-compat-pedantic \ - -Wno-date-time \ - -Wno-undef \ - -Wno-header-hygiene \ - -Wno-unused-macros - -CPPFLAGS += -I../include -Wall -Wextra $(CPPFLAGS_$(CXX)) -CXXFLAGS += -std=c++11 -CC = $(CXX) # Cheat so that linking uses the C++ compiler - -all: $(TARGETS) - -test: $(TARGETS) - sh run-tests.sh - -clean: - rm -f *.o $(TARGETS) - rm -rf actual - -pcg-test-noadvance.o: pcg-test-noadvance.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -pcg-test.o: pcg-test.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -check-pcg8_once_insecure.o: check-pcg8_once_insecure.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg8_oneseq_once_insecure.o: check-pcg8_oneseq_once_insecure.cpp \ - pcg-test.cpp ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg16_once_insecure.o: check-pcg16_once_insecure.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg16_oneseq_once_insecure.o: check-pcg16_oneseq_once_insecure.cpp \ - pcg-test.cpp ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32.o: check-pcg32.cpp pcg-test.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -check-pcg32_c1024.o: check-pcg32_c1024.cpp pcg-test-noadvance.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_c1024_fast.o: check-pcg32_c1024_fast.cpp \ - pcg-test-noadvance.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -check-pcg32_c64.o: check-pcg32_c64.cpp pcg-test-noadvance.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_c64_fast.o: check-pcg32_c64_fast.cpp pcg-test-noadvance.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_c64_oneseq.o: check-pcg32_c64_oneseq.cpp \ - pcg-test-noadvance.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -check-pcg32_fast.o: check-pcg32_fast.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k1024.o: check-pcg32_k1024.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k1024_fast.o: check-pcg32_k1024_fast.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k16384.o: check-pcg32_k16384.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k16384_fast.o: check-pcg32_k16384_fast.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k2.o: check-pcg32_k2.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k2_fast.o: check-pcg32_k2_fast.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k64.o: check-pcg32_k64.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k64_fast.o: check-pcg32_k64_fast.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_k64_oneseq.o: check-pcg32_k64_oneseq.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_once_insecure.o: check-pcg32_once_insecure.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_oneseq.o: check-pcg32_oneseq.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_oneseq_once_insecure.o: check-pcg32_oneseq_once_insecure.cpp \ - pcg-test.cpp ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg32_unique.o: check-pcg32_unique.cpp pcg-test-noadvance.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64.o: check-pcg64.cpp pcg-test.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -check-pcg64_c1024.o: check-pcg64_c1024.cpp pcg-test-noadvance.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_c1024_fast.o: check-pcg64_c1024_fast.cpp \ - pcg-test-noadvance.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -check-pcg64_c32.o: check-pcg64_c32.cpp pcg-test-noadvance.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_c32_fast.o: check-pcg64_c32_fast.cpp pcg-test-noadvance.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_c32_oneseq.o: check-pcg64_c32_oneseq.cpp \ - pcg-test-noadvance.cpp ../include/pcg_random.hpp \ - ../include/pcg_extras.hpp ../include/pcg_uint128.hpp -check-pcg64_fast.o: check-pcg64_fast.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_k1024.o: check-pcg64_k1024.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_k1024_fast.o: check-pcg64_k1024_fast.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_k32.o: check-pcg64_k32.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_k32_fast.o: check-pcg64_k32_fast.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_k32_oneseq.o: check-pcg64_k32_oneseq.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_once_insecure.o: check-pcg64_once_insecure.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_oneseq.o: check-pcg64_oneseq.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_oneseq_once_insecure.o: check-pcg64_oneseq_once_insecure.cpp \ - pcg-test.cpp ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg64_unique.o: check-pcg64_unique.cpp pcg-test-noadvance.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg128_once_insecure.o: check-pcg128_once_insecure.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp -check-pcg128_oneseq_once_insecure.o: \ - check-pcg128_oneseq_once_insecure.cpp pcg-test.cpp \ - ../include/pcg_random.hpp ../include/pcg_extras.hpp \ - ../include/pcg_uint128.hpp diff --git a/test-high/check-pcg128_once_insecure.cpp b/test-high/check-pcg128_once_insecure.cpp deleted file mode 100644 index 7baf4e5..0000000 --- a/test-high/check-pcg128_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg128_once_insecure -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg128_oneseq_once_insecure.cpp b/test-high/check-pcg128_oneseq_once_insecure.cpp deleted file mode 100644 index 54b980b..0000000 --- a/test-high/check-pcg128_oneseq_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg128_oneseq_once_insecure -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg16_once_insecure.cpp b/test-high/check-pcg16_once_insecure.cpp deleted file mode 100644 index 2e53283..0000000 --- a/test-high/check-pcg16_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg16_once_insecure -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg16_oneseq_once_insecure.cpp b/test-high/check-pcg16_oneseq_once_insecure.cpp deleted file mode 100644 index b66743e..0000000 --- a/test-high/check-pcg16_oneseq_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg16_oneseq_once_insecure -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32.cpp b/test-high/check-pcg32.cpp deleted file mode 100644 index e7c2df3..0000000 --- a/test-high/check-pcg32.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32 -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_c1024.cpp b/test-high/check-pcg32_c1024.cpp deleted file mode 100644 index cb97cd1..0000000 --- a/test-high/check-pcg32_c1024.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_c1024 -#define TWO_ARG_INIT 1 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg32_c1024_fast.cpp b/test-high/check-pcg32_c1024_fast.cpp deleted file mode 100644 index de06b13..0000000 --- a/test-high/check-pcg32_c1024_fast.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_c1024_fast -#define TWO_ARG_INIT 0 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg32_c64.cpp b/test-high/check-pcg32_c64.cpp deleted file mode 100644 index 7fbdee1..0000000 --- a/test-high/check-pcg32_c64.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_c64 -#define TWO_ARG_INIT 1 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg32_c64_fast.cpp b/test-high/check-pcg32_c64_fast.cpp deleted file mode 100644 index 4f21ce1..0000000 --- a/test-high/check-pcg32_c64_fast.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_c64_fast -#define TWO_ARG_INIT 0 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg32_c64_oneseq.cpp b/test-high/check-pcg32_c64_oneseq.cpp deleted file mode 100644 index b3343fb..0000000 --- a/test-high/check-pcg32_c64_oneseq.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_c64_oneseq -#define TWO_ARG_INIT 0 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg32_fast.cpp b/test-high/check-pcg32_fast.cpp deleted file mode 100644 index 46ee2c7..0000000 --- a/test-high/check-pcg32_fast.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_fast -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k1024.cpp b/test-high/check-pcg32_k1024.cpp deleted file mode 100644 index 8f10df0..0000000 --- a/test-high/check-pcg32_k1024.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k1024 -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k1024_fast.cpp b/test-high/check-pcg32_k1024_fast.cpp deleted file mode 100644 index 181f1a1..0000000 --- a/test-high/check-pcg32_k1024_fast.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k1024_fast -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k16384.cpp b/test-high/check-pcg32_k16384.cpp deleted file mode 100644 index 41275bb..0000000 --- a/test-high/check-pcg32_k16384.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k16384 -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k16384_fast.cpp b/test-high/check-pcg32_k16384_fast.cpp deleted file mode 100644 index 57943a4..0000000 --- a/test-high/check-pcg32_k16384_fast.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k16384_fast -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k2.cpp b/test-high/check-pcg32_k2.cpp deleted file mode 100644 index e6242d7..0000000 --- a/test-high/check-pcg32_k2.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k2 -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k2_fast.cpp b/test-high/check-pcg32_k2_fast.cpp deleted file mode 100644 index 1429f0b..0000000 --- a/test-high/check-pcg32_k2_fast.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k2_fast -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k64.cpp b/test-high/check-pcg32_k64.cpp deleted file mode 100644 index 114730e..0000000 --- a/test-high/check-pcg32_k64.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k64 -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k64_fast.cpp b/test-high/check-pcg32_k64_fast.cpp deleted file mode 100644 index c1f9a85..0000000 --- a/test-high/check-pcg32_k64_fast.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k64_fast -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_k64_oneseq.cpp b/test-high/check-pcg32_k64_oneseq.cpp deleted file mode 100644 index 6351f2c..0000000 --- a/test-high/check-pcg32_k64_oneseq.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_k64_oneseq -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_once_insecure.cpp b/test-high/check-pcg32_once_insecure.cpp deleted file mode 100644 index 78c0254..0000000 --- a/test-high/check-pcg32_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_once_insecure -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_oneseq.cpp b/test-high/check-pcg32_oneseq.cpp deleted file mode 100644 index 8881637..0000000 --- a/test-high/check-pcg32_oneseq.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_oneseq -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_oneseq_once_insecure.cpp b/test-high/check-pcg32_oneseq_once_insecure.cpp deleted file mode 100644 index a2bdf35..0000000 --- a/test-high/check-pcg32_oneseq_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_oneseq_once_insecure -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg32_unique.cpp b/test-high/check-pcg32_unique.cpp deleted file mode 100644 index 2ac2199..0000000 --- a/test-high/check-pcg32_unique.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg32_unique -#define TWO_ARG_INIT 0 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg64.cpp b/test-high/check-pcg64.cpp deleted file mode 100644 index a656ed6..0000000 --- a/test-high/check-pcg64.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg64 -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_c1024.cpp b/test-high/check-pcg64_c1024.cpp deleted file mode 100644 index 0d55daf..0000000 --- a/test-high/check-pcg64_c1024.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_c1024 -#define TWO_ARG_INIT 1 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg64_c1024_fast.cpp b/test-high/check-pcg64_c1024_fast.cpp deleted file mode 100644 index fa93477..0000000 --- a/test-high/check-pcg64_c1024_fast.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_c1024_fast -#define TWO_ARG_INIT 0 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg64_c32.cpp b/test-high/check-pcg64_c32.cpp deleted file mode 100644 index dc3a4e4..0000000 --- a/test-high/check-pcg64_c32.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_c32 -#define TWO_ARG_INIT 1 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg64_c32_fast.cpp b/test-high/check-pcg64_c32_fast.cpp deleted file mode 100644 index 823db1d..0000000 --- a/test-high/check-pcg64_c32_fast.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_c32_fast -#define TWO_ARG_INIT 0 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg64_c32_oneseq.cpp b/test-high/check-pcg64_c32_oneseq.cpp deleted file mode 100644 index ec33f6d..0000000 --- a/test-high/check-pcg64_c32_oneseq.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_c32_oneseq -#define TWO_ARG_INIT 0 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg64_fast.cpp b/test-high/check-pcg64_fast.cpp deleted file mode 100644 index 107c84d..0000000 --- a/test-high/check-pcg64_fast.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg64_fast -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_k1024.cpp b/test-high/check-pcg64_k1024.cpp deleted file mode 100644 index 8eae2bc..0000000 --- a/test-high/check-pcg64_k1024.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_k1024 -#define TWO_ARG_INIT 1 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_k1024_fast.cpp b/test-high/check-pcg64_k1024_fast.cpp deleted file mode 100644 index 99e261b..0000000 --- a/test-high/check-pcg64_k1024_fast.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_k1024_fast -#define TWO_ARG_INIT 0 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_k32.cpp b/test-high/check-pcg64_k32.cpp deleted file mode 100644 index b6ec24c..0000000 --- a/test-high/check-pcg64_k32.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_k32 -#define TWO_ARG_INIT 1 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_k32_fast.cpp b/test-high/check-pcg64_k32_fast.cpp deleted file mode 100644 index af58bc6..0000000 --- a/test-high/check-pcg64_k32_fast.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_k32_fast -#define TWO_ARG_INIT 0 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_k32_oneseq.cpp b/test-high/check-pcg64_k32_oneseq.cpp deleted file mode 100644 index 1b7cd05..0000000 --- a/test-high/check-pcg64_k32_oneseq.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#define RNG pcg64_k32_oneseq -#define TWO_ARG_INIT 0 -#define AWKWARD_128BIT_CODE 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_once_insecure.cpp b/test-high/check-pcg64_once_insecure.cpp deleted file mode 100644 index d5e472d..0000000 --- a/test-high/check-pcg64_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg64_once_insecure -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_oneseq.cpp b/test-high/check-pcg64_oneseq.cpp deleted file mode 100644 index b345127..0000000 --- a/test-high/check-pcg64_oneseq.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg64_oneseq -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_oneseq_once_insecure.cpp b/test-high/check-pcg64_oneseq_once_insecure.cpp deleted file mode 100644 index 060d39e..0000000 --- a/test-high/check-pcg64_oneseq_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg64_oneseq_once_insecure -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg64_unique.cpp b/test-high/check-pcg64_unique.cpp deleted file mode 100644 index 0269071..0000000 --- a/test-high/check-pcg64_unique.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg64_unique -#define TWO_ARG_INIT 0 - -#include "pcg-test-noadvance.cpp" - diff --git a/test-high/check-pcg8_once_insecure.cpp b/test-high/check-pcg8_once_insecure.cpp deleted file mode 100644 index 52e4fbf..0000000 --- a/test-high/check-pcg8_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg8_once_insecure -#define TWO_ARG_INIT 1 - -#include "pcg-test.cpp" - diff --git a/test-high/check-pcg8_oneseq_once_insecure.cpp b/test-high/check-pcg8_oneseq_once_insecure.cpp deleted file mode 100644 index 564bc3e..0000000 --- a/test-high/check-pcg8_oneseq_once_insecure.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#define RNG pcg8_oneseq_once_insecure -#define TWO_ARG_INIT 0 - -#include "pcg-test.cpp" - diff --git a/test-high/expected/.gitignore b/test-high/expected/.gitignore deleted file mode 100644 index 7802c9f..0000000 --- a/test-high/expected/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# These .out files shouldn't be ignored -!*.out diff --git a/test-high/run-test.cmake b/test-high/run-test.cmake new file mode 100644 index 0000000..bf91bf4 --- /dev/null +++ b/test-high/run-test.cmake @@ -0,0 +1,31 @@ +if (NOT RNG) + message(SEND_ERROR "No RNG defined") +endif() + +if (NOT EXECUTABLE) + message(SEND_ERROR "No EXECUTABLE defined") +endif() + +if (NOT EXPECTED) + message(SEND_ERROR "No EXPECTED defined") +endif() + +execute_process( + COMMAND ${EXECUTABLE} + OUTPUT_FILE ${EXECUTABLE}.out + RESULT_VARIABLE TEST_NOT_SUCCESSFUL +) + +if (TEST_NOT_SUCCESSFUL) + message(SEND_ERROR "${RNG} returned a non-zero value.") +endif() + +execute_process( + COMMAND ${CMAKE_COMMAND} + -E compare_files ${EXECUTABLE}.out ${EXPECTED} + RESULT_VARIABLE TEST_NOT_SUCCESSFUL +) + +if (TEST_NOT_SUCCESSFUL) + message(SEND_ERROR "Actual and expected results are different for ${RNG}.") +endif() diff --git a/test-high/run-tests.sh b/test-high/run-tests.sh deleted file mode 100755 index c72ab76..0000000 --- a/test-high/run-tests.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -# -# PCG Random Number Generation for C. -# -# Copyright 2014-2017 Melissa O'Neill , -# and the PCG Project contributors. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) -# -# Licensed under the Apache License, Version 2.0 (provided in -# LICENSE-APACHE.txt and at http://www.apache.org/licenses/LICENSE-2.0) -# or under the MIT license (provided in LICENSE-MIT.txt and at -# http://opensource.org/licenses/MIT), at your option. This file may not -# be copied, modified, or distributed except according to those terms. -# -# Distributed on an "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, either -# express or implied. See your chosen license for details. -# -# For additional information about the PCG random number generation scheme, -# visit http://www.pcg-random.org/. -# - -echo Performing a quick sanity check... - -mkdir -p actual -rm -f actual/* - -./check-pcg32 > actual/check-pcg32.out -./check-pcg32_oneseq > actual/check-pcg32_oneseq.out -./check-pcg32 > /dev/null -./check-pcg32_fast > actual/check-pcg32_fast.out - -./check-pcg64 > actual/check-pcg64.out -./check-pcg64_oneseq > actual/check-pcg64_oneseq.out -./check-pcg64_unique > /dev/null -./check-pcg64_fast > actual/check-pcg64_fast.out - -./check-pcg8_once_insecure > actual/check-pcg8_once_insecure.out -./check-pcg16_once_insecure > actual/check-pcg16_once_insecure.out -./check-pcg32_once_insecure > actual/check-pcg32_once_insecure.out -./check-pcg64_once_insecure > actual/check-pcg64_once_insecure.out -./check-pcg128_once_insecure > actual/check-pcg128_once_insecure.out - -./check-pcg8_oneseq_once_insecure > actual/check-pcg8_oneseq_once_insecure.out -./check-pcg16_oneseq_once_insecure > actual/check-pcg16_oneseq_once_insecure.out -./check-pcg32_oneseq_once_insecure > actual/check-pcg32_oneseq_once_insecure.out -./check-pcg64_oneseq_once_insecure > actual/check-pcg64_oneseq_once_insecure.out -./check-pcg128_oneseq_once_insecure > actual/check-pcg128_oneseq_once_insecure.out - -./check-pcg32_k2 > actual/check-pcg32_k2.out -./check-pcg32_k2_fast > actual/check-pcg32_k2_fast.out - -./check-pcg32_k64 > actual/check-pcg32_k64.out -./check-pcg32_k64_oneseq > actual/check-pcg32_k64_oneseq.out -./check-pcg32_k64_fast > actual/check-pcg32_k64_fast.out - -./check-pcg32_c64 > actual/check-pcg32_c64.out -./check-pcg32_c64_oneseq > actual/check-pcg32_c64_oneseq.out -./check-pcg32_c64_fast > actual/check-pcg32_c64_fast.out - -./check-pcg64_k32 > actual/check-pcg64_k32.out -./check-pcg64_k32_oneseq > actual/check-pcg64_k32_oneseq.out -./check-pcg64_k32_fast > actual/check-pcg64_k32_fast.out - -./check-pcg64_c32 > actual/check-pcg64_c32.out -./check-pcg64_c32_oneseq > actual/check-pcg64_c32_oneseq.out -./check-pcg64_c32_fast > actual/check-pcg64_c32_fast.out - -./check-pcg32_k1024 > actual/check-pcg32_k1024.out -./check-pcg32_k1024_fast > actual/check-pcg32_k1024_fast.out - -./check-pcg32_c1024 > actual/check-pcg32_c1024.out -./check-pcg32_c1024_fast > actual/check-pcg32_c1024_fast.out - -./check-pcg64_k1024 > actual/check-pcg64_k1024.out -./check-pcg64_k1024_fast > actual/check-pcg64_k1024_fast.out - -./check-pcg64_c1024 > actual/check-pcg64_c1024.out -./check-pcg64_c1024_fast > actual/check-pcg64_c1024_fast.out - -./check-pcg32_k16384 > actual/check-pcg32_k16384.out -./check-pcg32_k16384_fast > actual/check-pcg32_k16384_fast.out - -find actual -type f -size -80c -delete - -if diff -ru -x .gitignore expected actual -then - echo All tests succeeded. -else - echo '' - if diff -x "*-pcg64_[ck]*.out" \ - -x "*-pcg128_[ck]*.out" -ru expected actual > /dev/null - then - echo All tests except tests awkward tests with 128-bit math succceed. - else - echo ERROR: Some tests failed. - fi -fi From 14620234a75a21ab987bb6dcf962df6995c2717e Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Mon, 27 May 2019 15:43:54 +0200 Subject: [PATCH 02/11] Separate source from samples and tests --- CMakeLists.txt | 48 +++--------------------- sample/CMakeLists.txt | 34 ++++++++++++++--- src/CMakeLists.txt | 45 ++++++++++++++++++++++ {include => src/include}/pcg_extras.hpp | 0 {include => src/include}/pcg_random.hpp | 0 {include => src/include}/pcg_uint128.hpp | 0 src/pcg-config.cmake.in | 3 ++ test-high/CMakeLists.txt | 34 ++++++++++++----- 8 files changed, 107 insertions(+), 57 deletions(-) create mode 100644 src/CMakeLists.txt rename {include => src/include}/pcg_extras.hpp (100%) rename {include => src/include}/pcg_random.hpp (100%) rename {include => src/include}/pcg_uint128.hpp (100%) create mode 100644 src/pcg-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d1be34..fb8f5db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,45 +1,9 @@ -cmake_minimum_required(VERSION 3.1.3) +cmake_minimum_required(VERSION 3.8.0) -project( - PCG - VERSION 0.98.1 - LANGUAGES CXX -) +project(pcg-super) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +add_subdirectory(src) +add_subdirectory(sample) -add_library(headers INTERFACE) -target_include_directories( - headers INTERFACE - $ - $ -) -install( - TARGETS headers - EXPORT pcg -) -install( - EXPORT pcg - DESTINATION share/cmake/pcg - NAMESPACE pcg:: - FILE pcg-config.cmake -) -install( - DIRECTORY include/ - DESTINATION include - FILES_MATCHING PATTERN "*.hpp" -) - -set(BUILD_SAMPLES ON CACHE BOOL "Build sample programs.") - -if (BUILD_SAMPLES) - add_subdirectory(sample) -endif() - -set(TEST_PCG ON CACHE BOOL "Run the unit tests.") - -if (TEST_PCG) - enable_testing() - add_subdirectory(test-high) -endif() +enable_testing() +add_subdirectory(test-high) diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index a81d4f7..b28d796 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -1,17 +1,39 @@ +cmake_minimum_required(VERSION 3.8.0) + +project(pcg-samples) + +if (NOT TARGET pcg::pcg) + find_package(pcg CONFIG REQUIRED) +endif() + + add_executable(codebook codebook.cpp) -target_link_libraries(codebook PRIVATE headers) +target_link_libraries(codebook PRIVATE pcg::pcg) add_executable(cppref-sample cppref-sample.cpp) -target_link_libraries(cppref-sample PRIVATE headers) +target_link_libraries(cppref-sample PRIVATE pcg::pcg) add_executable(make-partytrick make-partytrick.cpp) -target_link_libraries(make-partytrick PRIVATE headers) +target_link_libraries(make-partytrick PRIVATE pcg::pcg) add_executable(pcg-demo pcg-demo.cpp) -target_link_libraries(pcg-demo PRIVATE headers) +target_link_libraries(pcg-demo PRIVATE pcg::pcg) add_executable(spew spew.cpp) -target_link_libraries(spew PRIVATE headers) +target_link_libraries(spew PRIVATE pcg::pcg) add_executable(use-partytrick use-partytrick.cpp) -target_link_libraries(use-partytrick PRIVATE headers) +target_link_libraries(use-partytrick PRIVATE pcg::pcg) + +install( + TARGETS + codebook + cppref-sample + make-partytrick + pcg-demo + spew + use-partytrick + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..11bcbe0 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.8.0) + +project(pcg VERSION 0.98.1 LANGUAGES CXX) + +add_library(pcg INTERFACE) +add_library(pcg::pcg ALIAS pcg) + +target_compile_features(pcg INTERFACE cxx_std_11) + +target_include_directories(pcg + INTERFACE + $ + $ +) + +install(TARGETS pcg EXPORT pcg) + +install(EXPORT pcg + FILE pcg-targets.cmake + NAMESPACE pcg:: + DESTINATION lib/cmake/pcg +) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file("pcg-config-version.cmake" + VERSION ${pcg_VERSION} + COMPATIBILITY SameMajorVersion +) + +configure_file(pcg-config.cmake.in pcg-config.cmake @ONLY) + +install( + FILES + "${pcg_BINARY_DIR}/pcg-config.cmake" + "${pcg_BINARY_DIR}/pcg-config-version.cmake" + DESTINATION + lib/cmake/pcg +) + +install( + DIRECTORY + include/ + DESTINATION + include +) diff --git a/include/pcg_extras.hpp b/src/include/pcg_extras.hpp similarity index 100% rename from include/pcg_extras.hpp rename to src/include/pcg_extras.hpp diff --git a/include/pcg_random.hpp b/src/include/pcg_random.hpp similarity index 100% rename from include/pcg_random.hpp rename to src/include/pcg_random.hpp diff --git a/include/pcg_uint128.hpp b/src/include/pcg_uint128.hpp similarity index 100% rename from include/pcg_uint128.hpp rename to src/include/pcg_uint128.hpp diff --git a/src/pcg-config.cmake.in b/src/pcg-config.cmake.in new file mode 100644 index 0000000..dd535b1 --- /dev/null +++ b/src/pcg-config.cmake.in @@ -0,0 +1,3 @@ +# include(CMakeFindDependencyMacro) +# find_dependency(XXX) +include("${CMAKE_CURRENT_LIST_DIR}/pcg-targets.cmake") diff --git a/test-high/CMakeLists.txt b/test-high/CMakeLists.txt index eb4f851..dde21b0 100644 --- a/test-high/CMakeLists.txt +++ b/test-high/CMakeLists.txt @@ -1,17 +1,30 @@ +cmake_minimum_required(VERSION 3.8.0) + +project(pcg-tests) + +if (NOT TARGET pcg::pcg) + find_package(pcg CONFIG REQUIRED) +endif() + +enable_testing() + function(define_test source rng two_arg_init) add_executable(${rng} ${source}) if(${ARGC} EQUAL 3) - target_compile_definitions( - ${rng} - PRIVATE RNG=${rng} TWO_ARG_INIT=${two_arg_init} + target_compile_definitions(${rng} + PRIVATE + RNG=${rng} + TWO_ARG_INIT=${two_arg_init} ) elseif(${ARGC} EQUAL 4) - target_compile_definitions( - ${rng} - PRIVATE RNG=${rng} TWO_ARG_INIT=${two_arg_init} AWKWARD_128BIT_CODE=${ARGV3} + target_compile_definitions(${rng} + PRIVATE + RNG=${rng} + TWO_ARG_INIT=${two_arg_init} + AWKWARD_128BIT_CODE=${ARGV3} ) endif() - target_link_libraries(${rng} PRIVATE headers) + target_link_libraries(${rng} PRIVATE pcg::pcg) add_test( NAME check-${rng} @@ -79,6 +92,9 @@ endforeach() # pcg32_unique and pcg64_unique are failing in the old run-tests.sh (/dev/null'ed) set_property( - TEST check-pcg32_unique check-pcg64_unique - PROPERTY WILL_FAIL TRUE + TEST + check-pcg32_unique + check-pcg64_unique + PROPERTY + WILL_FAIL TRUE ) From 914109f3dfa6a6947d0a70af88a8c690197281d3 Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Mon, 27 May 2019 16:31:38 +0200 Subject: [PATCH 03/11] Fix README accordingly --- README.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d08b60c..ae684fd 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,14 @@ Visit [PCG-Random website] for information on how to use this library, or look at the sample code in the `sample` directory -- hopefully it should be fairly self explanatory. -## Building +## Building, Testing and Installing The code is written in C++11, as an include-only library (i.e., there is nothing you need to build). -There are some provided demo programs and tests however. We also provide a -[cmake](https://cmake.org/)-based building and testing functionality. If you -do not have `cmake` installed on your system, you can +There are some provided demo programs and tests however. We provide a +[CMake](https://cmake.org/)-based building and testing functionality. If you +do not have CMake installed on your system, you can [download](https://cmake.org/download/) the latest version. Once installed, you can run @@ -44,18 +44,17 @@ cmake --build . --target test cmake --build . --target install ``` -Above, `cmake` creates necessary files inside the `build` folder, builds the -demo programs (`BUILD_SAMPLES=ON`), creates tests (`TEST_PCG=ON`), and finally -installs the header files to the `include` folder in the default system path. - -You can append `-DVARIABLE=VALUE` to `cmake` to change the default behaviour. -For instance, if you are only interested in installing the header files to the -`install` folder inside the current path, simply run +Above, CMake creates necessary files inside the `build` folder, builds the demo +programs, performs the tests, and finally installs the header files and demo +programs to the `include` and `bin` folders, respectively, in the default system +path. You can append `-D CMAKE_INSTALL_PREFIX=` to change the +default (system) path. For instance, if you would like to install the files in +the `install` folder under the current path, simply run ```bash mkdir build install cd build -cmake -DBUILD_SAMPLES=OFF -DTEST_PCG=OFF -DCMAKE_INSTALL_PREFIX=../install ../ +cmake -D CMAKE_INSTALL_PREFIX=../install ../ cmake --build . cmake --build . --target install ``` @@ -64,7 +63,7 @@ cmake --build . --target install The directories are arranged as follows: -* `include` -- contains `pcg_random.hpp` and supporting include files +* `src/include` -- contains `pcg_random.hpp` and supporting include files * `test-high` -- test code for the high-level API where the functions have shorter, less scary-looking names. * `sample` -- sample code, some similar to the code in `test-high` but more From 229c9e7db8acde61f1b3afbabc9043b1943d5d12 Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Mon, 27 May 2019 17:01:30 +0200 Subject: [PATCH 04/11] Add Travis YAML --- .travis.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..621b173 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: cpp + +matrix: + include: + - name: "Linux (gcc)" + os: linux + compiler: gcc + + - name: "Linux (clang)" + os: linux + compiler: clang + + - name: "OSX" + os: osx + + - name: "Windows" + os: windows + +before_script: + - mkdir build + - cd build + +script: + - cmake .. + - cmake --build . + - cmake --build . --target test + +notifications: + email: false From 734528783f14f8470af39d793584188a95849681 Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Mon, 27 May 2019 17:41:04 +0200 Subject: [PATCH 05/11] Make POSIX writing cross-platform compatible --- .travis.yml | 11 ++++++++--- sample/spew.cpp | 16 +++++++++------- sample/use-partytrick.cpp | 14 ++++++++------ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 621b173..b03a006 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,25 +5,30 @@ matrix: - name: "Linux (gcc)" os: linux compiler: gcc + script: + - cmake --build . --target test - name: "Linux (clang)" os: linux compiler: clang + script: + - cmake --build . --target test - name: "OSX" os: osx + script: + - cmake --build . --target test - name: "Windows" os: windows + script: + - cmake --build . --target RUN_TESTS before_script: - mkdir build - cd build - -script: - cmake .. - cmake --build . - - cmake --build . --target test notifications: email: false diff --git a/sample/spew.cpp b/sample/spew.cpp index ccb736d..5e971eb 100644 --- a/sample/spew.cpp +++ b/sample/spew.cpp @@ -22,7 +22,7 @@ /* * This program outputs 215 GB of random bits (binary data). This is * about the same as the total output of random.org in its 15 year history. - * The code uses 1.25e-8 of the period, and chooses an arbitrary stream from + * The code uses 1.25e-8 of the period, and chooses an arbitrary stream from * 2^64 streams. * * Typical usage: @@ -35,7 +35,12 @@ #include #include -#include // We use POSIX read/write for binary I/O +// We use POSIX read/write for binary I/O +#if defined(__unix__) || defined (__CYGWIN__) || defined (__APPLE__) + #include +#else + #include +#endif #include "pcg_random.hpp" @@ -43,11 +48,11 @@ int main() { pcg32_fast rng(pcg_extras::seed_seq_from{}); std::clog << rng << "\n\n"; - + constexpr size_t BUFFER_SIZE = 1024ull * 128ull; uint32_t buffer[BUFFER_SIZE]; constexpr size_t ROUNDS = 215 * 1073741824ull / sizeof(buffer); - + for (size_t i = 0; i < ROUNDS; ++i) { for (auto& v : buffer) v = rng(); @@ -55,6 +60,3 @@ int main() } return 0; } - - - \ No newline at end of file diff --git a/sample/use-partytrick.cpp b/sample/use-partytrick.cpp index 6c7455d..2b35444 100644 --- a/sample/use-partytrick.cpp +++ b/sample/use-partytrick.cpp @@ -36,11 +36,16 @@ #include #include -#include +// We use POSIX read/write for binary I/O +#if defined(__unix__) || defined (__CYGWIN__) || defined (__APPLE__) + #include +#else + #include +#endif #include "pcg_random.hpp" -static const char* saved_state = +static const char* saved_state = "6364136223846793005 3503324247726078831 6557656048857751321 103238831 " "665891259 1902651333 4073047566 368781010 3371458373 3520911659 1176018374 " "1290944887 2479283234 2214499777 3287447736 4241043352 2808175048 83300271 " @@ -65,7 +70,7 @@ int main() constexpr size_t BUFFER_SIZE = 1024ull * 128ull; uint32_t buffer[BUFFER_SIZE]; constexpr size_t ROUNDS = 215 * 1073741824ull / sizeof(buffer); - + for (size_t i = 0; i < ROUNDS; ++i) { for (auto& v : buffer) v = rng(); @@ -74,6 +79,3 @@ int main() return 0; } - - - \ No newline at end of file From 7fdd692a4cbd21da7ac0127ab14c2cb96e82325a Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Mon, 27 May 2019 17:59:39 +0200 Subject: [PATCH 06/11] Allow Windows to fail --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index b03a006..a0f24d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,10 @@ matrix: script: - cmake --build . --target RUN_TESTS + allow_failures: + - os: windows + fast_finish: true + before_script: - mkdir build - cd build From 45af5474f5898083b5739b1a67f9b8deca261533 Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Mon, 27 May 2019 18:15:08 +0200 Subject: [PATCH 07/11] Add build and license badges --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ae684fd..de18a1d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # PCG Random Number Generation, C++ Edition +[![Build Status][unix-img]][unix-link] ![License][license-img] + +[unix-img]: https://img.shields.io/travis/com/imneme/pcg-cpp/master.svg +[unix-link]: https://travis-ci.com/imneme/pcg-cpp +[license-img]: https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg + [PCG-Random website]: http://www.pcg-random.org This code provides an implementation of the PCG family of random number From 69863522673c2561339fe65d4478fd680b833f3b Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Tue, 28 May 2019 10:40:41 +0200 Subject: [PATCH 08/11] Restructure back to `include` --- CMakeLists.txt | 2 +- README.md | 2 +- {src => include}/CMakeLists.txt | 3 ++- {src => include}/pcg-config.cmake.in | 0 {src/include => include}/pcg_extras.hpp | 0 {src/include => include}/pcg_random.hpp | 0 {src/include => include}/pcg_uint128.hpp | 0 7 files changed, 4 insertions(+), 3 deletions(-) rename {src => include}/CMakeLists.txt (91%) rename {src => include}/pcg-config.cmake.in (100%) rename {src/include => include}/pcg_extras.hpp (100%) rename {src/include => include}/pcg_random.hpp (100%) rename {src/include => include}/pcg_uint128.hpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb8f5db..350c073 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.8.0) project(pcg-super) -add_subdirectory(src) +add_subdirectory(include) add_subdirectory(sample) enable_testing() diff --git a/README.md b/README.md index de18a1d..dec82d0 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ cmake --build . --target install The directories are arranged as follows: -* `src/include` -- contains `pcg_random.hpp` and supporting include files +* `include` -- contains `pcg_random.hpp` and supporting include files * `test-high` -- test code for the high-level API where the functions have shorter, less scary-looking names. * `sample` -- sample code, some similar to the code in `test-high` but more diff --git a/src/CMakeLists.txt b/include/CMakeLists.txt similarity index 91% rename from src/CMakeLists.txt rename to include/CMakeLists.txt index 11bcbe0..38bd424 100644 --- a/src/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -9,7 +9,7 @@ target_compile_features(pcg INTERFACE cxx_std_11) target_include_directories(pcg INTERFACE - $ + $ $ ) @@ -42,4 +42,5 @@ install( include/ DESTINATION include + FILES_MATCHING PATTERN "*.hpp" ) diff --git a/src/pcg-config.cmake.in b/include/pcg-config.cmake.in similarity index 100% rename from src/pcg-config.cmake.in rename to include/pcg-config.cmake.in diff --git a/src/include/pcg_extras.hpp b/include/pcg_extras.hpp similarity index 100% rename from src/include/pcg_extras.hpp rename to include/pcg_extras.hpp diff --git a/src/include/pcg_random.hpp b/include/pcg_random.hpp similarity index 100% rename from src/include/pcg_random.hpp rename to include/pcg_random.hpp diff --git a/src/include/pcg_uint128.hpp b/include/pcg_uint128.hpp similarity index 100% rename from src/include/pcg_uint128.hpp rename to include/pcg_uint128.hpp From ae73d7eff47987fcf46d1beb1e4265152b5bce7e Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Tue, 28 May 2019 23:30:21 +0200 Subject: [PATCH 09/11] Bug fix in `include` --- include/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 38bd424..4b4bd96 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -39,7 +39,7 @@ install( install( DIRECTORY - include/ + ${pcg_SOURCE_DIR}/ DESTINATION include FILES_MATCHING PATTERN "*.hpp" From 60a2598cd73756a55bdf5a7b3a4282e501523e73 Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Wed, 29 May 2019 10:59:38 +0200 Subject: [PATCH 10/11] Rename binaries to add `pcg` domain --- sample/CMakeLists.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index b28d796..73931d9 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -7,32 +7,32 @@ if (NOT TARGET pcg::pcg) endif() -add_executable(codebook codebook.cpp) -target_link_libraries(codebook PRIVATE pcg::pcg) +add_executable(pcg-codebook codebook.cpp) +target_link_libraries(pcg-codebook PRIVATE pcg::pcg) -add_executable(cppref-sample cppref-sample.cpp) -target_link_libraries(cppref-sample PRIVATE pcg::pcg) +add_executable(pcg-cppref-sample cppref-sample.cpp) +target_link_libraries(pcg-cppref-sample PRIVATE pcg::pcg) -add_executable(make-partytrick make-partytrick.cpp) -target_link_libraries(make-partytrick PRIVATE pcg::pcg) +add_executable(pcg-make-partytrick make-partytrick.cpp) +target_link_libraries(pcg-make-partytrick PRIVATE pcg::pcg) add_executable(pcg-demo pcg-demo.cpp) target_link_libraries(pcg-demo PRIVATE pcg::pcg) -add_executable(spew spew.cpp) -target_link_libraries(spew PRIVATE pcg::pcg) +add_executable(pcg-spew spew.cpp) +target_link_libraries(pcg-spew PRIVATE pcg::pcg) -add_executable(use-partytrick use-partytrick.cpp) -target_link_libraries(use-partytrick PRIVATE pcg::pcg) +add_executable(pcg-use-partytrick use-partytrick.cpp) +target_link_libraries(pcg-use-partytrick PRIVATE pcg::pcg) install( TARGETS - codebook - cppref-sample - make-partytrick + pcg-codebook + pcg-cppref-sample + pcg-make-partytrick pcg-demo - spew - use-partytrick + pcg-spew + pcg-use-partytrick ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin From 3d13f9232c0422f7a73bb5160dbe34f48e3b2f01 Mon Sep 17 00:00:00 2001 From: Arda Aytekin Date: Fri, 31 May 2019 15:23:56 +0200 Subject: [PATCH 11/11] Improve CMake and CI --- .gitignore | 2 +- .travis.yml | 34 +++++++++++++++++++++++++--------- cmake/cpack-linux.cmake | 10 ++++++++++ cmake/ctest-clang.cmake | 16 ++++++++++++++++ cmake/ctest-gcc.cmake | 22 ++++++++++++++++++++++ cmake/ctest-osx.cmake | 13 +++++++++++++ include/CMakeLists.txt | 34 ++++++++++++++++++++-------------- include/pcg-config.cmake.in | 1 + sample/CMakeLists.txt | 11 +++++++---- 9 files changed, 115 insertions(+), 28 deletions(-) create mode 100644 cmake/cpack-linux.cmake create mode 100644 cmake/ctest-clang.cmake create mode 100644 cmake/ctest-gcc.cmake create mode 100644 cmake/ctest-osx.cmake diff --git a/.gitignore b/.gitignore index b08260e..40c2331 100644 --- a/.gitignore +++ b/.gitignore @@ -44,7 +44,7 @@ cmake_install.cmake install_manifest.txt compile_commands.json CTestTestfile.cmake -build +build* # End of https://www.gitignore.io/api/cmake diff --git a/.travis.yml b/.travis.yml index a0f24d3..90d1b2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,22 +5,44 @@ matrix: - name: "Linux (gcc)" os: linux compiler: gcc + addons: + apt: + packages: valgrind script: - - cmake --build . --target test + - ctest --verbose --output-on-failure --script cmake/ctest-gcc.cmake + before_deploy: + - mkdir build + - cd build + - cmake -D CMAKE_BUILD_TYPE=Release .. + - cd .. + - cpack -G ZIP --config cmake/cpack-linux.cmake + deploy: + provider: releases + api_key: ${GITHUB_TOKEN} + file_glob: true + file: "*.zip" + skip_cleanup: true + on: + tags: true - name: "Linux (clang)" os: linux compiler: clang script: - - cmake --build . --target test + - ctest --verbose --output-on-failure --script cmake/ctest-clang.cmake - name: "OSX" os: osx script: - - cmake --build . --target test + - ctest --verbose --output-on-failure --script cmake/ctest-osx.cmake - name: "Windows" os: windows + before_script: + - mkdir build + - cd build + - cmake .. + - cmake --build . script: - cmake --build . --target RUN_TESTS @@ -28,11 +50,5 @@ matrix: - os: windows fast_finish: true -before_script: - - mkdir build - - cd build - - cmake .. - - cmake --build . - notifications: email: false diff --git a/cmake/cpack-linux.cmake b/cmake/cpack-linux.cmake new file mode 100644 index 0000000..8622da8 --- /dev/null +++ b/cmake/cpack-linux.cmake @@ -0,0 +1,10 @@ +include("build/CPackConfig.cmake") + +set(CPACK_INSTALL_CMAKE_PROJECTS + "build;pcg-super;ALL;/" +) + +set(CPACK_PACKAGE_FILE_NAME pcg-linux) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY + "PCG Random Number Generation, C++ Edition" +) diff --git a/cmake/ctest-clang.cmake b/cmake/ctest-clang.cmake new file mode 100644 index 0000000..ddbebf4 --- /dev/null +++ b/cmake/ctest-clang.cmake @@ -0,0 +1,16 @@ +set(ENV{CC} "clang") +set(ENV{CXX} "clang++") + +set(CTEST_PROJECT_NAME "pcg") +set(CTEST_SOURCE_DIRECTORY ".") +set(CTEST_BINARY_DIRECTORY "build-test-clang") +set(CTEST_CMAKE_GENERATOR "Unix Makefiles") + +ctest_start("Continuous") +ctest_configure() +ctest_build() +ctest_test(RETURN_VALUE SUCCESS) + +if(NOT ${SUCCESS} EQUAL 0) + message(SEND_ERROR "Testing failed.") +endif() diff --git a/cmake/ctest-gcc.cmake b/cmake/ctest-gcc.cmake new file mode 100644 index 0000000..962e19e --- /dev/null +++ b/cmake/ctest-gcc.cmake @@ -0,0 +1,22 @@ +set(ENV{CC} "gcc") +set(ENV{CXX} "g++") +set(ENV{CXXFLAGS} "--coverage") + +set(CTEST_PROJECT_NAME "pcg") +set(CTEST_SOURCE_DIRECTORY ".") +set(CTEST_BINARY_DIRECTORY "build-test-gcc") +set(CTEST_CMAKE_GENERATOR "Unix Makefiles") + +set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") +set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") + +ctest_start("Continuous") +ctest_configure() +ctest_build() +ctest_test(RETURN_VALUE SUCCESS) +ctest_coverage() +ctest_memcheck() + +if(NOT ${SUCCESS} EQUAL 0) + message(SEND_ERROR "Testing failed.") +endif() diff --git a/cmake/ctest-osx.cmake b/cmake/ctest-osx.cmake new file mode 100644 index 0000000..ca43546 --- /dev/null +++ b/cmake/ctest-osx.cmake @@ -0,0 +1,13 @@ +set(CTEST_PROJECT_NAME "pcg") +set(CTEST_SOURCE_DIRECTORY ".") +set(CTEST_BINARY_DIRECTORY "build-test-osx") +set(CTEST_CMAKE_GENERATOR "Unix Makefiles") + +ctest_start("Continuous") +ctest_configure() +ctest_build() +ctest_test(RETURN_VALUE SUCCESS) + +if(NOT ${SUCCESS} EQUAL 0) + message(SEND_ERROR "Testing failed.") +endif() diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 4b4bd96..807daf0 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.8.0) project(pcg VERSION 0.98.1 LANGUAGES CXX) +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + add_library(pcg INTERFACE) add_library(pcg::pcg ALIAS pcg) @@ -9,8 +12,8 @@ target_compile_features(pcg INTERFACE cxx_std_11) target_include_directories(pcg INTERFACE - $ - $ + $ + $ ) install(TARGETS pcg EXPORT pcg) @@ -18,29 +21,32 @@ install(TARGETS pcg EXPORT pcg) install(EXPORT pcg FILE pcg-targets.cmake NAMESPACE pcg:: - DESTINATION lib/cmake/pcg + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcg ) -include(CMakePackageConfigHelpers) -write_basic_package_version_file("pcg-config-version.cmake" - VERSION ${pcg_VERSION} - COMPATIBILITY SameMajorVersion +configure_package_config_file(pcg-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/pcg-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcg ) -configure_file(pcg-config.cmake.in pcg-config.cmake @ONLY) +write_basic_package_version_file(pcg-config-version.cmake + COMPATIBILITY SameMajorVersion +) install( FILES - "${pcg_BINARY_DIR}/pcg-config.cmake" - "${pcg_BINARY_DIR}/pcg-config-version.cmake" + ${CMAKE_CURRENT_BINARY_DIR}/pcg-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/pcg-config-version.cmake DESTINATION - lib/cmake/pcg + ${CMAKE_INSTALL_LIBDIR}/cmake/pcg ) install( DIRECTORY - ${pcg_SOURCE_DIR}/ + ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION - include - FILES_MATCHING PATTERN "*.hpp" + ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN *.hpp ) + +include(CPack) diff --git a/include/pcg-config.cmake.in b/include/pcg-config.cmake.in index dd535b1..281dcf3 100644 --- a/include/pcg-config.cmake.in +++ b/include/pcg-config.cmake.in @@ -1,3 +1,4 @@ +@PACKAGE_INIT@ # include(CMakeFindDependencyMacro) # find_dependency(XXX) include("${CMAKE_CURRENT_LIST_DIR}/pcg-targets.cmake") diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index 73931d9..bf4d939 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -2,11 +2,12 @@ cmake_minimum_required(VERSION 3.8.0) project(pcg-samples) +include(GNUInstallDirs) + if (NOT TARGET pcg::pcg) find_package(pcg CONFIG REQUIRED) endif() - add_executable(pcg-codebook codebook.cpp) target_link_libraries(pcg-codebook PRIVATE pcg::pcg) @@ -33,7 +34,9 @@ install( pcg-demo pcg-spew pcg-use-partytrick - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) + +include(CPack)