CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #
  2. # Copyright (c) 2008-2014 the Urho3D 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. # Define target name
  23. set (TARGET_NAME LuaScript)
  24. # Optionally enable Lua / C++ wrapper safety checks
  25. if (NOT URHO3D_SAFE_LUA)
  26. add_definitions (-DTOLUA_RELEASE)
  27. endif ()
  28. # The host tool must be built natively and would be used when cross-compiling
  29. if (CMAKE_CROSSCOMPILING OR IOS)
  30. execute_process (COMMAND ${PROJECT_ROOT_DIR}/Bin/tolua++ -v RESULT_VARIABLE TOLUA_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
  31. if (NOT TOLUA_EXIT_CODE EQUAL 0)
  32. message (WARNING "For cross-compiling build to be successful, the 'tolua++' tool must be built natively first and present in the 'Bin' folder." )
  33. endif ()
  34. else ()
  35. add_subdirectory (../../ThirdParty/toluapp/src/bin ../../ThirdParty/toluapp/src/bin)
  36. set (TOLUADEP tolua++)
  37. endif ()
  38. # Define generated source files
  39. file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated)
  40. file (GLOB API_PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/*.pkg)
  41. # Remove NavigationLuaAPI.pkg
  42. if (NOT URHO3D_NAVIGATION)
  43. list (REMOVE_ITEM API_PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/NavigationLuaAPI.pkg)
  44. endif ()
  45. # Remove NetworkLuaAPI.pkg
  46. if (NOT URHO3D_NETWORK)
  47. list (REMOVE_ITEM API_PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/NetworkLuaAPI.pkg)
  48. endif ()
  49. # Remove PhysicsLuaAPI.pkg
  50. if (NOT URHO3D_PHYSICS)
  51. list (REMOVE_ITEM API_PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/PhysicsLuaAPI.pkg)
  52. endif ()
  53. # Remove Urho2DLuaAPI.pkg
  54. if (NOT URHO3D_URHO2D)
  55. list (REMOVE_ITEM API_PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/Urho2DLuaAPI.pkg)
  56. endif ()
  57. foreach (API_PKG_FILE ${API_PKG_FILES})
  58. get_filename_component (NAME ${API_PKG_FILE} NAME)
  59. string (REGEX REPLACE LuaAPI\\.pkg$ "" API ${NAME})
  60. set (GEN_CPP_FILE generated/${API}LuaAPI.cpp)
  61. set (GEN_CPP_FILES ${GEN_CPP_FILES} ${GEN_CPP_FILE})
  62. file (GLOB PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/${API}/*.pkg)
  63. add_custom_command (OUTPUT ${GEN_CPP_FILE}
  64. COMMAND ${PROJECT_ROOT_DIR}/Bin/tolua++ -L ToCppHook.lua -o ${CMAKE_CURRENT_BINARY_DIR}/${GEN_CPP_FILE} ${NAME}
  65. DEPENDS ${TOLUADEP} ${API_PKG_FILE} ${PKG_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/ToCppHook.lua
  66. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pkgs
  67. COMMENT "Generating tolua++ API binding on the fly for ${API}")
  68. endforeach ()
  69. # Define source files
  70. define_source_files (EXTRA_CPP_FILES ${GEN_CPP_FILES})
  71. install (FILES ${H_FILES} DESTINATION ${DEST_INCLUDE_DIR})
  72. # Define dependency libs
  73. set (LIBS ../../ThirdParty/Lua${JIT}/src)
  74. set (LINK_LIBS_ONLY toluapp)
  75. set (INCLUDE_DIRS_ONLY . .. ../Audio ../Container ../Core ../Engine ../Graphics ../Input ../IO ../Math ../Navigation ../Resource ../Scene ../UI
  76. ../../ThirdParty/SDL/include ../../ThirdParty/toluapp/include ${CMAKE_BINARY_DIR}/Engine)
  77. if (URHO3D_NAVIGATION)
  78. set (INCLUDE_DIRS_ONLY ${INCLUDE_DIRS_ONLY} ../Navigation)
  79. endif ()
  80. if (URHO3D_NETWORK)
  81. set (INCLUDE_DIRS_ONLY ${INCLUDE_DIRS_ONLY} ../Network ../../ThirdParty/kNet/include)
  82. endif ()
  83. if (URHO3D_PHYSICS)
  84. set (INCLUDE_DIRS_ONLY ${INCLUDE_DIRS_ONLY} ../Physics ../../ThirdParty/Bullet/src)
  85. endif ()
  86. if (URHO3D_URHO2D)
  87. set (INCLUDE_DIRS_ONLY ${INCLUDE_DIRS_ONLY} ../Urho2D ../../ThirdParty/Box2D)
  88. endif ()
  89. # Setup target
  90. setup_library ()