README.md: Make CMake config mode example more clear

This commit is contained in:
Sebastian Pipping 2021-05-22 15:29:58 +02:00
parent caaf43470d
commit 100bc7072c

View file

@ -45,7 +45,7 @@ This approach leverages CMake's own [module `FindEXPAT`](https://cmake.org/cmake
Notice the *uppercase* `EXPAT` in the following example:
```cmake
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.0) # or 3.10, see below
project(hello VERSION 1.0.0)
@ -55,12 +55,12 @@ add_executable(hello
hello.c
)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10")
target_link_libraries(hello PUBLIC EXPAT::EXPAT)
else()
target_include_directories(hello PRIVATE ${EXPAT_INCLUDE_DIRS})
target_link_libraries(hello PUBLIC ${EXPAT_LIBRARIES})
endif()
# a) for CMake >=3.10 (see CMake's FindEXPAT docs)
target_link_libraries(hello PUBLIC EXPAT::EXPAT)
# b) for CMake >=3.0
target_include_directories(hello PRIVATE ${EXPAT_INCLUDE_DIRS})
target_link_libraries(hello PUBLIC ${EXPAT_LIBRARIES})
```
### b) Config Mode