forked from sweeneychris/RpolyPlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
102 lines (87 loc) · 4.07 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
# Modified by Einar J.M. Baumann (2018) <einar.baumann@gmail.com>
# Disabled testing and added install target
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(RpolyPlusPlus C CXX)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# By default, the unit tests will be built.
OPTION(BUILD_TESTING "Enable testing" OFF)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Set Minimum Eigen version and find the installed package.
SET(MIN_EIGEN_VERSION 3.2.0)
IF (USE_LOCAL_EIGEN3)
message(STATUS "Using local Eigen3 in RpolyPlusPlus build.")
set(EIGEN3_INCLUDE_DIR "${EIGEN3_ROOT}")
message(STATUS "${EIGEN3_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR})
ELSE()
FIND_PACKAGE(Eigen3 ${MIN_EIGEN_VERSION} REQUIRED)
IF (EIGEN3_FOUND)
MESSAGE(STATUS "Found Eigen version ${EIGEN3_VERSION}: ${EIGEN3_INCLUDE_DIR}")
ENDIF (EIGEN3_FOUND)
ENDIF(USE_LOCAL_EIGEN3)
# Use a larger inlining threshold for Clang, since it hobbles Eigen,
# resulting in an unreasonably slow version of the blas routines. The
# -Qunused-arguments is needed because CMake passes the inline
# threshold to the linker and clang complains about it and dies.
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Qunused-arguments -mllvm -inline-threshold=600")
# Older versions of Clang (<= 2.9) do not support the 'return-type-c-linkage'
# option, so check for its presence before adding it to the default flags set.
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-Wno-return-type-c-linkage"
HAVE_RETURN_TYPE_C_LINKAGE)
IF (HAVE_RETURN_TYPE_C_LINKAGE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage")
ENDIF(HAVE_RETURN_TYPE_C_LINKAGE)
ENDIF ()
# NOTE: This fix came from Ceres solver with the following comment:
#
# Eigen SparseQR generates various compiler warnings related to unused and
# uninitialised local variables, which prevents Ceres compilation as we use
# -Werror. To avoid having to individually suppress these warnings around
# the #include statments for Eigen headers across all GCC/Clang versions, we
# tell CMake to treat Eigen headers as system headers. This results in all
# compiler warnings from them being suppressed.
#
# Note that this is *not* propagated to clients, ie CERES_INCLUDE_DIRS
# used by clients after find_package(Ceres) does not identify Eigen as
# as system headers.
#INCLUDE_DIRECTORIES(SYSTEM ${EIGEN3_INCLUDE_DIRS})
SET(RPOLY_PLUS_PLUS_SRCS
src/polynomial.cc
src/find_polynomial_roots_jenkins_traub.cc)
ADD_LIBRARY(rpoly_plus_plus SHARED ${RPOLY_PLUS_PLUS_SRCS})
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
MESSAGE("\n=================================================================================")
MESSAGE("\n-- Build type: Debug. Performance will be terrible!")
MESSAGE("-- Add -DCMAKE_BUILD_TYPE=Release to the CMake command line to get an optimized build.")
MESSAGE("\n=================================================================================")
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug")
#IF (BUILD_TESTING)
#ADD_SUBDIRECTORY(gtest)
#INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/gtest/include")
#MACRO (GTEST FILENAME)
#STRING(REPLACE "/" ";" TEST_NAME_LIST ${FILENAME})
#LIST(REVERSE TEST_NAME_LIST)
#LIST(GET TEST_NAME_LIST 0 TEST_NAME)
#ADD_EXECUTABLE(${TEST_NAME}_test test/test_main.cc test/${FILENAME}_test.cc)
#TARGET_LINK_LIBRARIES(${TEST_NAME}_test
#gtest
#rpoly_plus_plus)
#ADD_TEST(NAME ${TEST_NAME}_test
#COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_NAME}_test)
#ENDMACRO (GTEST)
#GTEST(find_polynomial_roots_jenkins_traub)
#ENDIF (BUILD_TESTING)
# --- Add install target ---
SET(RPPP_INTERFACES
src/find_polynomial_roots_jenkins_traub.h
src/polynomial.h
)
set_target_properties(rpoly_plus_plus PROPERTIES PUBLIC_HEADER "${RPPP_INTERFACES}")
install(TARGETS rpoly_plus_plus DESTINATION lib
PUBLIC_HEADER DESTINATION include/RpolyPlusPlus)