neocomm/CMakeLists.txt

89 lines
2.5 KiB
CMake
Raw Normal View History

2018-03-30 11:11:29 +00:00
# Copyright (C) 2018 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
# Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 2.8)
2018-04-01 14:29:21 +00:00
project(NeoComm CXX)
2018-03-30 11:11:29 +00:00
# Binary filename
set(TARGET_NAME "neocomm")
set(TARGET_VERSION "1.0-beta")
# Use DEBUG by default
if(NOT CMAKE_BUILD_TYPE)
2018-09-02 09:22:36 +00:00
set(CMAKE_BUILD_TYPE "release")
2018-03-30 11:11:29 +00:00
endif()
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
option(BUILD_SHARED_LIB "Build a dynamic library." OFF)
find_package(GnuTLS REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(OPENDHT REQUIRED opendht>=1.4.0)
include_directories(
2018-09-01 17:54:59 +00:00
"include/")
2018-03-30 11:11:29 +00:00
# Define files
set(SRCS
2018-09-04 13:51:41 +00:00
"src/channel.cpp"
2018-09-01 17:40:04 +00:00
"src/node.cpp")
2018-03-30 11:11:29 +00:00
set(HDRS
2018-09-01 17:40:04 +00:00
"include/neocomm/channel.hpp"
2018-09-04 13:51:41 +00:00
"include/neocomm/message.hpp"
2018-09-01 17:40:04 +00:00
"include/neocomm/node.hpp")
2018-03-30 11:11:29 +00:00
# Define C++ compiler flags
set(CMAKE_CXX_FLAGS "-std=c++14 -Wall -Wextra -Wpedantic -Wfatal-errors -Werror -pedantic-errors -fno-elide-constructors")
2018-03-30 11:11:29 +00:00
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
#if(CMAKE_BUILD_TYPE STREQUAL "debug" OR CMAKE_BUILD_TYPE STREQUAL "relwithdebinfo")
#add_definitions(-DDEBUG)
#else()
#add_definitions(-DNDEBUG)
#endif()
2018-03-30 11:11:29 +00:00
2018-04-01 14:29:21 +00:00
if(WIN32)
add_definitions(-DWOE32)
elseif(UNIX)
add_definitions(-DUNIX)
endif()
2018-03-30 11:11:29 +00:00
# Create the executable
if(${BUILD_SHARED_LIB})
add_library(${TARGET_NAME} SHARED ${SRCS})
target_link_libraries(${TARGET_NAME}
${GNUTLS_LIBRARIES}
${OPENDHT_LIBRARIES})
else()
add_library(${TARGET_NAME} STATIC ${SRCS})
endif()
set_target_properties(${TARGET_NAME}
2018-09-01 17:40:04 +00:00
PROPERTIES PUBLIC_HEADER "${HDRS}")
2018-03-30 11:11:29 +00:00
install(TARGETS ${TARGET_NAME}
2018-09-02 10:08:50 +00:00
ARCHIVE DESTINATION "lib/"
LIBRARY DESTINATION "lib/"
PUBLIC_HEADER DESTINATION "include/neocomm/"
2018-03-30 11:11:29 +00:00
CONFIGURATIONS release minsizerel)
2018-09-02 10:08:50 +00:00
install(FILES "include/neocomm.hpp"
DESTINATION "include/")