diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b8d9b358e..0a5c3f88ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,9 @@ message(STATUS "PNG include dirs: ${PNG_INCLUDE_DIRS}") find_package(TIFF REQUIRED) message(STATUS "TIFF include dirs: ${TIFF_INCLUDE_DIRS}") +find_package(WEBSOCKETS REQUIRED) +message(STATUS "WEBSOCKETS include dirs: ${WEBSOCKETS_INCLUDE_DIRS}") + if(NOT MINGW) include_directories( diff --git a/cmake/Modules/FindWEBSOCKETS.cmake b/cmake/Modules/FindWEBSOCKETS.cmake new file mode 100644 index 0000000000..aab748a5e0 --- /dev/null +++ b/cmake/Modules/FindWEBSOCKETS.cmake @@ -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) diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index 2b02f0f9d4..eb08750767 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -119,11 +119,11 @@ elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) endif() if(MINGW) - set(PLATFORM_SPECIFIC_LIBS curl websockets glew32 opengl32 iconv bz2) + set(PLATFORM_SPECIFIC_LIBS curl glew32 opengl32 iconv bz2) elseif(WINDOWS) - set(PLATFORM_SPECIFIC_LIBS libcurl_imp libwebsockets glew32 opengl32 libiconv) + set(PLATFORM_SPECIFIC_LIBS libcurl_imp glew32 opengl32 libiconv) 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) INCLUDE_DIRECTORIES ( /System/Library/Frameworks ) @@ -138,7 +138,6 @@ elseif(MACOSX OR APPLE) set(PLATFORM_SPECIFIC_LIBS curl - websockets ${COCOA_LIBRARY} ${OPENGL_LIBRARY} ${OPENAL_LIBRARY} @@ -168,6 +167,7 @@ include_directories( ${PNG_INCLUDE_DIRS} ${TIFF_INCLUDE_DIRS} ${TinyXML2_INCLUDE_DIRS} + ${WEBSOCKETS_INCLUDE_DIRS} ) target_link_libraries(cocos2d protobuf unzip xxhash @@ -176,6 +176,7 @@ target_link_libraries(cocos2d ${PNG_LIBRARIES} ${TIFF_LIBRARIES} ${TinyXML2_LIBRARIES} + ${WEBSOCKETS_LIBRARIES} ${FREETYPE_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} )