diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cd48ea..6e825d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,11 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src ) +# Target for header-only usage +add_library(${PROJECT_NAME}_headers INTERFACE) +target_include_directories(${PROJECT_NAME}_headers INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR}/include) + # Test Configuration if(CGLM_USE_TEST) include(CTest) diff --git a/README.md b/README.md index 595812e..c272051 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,24 @@ option(CGLM_USE_C99 "" OFF) # C11 option(CGLM_USE_TEST "Enable Tests" OFF) # for make check - make test ``` +#### Use as header-only library with your CMake project + +This requires no building or installation of cglm. + +* Example: + +``` cmake +cmake_minimum_required(VERSION 3.8.2) + +project() + +add_executable(${PROJECT_NAME} src/main.c) +target_link_libraries(${LIBRARY_NAME} PRIVATE + cglm_headers) + +add_subdirectory(external/cglm/ EXCLUDE_FROM_ALL) +``` + #### Use with your CMake project * Example: ```cmake diff --git a/docs/source/build.rst b/docs/source/build.rst index 84da24d..e2eb23d 100644 --- a/docs/source/build.rst +++ b/docs/source/build.rst @@ -32,6 +32,22 @@ If you don't want to install **cglm** to your system's folder you can get static option(CGLM_USE_C99 "" OFF) # C11 option(CGLM_USE_TEST "Enable Tests" OFF) # for make check - make test +**Use as header-only library with your CMake project example** +This requires no building or installation of cglm. + +.. code-block:: CMake + :linenos: + + cmake_minimum_required(VERSION 3.8.2) + + project() + + add_executable(${PROJECT_NAME} src/main.c) + target_link_libraries(${LIBRARY_NAME} PRIVATE + cglm_headers) + + add_subdirectory(external/cglm/ EXCLUDE_FROM_ALL) + **Use with your CMake project example** .. code-block:: CMake