CMakeLists.txt 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #
  2. # Copyright (c) 2008-2013 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. # Enable Lua / C++ wrapper safety checks by default. These can be disabled for performance
  25. if (NOT DEFINED ENABLE_SAFE_LUA)
  26. set (ENABLE_SAFE_LUA 1)
  27. endif ()
  28. if (NOT ENABLE_SAFE_LUA)
  29. add_definitions (-DTOLUA_RELEASE)
  30. endif ()
  31. # Define source files
  32. file (GLOB CPP_FILES *.cpp)
  33. file (GLOB H_FILES *.h)
  34. set (SOURCE_FILES ${CPP_FILES} ${H_FILES})
  35. # Define generated source files
  36. file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated)
  37. file (GLOB API_PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/*.pkg)
  38. foreach (API_PKG_FILE ${API_PKG_FILES})
  39. get_filename_component (NAME ${API_PKG_FILE} NAME)
  40. string (REGEX REPLACE LuaAPI\\.pkg$ "" API ${NAME})
  41. set (GEN_CPP_FILE generated/${API}LuaAPI.cpp)
  42. set (GEN_CPP_FILES ${GEN_CPP_FILES} ${GEN_CPP_FILE})
  43. file (GLOB PKG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgs/${API}/*.pkg)
  44. add_custom_command (OUTPUT ${GEN_CPP_FILE}
  45. COMMAND ${PROJECT_ROOT_DIR}/Bin/tolua++ -L basic.lua -o ${CMAKE_CURRENT_BINARY_DIR}/${GEN_CPP_FILE} ${NAME} DEPENDS ${API_PKG_FILE} ${PKG_FILES}
  46. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pkgs
  47. COMMENT "Generating tolua++ API binding on the fly for ${API}")
  48. endforeach ()
  49. set (SOURCE_FILES ${SOURCE_FILES} ${GEN_CPP_FILES})
  50. # Define dependency libs
  51. set (LIBS ../../Engine/Audio ../../Engine/Container ../../Engine/Core ../../Engine/Engine ../../Engine/Graphics ../../Engine/Input ../../Engine/IO ../../Engine/Math ../../Engine/Navigation ../../Engine/Network
  52. ../../Engine/Physics ../../Engine/Resource ../../Engine/Scene ../../Engine/UI ../../ThirdParty/Lua/src)
  53. set (LINK_LIBS_ONLY tolua++_static)
  54. set (INCLUDE_DIRS_ONLY . ../../ThirdParty/Bullet/src ../../ThirdParty/kNet/include ../../ThirdParty/tolua++/include)
  55. # Setup target
  56. enable_pch ()
  57. setup_library ()
  58. # For IOS, Android, and Raspberry-Pi cross-compiling build to be successful, the "tolua++" tool must be already present in the "Bin" folder
  59. # One way to achieve this is to first do a native desktop build where all the tools would be generated, then switch to IOS/Android/Raspberry-Pi cross-compiling build
  60. # Intentionally do not include NOT RASPI in the condition below because the dependency is still required for Raspberry Pi native build
  61. if (NOT IOS AND NOT ANDROID)
  62. # Add dependency to the "tolua++" bin tool
  63. add_dependencies (${TARGET_NAME} tolua++)
  64. endif ()