Find libwebsockets in unified way

This commit is contained in:
Vladimir Timofeev 2014-11-16 13:22:54 +03:00
parent 1d629dfe7d
commit c7bff5ea9e
3 changed files with 76 additions and 4 deletions

View File

@ -239,6 +239,9 @@ message(STATUS "PNG include dirs: ${PNG_INCLUDE_DIRS}")
find_package(TIFF REQUIRED) find_package(TIFF REQUIRED)
message(STATUS "TIFF include dirs: ${TIFF_INCLUDE_DIRS}") message(STATUS "TIFF include dirs: ${TIFF_INCLUDE_DIRS}")
find_package(WEBSOCKETS REQUIRED)
message(STATUS "WEBSOCKETS include dirs: ${WEBSOCKETS_INCLUDE_DIRS}")
if(NOT MINGW) if(NOT MINGW)
include_directories( include_directories(

View File

@ -0,0 +1,68 @@
#.rst:
# FindWEBSOCKETS
# --------
#
# Find websockets library
#
# ::
#
# WEBSOCKETS_INCLUDE_DIRS, where to find libwebsockets.h.
# WEBSOCKETS_LIBRARIES, the libraries needed to use WEBSOCKETS.
# WEBSOCKETS_FOUND, If false, do not try to use WEBSOCKETS.
#
if(USE_PREBUILT_LIBS)
find_path(WEBSOCKETS_INCLUDE_DIR libwebsockets.h
PATH_SUFFIXES include/${PLATFORM_FOLDER} include
PATHS ${COCOS_EXTERNAL_DIR}/websockets
NO_DEFAULT_PATH
)
find_library(WEBSOCKETS_LIBRARY NAMES websockets libwebsockets
PATH_SUFFIXES
prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
prebuilt/${PLATFORM_FOLDER}
PATHS ${COCOS_EXTERNAL_DIR}/websockets
NO_DEFAULT_PATH
)
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
if(NOT WEBSOCKETS_INCLUDE_DIR OR NOT WEBSOCKETS_LIBRARY)
unset(WEBSOCKETS_INCLUDE_DIR CACHE)
unset(WEBSOCKETS_LIBRARY CACHE)
endif()
endif()
find_path(WEBSOCKETS_INCLUDE_DIR libwebsockets.h
HINTS ENV WEBSOCKETS_DIR
PATH_SUFFIXES include/websockets include/libwebsockets include
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
find_library(WEBSOCKETS_LIBRARY NAMES websockets libwebsockets
HINTS ENV WEBSOCKETS_DIR
PATH_SUFFIXES lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
)
set(WEBSOCKETS_INCLUDE_DIRS ${WEBSOCKETS_INCLUDE_DIR})
set(WEBSOCKETS_LIBRARIES ${WEBSOCKETS_LIBRARY})
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(WEBSOCKETS DEFAULT_MSG WEBSOCKETS_LIBRARIES WEBSOCKETS_INCLUDE_DIRS)
mark_as_advanced(WEBSOCKETS_LIBRARIES WEBSOCKETS_INCLUDE_DIRS)

View File

@ -119,11 +119,11 @@ elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
endif() endif()
if(MINGW) if(MINGW)
set(PLATFORM_SPECIFIC_LIBS curl websockets glew32 opengl32 iconv bz2) set(PLATFORM_SPECIFIC_LIBS curl glew32 opengl32 iconv bz2)
elseif(WINDOWS) elseif(WINDOWS)
set(PLATFORM_SPECIFIC_LIBS libcurl_imp libwebsockets glew32 opengl32 libiconv) set(PLATFORM_SPECIFIC_LIBS libcurl_imp glew32 opengl32 libiconv)
elseif(LINUX) elseif(LINUX)
set(PLATFORM_SPECIFIC_LIBS curl websockets ssl crypto fontconfig pthread GLEW GL X11 rt ${FMOD_LIB}) set(PLATFORM_SPECIFIC_LIBS curl ssl crypto fontconfig pthread GLEW GL X11 rt ${FMOD_LIB})
elseif(MACOSX OR APPLE) elseif(MACOSX OR APPLE)
INCLUDE_DIRECTORIES ( /System/Library/Frameworks ) INCLUDE_DIRECTORIES ( /System/Library/Frameworks )
@ -138,7 +138,6 @@ elseif(MACOSX OR APPLE)
set(PLATFORM_SPECIFIC_LIBS set(PLATFORM_SPECIFIC_LIBS
curl curl
websockets
${COCOA_LIBRARY} ${COCOA_LIBRARY}
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
${OPENAL_LIBRARY} ${OPENAL_LIBRARY}
@ -168,6 +167,7 @@ include_directories(
${PNG_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS}
${TIFF_INCLUDE_DIRS} ${TIFF_INCLUDE_DIRS}
${TinyXML2_INCLUDE_DIRS} ${TinyXML2_INCLUDE_DIRS}
${WEBSOCKETS_INCLUDE_DIRS}
) )
target_link_libraries(cocos2d target_link_libraries(cocos2d
protobuf unzip xxhash protobuf unzip xxhash
@ -176,6 +176,7 @@ target_link_libraries(cocos2d
${PNG_LIBRARIES} ${PNG_LIBRARIES}
${TIFF_LIBRARIES} ${TIFF_LIBRARIES}
${TinyXML2_LIBRARIES} ${TinyXML2_LIBRARIES}
${WEBSOCKETS_LIBRARIES}
${FREETYPE_LIBRARIES} ${FREETYPE_LIBRARIES}
${PLATFORM_SPECIFIC_LIBS} ${PLATFORM_SPECIFIC_LIBS}
) )