Commit 4ee126e8 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added CMakeLists for cmake compilation

parent 32e97907
############################################################################
# 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_OBJC )
if(NOT MSVC)
list(APPEND STRICT_OPTIONS_CPP "-std=c++11" "-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)
\ No newline at end of file
############################################################################
# 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.
#
############################################################################
set(HEADER_FILES
abnf.hh
belr.hh
grammarbuilder.hh
parser.hh
)
set(BELR_HEADER_FILES )
foreach(HEADER_FILE ${HEADER_FILES})
list(APPEND BELR_HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/belr/${HEADER_FILE}")
endforeach()
set(BELR_HEADER_FILES ${BELR_HEADER_FILES} PARENT_SCOPE)
install(FILES ${BELR_HEADER_FILES}
DESTINATION include/belr
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
############################################################################
# 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.
#
############################################################################
set(BELR_HEADER_FILES )
set(BELR_SOURCE_FILES_C )
set(BELR_SOURCE_FILES_CXX
abnf.cc
belr.cc
grammarbuilder.cc
parser.cc
)
apply_compile_flags(BELR_SOURCE_FILES_C "CPP" "C")
apply_compile_flags(BELR_SOURCE_FILES_CXX "CPP" "CXX")
if(ENABLE_STATIC)
add_library(belr STATIC ${BELR_HEADER_FILES} ${BELR_SOURCE_FILES_C} ${BELR_SOURCE_FILES_CXX})
else()
add_library(belr SHARED ${BELR_HEADER_FILES} ${BELR_SOURCE_FILES_C} ${BELR_SOURCE_FILES_CXX})
set_target_properties(belr PROPERTIES VERSION ${BELR_SO_VERSION})
endif()
target_link_libraries(belr)
install(TARGETS belr EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
install(FILES ${BELR_HEADER_FILES}
DESTINATION include/belr
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
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