diff --git a/CMakeLists.txt b/CMakeLists.txt index dbecb56..88a085b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,20 +4,22 @@ project(plug VERSION 1.4.3) message(STATUS "~~~ ${PROJECT_NAME} v${PROJECT_VERSION} ~~~") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -option(UNITTEST "Build Unit Tests" ON) -message(STATUS "Unit Tests : ${UNITTEST}") +option(PLUG_UNITTEST "Build Unit Tests" ON) +message(STATUS "Unit Tests : ${PLUG_UNITTEST}") -option(COVERAGE "Enable Coverage" OFF) -message(STATUS "Coverage : ${COVERAGE}") +option(PLUG_COVERAGE "Enable Coverage" OFF) +message(STATUS "Coverage : ${PLUG_COVERAGE}") -option(LTO "Enable LTO" OFF) -message(STATUS "LTO : ${LTO}") +option(PLUG_LTO "Enable LTO" OFF) +message(STATUS "LTO : ${PLUG_LTO}") -option(SANITIZER_ASAN "Enable ASan" OFF) -message(STATUS "ASan : ${SANITIZER_ASAN}") +option(PLUG_SANITIZER_ASAN "Enable ASan" OFF) +message(STATUS "ASan : ${PLUG_SANITIZER_ASAN}") -option(SANITIZER_UBSAN "Enable UBSan" OFF) -message(STATUS "UBSan : ${SANITIZER_UBSAN}") +option(PLUG_SANITIZER_UBSAN "Enable UBSan" OFF) +message(STATUS "UBSan : ${PLUG_SANITIZER_UBSAN}") + +include(DeprecatedOptions) if( CMAKE_BUILD_TYPE ) @@ -28,11 +30,11 @@ endif() include(GNUInstallDirs) -if( LTO ) +if( PLUG_LTO ) include(LTO) endif() -if( COVERAGE ) +if( PLUG_COVERAGE ) include(Coverage) endif() @@ -65,7 +67,7 @@ include_directories("include") add_subdirectory(src) -if( UNITTEST ) +if( PLUG_UNITTEST ) enable_testing() add_subdirectory("test") endif() diff --git a/cmake/DeprecatedOptions.cmake b/cmake/DeprecatedOptions.cmake new file mode 100644 index 0000000..55331f0 --- /dev/null +++ b/cmake/DeprecatedOptions.cmake @@ -0,0 +1,15 @@ + +function(deprecate_options) + foreach (arg IN LISTS ARGN) + if (DEFINED ${arg}) + message(WARNING "Option ${arg} is deprecated, please use PLUG_${arg} instead, value will be ignored!") + endif() + endforeach() +endfunction() + +deprecate_options(UNITTEST + COVERAGE + LTO + SANITIZER_ASAN + SANITIZER_UBSAN + ) diff --git a/cmake/Sanitizer.cmake b/cmake/Sanitizer.cmake index 8678797..c10b09d 100644 --- a/cmake/Sanitizer.cmake +++ b/cmake/Sanitizer.cmake @@ -8,11 +8,11 @@ macro(enable_sanitizer san) endmacro() -if( SANITIZER_ASAN ) +if( PLUG_SANITIZER_ASAN ) enable_sanitizer(address) endif() -if( SANITIZER_UBSAN ) +if( PLUG_SANITIZER_UBSAN ) enable_sanitizer(undefined) endif() diff --git a/script/ci_build.sh b/script/ci_build.sh index ec3d3bc..35536da 100755 --- a/script/ci_build.sh +++ b/script/ci_build.sh @@ -10,13 +10,13 @@ for arg in "$@" do case "${arg}" in -asan) - BUILD_ARGS+=("-DSANITIZER_ASAN=ON") + BUILD_ARGS+=("-DPLUG_SANITIZER_ASAN=ON") ;; -ubsan) - BUILD_ARGS+=("-DSANITIZER_UBSAN=ON") + BUILD_ARGS+=("-DPLUG_SANITIZER_UBSAN=ON") ;; -cov) - BUILD_ARGS+=("-DCOVERAGE=ON") + BUILD_ARGS+=("-DPLUG_COVERAGE=ON") COVERAGE=true; BUILD_TYPE="Debug" apt-get install -y --no-install-recommends python3-pip python3-pkg-resources python3-setuptools