Skip to content

Commit

Permalink
Use system-installed cJSON, if available
Browse files Browse the repository at this point in the history
  • Loading branch information
mvieth committed Jul 13, 2024
1 parent 2705ac0 commit 9ade05b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,14 @@ if(WITH_SYSTEM_ZLIB)
endif()
endif()

option(WITH_SYSTEM_CJSON "Use system cJSON" TRUE)
if(WITH_SYSTEM_CJSON)
find_package(cJSON)
if(cJSON_FOUND)
set(HAVE_CJSON ON)
endif()
endif()

### ---[ Create the config.h file
set(pcl_config_h_in "${CMAKE_CURRENT_SOURCE_DIR}/pcl_config.h.in")
set(pcl_config_h "${CMAKE_CURRENT_BINARY_DIR}/include/pcl/pcl_config.h")
Expand Down
10 changes: 8 additions & 2 deletions outofcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if(NOT build)
endif()

set(srcs
src/cJSON.cpp
src/outofcore_node_data.cpp
src/outofcore_base_data.cpp
)
Expand All @@ -32,7 +31,6 @@ set(incs
"include/pcl/${SUBSYS_NAME}/outofcore_breadth_first_iterator.h"
"include/pcl/${SUBSYS_NAME}/outofcore_depth_first_iterator.h"
"include/pcl/${SUBSYS_NAME}/boost.h"
"include/pcl/${SUBSYS_NAME}/cJSON.h"
"include/pcl/${SUBSYS_NAME}/octree_base.h"
"include/pcl/${SUBSYS_NAME}/octree_base_node.h"
"include/pcl/${SUBSYS_NAME}/octree_abstract_node_container.h"
Expand Down Expand Up @@ -65,11 +63,19 @@ set(visualization_incs
"include/pcl/${SUBSYS_NAME}/visualization/viewport.h"
)

if(NOT HAVE_CJSON)
list(APPEND srcs src/cJSON.cpp)
list(APPEND incs "include/pcl/${SUBSYS_NAME}/cJSON.h")
endif()

set(LIB_NAME "pcl_${SUBSYS_NAME}")

PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${incs} ${impl_incs} ${visualization_incs})
#PCL_ADD_SSE_FLAGS("${LIB_NAME}")
target_link_libraries("${LIB_NAME}" pcl_common pcl_visualization ${Boost_SYSTEM_LIBRARY})
if(HAVE_CJSON)
target_link_libraries("${LIB_NAME}" ${CJSON_LIBRARIES})
endif()
PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC} PCL_DEPS ${SUBSYS_DEPS})

# Install include files
Expand Down
5 changes: 5 additions & 0 deletions outofcore/include/pcl/outofcore/impl/octree_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
#include <pcl/outofcore/octree_base.h>

// JSON
#include <pcl/pcl_config.h> // for HAVE_CJSON
#if defined(HAVE_CJSON)
#include <cjson/cJSON.h>
#else
#include <pcl/outofcore/cJSON.h>
#endif

#include <pcl/filters/random_sample.h>
#include <pcl/filters/extract_indices.h>
Expand Down
5 changes: 5 additions & 0 deletions outofcore/include/pcl/outofcore/impl/octree_base_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@
#include <pcl/filters/extract_indices.h>

// JSON
#include <pcl/pcl_config.h> // for HAVE_CJSON
#if defined(HAVE_CJSON)
#include <cjson/cJSON.h>
#else
#include <pcl/outofcore/cJSON.h>
#endif

namespace pcl
{
Expand Down
5 changes: 5 additions & 0 deletions outofcore/include/pcl/outofcore/outofcore_base_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@

#include <pcl/memory.h>
#include <pcl/pcl_macros.h>
#include <pcl/pcl_config.h> // for HAVE_CJSON
#if defined(HAVE_CJSON)
#include <cjson/cJSON.h>
#else
#include <pcl/outofcore/cJSON.h>
#endif

#include <pcl/outofcore/metadata.h>

Expand Down
5 changes: 5 additions & 0 deletions outofcore/include/pcl/outofcore/outofcore_node_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@

#include <pcl/memory.h>
#include <pcl/pcl_macros.h>
#include <pcl/pcl_config.h> // for HAVE_CJSON
#if defined(HAVE_CJSON)
#include <cjson/cJSON.h>
#else
#include <pcl/outofcore/cJSON.h>
#endif

#include <pcl/common/eigen.h>

Expand Down

0 comments on commit 9ade05b

Please sign in to comment.