CMakeLists.txt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright (C) 2017 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
  2. # Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. cmake_minimum_required(VERSION 3.1)
  17. project(NeoComm)
  18. set(TARGET_NAME "neocomm")
  19. set(TARGET_VERSION_MAJOR 1)
  20. set(TARGET_VERSION_MINOR 0)
  21. if(NOT CMAKE_BUILD_TYPE)
  22. set(CMAKE_BUILD_TYPE "release")
  23. endif()
  24. string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
  25. message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
  26. option(BUILD_SHARED_LIB
  27. "Whether to build a shared object instead of a static." OFF)
  28. find_package(GnuTLS REQUIRED)
  29. find_package(PkgConfig REQUIRED)
  30. pkg_check_modules(OPENDHT REQUIRED opendht>=1.4.0)
  31. include_directories(
  32. "include/"
  33. SYSTEM OPENDHT_INCLUDE_DIRS)
  34. set(SRCS
  35. src/channel.cpp
  36. src/error.cpp
  37. src/message.cpp
  38. src/node.cpp)
  39. set(CMAKE_CXX_FLAGS
  40. "-std=c++11 -Wall -Wextra -Wpedantic -Werror -Wfatal-errors -pedantic-errors -fno-elide-constructors")
  41. set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
  42. set(CMAKE_CXX_FLAGS_RELEASE "-O3")
  43. set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3")
  44. set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
  45. if(NOT CMAKE_BUILD_TYPE MATCHES "debug" AND
  46. NOT CMAKE_BUILD_TYPE MATCHES "relwithdebinfo")
  47. add_definitions("-DNDEBUG")
  48. else()
  49. add_definitions("-DDEBUG")
  50. endif()
  51. if(WIN32)
  52. add_definitions("-DWOE32")
  53. endif()
  54. if(BUILD_SHARED_LIB)
  55. add_library(${TARGET_NAME} SHARED ${SRCS})
  56. else()
  57. add_library(${TARGET_NAME} STATIC ${SRCS})
  58. endif()
  59. if(BUILD_SHARED_LIB)
  60. target_link_libraries(${TARGET_NAME}
  61. ${GNUTLS_LIBRARIES}
  62. ${OPENDHT_LIBRARIES})
  63. endif()