-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
75 lines (59 loc) · 2.19 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
cmake_minimum_required (VERSION 3.8.0)
project("pbc-bindings")
# set output directories.
set(CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test)
# this is the directory for our custom CMake modules.
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# prefer to Homebrew formulae over system Framework on macOS.
if(APPLE)
set(CMAKE_FIND_FRAMEWORK LAST)
endif()
find_package(PBC REQUIRED)
include_directories(${PBC_INCLUDE_DIRS})
list(APPEND linked_libraries ${PBC_LIBRARIES})
find_package(GMP REQUIRED)
include_directories(${GMP_INCLUDE_DIRS})
list(APPEND linked_libraries ${GMP_LIBRARIES} ${GMPXX_LIBRARIES})
# enable c++14.
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 14)
# option to enable SWIG bindings
option(ENABLE_PYTHON "Enable SWIG Python 3 bindings" OFF)
option(ENABLE_RUBY "Enable SWIG Ruby bindings" OFF)
# option to enable test
option(ENABLE_TEST "Enable test" OFF)
if(ENABLE_PYTHON OR ENABLE_RUBY)
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
include_directories("${PROJECT_SOURCE_DIR}/include")
set_source_files_properties("swig/pbc.i" PROPERTIES CPLUSPLUS ON)
endif()
if(ENABLE_PYTHON)
find_package(PythonLibs 3.3 REQUIRED)
include_directories(${PYTHON_INCLUDE_PATH})
set(CMAKE_SWIG_OUTDIR "${CMAKE_BINARY_DIR}/swig/python")
swig_add_library(pbc LANGUAGE python SOURCES swig/pbc.i)
swig_link_libraries(pbc ${linked_libraries} ${PYTHON_LIBRARIES})
set_target_properties(${SWIG_MODULE_pbc_REAL_NAME}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR})
endif()
if(ENABLE_RUBY)
find_package(Ruby 2.0 REQUIRED)
include_directories(${RUBY_INCLUDE_DIRS})
set(CMAKE_SWIG_OUTDIR "${CMAKE_BINARY_DIR}/swig/ruby")
swig_add_library(pbc LANGUAGE ruby SOURCES swig/pbc.i)
swig_link_libraries(pbc ${linked_libraries} ${RUBY_LIBRARY})
set_target_properties(${SWIG_MODULE_pbc_REAL_NAME}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SWIG_OUTDIR})
endif()
if(ENABLE_TEST)
enable_testing()
add_subdirectory(test/cpp)
if(ENABLE_PYTHON)
add_subdirectory(test/python)
endif()
if(ENABLE_RUBY)
add_subdirectory(test/ruby)
endif()
endif()