Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
113 lines (80 sloc) 2.36 KB

primesieve build instructions

Prerequisites

You need to have installed a C++ compiler which supports C++11 (or later) and CMake β‰₯ 3.4.

# macOS
xcode-select --install
brew install cmake

# Debian, Ubuntu
sudo apt install g++ cmake

# Fedora, Red Hat
sudo dnf install gcc-c++ cmake

# Arch Linux
sudo pacman -S gcc cmake

Unix-like OSes

Open a terminal, cd into the primesieve directory and run:

cmake .
make -j
sudo make install

Microsoft Visual C++

First install Visual Studio (includes CMake) on your Windows PC. Then go to the start menu, select Visual Studio and open a x64 Command Prompt. Now cd into the primesieve directory and run the commands below:

# Use 'cmake -G' to find your Visual Studio version
cmake -G "Visual Studio 15 2017 Win64" .
cmake --build . --config Release

# Optionally install using Admin shell
cmake --build . --config Release --target install

MinGW/MSYS2 (Windows)

Open a terminal, cd into the primesieve directory and run:

cmake -G "Unix Makefiles" .
make -j
sudo make install

MinGW cross compilation

Open a terminal, cd into the primesieve directory and run:

CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix \
cmake -DCMAKE_SYSTEM_NAME=Windows .

make -j

CMake configure options

By default the primesieve binary and the static/shared libprimesieve will be built. The build options can be modified at the configure step using e.g. cmake . -DBUILD_TESTS=ON.

option(BUILD_PRIMESIEVE  "Build primesieve binary"    ON)
option(BUILD_SHARED_LIBS "Build shared libprimesieve" ON)
option(BUILD_STATIC_LIBS "Build static libprimesieve" ON)
option(BUILD_DOC         "Build documentation"        OFF)
option(BUILD_EXAMPLES    "Build example programs"     OFF)
option(BUILD_TESTS       "Build test programs"        OFF)

Run the tests

Open a terminal, cd into the primesieve directory and run:

cmake -DBUILD_TESTS=ON .
make -j
ctest

C/C++ examples

Open a terminal, cd into the primesieve directory and run:

cmake -DBUILD_EXAMPLES=ON .
make -j

API documentation

To build the primesieve C/C++ API documentation in html/PDF format you need to have installed the doxygen, doxygen-latex and graphviz (dot) packages.

cmake -DBUILD_DOC=ON .
make doc
You can’t perform that action at this time.