-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
58 lines (45 loc) · 1.42 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
cmake_minimum_required(VERSION 3.10.0)
project(jq VERSION 0.0.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "-O1 -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
########################################################################
#
# jq
set(JQ_VERSION 1.6)
set(JQ_DIR ${CMAKE_CURRENT_BINARY_DIR}/jq-${JQ_VERSION}/src/libjq)
set(JQ_INCLUDE_DIR ${JQ_DIR}/src)
include(ExternalProject)
ExternalProject_Add(libjq
GIT_REPOSITORY https://github.com/stedolan/jq.git
GIT_TAG jq-${JQ_VERSION}
CONFIGURE_COMMAND autoreconf -fi
&& ./configure --with-oniguruma=builtin --with-pic
BUILD_COMMAND make LDFLAGS=-all-static -j8
&& cd ${JQ_DIR}/modules/oniguruma && make
BUILD_IN_SOURCE 1
INSTALL_COMMAND cp .libs/libjq.a ${CMAKE_CURRENT_BINARY_DIR}
&& cp modules/oniguruma/src/.libs/libonig.a ${CMAKE_CURRENT_BINARY_DIR}
PREFIX jq-${JQ_VERSION}
)
link_directories(${CMAKE_BINARY_DIR})
########################################################################
#
# Define the jq-impl library.
add_library(jq_impl SHARED
src/jq_impl.cc
src/utils.cc
)
add_dependencies(jq_impl libjq)
target_include_directories(jq_impl PUBLIC
${JQ_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src)
target_link_libraries(jq_impl jq pthread onig)
set_target_properties(jq_impl PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PREFIX ""
OUTPUT_NAME "jq-impl"
)