forked from CoatiSoftware/SourcetrailDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
118 lines (84 loc) · 4.25 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
106
107
108
109
110
111
112
113
114
115
116
117
118
cmake_minimum_required (VERSION 2.6)
# --- Options ---
set(BUILD_BINDINGS_PERL OFF CACHE BOOL "Build the SourcetrailDB Perl bindings.")
set(BUILD_BINDINGS_PYTHON OFF CACHE BOOL "Build the SourcetrailDB Python bindings.")
set(BUILD_BINDINGS_JAVA OFF CACHE BOOL "Build the SourcetrailDB Java bindings.")
set(BUILD_BINDINGS_CSHARP OFF CACHE BOOL "Build the SourcetrailDB C# bindings.")
set(BUILD_EXAMPLES ON CACHE BOOL "Build the examples.")
set(PROJECT_NAME "SourcetrailDB")
project(${PROJECT_NAME})
# --- Default Flags ---
set(CMAKE_BUILD_TYPE_INIT "Release")
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -fPIC")
endif()
# --- Version ---
file (STRINGS "version.txt" VERSION_STRING)
string(REGEX REPLACE "v([0-9]+)\\..*" "\\1" INTERFACE_VERSION "${VERSION_STRING}")
string(REGEX REPLACE "v[0-9]+\\.db([0-9]+)\\..*" "\\1" DATABASE_VERSION "${VERSION_STRING}")
string(REGEX REPLACE "v[0-9]+\\.db[0-9]+\\.p([0-9]+).*" "\\1" PATCH_VERSION "${VERSION_STRING}")
set(VERSION_STRING_UNDERSCORE "v${INTERFACE_VERSION}_db${DATABASE_VERSION}_p${PATCH_VERSION}")
message(STATUS "SourcetrailDB Version: ${VERSION_STRING}")
message(STATUS "Interface Version: ${INTERFACE_VERSION}")
message(STATUS "Database Version: ${DATABASE_VERSION}")
message(STATUS "Patch Version: ${PATCH_VERSION}")
# --- Core ---
set(LIB_CORE_TARGET_NAME "lib_core")
set(CORE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/core") # can be accessed in subdirectory CMake files
set(CORE_BINARY_DIR "${CMAKE_BINARY_DIR}/core") # can be accessed in subdirectory CMake files
add_subdirectory(${CORE_SOURCE_DIR} ${CORE_BINARY_DIR})
# --- Perl Binding ---
if (BUILD_BINDINGS_PERL)
message(STATUS "The SourcetrailDB Perl bindings will be built.")
set(PERL_BINDING_TARGET_NAME "bindings_perl")
set(PERL_BINDING_OUTPUT_DIR "")
add_subdirectory("${CMAKE_SOURCE_DIR}/bindings_perl" "${CMAKE_BINARY_DIR}/bindings_perl")
else()
message(STATUS "Building the SourcetrailDB Perl bindings will be skipped. You can enable building this target by setting 'BUILD_BINDINGS_PERL' to 'ON'.")
endif()
# --- Python Binding ---
if (BUILD_BINDINGS_PYTHON)
message(STATUS "The SourcetrailDB Python bindings will be built.")
set(PYTHON_BINDING_TARGET_NAME "bindings_python")
set(PYTHON_BINDING_OUTPUT_DIR "")
add_subdirectory("${CMAKE_SOURCE_DIR}/bindings_python" "${CMAKE_BINARY_DIR}/bindings_python")
else()
message(STATUS "Building the SourcetrailDB Python bindings will be skipped. You can enable building this target by setting 'BUILD_BINDINGS_PYTHON' to 'ON'.")
endif()
# --- Java Binding ---
if (BUILD_BINDINGS_JAVA)
message(STATUS "The SourcetrailDB Java bindings will be built.")
set(JAVA_BINDING_TARGET_NAME "bindings_java")
set(JAVA_BINDING_OUTPUT_DIR "")
add_subdirectory("${CMAKE_SOURCE_DIR}/bindings_java" "${CMAKE_BINARY_DIR}/bindings_java")
else()
message(STATUS "Building the SourcetrailDB Java bindings will be skipped. You can enable building this target by setting 'BUILD_BINDINGS_JAVA' to 'ON'.")
endif()
# --- C# Binding ---
if (BUILD_BINDINGS_CSHARP)
message(STATUS "The SourcetrailDB C# bindings will be built.")
set(CSHARP_BINDING_TARGET_NAME "bindings_csharp")
set(CSHARP_BINDING_OUTPUT_DIR "")
add_subdirectory("${CMAKE_SOURCE_DIR}/bindings_csharp" "${CMAKE_BINARY_DIR}/bindings_csharp")
else()
message(STATUS "Building the SourcetrailDB C# bindings will be skipped. You can enable building this target by setting 'BUILD_BINDINGS_CSHARP' to 'ON'.")
endif()
# --- Examples ---
if (BUILD_EXAMPLES)
message(STATUS "The examples will be built.")
add_subdirectory("${CMAKE_SOURCE_DIR}/examples/cpp_api_example")
add_subdirectory("${CMAKE_SOURCE_DIR}/examples/cpp_poetry_indexer")
if (BUILD_BINDINGS_PYTHON)
add_subdirectory("${CMAKE_SOURCE_DIR}/examples/python_api_example")
else()
message(STATUS "Skip python binding sample. You can enable building it by setting 'BUILD_BINDINGS_PYTHON' to 'ON'.")
endif()
if (BUILD_BINDINGS_JAVA)
add_subdirectory("${CMAKE_SOURCE_DIR}/examples/java_api_example")
else()
message(STATUS "Skip java binding sample. You can enable building it by setting 'BUILD_BINDINGS_JAVA' to 'ON'.")
endif()
else()
message(STATUS "Building examples will be skipped. You can enable building examples by setting 'BUILD_EXAMPLES' to 'ON'.")
endif()