1- # Copyright (c) 2021, David Keller
2- # All rights reserved.
3- # Redistribution and use in source and binary forms, with or without
4- # modification, are permitted provided that the following conditions are met:
5- #
6- # * Redistributions of source code must retain the above copyright
7- # notice, this list of conditions and the following disclaimer.
8- # * Redistributions in binary form must reproduce the above copyright
9- # notice, this list of conditions and the following disclaimer in the
10- # documentation and/or other materials provided with the distribution.
11- # * Neither the name of the University of California, Berkeley nor the
12- # names of its contributors may be used to endorse or promote products
13- # derived from this software without specific prior written permission.
14- #
15- # THIS SOFTWARE IS PROVIDED BY DAVID KELLER AND CONTRIBUTORS ``AS IS AND ANY
16- # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18- # DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
19- # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20- # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21- # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22- # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24- # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25- cmake_minimum_required (VERSION 3.10 )
1+ # SPDX-License-Identifier: MIT
262
27- project (kademlia)
28- include (CTest )
3+ cmake_minimum_required (VERSION 3.27 )
294
30- list ( INSERT CMAKE_MODULE_PATH 0 " ${PROJECT_SOURCE_DIR} /cmake" )
5+ project (kademlia LANGUAGES CXX VERSION 0.0.2 )
316
32- # C++11.
33- if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
34- if (MSVC_VERSION LESS 1910) # 1910 -> VS 15.0
35- message (FATAL_ERROR "Current compiler does'nt support c++11 yet" )
36- endif ()
37- add_definitions (
38- -D_WIN32_WINNT=_WIN32_WINNT_WIN7
39- -D_WINSOCK_DEPRECATED_NO_WARNINGS
40- )
41- else ()
42- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
43- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" )
44- endif ()
7+ include (cmake/options.cmake )
8+ include (cmake/dependencies.cmake )
9+ include (cmake/project_setup.cmake )
4510
46- include (CheckCXXCompilerFlag )
47- check_cxx_compiler_flag (-std=c++11 IS_CXX11_SUPPORTED )
48- if (NOT IS_CXX11_SUPPORTED)
49- message (FATAL_ERROR "Current compiler does'nt support c++11 yet" )
50- endif ()
51- set (CMAKE_CXX_FLAGS "-Wall -std=c++11 -fvisibility=hidden ${CMAKE_CXX_FLAGS} " )
52- endif ()
53-
54- # Coverage
55- option (ENABLE_COVERAGE "Enable coverage target" )
56- if (ENABLE_COVERAGE)
57- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
58- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
59- set (CMAKE_EXEC_LINKER_FLAGS "${CMAKE_EXEC_LINKER_FLAGS} --coverage" )
60- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
61- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" )
62- set (CMAKE_EXEC_LINKER_FLAGS "${CMAKE_EXEC_LINKER_FLAGS} --coverage" )
63- else ()
64- message (FATAL_ERROR "Can't generate coverage target on ${CMAKE_CXX_COMPILER_ID} " )
65- endif ()
66- endif ()
67-
68- # Documentation
69- option (ENABLE_DOCUMENTATION "Enable documentation" OFF )
70-
71- # Threads
72- find_package (Threads REQUIRED )
73-
74- # Boost
75- if (WIN32 )
76- set (Boost_USE_STATIC_LIBS ON )
77- endif ()
78- find_package (Boost 1.70 CONFIG REQUIRED COMPONENTS
79- system
80- filesystem
81- unit_test_framework )
82-
83- # Crypto
84- find_package (OpenSSL REQUIRED )
85-
86- # Setup C++ definitions.
87- add_definitions (-DPACKAGE_VERSION= "0.0.0" )
88- add_definitions (-DPACKAGE_BUGREPORT= "david.keller@litchis.fr" )
89- if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
90- add_definitions (-DKADEMLIA_ENABLE_DEBUG )
91- endif ()
92-
93- # Setup includes directories.
94- include_directories (BEFORE include src test )
95- include_directories (${Boost_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} )
96-
97- # Build everything.
98- add_subdirectory (include )
9911add_subdirectory (src )
100- if (BUILD_TESTING)
101- enable_testing ()
102- add_subdirectory (test )
103- endif ()
12+ add_subdirectory (include )
13+ add_subdirectory (test )
10414add_subdirectory (examples )
105-
106- if (ENABLE_DOCUMENTATION)
15+ if (KADEMLIA_ENABLE_DOCUMENTATION)
10716 add_subdirectory (docs )
10817endif ()
10918
19+ include (cmake/install.cmake )
0 commit comments