-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
82 lines (63 loc) · 2.2 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
cmake_minimum_required(VERSION 3.13)
project(xava C CXX)
# Include common funnctions
include(src/cmake/utilities.cmake)
# Fix/handle common build errors
include(src/cmake/build-fix.cmake)
# Debug is default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
# Allow for custom link prefixes (in order to optimize CMake builds for packagers)
if(NOT XAVA_LINK_TO_INSTALL_DIR)
set(XAVA_LINK_TO_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
endif()
# Define XAVA version
set(xava_VERSION_MAJOR 0)
set(xava_VERSION_MINOR 7)
set(xava_VERSION_PATCH 1)
set(xava_VERSION_TWEAK 1)
set(xava_VERSION "${xava_VERSION_MAJOR}.${xava_VERSION_MINOR}.${xava_VERSION_PATCH}.${xava_VERSION_TWEAK}" CACHE STRING "XAVA version")
# Definitions
add_definitions(-DPACKAGE="xava" -DVERSION="${xava_VERSION}")
add_definitions(-DXAVA_VERSION_MAJOR"=${xava_VERSION_MAJOR}")
add_definitions(-DXAVA_VERSION_MINOR"=${xava_VERSION_MINOR}")
add_definitions(-DXAVA_VERSION_PATCH"=${xava_VERSION_PATCH}")
add_definitions(-DXAVA_VERSION_TWEAK"=${xava_VERSION_TWEAK}")
add_definitions(-DPREFIX="${XAVA_LINK_TO_INSTALL_DIR}")
# Do OS-specific stuff
include(src/cmake/os-prerequisites.cmake)
# Set appropriate C flags
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "-Wall -Wextra ${BUILD_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG ${BUILD_DEBUG_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "-O3 -fvisibility='internal'")
set(CMAKE_CXX_FLAGS "-Wall -Wextra ${BUILD_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG ${BUILD_DEBUG_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fvisibility='internal' ")
find_package(PkgConfig REQUIRED)
# math lib
find_library(MATH_LIB m HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
if(NOT MATH_LIB)
message(FATAL_ERROR "math library not found")
endif()
# pthread
find_library(THREAD_LIB pthread HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
if(NOT THREAD_LIB)
message(FATAL_ERROR "pthread library not found")
endif()
include_directories(src)
# Build shared library
include("src/shared/build.cmake")
# Build modules
include("src/cmake/modules.cmake")
# Build executable
add_executable(
xava
${ADDITIONAL_OBJS}
src/config.c
src/xava.c
)
# Link executable
target_link_libraries(xava xava-shared m pthread)
include(src/cmake/install_and_configure.cmake)