-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
49 lines (37 loc) · 1.18 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# minimum cmake requirement
cmake_minimum_required(VERSION 3.18)
# project name
project(Primal)
# set the c++ standard
set(CMAKE_CXX_STANDARD 20)
# set policies and compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set output path
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
# set the debug and release compiler flags
set(CMAKE_CXX_FLAGS_DEBUG "-g -pg -Og -Wall -Wextra -Wl,-rpath,'$ORIGIN' --coverage")
set(CMAKE_CXX_FLAGS_RELEASE "-s -O3 -flto=auto -march=native -Wl,-rpath,'$ORIGIN'")
# set static flags
if(STATIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
endif()
# include directories
include_directories(include external/include)
# find custom packages
find_library(LIBGMPXX NAMES gmpxx PATHS external/lib NO_DEFAULT_PATH)
find_library(LIBGMP NAMES gmp PATHS external/lib NO_DEFAULT_PATH)
# find system packages
find_package(OpenMP REQUIRED)
# add fractoid executable
add_executable(primal
src/main.cpp
src/pi.cpp
src/sieve.cpp
src/timer.cpp
)
# link the libraries
target_link_libraries(primal ${LIBGMP} ${LIBGMPXX})
# link OpenMP
if(OpenMP_CXX_FOUND)
target_link_libraries(primal OpenMP::OpenMP_CXX)
endif()