From ca782d922c07edd89225fd21ceca8bfff164c78c Mon Sep 17 00:00:00 2001 From: "Amine B. Hassouna" Date: Sun, 3 Feb 2019 23:08:47 +0100 Subject: [PATCH] Add 'Usage' section in README.md --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 8fd63e0..1cf38cc 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,53 @@ The improvements made to these modules are as follows: *For more details, please see the embedded documentation in `FindSDL2_.cmake` file.* +## Usage + +There is two approaches that can be adopted: A legacy approach and a modern +approach. Both of them are supported. + +### Modern CMake + +We can link to the SDL2:: targets like the following example:
+*This example requires the SDL2, SDL2_image and the SDL2_gfx libraries* + +```cmake +# Find SDL2, SDL2_image and SDL2_gfx libraries +find_package(SDL2 REQUIRED) +find_package(SDL2_image REQUIRED) +find_package(SDL2_gfx REQUIRED) + +# Link SDL2::Main, SDL2::Image and SDL2::GFX to our project +target_link_libraries(${PROJECT_NAME} SDL2::Main SDL2::Image SDL2::GFX) +``` + +*Use the appropriate packages for you project.*
+*Please see above, for the whole list of packages*
+*For more details, please see the embedded documentation in modules files* + +### Legacy CMake + +We can also specify manually the include directories and libraries to link to: + +```cmake +# Find and link SDL2 +find_package(SDL2 REQUIRED) +target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES}) + +# Find and link SDL2_image +find_package(SDL2_image REQUIRED) +target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_IMAGE_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} ${SDL2_IMAGE_LIBRARIES}) + +# Find and link SDL2_gfx +find_package(SDL2_gfx REQUIRED) +target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_GFX_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} ${SDL2_GFX_LIBRARIES}) + +``` + +*For more details, please see the embedded documentation in modules files* ## Special customization variables