CMakeLists.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. cmake_minimum_required(VERSION 3.10...3.17)
  2. #[=======================================================================[.rst:
  3. CMake Version requirements
  4. --------------------------
  5. To enable use of the emscripten emsdk hack for pseudo shared library support
  6. without polluting options for consumers we need to use the
  7. CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE which was introduced in version 3.17
  8. For more information check cmake/emsdkHack.cmake
  9. SCons Compatibility
  10. -------------------
  11. There is an understandable conflict between build systems as they define
  12. similar concepts in different ways. When there isn't a 1:1 relationship,
  13. compromises need to be made to resolve those differences.
  14. As we are attempting to maintain feature parity, and ease of maintenance, these
  15. CMake scripts are built to resemble the SCons build system wherever possible.
  16. Where they are not, we will attempt to document common difference in
  17. doc/cmake.rst and platform specific differences in their respective
  18. cmake/<platform>.cmake file.
  19. The file structure and file content are made to match, if not in content then
  20. in spirit. The closer the two build systems look the easier they will be to
  21. maintain.
  22. Where the SCons additional scripts in the tools directory, The CMake scripts
  23. are in the cmake directory.
  24. For example; the tools/godotcpp.py is matched by the cmake/godotcpp.cmake file
  25. .. highlight:: python
  26. cpp_tool = Tool("godotcpp", toolpath=["tools"])
  27. cpp_tool.options(opts, env)
  28. The CMake equivalent is below.
  29. ]=======================================================================]
  30. include(cmake/godotcpp.cmake)
  31. godotcpp_options()
  32. #[[ People are compiling godot by itself and expecting template_debug
  33. Replace this with PROJECT_IS_TOP_LEVEL, <PROJECT-NAME>_IS_TOP_LEVEL when minimum reaches 3.21
  34. ]]
  35. if(NOT PROJECT_NAME)
  36. set(GODOTCPP_IS_TOP_LEVEL ON)
  37. endif()
  38. # Define our project.
  39. project(
  40. godot-cpp
  41. VERSION 4.4
  42. DESCRIPTION "C++ bindings for the Godot Engine's GDExtensions API."
  43. HOMEPAGE_URL "https://github.com/godotengine/godot-cpp"
  44. LANGUAGES CXX
  45. )
  46. compiler_detection()
  47. godotcpp_generate()
  48. # Conditionally enable the godot-cpp.test.<target> integration testing targets
  49. if(GODOTCPP_ENABLE_TESTING)
  50. add_subdirectory(test)
  51. endif()
  52. #[[ If this is the top level CMakeLists.txt, Generators which honor the
  53. USE_FOLDERS flag will organize godot-cpp targets under a subfolder named
  54. 'godot-cpp'. This is enable by default from CMake version 3.26 ]]
  55. set_property(GLOBAL PROPERTY USE_FOLDERS ON)