forked from forcedotcom/distributions
-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
97 lines (82 loc) · 3.32 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
cmake_minimum_required(VERSION 2.6)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
project(distributions)
set(DISTRIBUTIONS_SHARED_LIBS m)
if(APPLE)
# for anaconda builds
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7")
# clang complains about register
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++0x")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-unused-parameter -Wno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -msse4.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -funsafe-math-optimizations")
if(DEFINED ENV{CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{CXX_FLAGS}")
endif()
message("CXX_FLAGS =${CMAKE_CXX_FLAGS}")
set(CMAKE_CONFIGURATION_TYPES Python Debug Release)
set(CMAKE_DEBUG_POSTFIX _debug)
set(CMAKE_RELEASE_POSTFIX _release)
set(CMAKE_CXX_FLAGS_PYTHON "${CMAKE_CXX_FLAGS} -g -fno-omit-frame-pointer -DDIST_DEBUG_LEVEL=3 -DDIST_THROW_ON_ERROR")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -DDIST_DEBUG_LEVEL=3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1")
if(DEFINED EXTRA_INCLUDE_PATH)
include_directories(${EXTRA_INCLUDE_PATH})
endif()
if(DEFINED EXTRA_LIBRARY_PATH)
link_directories(${EXTRA_LIBRARY_PATH})
endif()
find_package(Eigen3 REQUIRED)
get_filename_component(PARENT_DIR ${EIGEN3_INCLUDE_DIR} PATH)
include_directories(${PARENT_DIR})
find_package(Yeppp)
if(YEPPP_FOUND)
message(STATUS "Using YEPPP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_YEPPP")
include_directories(${YEPPP_INCLUDE_DIRS})
link_directories(${YEPPP_LIBRARY_DIRS})
#set(DISTRIBUTIONS_SHARED_LIBS ${DISTRIBUTIONS_SHARED_LIBS} ${YEPPP_LIBRARIES})
#set(DISTRIBUTIONS_STATIC_LIBS ${DISTRIBUTIONS_STATIC_LIBS} ${YEPPP_LIBRARIES})
endif()
find_package(LibM)
if(AMD_LIBM_FOUND)
message(STATUS "Using AMD LibM")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_AMD_LIBM")
include_directories(${AMD_LIBM_INCLUDE_DIRS})
link_directories(${AMD_LIBM_LIBRARY_DIRS})
set(DISTRIBUTIONS_SHARED_LIBS ${DISTRIBUTIONS_SHARED_LIBS} ${AMD_LIBM_LIBRARIES})
set(DISTRIBUTIONS_STATIC_LIBS ${DISTRIBUTIONS_STATIC_LIBS} ${AMD_LIBM_LIBRARIES})
endif()
find_package(MKL)
if(MKL_FOUND)
message(STATUS "Using Intel MKL")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_INTEL_MKL")
include_directories(${MKL_INCLUDE_DIRS})
link_directories(${MKL_LIBRARY_DIRS})
set(DISTRIBUTIONS_SHARED_LIBS ${DISTRIBUTIONS_SHARED_LIBS} ${MKL_LIBRARIES})
set(DISTRIBUTIONS_STATIC_LIBS ${DISTRIBUTIONS_STATIC_LIBS} ${MKL_LIBRARIES})
endif()
if (DEFINED ENV{DISTRIBUTIONS_USE_PROTOBUF})
find_package(Protobuf)
if(NOT PROTOBUF_FOUND)
message(FATAL_ERROR
"DISTRIBUTIONS_USE_PROTOBUF specified but protobuf not found")
endif()
message(STATUS "Using Google Protocol Buffers")
set(DISTRIBUTIONS_SHARED_LIBS ${DISTRIBUTIONS_SHARED_LIBS} protobuf)
set(DISTRIBUTIONS_STATIC_LIBS ${DISTRIBUTIONS_STATIC_LIBS} protobuf)
endif()
enable_testing()
include(CTest)
add_subdirectory(src)
add_subdirectory(benchmarks)
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_FILE_NAME "distributions")
include(CPack)