mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 08:39:20 +00:00
Handle strict compilation flags when building with CMake.
This commit is contained in:
parent
e1477de9ff
commit
7f2a985d84
6 changed files with 49 additions and 18 deletions
|
|
@ -46,6 +46,7 @@ option(ENABLE_LIME "Enable Instant Messaging Encryption." NO)
|
|||
option(ENABLE_MSG_STORAGE "Turn on compilation of message storage." YES)
|
||||
cmake_dependent_option(ENABLE_NOTIFY "Enable libnotify support." YES "ENABLE_GTK_UI" NO)
|
||||
option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation directory." NO)
|
||||
option(ENABLE_STRICT "Build with strict compile options." YES)
|
||||
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
|
||||
option(ENABLE_TUNNEL "Turn on compilation of tunnel support." NO)
|
||||
option(ENABLE_TUTORIALS "Enable compilation of tutorials." YES)
|
||||
|
|
@ -58,6 +59,22 @@ option(ENABLE_NLS "Build with internationalisation support" YES)
|
|||
option(ENABLE_CALL_LOGS_STORAGE "Turn on compilation of call logs storage." YES)
|
||||
|
||||
|
||||
macro(apply_compile_flags SOURCE_FILES)
|
||||
if(${SOURCE_FILES})
|
||||
set(options "")
|
||||
foreach(a ${ARGV})
|
||||
if(STRICT_OPTIONS_${a})
|
||||
string(REPLACE ";" " " options_${a} "${STRICT_OPTIONS_${a}}")
|
||||
set(options "${options} ${options_${a}}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(options)
|
||||
set_source_files_properties(${${SOURCE_FILES}} PROPERTIES COMPILE_FLAGS "${options}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(CheckSymbolExists)
|
||||
|
|
@ -197,22 +214,27 @@ if(ENABLE_DEBUG_LOGS)
|
|||
add_definitions("-DDEBUG")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wuninitialized -Wdeclaration-after-statement -fno-strict-aliasing -Werror")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wuninitialized -Werror")
|
||||
set(STRICT_OPTIONS_CPP )
|
||||
set(STRICT_OPTIONS_C )
|
||||
set(STRICT_OPTIONS_OBJC )
|
||||
if(NOT MSVC)
|
||||
list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized")
|
||||
list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement")
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -Wno-array-bounds")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -Wno-array-bounds")
|
||||
list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
|
||||
endif()
|
||||
if(APPLE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unknown-warning-option -Wno-tautological-compare -Wno-unused-function")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unknown-warning-option -Wno-tautological-compare -Wno-unused-function")
|
||||
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" "-fno-strict-aliasing")
|
||||
endif()
|
||||
endif()
|
||||
if(STRICT_OPTIONS_CPP)
|
||||
list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
|
||||
endif()
|
||||
if(STRICT_OPTIONS_C)
|
||||
list(REMOVE_DUPLICATES STRICT_OPTIONS_C)
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ set(LINPHONECSH_SOURCE_FILES
|
|||
shell.c
|
||||
)
|
||||
|
||||
apply_compile_flags(LINPHONEC_SOURCE_FILES "CPP" "C")
|
||||
add_executable(linphonec ${LINPHONEC_SOURCE_FILES})
|
||||
target_link_libraries(linphonec linphone)
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ set(LINPHONE_HEADER_FILES
|
|||
xmlrpc.h
|
||||
)
|
||||
|
||||
set(LINPHONE_SOURCE_FILES
|
||||
set(LINPHONE_SOURCE_FILES_C
|
||||
account_creator.c
|
||||
address.c
|
||||
authentication.c
|
||||
|
|
@ -111,15 +111,16 @@ set(LINPHONE_SOURCE_FILES
|
|||
xmlrpc.c
|
||||
vtables.c
|
||||
)
|
||||
set(LINPHONE_SOURCE_FILES_CXX )
|
||||
|
||||
if(ENABLE_TUNNEL)
|
||||
list(APPEND LINPHONE_SOURCE_FILES
|
||||
list(APPEND LINPHONE_SOURCE_FILES_CXX
|
||||
linphone_tunnel.cc
|
||||
TunnelManager.cc
|
||||
)
|
||||
add_definitions(-DTUNNEL_ENABLED)
|
||||
else()
|
||||
list(APPEND LINPHONE_SOURCE_FILES linphone_tunnel_stubs.c)
|
||||
list(APPEND LINPHONE_SOURCE_FILES_C linphone_tunnel_stubs.c)
|
||||
endif()
|
||||
|
||||
find_package(Git)
|
||||
|
|
@ -133,6 +134,9 @@ add_definitions(
|
|||
-DLIBLINPHONE_EXPORTS
|
||||
)
|
||||
|
||||
apply_compile_flags(LINPHONE_SOURCE_FILES_C "CPP" "C")
|
||||
apply_compile_flags(LINPHONE_SOURCE_FILES_CXX "CPP" "CXX")
|
||||
|
||||
set(LIBS
|
||||
${BELLESIP_LIBRARIES}
|
||||
${MEDIASTREAMER2_LIBRARIES}
|
||||
|
|
@ -161,10 +165,10 @@ if(INTL_FOUND)
|
|||
endif()
|
||||
|
||||
if(ENABLE_STATIC)
|
||||
add_library(linphone STATIC ${LINPHONE_HEADER_FILES} ${LINPHONE_SOURCE_FILES})
|
||||
add_library(linphone STATIC ${LINPHONE_HEADER_FILES} ${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX})
|
||||
target_link_libraries(linphone ${LIBS})
|
||||
else()
|
||||
add_library(linphone SHARED ${LINPHONE_HEADER_FILES} ${LINPHONE_SOURCE_FILES})
|
||||
add_library(linphone SHARED ${LINPHONE_HEADER_FILES} ${LINPHONE_SOURCE_FILES_C} ${LINPHONE_SOURCE_FILES_CXX})
|
||||
set_target_properties(linphone PROPERTIES VERSION ${LINPHONE_SO_VERSION} LINKER_LANGUAGE CXX)
|
||||
target_link_libraries(linphone ${LIBS})
|
||||
if(MSVC)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ if(WIN32)
|
|||
list(APPEND SOURCE_FILES linphone.rc)
|
||||
endif()
|
||||
|
||||
apply_compile_flags(SOURCE_FILES "CPP" "C")
|
||||
if(WIN32)
|
||||
add_executable(linphone-gtk WIN32 ${SOURCE_FILES})
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ set(SOURCE_FILES
|
|||
tunnel_tester.c
|
||||
upnp_tester.c
|
||||
video_tester.c
|
||||
)
|
||||
)
|
||||
|
||||
apply_compile_flags(SOURCE_FILES "CPP" "C")
|
||||
|
||||
#executable must be available on root path, not host one
|
||||
find_program(SIPP_PROGRAM NAMES sipp sipp.exe ONLY_CMAKE_FIND_ROOT_PATH)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ set(LP_GEN_WRAPPERS_LIBS
|
|||
${XML2_LIBRARIES}
|
||||
)
|
||||
|
||||
apply_compile_flags(LP_GEN_WRAPPERS_SOURCE_FILES "CPP" "CXX")
|
||||
add_executable(lp-gen-wrappers ${LP_GEN_WRAPPERS_SOURCE_FILES})
|
||||
target_link_libraries(lp-gen-wrappers ${LP_GEN_WRAPPERS_LIBS})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue