-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathCMakeLists.txt
105 lines (88 loc) · 2.93 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
cmake_minimum_required(VERSION 3.12)
cmake_policy(VERSION 3.12)
if(POLICY CMP0078)
cmake_policy(SET CMP0078 NEW) # UseSWIG: do not use legacy target names
endif(POLICY CMP0078)
if(POLICY CMP0086)
cmake_policy(SET CMP0086 NEW) # UseSWIG: pass -module option
endif(POLICY CMP0086)
# Add etc/cmake to CMake's search path so we can put our private stuff there
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/etc/cmake)
# Set a default build type if none was specified
# This must precede the project() line, which would set the CMAKE_BUILD_TYPE
# to 'Debug' with single-config generators on Windows.
# Note that we must do this only if PROJECT_NAME is not set at this point. If
# it is set, it means that plfit is being used as a subproject of another
# project.
if(NOT PROJECT_NAME)
include(BuildType)
endif()
project(
plfit
VERSION 1.0.1
DESCRIPTION "Library to fit power-law distributions to empirical data"
HOMEPAGE_URL "https://github.com/ntamas/plfit"
LANGUAGES C
)
enable_testing()
# Set C standard version
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED True)
# Expose the BUILD_SHARED_LIBS option in the ccmake UI
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
# Add switches to use LTO and sanitizers if needed
include(lto)
include(sanitizers)
include(JoinPaths)
option(PLFIT_COMPILE_PYTHON_MODULE
"Whether we want to compile the Python module (requires SWIG)"
OFF)
option(PLFIT_USE_SSE
"Use SSE/SSE2 optimizations if available"
ON)
option(PLFIT_USE_OPENMP
"Use OpenMP parallelization if available (experimental)"
OFF)
# Check for required headers
include(CheckIncludeFiles)
check_include_files(emmintrin.h HAVE_EMMINTRIN_H)
check_include_files(malloc.h HAVE_MALLOC_H)
if(MSVC)
# /Wall is too much for MSVC; use /W4 instead.
# Don't produce C4100 warnings (unused formal parameter)
add_definitions(-W4 -wd4100 -DHAVE_CONFIG_H -D_CRT_SECURE_NO_DEPRECATE)
else()
# On Linux and Mac we are okay with -Wall
add_definitions(-Wall -DHAVE_CONFIG_H)
endif()
if(PLFIT_USE_SSE)
message(STATUS "Using SSE/SSE2 optimizations if available")
add_definitions(-DUSE_SSE)
else()
message(STATUS "SSE/SSE2 optimizations disabled")
endif()
if(PLFIT_USE_OPENMP)
find_package(OpenMP)
if(OPENMP_FOUND)
message(STATUS "Using OpenMP parallelization (experimental)")
else()
message(STATUS "OpenMP not supported by compiler; disabling OpenMP parallelization")
endif()
else()
message(STATUS "OpenMP parallelization disabled")
endif()
if(WIN32)
# No need to link to the m library on Windows
set(MATH_LIBRARY "")
else()
FIND_LIBRARY(MATH_LIBRARY NAMES m)
endif()
# Set default symbol visibility to hidden
set(CMAKE_C_VISIBILITY_PRESET hidden)
# Add version information
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/plfit_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/plfit_version.h
)
add_subdirectory(src)
add_subdirectory(test)