From 3e0ada4c84b7cf7b8b2e3eb4b852771368fed875 Mon Sep 17 00:00:00 2001 From: Martell Malone Date: Wed, 22 Jul 2015 14:19:22 +0100 Subject: [PATCH] fix building with system prebuilt libs --- CMakeLists.txt | 25 ++++++++++++++-------- cmake/Modules/FindRecast.cmake | 32 +++++++++++++++++++++++++++++ cmake/Modules/Findflatbuffers.cmake | 32 +++++++++++++++++++++++++++++ cmake/Modules/Findxxhash.cmake | 32 +++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 cmake/Modules/FindRecast.cmake create mode 100644 cmake/Modules/Findflatbuffers.cmake create mode 100644 cmake/Modules/Findxxhash.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fc7c0016c148..98e96619c1ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,16 +326,23 @@ cocos_find_package(TIFF TIFF REQUIRED) cocos_find_package(WEBSOCKETS WEBSOCKETS REQUIRED) cocos_find_package(CURL CURL REQUIRED) -add_subdirectory(external/flatbuffers) -set(FLATBUFFERS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external) -message(STATUS "Flatbuffers include dirs: ${FLATBUFFERS_INCLUDE_DIRS}") - - -# build xxhash -add_subdirectory(external/xxhash) -set(XXHASH_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/xxhash) -set(XXHASH_LIBRARIES xxhash) +# flatbuffers +if(USE_PREBUILT_LIBS) + add_subdirectory(external/flatbuffers) + set(FLATBUFFERS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external) + message(STATUS "Flatbuffers include dirs: ${FLATBUFFERS_INCLUDE_DIRS}") +else() + cocos_find_package(flatbuffers flatbuffers REQUIRED) +endif() +# xxhash +if(USE_PREBUILT_LIBS) + add_subdirectory(external/xxhash) + set(XXHASH_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/xxhash) + set(XXHASH_LIBRARIES xxhash) +else() + cocos_find_package(xxhash xxhash REQUIRED) +endif() # libcocos2d.a add_subdirectory(cocos) diff --git a/cmake/Modules/FindRecast.cmake b/cmake/Modules/FindRecast.cmake new file mode 100644 index 000000000000..d87b3bfbc8d8 --- /dev/null +++ b/cmake/Modules/FindRecast.cmake @@ -0,0 +1,32 @@ +#.rst: +# FindRecast +# ------------ +# +# Locate RECAST library +# +# This module defines +# +# :: +# +# RECAST_LIBRARIES, the library to link against +# RECAST_FOUND, the libraries needed to use RECAST +# RECAST_INCLUDE_DIRS, where to find headers. +# + +find_path(RECAST_INCLUDE_DIR + NAMES Recast/Recast.h + PATH_SUFFIXES include +) + +find_library(RECAST_LIBRARY + NAMES Recast + PATH_SUFFIXES lib +) + +set(RECAST_INCLUDE_DIRS "${RECAST_INCLUDE_DIR}") +set(RECAST_LIBRARIES "${RECAST_LIBRARY}") + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(RECAST DEFAULT_MSG RECAST_LIBRARIES RECAST_INCLUDE_DIRS) + +mark_as_advanced(RECAST_INCLUDE_DIR RECAST_LIBRARY) diff --git a/cmake/Modules/Findflatbuffers.cmake b/cmake/Modules/Findflatbuffers.cmake new file mode 100644 index 000000000000..f6302e53cf07 --- /dev/null +++ b/cmake/Modules/Findflatbuffers.cmake @@ -0,0 +1,32 @@ +#.rst: +# Findflatbuffers +# ------------ +# +# Locate flatbuffers library +# +# This module defines +# +# :: +# +# FLATBUFFERS_LIBRARIES, the library to link against +# FLATBUFFERS_FOUND, the libraries needed to use flatbuffers +# FLATBUFFERS_INCLUDE_DIRS, where to find headers. +# + +find_path(FLATBUFFERS_INCLUDE_DIR + NAMES flatbuffers.h + PATH_SUFFIXES include include/flatbuffers +) + +find_library(FLATBUFFERS_LIBRARY + NAMES flatbuffers + PATH_SUFFIXES lib +) + +set(FLATBUFFERS_INCLUDE_DIRS "${FLATBUFFERS_INCLUDE_DIR}") +set(FLATBUFFERS_LIBRARIES "${FLATBUFFERS_LIBRARY}") + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(FLATBUFFERS DEFAULT_MSG FLATBUFFERS_LIBRARIES FLATBUFFERS_INCLUDE_DIRS) + +mark_as_advanced(FLATBUFFERS_INCLUDE_DIR FLATBUFFERS_LIBRARY) diff --git a/cmake/Modules/Findxxhash.cmake b/cmake/Modules/Findxxhash.cmake new file mode 100644 index 000000000000..034a69486441 --- /dev/null +++ b/cmake/Modules/Findxxhash.cmake @@ -0,0 +1,32 @@ +#.rst: +# Findxxhash +# ------------ +# +# Locate xxhash library +# +# This module defines +# +# :: +# +# XXHASH_LIBRARIES, the library to link against +# XXHASH_FOUND, the libraries needed to use flatbuffers +# XXHASH_INCLUDE_DIRS, where to find headers. +# + +find_path(XXHASH_INCLUDE_DIR + NAMES xxhash.h xxhash.h + PATH_SUFFIXES include include/xxhash +) + +find_library(XXHASH_LIBRARY + NAMES xxhash + PATH_SUFFIXES lib +) + +set(XXHASH_INCLUDE_DIRS "${XXHASH_INCLUDE_DIR}") +set(XXHASH_LIBRARIES "${XXHASH_LIBRARY}") + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(XXHASH DEFAULT_MSG XXHASH_LIBRARIES XXHASH_INCLUDE_DIRS) + +mark_as_advanced(XXHASH_INCLUDE_DIR XXHASH_LIBRARY)