############################################################################ # CMakeLists.txt # Copyright (C) 2015 Belledonne Communications, Grenoble France # ############################################################################ # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################ cmake_minimum_required(VERSION 3.0) project(BELR C CXX) set(BELR_MAJOR_VERSION "0") set(BELR_MINOR_VERSION "0") set(BELR_MICRO_VERSION "1") set(BELR_VERSION "${BELR_MAJOR_VERSION}.${BELR_MINOR_VERSION}.${BELR_MICRO_VERSION}") set(BELR_SO_VERSION "1") 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) include(CMakePushCheckState) set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC") if(MSVC) list(APPEND CMAKE_REQUIRED_INCLUDES "${MSVC_INCLUDE_DIR}") endif() # find_package should be invoked here to check for libraries - however do NOT # call include_directories here (see below) if(UNIX AND NOT APPLE) include(CheckIncludeFiles) check_include_files(libudev.h HAVE_LIBUDEV_H) endif() include_directories( include/ src/ ${CMAKE_CURRENT_BINARY_DIR} ) if(MSVC) include_directories(${MSVC_INCLUDE_DIR}) endif() set(STRICT_OPTIONS_CPP ) set(STRICT_OPTIONS_C ) set(STRICT_OPTIONS_CXX ) set(STRICT_OPTIONS_OBJC ) if(NOT MSVC) list(APPEND STRICT_OPTIONS_CXX "-std=c++11") list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations") list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Wno-error=strict-prototypes") if(CMAKE_C_COMPILER_ID STREQUAL "Clang") list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds") 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" "-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() add_subdirectory(include) add_subdirectory(src)