build.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. Build cglm
  2. ================================
  3. | **cglm** does not have any external dependencies.
  4. **NOTE:**
  5. If you only need to inline versions, you don't need to build **cglm**, you don't need to link it to your program.
  6. Just import cglm to your project as dependency / external lib by copy-paste then use it as usual
  7. CMake (All platforms):
  8. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. .. code-block:: bash
  10. :linenos:
  11. $ mkdir build
  12. $ cd build
  13. $ cmake .. # [Optional] -DCGLM_SHARED=ON
  14. $ make
  15. $ sudo make install # [Optional]
  16. **make** will build cglm to **build** folder.
  17. If you don't want to install **cglm** to your system's folder you can get static and dynamic libs in this folder.
  18. **CMake Options:**
  19. .. code-block:: CMake
  20. :linenos:
  21. option(CGLM_SHARED "Shared build" ON)
  22. option(CGLM_STATIC "Static build" OFF)
  23. option(CGLM_USE_C99 "" OFF) # C11
  24. option(CGLM_USE_TEST "Enable Tests" OFF) # for make check - make test
  25. **Use with your CMake project example**
  26. .. code-block:: CMake
  27. :linenos:
  28. cmake_minimum_required(VERSION 3.8.2)
  29. project(<Your Project Name>)
  30. add_executable(${PROJECT_NAME} src/main.c)
  31. target_link_libraries(${LIBRARY_NAME} PRIVATE
  32. cglm)
  33. add_subdirectory(external/cglm/)
  34. Meson (All platforms):
  35. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. .. code-block::
  37. :linenos:
  38. $ meson build # [Optional] --default-library=static
  39. $ cd build
  40. $ ninja
  41. $ sudo ninja install # [Optional]
  42. **Meson Options:**
  43. .. code-block::
  44. :linenos:
  45. c_std=c11
  46. buildtype=release
  47. default_library=shared
  48. enable_tests=false # to run tests: ninja test
  49. **Use with your Meson project**
  50. .. code-block::
  51. :linenos:
  52. # Clone cglm or create a cglm.wrap under <source_root>/subprojects
  53. project('name', 'c')
  54. cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep')
  55. executable('exe', 'src/main.c', dependencies : cglm_dep)
  56. Unix (Autotools):
  57. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  58. .. code-block:: bash
  59. :linenos:
  60. $ sh autogen.sh
  61. $ ./configure
  62. $ make
  63. $ make check # run tests (optional)
  64. $ [sudo] make install # install to system (optional)
  65. **make** will build cglm to **.libs** sub folder in project folder.
  66. If you don't want to install **cglm** to your system's folder you can get static and dynamic libs in this folder.
  67. Windows (MSBuild):
  68. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69. Windows related build files, project files are located in `win` folder,
  70. make sure you are inside in cglm/win folder.
  71. Code Analysis are enabled, it may take awhile to build.
  72. .. code-block:: bash
  73. :linenos:
  74. $ cd win
  75. $ .\build.bat
  76. if *msbuild* is not worked (because of multi versions of Visual Studio)
  77. then try to build with *devenv*:
  78. .. code-block:: bash
  79. :linenos:
  80. $ devenv cglm.sln /Build Release
  81. Currently tests are not available on Windows.
  82. Documentation (Sphinx):
  83. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84. **cglm** uses sphinx framework for documentation, it allows lot of formats for documentation. To see all options see sphinx build page:
  85. https://www.sphinx-doc.org/en/master/man/sphinx-build.html
  86. Example build:
  87. .. code-block:: bash
  88. :linenos:
  89. $ cd cglm/docs
  90. $ sphinx-build source build