Skip to content

Commit

Permalink
Add Azure Pipelines to CI targets that support -Werror
Browse files Browse the repository at this point in the history
So we find errors potential issues faster.

but - on some of the build machines check_symbol causes issues with
-Werror, so make sure it's off when we use that.

Signed-off-by: Robin Getz <robin.getz@analog.com>
  • Loading branch information
rgetz authored and pcercuei committed Feb 21, 2022
1 parent 163f9a5 commit b370c44
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CI/travis/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ INSIDE_DOCKER_BUILD_DIR=/docker_build_dir
#
# If these nothing should be passed, then clear or
#'unset INSIDE_DOCKER_TRAVIS_CI_ENV' after this script is included
INSIDE_DOCKER_TRAVIS_CI_ENV="TRAVIS TRAVIS_COMMIT TRAVIS_PULL_REQUEST OS_TYPE OS_VERSION ARTIFACTNAME"
INSIDE_DOCKER_TRAVIS_CI_ENV="TF_BUILD TRAVIS TRAVIS_COMMIT TRAVIS_PULL_REQUEST OS_TYPE OS_VERSION ARTIFACTNAME"

COMMON_SCRIPTS="inside_docker.sh"

Expand Down
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,12 @@ endif()
# make sure all check_symbol_exists are before this point, otherwise they fail
# on some versions of compilers
if (MSVC)
if(DEFINED ENV{CI} AND DEFINED ENV{APPVEYOR})
message(STATUS "Running in an AppVeyor environment, setting -Werror")
# why can't different CIs use the same flags?
# Travis CI : CI=True & TRAVIS=True
# Appveyor : CI=True & APPVEYOR=True
# Azure Pipelines: TF_BUILD=True
if(DEFINED ENV{TF_BUILD} OR (DEFINED ENV{CI} AND DEFINED ENV{APPVEYOR}))
message(STATUS "Running in an Azure or AppVeyor environment, setting -Werror")
add_compile_options(/WX)
endif()
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
Expand All @@ -181,10 +185,13 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
if(DEFINED ENV{CI} AND (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR}))
message(STATUS "Running in CI environment (Travis or AppVeyor), setting -Werror")
if(DEFINED ENV{TF_BUILD} OR (DEFINED ENV{CI} AND (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR})))
message(STATUS "Running in CI environment (Azure, Travis or AppVeyor), setting -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
else()
message(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}")
message(STATUS "GCC ${CMAKE_COMPILER_IS_GNUCC}")
endif()

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Expand Down
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ if (PTHREAD_LIBRARIES
set(TEMP1 ${CMAKE_REQUIRED_INCLUDES})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CURSES_LIBRARY} ${CDK_LIBRARY})
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBCKD_INCLUDE_DIR})
set(TMP_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "")
check_symbol_exists(CDK_CSTRING2 "cdk.h" HAS_CDK_CSTRING2)
set(CMAKE_C_FLAGS "${TMP_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES ${TEMP})
set(CMAKE_REQUIRED_INCLUDES ${TEMP1})
endif()
Expand Down
3 changes: 3 additions & 0 deletions iiod/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARIES})
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
set(TMP_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "")
check_symbol_exists(pthread_setname_np "pthread.h" HAS_PTHREAD_SETNAME_NP)
set(CMAKE_C_FLAGS "${TMP_FLAGS}")
set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_DEFINITIONS)

Expand Down

0 comments on commit b370c44

Please sign in to comment.