Commit 7e2be4c9 authored by Ghislain MARY's avatar Ghislain MARY

Handle strict compilation options with CMake.

parent 91ea725e
......@@ -37,6 +37,7 @@ set(VERSION "${PACKAGE_VERSION}")
option(ENABLE_RTP_MAP_ALWAYS_IN_SDP "Always include rtpmap in SDP." OFF)
option(ENABLE_SERVER_SOCKETS "Enable server sockets" ON)
option(ENABLE_STATIC "Build static library (default is shared library)." OFF)
option(ENABLE_STRICT "Build with strict compile options." YES)
option(ENABLE_TLS "Enable TLS support" ON)
option(ENABLE_TUNNEL "Enable tunnel support" OFF)
option(ENABLE_TESTS "Enable compilation of tests" ON)
......@@ -157,14 +158,25 @@ if(MSVC)
include_directories(${MSVC_INCLUDE_DIR})
endif()
add_definitions(-DHAVE_CONFIG_H)
add_definitions("-DHAVE_CONFIG_H")
set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_C )
if(NOT MSVC)
add_definitions(-Wall -Wno-error=unknown-pragmas)
list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_definitions(-Werror -Wno-error=unknown-warning-option -Qunused-arguments -Wno-tautological-compare)
list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-builtin-requires-header" "-Wno-unused-function" "-Wno-gnu-designator" "-Wno-array-bounds")
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_definitions(-Werror -Wno-error=pragmas)
list(APPEND STRICT_OPTIONS_CPP "-Wno-error=pragmas")
endif()
if(APPLE)
list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds")
endif()
if(ENABLE_STRICT)
list(APPEND STRICT_OPTIONS_CPP "-Werror" "-Wno-error=unknown-pragmas" "-Wuninitialized" "-fno-strict-aliasing")
list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement")
endif()
list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
list(REMOVE_DUPLICATES STRICT_OPTIONS_C)
endif()
set(LINK_FLAGS )
if(APPLE)
......
......@@ -166,6 +166,7 @@ if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
endif()
target_include_directories(bellesip PUBLIC ${INCLUDES})
target_link_libraries(bellesip ${LIBS})
target_compile_options(bellesip PRIVATE ${STRICT_OPTIONS_CPP} ${STRICT_OPTIONS_C})
install(TARGETS bellesip EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION bin
......
......@@ -51,6 +51,7 @@ if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
endif()
target_include_directories(belle_sip_tester PUBLIC ${CUNIT_INCLUDE_DIR} PRIVATE common)
target_link_libraries(belle_sip_tester ${CUNIT_LIBRARIES} bellesip)
target_compile_options(belle_sip_tester PRIVATE ${STRICT_OPTIONS_CPP} ${STRICT_OPTIONS_C})
add_test(NAME belle_sip_tester COMMAND belle_sip_tester --verbose)
......@@ -61,6 +62,7 @@ if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
set_target_properties(belle_sip_object_describe PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
endif()
target_link_libraries(belle_sip_object_describe bellesip)
target_compile_options(belle_sip_object_describe PRIVATE ${STRICT_OPTIONS_CPP} ${STRICT_OPTIONS_C})
set(PARSE_SOURCES parse.c)
......@@ -70,3 +72,4 @@ if(NOT "${LINK_FLAGS_STR}" STREQUAL "")
set_target_properties(belle_sip_parse PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}")
endif()
target_link_libraries(belle_sip_parse bellesip)
target_compile_options(belle_sip_parse PRIVATE ${STRICT_OPTIONS_CPP} ${STRICT_OPTIONS_C})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment