build.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 as header-only library with your CMake project example**
  26. This requires no building or installation of cglm.
  27. .. code-block:: CMake
  28. :linenos:
  29. cmake_minimum_required(VERSION 3.8.2)
  30. project(<Your Project Name>)
  31. add_executable(${PROJECT_NAME} src/main.c)
  32. target_link_libraries(${LIBRARY_NAME} PRIVATE
  33. cglm_headers)
  34. add_subdirectory(external/cglm/ EXCLUDE_FROM_ALL)
  35. **Use with your CMake project example**
  36. .. code-block:: CMake
  37. :linenos:
  38. cmake_minimum_required(VERSION 3.8.2)
  39. project(<Your Project Name>)
  40. add_executable(${PROJECT_NAME} src/main.c)
  41. target_link_libraries(${LIBRARY_NAME} PRIVATE
  42. cglm)
  43. add_subdirectory(external/cglm/)
  44. Meson (All platforms):
  45. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. .. code-block::
  47. :linenos:
  48. $ meson build # [Optional] --default-library=static
  49. $ cd build
  50. $ ninja
  51. $ sudo ninja install # [Optional]
  52. **Meson Options:**
  53. .. code-block::
  54. :linenos:
  55. c_std=c11
  56. buildtype=release
  57. default_library=shared
  58. enable_tests=false # to run tests: ninja test
  59. **Use with your Meson project**
  60. .. code-block::
  61. :linenos:
  62. # Clone cglm or create a cglm.wrap under <source_root>/subprojects
  63. project('name', 'c')
  64. cglm_dep = dependency('cglm', fallback : 'cglm', 'cglm_dep')
  65. executable('exe', 'src/main.c', dependencies : cglm_dep)
  66. Unix (Autotools):
  67. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. .. code-block:: bash
  69. :linenos:
  70. $ sh autogen.sh
  71. $ ./configure
  72. $ make
  73. $ make check # run tests (optional)
  74. $ [sudo] make install # install to system (optional)
  75. **make** will build cglm to **.libs** sub folder in project folder.
  76. If you don't want to install **cglm** to your system's folder you can get static and dynamic libs in this folder.
  77. Windows (MSBuild):
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. Windows related build files, project files are located in `win` folder,
  80. make sure you are inside in cglm/win folder.
  81. Code Analysis are enabled, it may take awhile to build.
  82. .. code-block:: bash
  83. :linenos:
  84. $ cd win
  85. $ .\build.bat
  86. if *msbuild* is not worked (because of multi versions of Visual Studio)
  87. then try to build with *devenv*:
  88. .. code-block:: bash
  89. :linenos:
  90. $ devenv cglm.sln /Build Release
  91. Currently tests are not available on Windows.
  92. Documentation (Sphinx):
  93. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  94. **cglm** uses sphinx framework for documentation, it allows lot of formats for documentation. To see all options see sphinx build page:
  95. https://www.sphinx-doc.org/en/master/man/sphinx-build.html
  96. Example build:
  97. .. code-block:: bash
  98. :linenos:
  99. $ cd cglm/docs
  100. $ sphinx-build source build