Skip to content

Commit 8be99e3

Browse files
committed
Support catkin and catkin_simple
Signed-off-by: Kunlin Yu <yukunlin@syriusrobotics.com>
1 parent 452784d commit 8be99e3

File tree

6 files changed

+49
-20
lines changed

6 files changed

+49
-20
lines changed

CMakeLists.txt

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ project(cql2cpp
77
)
88
add_definitions(-DCQL2CPP_VERSION="${PROJECT_VERSION}")
99

10+
11+
find_package(catkin QUIET)
12+
find_package(catkin_simple QUIET)
13+
if (catkin_simple_FOUND)
14+
catkin_package()
15+
catkin_simple()
16+
endif()
17+
1018
find_package(SQLite3 QUIET)
1119
find_package(libspatialite QUIET)
12-
1320
if (SQLite3_FOUND AND libspatialite_FOUND)
1421
set(SQLITE_LIBS SQLite::SQLite3 libspatialite::libspatialite)
1522
else()
@@ -22,12 +29,6 @@ find_package(glog REQUIRED)
2229

2330
include_directories(${CMAKE_BINARY_DIR})
2431
include_directories(${CMAKE_SOURCE_DIR}/include)
25-
install(DIRECTORY
26-
${CMAKE_SOURCE_DIR}/include/cql2cpp
27-
${CMAKE_SOURCE_DIR}/include/argparse
28-
DESTINATION include
29-
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
30-
)
3132

3233
set(CMAKE_CXX_STANDARD 17)
3334
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -44,12 +45,18 @@ add_custom_command(
4445

4546
# Parser
4647
set(BISON_FILE ${CMAKE_SOURCE_DIR}/src/cql2_parser.y)
47-
set(BISON_OUTPUT ${CMAKE_BINARY_DIR}/cql2_parser_base.cc)
48+
set(BISON_OUTPUT_HH ${CMAKE_BINARY_DIR}/cql2cpp/cql2_parser_base.hh)
49+
set(BISON_OUTPUT_CC ${CMAKE_BINARY_DIR}/cql2cpp/cql2_parser_base.cc)
4850
add_custom_command(
49-
OUTPUT ${BISON_OUTPUT}
50-
COMMAND bison -v -d -o ${BISON_OUTPUT} ${BISON_FILE} -W -Wcounterexamples
51+
OUTPUT ${BISON_OUTPUT_CC}
52+
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/cql2cpp && bison -v --header=${BISON_OUTPUT_HH} --output=${BISON_OUTPUT_CC} ${BISON_FILE} -W -Wcounterexamples
5153
DEPENDS ${BISON_FILE}
52-
COMMENT "Generating ${BISON_OUTPUT} from ${BISON_FILE} using bison"
54+
COMMENT "Generating ${BISON_OUTPUT_CC} from ${BISON_FILE} using bison"
55+
)
56+
install(DIRECTORY
57+
${CMAKE_BINARY_DIR}/cql2cpp
58+
DESTINATION include
59+
FILES_MATCHING PATTERN "*.hh"
5360
)
5461

5562
add_definitions(-DUSE_UNSTABLE_GEOS_CPP_API)
@@ -60,20 +67,26 @@ set(CQL2CPP_SRC
6067
src/global_yylex.cc
6168
src/value.cc
6269
${FLEX_OUTPUT}
63-
${BISON_OUTPUT}
70+
${BISON_OUTPUT_CC}
6471
)
6572

6673
# library
67-
add_library(cql2cpp ${CQL2CPP_SRC})
74+
if (catkin_simple_FOUND)
75+
cs_add_library(cql2cpp ${CQL2CPP_SRC})
76+
else()
77+
add_library(cql2cpp ${CQL2CPP_SRC})
78+
endif()
6879
target_compile_options(cql2cpp PRIVATE -Wno-register -Wno-write-strings)
6980
target_link_libraries(cql2cpp GEOS::geos glog::glog)
70-
install(TARGETS cql2cpp LIBRARY DESTINATION lib/)
7181

7282
# CLI tool
73-
add_executable(cql2 src/main.cc)
83+
if (catkin_simple_FOUND)
84+
cs_add_executable(cql2 src/main.cc)
85+
else()
86+
add_executable(cql2 src/main.cc)
87+
endif()
7488
target_compile_options(cql2 PRIVATE -Wno-register -Wno-write-strings)
7589
target_link_libraries(cql2 cql2cpp GEOS::geos glog::glog)
76-
install(TARGETS cql2 RUNTIME DESTINATION lib/${PROJECT_NAME}/)
7790

7891
# Test
7992
enable_testing()
@@ -90,3 +103,18 @@ add_test(NAME test_bbox_reader COMMAND test_bbox_reader WORKING_DIRECTORY ${TEST
90103
add_executable(test_sql ${TEST_DIR}/test_sql.cc)
91104
target_link_libraries(test_sql cql2cpp GTest::GTest GTest::Main glog::glog ${SQLITE_LIBS})
92105
add_test(NAME test_sql COMMAND test_sql WORKING_DIRECTORY ${TEST_DIR})
106+
107+
108+
if (catkin_simple_FOUND)
109+
cs_install()
110+
cs_export()
111+
else()
112+
install(DIRECTORY
113+
${CMAKE_SOURCE_DIR}/include/cql2cpp
114+
${CMAKE_SOURCE_DIR}/include/argparse
115+
DESTINATION include
116+
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
117+
)
118+
install(TARGETS cql2cpp LIBRARY DESTINATION lib/)
119+
install(TARGETS cql2 RUNTIME DESTINATION lib/${PROJECT_NAME}/)
120+
endif()

include/cql2cpp/cql2_lexer-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#pragma once
1212

13-
#include <cql2_parser_base.hh>
13+
#include <cql2cpp/cql2_parser_base.hh>
1414
#include <istream>
1515
#include <ostream>
1616

include/cql2cpp/cql2_parser_text.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <FlexLexer.h>
1414
#include <glog/logging.h>
1515

16-
#include <cql2_parser_base.hh>
16+
#include <cql2cpp/cql2_parser_base.hh>
1717

1818
namespace cql2cpp {
1919

include/cql2cpp/global_yylex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#pragma once
1212

13-
#include <cql2_parser_base.hh>
13+
#include <cql2cpp/cql2_parser_base.hh>
1414

1515
enum LexerInstance {
1616
CQL2_TEXT,

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
<license>MIT</license>
1111

1212
<buildtool_depend>catkin</buildtool_depend>
13+
<buildtool_depend>catkin_simple</buildtool_depend>
1314
</package>
1415

src/cql2_lexer.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%{
2-
#include <cql2_parser_base.hh>
2+
#include <cql2cpp/cql2_parser_base.hh>
33
#include <cql2cpp/cql2_lexer-internal.h>
44

55
using cql2cpp::Cql2ParserBase;

0 commit comments

Comments
 (0)