Advertisement
vivienneanthony

Find My Engine STD

Nov 5th, 2015
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 8.22 KB | None
  1. #
  2. # Copyright (c) 2008-2015 the ENGINESTD project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22.  
  23. # Find ENGINESTD include directories and library in source & build tree or installed ENGINESTD SDK.
  24. #
  25. #  ENGINESTD_FOUND
  26. #  ENGINESTD_INCLUDE_DIRS
  27. #  ENGINESTD_LIBRARIES
  28. #  ENGINESTD_LIBRARIES_REL (WIN32 only)
  29. #  ENGINESTD_LIBRARIES_DBG (WIN32 only)
  30. #  ENGINESTD_DLL (WIN32 only)
  31. #  ENGINESTD_DLL_REL (WIN32 only)
  32. #  ENGINESTD_DLL_DBG (WIN32 only)
  33. #
  34. #
  35. # For internal ENGINESTD project, the ENGINESTD "build tree" path is already known.
  36. #
  37. # For external project that attempts to use the ENGINESTD build tree or installed ENGINESTD SDK,
  38. # use ENGINESTD_HOME environment variable or build option to specify the path (not needed when the path is a system-wide default location).
  39. # When setting ENGINESTD_HOME variable, it should be set to a parent directory containing both the "include" or "lib" subdirectories.
  40. # For example: set ENGINESTD_HOME=/home/john/usr/local, if the SDK is installed using DESTDIR=/home/john and CMAKE_INSTALL_PREFIX=/usr/local
  41. #
  42.  
  43. if (ENGINESTD_FOUND)
  44.     # All the subprojects should use the same ENGINESTD library, so only need to search on the first (sub)project that requires ENGINESTD library
  45.     return ()
  46. endif ()
  47.  
  48. # If the ENGINESTD_LIB_TYPE build option changes then invalidate the found library cache
  49. if (NOT ENGINESTD_LIB_TYPE STREQUAL ENGINESTD_FOUND_LIB_TYPE)
  50.     unset (ENGINESTD_LIBRARIES CACHE)
  51.     set (ENGINESTD_FOUND_LIB_TYPE ${ENGINESTD_LIB_TYPE} CACHE INTERNAL "Lib type when ENGINESTD library was last found")
  52.  
  53.     # ENGINESTD prefers static library type by default while CMake prefers shared one, so we need to change CMake preference to agree with ENGINESTD
  54.     if (NOT ENGINESTD_LIB_TYPE STREQUAL SHARED)
  55.         list (REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
  56.     endif ()
  57. endif ()
  58.  
  59. # Cater for the shared library extension in Emscripten build has been changed to ".bc"
  60. if (EMSCRIPTEN)
  61.     string (REPLACE .so .bc CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}")   # Stringify for string replacement
  62. endif ()
  63.  
  64. set (PATH_SUFFIX EngineStd)
  65. if (CMAKE_PROJECT_NAME STREQUAL EngineStd)
  66.     if(TARGET EQUAL HangarsClient OR TARGET EQUAL HangarsServer)
  67.         # Library location is already known to be in the build tree
  68.     set (ENGINESTD_HOME ${CMAKE_BINARY_DIR})
  69.     set (ENGINESTD_INCLUDE_DIRS  ${ENGINESTD_HOME}/include/${PATH_SUFFIX})
  70.    
  71.         set (ENGINESTD_LIBRARIES EngineStd)
  72.         set (FOUND_MESSAGE "Found ENGINESTD: as CMake target")
  73.     endif()
  74. else ()
  75.     # Library location would be searched (based on ENGINESTD_HOME variable if provided and in system-wide default location)
  76.     if (NOT ENGINESTD_HOME AND DEFINED ENV{ENGINESTD_HOME})
  77.         file (TO_CMAKE_PATH "$ENV{ENGINESTD_HOME}" ENGINESTD_HOME)
  78.     endif ()
  79.     # ENGINESTD_HOME variable should be an absolute path, so use a non-rooted search even when we are cross-compiling
  80.     if (ENGINESTD_HOME)
  81.         list (APPEND CMAKE_PREFIX_PATH ${ENGINESTD_HOME})
  82.         set (SEARCH_OPT NO_CMAKE_FIND_ROOT_PATH)
  83.     endif ()
  84.     # For Android platform, search in path similar to ANDROID_LIBRARY_OUTPUT_PATH variable
  85.     if (ANDROID)
  86.         if (ENGINESTD_HOME)
  87.             set (ENGINESTD_LIB_SEARCH_HINT HINTS ${ENGINESTD_HOME}/libs/${ANDROID_NDK_ABI_NAME})
  88.         else ()
  89.             set (ENGINESTD_LIB_SEARCH_HINT HINTS /usr/local/libs/${ANDROID_NDK_ABI_NAME})
  90.         endif ()
  91.     endif ()
  92.     if (NOT ENGINESTD_64BIT)
  93.         # For 32-bit, force to search in 'lib' path even when the host system defaulted to use 'lib64'
  94.         set_property (GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
  95.     elseif (WIN32)
  96.         # For 64-bit, force to search in 'lib64' path even when the Windows platform is not defaulted to use it
  97.         set_property (GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
  98.     endif ()
  99.     find_path (ENGINESTD_INCLUDE_DIRS EngineStd.h PATH_SUFFIXES ${PATH_SUFFIX} ${SEARCH_OPT})
  100.     if (ENGINESTD_INCLUDE_DIRS)
  101.         set (BASE_INCLUDE_DIR ${ENGINESTD_INCLUDE_DIRS})   # Preserve the base include dir because the original variable will be turned into a list below
  102.         get_filename_component (PATH ${ENGINESTD_INCLUDE_DIRS} PATH)
  103.         set (ENGINESTD_INCLUDE_DIRS ${PATH} )      
  104.         if (NOT ENGINESTD_HOME)
  105.             # ENGINESTD_HOME is not set when using SDK installed on system-wide default location, so set it now
  106.             get_filename_component (PATH ${PATH} PATH)
  107.             set (ENGINESTD_HOME ${PATH})
  108.         endif ()
  109.     endif ()   
  110.     find_library (ENGINESTD_LIBRARIES NAMES EngineStd ${ENGINESTD_LIB_SEARCH_HINT} PATH_SUFFIXES ${PATH_SUFFIX} ${SEARCH_OPT})
  111.     if (WIN32)
  112.         # For Windows platform, give a second chance to search for a debug version of the library
  113.         find_library (ENGINESTD_LIBRARIES_DBG NAMES EngineStd_d ${ENGINESTD_LIB_SEARCH_HINT} PATH_SUFFIXES ${PATH_SUFFIX} ${SEARCH_OPT})
  114.         # If both the non-debug and debug version of the libraries are found then use them both
  115.         set (ENGINESTD_LIBRARIES_REL ${ENGINESTD_LIBRARIES})
  116.         # Otherwise, ENGINESTD_LIBRARIES variable should have the path to either one of the version
  117.         if (ENGINESTD_LIBRARIES)
  118.             if (ENGINESTD_LIBRARIES_DBG)
  119.                 list (APPEND ENGINESTD_LIBRARIES ${ENGINESTD_LIBRARIES_DBG})
  120.             endif ()
  121.         else ()
  122.             set (ENGINESTD_LIBRARIES ${ENGINESTD_LIBRARIES_DBG})
  123.         endif ()
  124.         # For shared library type, also initialize the ENGINESTD_DLL variable for later use
  125.         if (ENGINESTD_LIB_TYPE STREQUAL SHARED AND ENGINESTD_HOME)
  126.             find_file (ENGINESTD_DLL_REL EngineStd.dll HINTS ${URHO3D_HOME}/bin NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  127.             if (ENGINESTD_DLL_REL)
  128.                 list (APPEND ENGINESTD_DLL ${ENGINESTD_DLL_REL})
  129.             endif ()
  130.             find_file (ENGINESTD_DLL_DBG EngineStd_d.dll HINTS ${URHO3D_HOME}/bin NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
  131.             if (ENGINESTD_DLL_DBG)
  132.                 list (APPEND ENGINESTD_DLL ${ENGINESTD_DLL_DBG})
  133.             endif ()
  134.         endif ()
  135.     endif ()
  136. endif ()
  137.  
  138. if (ENGINESTD_INCLUDE_DIRS AND ENGINESTD_LIBRARIES)
  139.     set (ENGINESTD_FOUND 1)
  140.     if (NOT FOUND_MESSAGE)
  141.         set (FOUND_MESSAGE "Found ENGINESTD: ${ENGINESTD_LIBRARIES}")
  142.     endif ()
  143.     include (FindPackageMessage)
  144.     FIND_PACKAGE_MESSAGE (ENGINESTD ${FOUND_MESSAGE} "[${ENGINESTD_LIBRARIES}][${ENGINESTD_INCLUDE_DIRS}]")
  145.     set (ENGINESTD_HOME ${ENGINESTD_HOME} CACHE PATH "Path to ENGINESTD build tree or SDK installation location (external project only)" FORCE)
  146. elseif (ENGINESTD_FIND_REQUIRED)
  147.     if (ANDROID)
  148.         set (NOT_FOUND_MESSAGE "For Android platform, double check if you have specified to use the same ANDROID_ABI as the ENGINESTD library in the build tree or SDK.")
  149.     endif ()
  150.     message (FATAL_ERROR
  151.         "Could not find ENGINESTD library in ENGINESTD build tree or SDK installation. "
  152.         "Use ENGINESTD_HOME environment variable or build option to specify the location of the build tree or SDK installation. ${NOT_FOUND_MESSAGE}")
  153. endif ()
  154.  
  155. mark_as_advanced (ENGINESTD_INCLUDE_DIRS ENGINESTD_LIBRARIES ENGINESTD_LIBRARIES_REL ENGINESTD_LIBRARIES_DBG ENGINESTD_DLL ENGINESTD_DLL_REL ENGINESTD_DLL_DBG ENGINESTD_HOME)
Advertisement
RAW Paste Data Copied
Advertisement