build: Rename CMake flags to new format

Upending UVGRTP to each CMake option makes it less likely to conflict between
other libraries built at the same time. Added also some backwards compatibility
for old options.
This commit is contained in:
Joni Räsänen 2023-05-03 12:43:10 +03:00
parent 03ee03cd07
commit aeaa71e6b4
5 changed files with 35 additions and 17 deletions

View File

@ -28,7 +28,7 @@ cmake ..
Alternatively, if you want to disable Crypto++, use command:
```
cmake -DDISABLE_CRYPTO=1 ..
cmake -DUVGRTP_DISABLE_CRYPTO=1 ..
```
If you are using MinGW for your compilation, add the generate parameter the generate the MinGW build configuration:
@ -107,7 +107,7 @@ You can also use `pkg-config` to get the flags.
It is possible to silence all prints coming from uvgRTP by enabling following parameter:
```
cmake -DDISABLE_PRINTS=1 ..
cmake -DUVGRTP_DISABLE_PRINTS=1 ..
```
## Allow compiler warnings by disabling Werror
@ -115,7 +115,7 @@ cmake -DDISABLE_PRINTS=1 ..
If the compiler warnings are causing your build to fail without you making any modifications, you may use this option to disable the `-Werror`-flag:
```
cmake -DDISABLE_WERROR=1 ..
cmake -DUVGRTP_DISABLE_WERROR=1 ..
```
Creation of an issue on Github that describes these warnings is also appreciated.
@ -125,7 +125,7 @@ Creation of an issue on Github that describes these warnings is also appreciated
By default, uvgRTP configures both examples and tests as additional targets to build. If this is undesirable, you can disable their configuration with following CMake parameters:
```
cmake -DUVGRTP_DISABLE_TESTS=1 -UVGRTP_DISABLE_EXAMPLES=1 ..
cmake -DUVGRTP_DISABLE_TESTS=1 -DUVGRTP_DISABLE_EXAMPLES=1 ..
```
## Release commit (for devs)
@ -133,6 +133,6 @@ cmake -DUVGRTP_DISABLE_TESTS=1 -UVGRTP_DISABLE_EXAMPLES=1 ..
The release commit can be specified in CMake. This slightly changes how the version is printed. This feature is mostly useful for distributing release versions. Use the following command:
```
cmake -DRELEASE_COMMIT=1 ..
cmake -DUVGRTP_RELEASE_COMMIT=1 ..
```

View File

@ -16,14 +16,33 @@ project(uvgrtp
include(GNUInstallDirs)
option(DISABLE_CRYPTO "Do not build uvgRTP with crypto enabled" OFF)
option(DISABLE_PRINTS "Do not print anything from uvgRTP" OFF)
option(DISABLE_WERROR "Ignore compiler warnings" OFF)
option(UVGRTP_DISABLE_CRYPTO "Do not build uvgRTP with crypto enabled" OFF)
option(UVGRTP_DISABLE_PRINTS "Do not print anything from uvgRTP" OFF)
option(UVGRTP_DISABLE_WERROR "Ignore compiler warnings" OFF)
option(UVGRTP_DISABLE_TESTS "Do not build unit tests" OFF)
option(UVGRTP_DISABLE_EXAMPLES "Do not build examples" OFF)
option(UVGRTP_DOWNLOAD_CRYPTO "Download headers for Crypto++ if they are missing" OFF)
option(UVGRTP_RELEASE_COMMIT "Explicitly say that this is a release version in version prints" OFF)
# obsolete, do not use
option(DISABLE_CRYPTO "Do not build uvgRTP with crypto enabled" OFF)
option(DISABLE_PRINTS "Do not print anything from uvgRTP" OFF)
option(DISABLE_WERROR "Ignore compiler warnings" OFF)
# offer some backwards compatibility for old flags
if (DISABLE_CRYPTO)
set(UVGRTP_DISABLE_CRYPTO ON)
endif()
if (DISABLE_PRINTS)
set(UVGRTP_DISABLE_PRINTS ON)
endif()
if (DISABLE_WERROR)
set(UVGRTP_DISABLE_WERROR ON)
endif()
include(cmake/FindDependencies.cmake)
include(cmake/Versioning.cmake)
@ -168,19 +187,19 @@ endif()
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /Zc:__cplusplus /W4)
else()
if (DISABLE_WERROR)
if (UVGRTP_DISABLE_WERROR)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
else ()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
endif()
if (DISABLE_CRYPTO)
if (UVGRTP_DISABLE_CRYPTO)
list(APPEND UVGRTP_CXX_FLAGS "-D__RTP_NO_CRYPTO__")
target_compile_definitions(${PROJECT_NAME} PRIVATE __RTP_NO_CRYPTO__)
endif()
if (DISABLE_PRINTS)
if (UVGRTP_DISABLE_PRINTS)
list(APPEND UVGRTP_CXX_FLAGS "-D__RTP_SILENT__")
target_compile_definitions(${PROJECT_NAME} PRIVATE __RTP_SILENT__)
endif()
@ -218,7 +237,7 @@ if (UNIX)
endif(NOT DEFINED ENV{PKG_CONFIG_PATH})
# Find crypto++
if(NOT DISABLE_CRYPTO)
if(NOT UVGRTP_DISABLE_CRYPTO)
pkg_search_module(CRYPTOPP libcrypto++ cryptopp)
if(CRYPTOPP_FOUND)
list(APPEND UVGRTP_CXX_FLAGS ${CRYPTOPP_CFLAGS_OTHER})

View File

@ -17,8 +17,7 @@ if(uvgrtp_GIT_HASH)
SET(uvgrtp_GIT_HASH "${uvgrtp_GIT_HASH}")
endif()
option(RELEASE_COMMIT "Create a release version" OFF)
if(RELEASE_COMMIT)
if(UVGRTP_RELEASE_COMMIT)
set (LIBRARY_VERSION ${PROJECT_VERSION})
elseif(uvgrtp_GIT_HASH)
set (LIBRARY_VERSION ${PROJECT_VERSION} + "-" + ${uvgrtp_GIT_HASH})
@ -36,7 +35,7 @@ target_include_directories(${PROJECT_NAME}_version
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
)
if (RELEASE_COMMIT)
if (UVGRTP_RELEASE_COMMIT)
target_compile_definitions(${PROJECT_NAME}_version PRIVATE RTP_RELEASE_COMMIT)
endif()

View File

@ -30,7 +30,7 @@ target_sources(sync_sender PRIVATE sync_sender.cc)
target_sources(sync_receiver PRIVATE sync_receiver.cc)
# set crypto++ to be linked in examples if available
if (NOT DISABLE_CRYPTO AND CRYPTOPP_FOUND)
if (NOT UVGRTP_DISABLE_CRYPTO AND CRYPTOPP_FOUND)
if(MSVC)
set(CRYPTOPP_LIB_NAME "cryptlib")
else()

View File

@ -19,7 +19,7 @@ target_sources(${PROJECT_NAME} PRIVATE
target_include_directories(${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>)
# set crypto++ to be linked in tests if available
if (NOT DISABLE_CRYPTO AND CRYPTOPP_FOUND)
if (NOT UVGRTP_DISABLE_CRYPTO AND CRYPTOPP_FOUND)
if(MSVC)
set(CRYPTOPP_LIB_NAME "cryptlib")
else()