Commit d9c894ba authored by Simon Morlat's avatar Simon Morlat
Browse files

Fix compilation issue. -std=c99 is too strict, as it excludes definition of...

Fix compilation issue. -std=c99 is too strict, as it excludes definition of essential structures such as struct addrinfo.
parent 6208826f
1 merge request!14Fix compilation issue. -std=c99 is too strict, as it excludes definition of...
Showing with 175 additions and 172 deletions
############################################################################ ############################################################################
# CMakeLists.txt # CMakeLists.txt
# Copyright (C) 2017 Belledonne Communications, Grenoble France # Copyright (C) 2017 Belledonne Communications, Grenoble France
# #
############################################################################ ############################################################################
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
############################################################################ ############################################################################
include(GNUInstallDirs) include(GNUInstallDirs)
include(CheckSymbolExists) include(CheckSymbolExists)
include(CheckLibraryExists) include(CheckLibraryExists)
include(CMakePushCheckState) include(CMakePushCheckState)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(lime VERSION 0.0.1 LANGUAGES CXX C) project(lime VERSION 0.0.1 LANGUAGES CXX C)
set(LIME_SO_VERSION "0") set(LIME_SO_VERSION "0")
set(LIME_VERSION ${PROJECT_VERSION}) set(LIME_VERSION ${PROJECT_VERSION})
option(ENABLE_SHARED "Build shared library." ON) option(ENABLE_SHARED "Build shared library." ON)
option(ENABLE_STATIC "Build static library." ON) option(ENABLE_STATIC "Build static library." ON)
option(ENABLE_STRICT "Build with strict compile options." YES) option(ENABLE_STRICT "Build with strict compile options." YES)
option(ENABLE_CURVE25519 "Enable support of Curve 25519." YES) option(ENABLE_CURVE25519 "Enable support of Curve 25519." YES)
option(ENABLE_CURVE448 "Enable support of Curve 448(goldilock)." YES) option(ENABLE_CURVE448 "Enable support of Curve 448(goldilock)." YES)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES) option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES)
option(ENABLE_PROFILING "Enable profiling, GCC only" NO) option(ENABLE_PROFILING "Enable profiling, GCC only" NO)
option(ENABLE_C_INTERFACE "Enable support of C89 foreign function interface" NO) option(ENABLE_C_INTERFACE "Enable support of C89 foreign function interface" NO)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX) if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}") message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif() endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS) if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
set(BcToolbox_FIND_COMPONENTS tester) set(BcToolbox_FIND_COMPONENTS tester)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake") include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else() else()
find_package(BcToolbox 0.5.1 REQUIRED OPTIONAL_COMPONENTS tester) find_package(BcToolbox 0.5.1 REQUIRED OPTIONAL_COMPONENTS tester)
endif() endif()
find_package(Soci REQUIRED) find_package(Soci REQUIRED)
include_directories( include_directories(
include/ include/
src/ src/
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
) )
if(MSVC) if(MSVC)
include_directories(${MSVC_INCLUDE_DIR}) include_directories(${MSVC_INCLUDE_DIR})
endif() endif()
set(LIME_INCLUDE_DIRS set(LIME_INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
) )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON)
set(LIME_CPPFLAGS ${BCTOOLBOX_CPPFLAGS}) set(LIME_CPPFLAGS ${BCTOOLBOX_CPPFLAGS})
if(LIME_CPPFLAGS) if(LIME_CPPFLAGS)
list(REMOVE_DUPLICATES LIME_CPPFLAGS) list(REMOVE_DUPLICATES LIME_CPPFLAGS)
add_definitions(${LIME_CPPFLAGS}) add_definitions(${LIME_CPPFLAGS})
endif() endif()
add_definitions("-DLIME_EXPORTS") add_definitions("-DLIME_EXPORTS")
set(STRICT_OPTIONS_C) set(STRICT_OPTIONS_C)
set(STRICT_OPTIONS_CPP ) set(STRICT_OPTIONS_CPP )
set(STRICT_OPTIONS_CXX ) set(STRICT_OPTIONS_CXX )
set(STRICT_OPTIONS_OBJC ) set(STRICT_OPTIONS_OBJC )
if(MSVC)
if(ENABLE_STRICT) set(CMAKE_CXX_STANDARD 11)
list(APPEND STRICT_OPTIONS_CPP "/WX") set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
# avoid conflicts with std::min and std::max set(CMAKE_C_STANDARD 99)
add_definitions("-DNOMINMAX")
else() if(MSVC)
if (ENABLE_PROFILING) if(ENABLE_STRICT)
list(APPEND STRICT_OPTIONS_CXX "-g -pg") list(APPEND STRICT_OPTIONS_CPP "/WX")
endif() endif()
list(APPEND STRICT_OPTIONS_CXX "-std=c++11") # avoid conflicts with std::min and std::max
#list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations") # turn off deprecated-declaration warning to avoid being flooded by soci.h add_definitions("-DNOMINMAX")
list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-deprecated-declarations" "-Wno-missing-field-initializers") else()
if(ENABLE_C_INTERFACE) if (ENABLE_PROFILING)
list(APPEND STRICT_OPTIONS_C "-std=c99") list(APPEND STRICT_OPTIONS_CXX "-g -pg")
endif() endif()
if(CMAKE_C_COMPILER_ID STREQUAL "Clang") #list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations") # turn off deprecated-declaration warning to avoid being flooded by soci.h
list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds") list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-deprecated-declarations" "-Wno-missing-field-initializers")
endif()
if(APPLE) if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds") list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
endif() endif()
if(ENABLE_STRICT) if(APPLE)
list(APPEND STRICT_OPTIONS_CPP "-Werror" "-Wextra" "-Wno-unused-parameter" "-fno-strict-aliasing") list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds")
endif() endif()
endif() if(ENABLE_STRICT)
if(STRICT_OPTIONS_CPP) list(APPEND STRICT_OPTIONS_CPP "-Werror" "-Wextra" "-Wno-unused-parameter" "-fno-strict-aliasing")
list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP) endif()
endif() endif()
if(STRICT_OPTIONS_CPP)
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS) list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
set(EXPORT_TARGETS_NAME "LinphoneBuilder") endif()
else()
set(EXPORT_TARGETS_NAME "lime") if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
endif() set(EXPORT_TARGETS_NAME "LinphoneBuilder")
else()
if (ENABLE_CURVE25519) set(EXPORT_TARGETS_NAME "lime")
add_definitions("-DEC25519_ENABLED") endif()
message(STATUS "Support Curve 25519")
endif() if (ENABLE_CURVE25519)
add_definitions("-DEC25519_ENABLED")
if (ENABLE_CURVE448) message(STATUS "Support Curve 25519")
add_definitions("-DEC448_ENABLED") endif()
message(STATUS "Support Curve 448")
endif() if (ENABLE_CURVE448)
add_definitions("-DEC448_ENABLED")
if(ENABLE_C_INTERFACE) message(STATUS "Support Curve 448")
add_definitions("-DFFI_ENABLED") endif()
message(STATUS "Provide C89 interface")
endif() if(ENABLE_C_INTERFACE)
add_definitions("-DFFI_ENABLED")
add_subdirectory(include) message(STATUS "Provide C89 interface")
add_subdirectory(src) endif()
if(ENABLE_UNIT_TESTS AND BCTOOLBOX_TESTER_FOUND)
enable_testing() add_subdirectory(include)
add_subdirectory(tester) add_subdirectory(src)
endif() if(ENABLE_UNIT_TESTS AND BCTOOLBOX_TESTER_FOUND)
enable_testing()
export(EXPORT ${EXPORT_TARGETS_NAME}Targets add_subdirectory(tester)
FILE "${CMAKE_CURRENT_BINARY_DIR}/LimeTargets.cmake" endif()
)
configure_file(cmake/LimeConfig.cmake.in export(EXPORT ${EXPORT_TARGETS_NAME}Targets
"${CMAKE_CURRENT_BINARY_DIR}/LimeConfig.cmake" FILE "${CMAKE_CURRENT_BINARY_DIR}/LimeTargets.cmake"
@ONLY )
) configure_file(cmake/LimeConfig.cmake.in
set(ConfigPackageLocation "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake") "${CMAKE_CURRENT_BINARY_DIR}/LimeConfig.cmake"
install(EXPORT ${EXPORT_TARGETS_NAME}Targets @ONLY
FILE LimeTargets.cmake )
DESTINATION ${ConfigPackageLocation} set(ConfigPackageLocation "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
) install(EXPORT ${EXPORT_TARGETS_NAME}Targets
install(FILES FILE LimeTargets.cmake
"${CMAKE_CURRENT_BINARY_DIR}/LimeConfig.cmake" DESTINATION ${ConfigPackageLocation}
DESTINATION ${ConfigPackageLocation} )
) install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/LimeConfig.cmake"
# Doxygen DESTINATION ${ConfigPackageLocation}
find_package(Doxygen) )
if (DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) # Doxygen
add_custom_target(doc find_package(Doxygen)
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile if (DOXYGEN_FOUND)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
COMMENT "Generating API documentation with Doxygen" VERBATIM add_custom_target(doc
) ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
endif() WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
add_subdirectory(build) )
endif()
add_subdirectory(build)
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