Skip to content

Commit

Permalink
Add yajl into the cmake build in a generic way.
Browse files Browse the repository at this point in the history
Use yajl2 for MSVC.
  • Loading branch information
ahmedcharles committed Apr 21, 2014
1 parent 3c83ee3 commit c2f608d
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 2 deletions.
79 changes: 79 additions & 0 deletions cmake/FindYAJL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Locate YAJL library
# This module defines
# YAJL_FOUND, if false, do not try to link to YAJL
# YAJL_LIBRARIES
# YAJL_INCLUDE_DIR, where to find yajl_*.h


FIND_PATH(YAJL_INCLUDE_DIR yajl/yajl_version.h
HINTS
${YAJL_DIR} $ENV{YAJL_DIR}
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)

FIND_LIBRARY(YAJL_LIBRARY_RELEASE
NAMES yajl yajl_s
HINTS
${YAJL_DIR} $ENV{YAJL_DIR}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
)

FIND_LIBRARY(YAJL_LIBRARY_DEBUG
NAMES yajld yajl_sd
HINTS
${YAJL_DIR} $ENV{YAJL_DIR}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
)

IF(YAJL_LIBRARY_DEBUG AND YAJL_LIBRARY_RELEASE)
SET(YAJL_LIBRARY optimized ${YAJL_LIBRARY_RELEASE} debug ${YAJL_LIBRARY_DEBUG} )
GET_FILENAME_COMPONENT(YAJL_FILENAME ${YAJL_LIBRARY_RELEASE} NAME_WE)
ELSEIF(YAJL_LIBRARY_RELEASE)
SET(YAJL_LIBRARY ${YAJL_LIBRARY_RELEASE} )
GET_FILENAME_COMPONENT(YAJL_FILENAME ${YAJL_LIBRARY_RELEASE} NAME_WE)
ELSEIF(YAJL_LIBRARY_DEBUG)
SET(YAJL_LIBRARY ${YAJL_LIBRARY_DEBUG} )
GET_FILENAME_COMPONENT(YAJL_FILENAME ${YAJL_LIBRARY_DEBUG} NAME_WE)
ENDIF()

STRING(FIND ${YAJL_FILENAME} yajl_s YAJL_STATIC)

IF(YAJL_STATIC EQUAL -1)
ADD_DEFINITIONS(-DYAJL_SHARED)
ENDIF()

SET( YAJL_LIBRARIES "${YAJL_LIBRARY}" CACHE STRING "YAJL Libraries")

INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set YAJL_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAJL DEFAULT_MSG YAJL_LIBRARIES YAJL_INCLUDE_DIR)

MARK_AS_ADVANCED(YAJL_INCLUDE_DIR YAJL_LIBRARIES YAJL_LIBRARY YAJL_LIBRARY_RELEASE YAJL_LIBRARY_DEBUG)
7 changes: 5 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ mudlet.h

SET(PCRE_DIR "${PROJECT_SOURCE_DIR}/.." CACHE PATH "PCRE install directory.")

SET(YAJL_DIR "${PROJECT_SOURCE_DIR}/.." CACHE PATH "YAJL install directory.")

IF(EXISTS "${PROJECT_SOURCE_DIR}/../include/lua.h")
SET(LUA_INCLUDE_DIR_TEMP "${PROJECT_SOURCE_DIR}/../include")
GET_FILENAME_COMPONENT(LUA_INCLUDE_DIR ${LUA_INCLUDE_DIR_TEMP} ABSOLUTE CACHE)
Expand Down Expand Up @@ -229,6 +231,7 @@ FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(Lua51 REQUIRED)
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(PCRE REQUIRED)
FIND_PACKAGE(YAJL REQUIRED)

SET(Boost_USE_STATIC_LIBS ON)
FIND_PACKAGE(Boost 1.44 COMPONENTS graph)
Expand All @@ -254,7 +257,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${mudlet_BINARY_DIR}/src
${ZLIB_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
"C:\\mudlet_package_MSVC\\hunspell-1.3.1\\src"
"C:\\mudlet_package_MSVC\\lloyd-yajl-f4b2b1a\\yajl-2.0.1\\include"
${YAJL_INCLUDE_DIR}
"C:\\mudlet_package_MSVC\\libircclient-qt-0.5.0\\include"
)

Expand Down Expand Up @@ -282,7 +285,7 @@ mudlet
${PCRE_LIBRARIES}
C:\\mudlet_package_MSVC\\hunspell-1.3.1\\src\\win_api\\Release_dll\\libhunspell\\libhunspell.lib
${OPENGL_LIBRARIES}
"C:\\Users\\heiko\\Desktop\\lloyd-yajl-f4b2b1a\\yajl-2.0.1\\lib\\Release\\yajl.lib"
${YAJL_LIBRARIES}
"C:\\mudlet_package_MSVC\\libircclient-qt-0.5.0\\lib\\ircclient-qt.lib"
${Boost_LIBRARIES}
)
Expand Down

0 comments on commit c2f608d

Please sign in to comment.