Skip to content

Commit

Permalink
sjparser: fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mmd-osm committed Sep 9, 2024
1 parent 6e9e85f commit d2aad61
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
48 changes: 48 additions & 0 deletions contrib/sjparser/cmake/FindYAJL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
find_package(PkgConfig)
pkg_check_modules(PC_YAJL QUIET yajl)

find_path(YAJL_INCLUDE_DIR
NAMES yajl/yajl_gen.h
PATHS ${PC_YAJL_INCLUDE_DIRS}
PATH_SUFFIXES yajl
)
find_library(YAJL_LIBRARY
NAMES yajl
PATHS ${PC_YAJL_LIBRARY_DIRS}
)

set(YAJL_VERSION ${PC_YAJL_VERSION})
set(YAJL_VERSION_STRING ${YAJL_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(YAJL
FOUND_VAR YAJL_FOUND
REQUIRED_VARS
YAJL_LIBRARY
YAJL_INCLUDE_DIR
VERSION_VAR YAJL_VERSION
)

if(YAJL_FOUND)
set(YAJL_LIBRARIES ${YAJL_LIBRARY})
set(YAJL_INCLUDE_DIRS ${YAJL_INCLUDE_DIR})
set(YAJL_DEFINITIONS ${PC_YAJL_CFLAGS_OTHER})
endif()

if(YAJL_FOUND AND NOT TARGET YAJL::YAJL)
add_library(YAJL::YAJL UNKNOWN IMPORTED)
set_target_properties(YAJL::YAJL PROPERTIES
IMPORTED_LOCATION "${YAJL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${YAJL_INCLUDE_DIR}"
INTERFACE_COMPILE_OPTIONS "${PC_YAJL_CFLAGS_OTHER}"
VERSION "${YAJL_VERSION}"
)
endif()

mark_as_advanced(
YAJL_INCLUDE_DIR
YAJL_LIBRARY
YAJL_VERSION
YAJL_VERSION_STRING
)

9 changes: 3 additions & 6 deletions contrib/sjparser/library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
find_library(YAJL_LIB yajl)
if(NOT YAJL_LIB)
message(FATAL_ERROR "Can't find yajl library")
endif()
find_package(YAJL 2 REQUIRED)

add_library(sjparser STATIC
sjparser/parsing_error.cpp
Expand Down Expand Up @@ -42,7 +39,7 @@ set_target_properties(sjparser PROPERTIES OUTPUT_NAME sjparser_static)

setup_compilation_options(sjparser)

target_link_libraries(sjparser PUBLIC ${YAJL_LIB})
target_link_libraries(sjparser PUBLIC YAJL::YAJL)

target_include_directories(sjparser PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand All @@ -60,7 +57,7 @@ if(SJPARSER_BUILD_SHARED_LIBRARY)

setup_compilation_options(sjparser_shared)

target_link_libraries(sjparser_shared PUBLIC ${YAJL_LIB})
target_link_libraries(sjparser_shared PUBLIC YAJL::YAJL)

target_include_directories(sjparser_shared PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand Down

0 comments on commit d2aad61

Please sign in to comment.