Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: (feature) YAJL version number #69

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions CMake/FindYAJL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,25 @@ find_path(YAJL_INCLUDE_DIR yajl/yajl_version.h DOC "YAJL include directory")
find_library(YAJL_SHARED_LIBRARY NAMES yajl libyajl DOC "Shared YAJL library")
find_library(YAJL_STATIC_LIBRARY NAMES yajl_s libyajl_s DOC "Static YAJL library")

# Version
if (YAJL_INCLUDE_DIR)
file(STRINGS "${YAJL_INCLUDE_DIR}/yajl/yajl_version.h" YAJL_H REGEX "^#define YAJL_MAJOR ")
string(REGEX REPLACE "#define YAJL_MAJOR ([0-9]+).*$" "\\1" YAJL_MAJOR "${YAJL_H}")
file(STRINGS "${YAJL_INCLUDE_DIR}/yajl/yajl_version.h" YAJL_H REGEX "^#define YAJL_MINOR ")
string(REGEX REPLACE "#define YAJL_MINOR ([0-9]+).*$" "\\1" YAJL_MINOR "${YAJL_H}")
file(STRINGS "${YAJL_INCLUDE_DIR}/yajl/yajl_version.h" YAJL_H REGEX "^#define YAJL_MICRO ")
string(REGEX REPLACE "#define YAJL_MICRO ([0-9]+).*$" "\\1" YAJL_MICRO "${YAJL_H}")
set(YAJL_VERSION "${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}")
endif ()


include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBYAJL_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(YAJL DEFAULT_MSG
YAJL_SHARED_LIBRARY YAJL_STATIC_LIBRARY YAJL_INCLUDE_DIR)
find_package_handle_standard_args(YAJL
FOUND_VAR YAJL_FOUND
REQUIRED_VARS YAJL_SHARED_LIBRARY YAJL_STATIC_LIBRARY YAJL_INCLUDE_DIR
VERSION_VAR YAJL_VERSION)

if (YAJL_FOUND)
add_library(yajl-shared SHARED IMPORTED)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ endif ()
# Include custom module for finding YAJL
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${HDF5_VOL_REST_RESOURCES_MOD_DIR}")

find_package (YAJL REQUIRED)
find_package (YAJL 2.0.4 REQUIRED)
if (YAJL_FOUND)
include_directories(${YAJL_INCLUDE_DIRS})
set (LINK_LIBS ${LINK_LIBS} yajl)
Expand Down