Debian Codegraph @

CMakeLists.txt

raw
1 # --------------------------------------------------------------------------------------
2 # Copyright (c) 2013-2026, Nucleic Development Team.
3 #
4 # Distributed under the terms of the Modified BSD License.
5 #
6 # The full license is in the file LICENSE, distributed with this software.
7 # --------------------------------------------------------------------------------------
8
9 cmake_minimum_required(VERSION 3.15)
10
11 # Read version from version.h
12 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/kiwi/version.h" VERSION_FILE)
13 string(REGEX MATCH "KIWI_MAJOR_VERSION ([0-9]+)" _ ${VERSION_FILE})
14 set(KIWI_MAJOR_VERSION ${CMAKE_MATCH_1})
15 string(REGEX MATCH "KIWI_MINOR_VERSION ([0-9]+)" _ ${VERSION_FILE})
16 set(KIWI_MINOR_VERSION ${CMAKE_MATCH_1})
17 string(REGEX MATCH "KIWI_MICRO_VERSION ([0-9]+)" _ ${VERSION_FILE})
18 set(KIWI_MICRO_VERSION ${CMAKE_MATCH_1})
19
20 project(kiwi
21 VERSION ${KIWI_MAJOR_VERSION}.${KIWI_MINOR_VERSION}.${KIWI_MICRO_VERSION}
22 LANGUAGES CXX
23 DESCRIPTION "A fast implementation of the Cassowary constraint solver"
24 )
25
26 # Determine if this is the top-level project
27 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
28 set(KIWI_IS_TOP_LEVEL TRUE)
29 else()
30 set(KIWI_IS_TOP_LEVEL FALSE)
31 endif()
32
33 # Options
34 option(KIWI_BUILD_BENCHMARKS "Build benchmarks" ${KIWI_IS_TOP_LEVEL})
35 option(KIWI_BUILD_TESTS "Build tests" ${KIWI_IS_TOP_LEVEL})
36
37 # C++ standard
38 set(CMAKE_CXX_STANDARD 11)
39 set(CMAKE_CXX_STANDARD_REQUIRED ON)
40 set(CMAKE_CXX_EXTENSIONS OFF)
41
42 # Header-only library
43 add_library(kiwi INTERFACE)
44 add_library(kiwi::kiwi ALIAS kiwi)
45
46 target_include_directories(kiwi
47 INTERFACE
48 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
49 $<INSTALL_INTERFACE:include>
50 )
51
52 target_compile_features(kiwi INTERFACE cxx_std_11)
53
54 target_compile_options(kiwi INTERFACE
55 $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:
56 -Wall
57 -Wextra
58 -Wpedantic
59 >
60 )
61
62 # Benchmarks
63 if(KIWI_BUILD_BENCHMARKS)
64 add_subdirectory(benchmarks)
65 endif()
66
67 # Tests
68 if(KIWI_BUILD_TESTS)
69 add_subdirectory(tests)
70 endif()
71
72 # Print configuration summary
73 message(STATUS "")
74 message(STATUS "Kiwi Configuration Summary:")
75 message(STATUS " Version: ${PROJECT_VERSION}")
76 message(STATUS " C++ Standard: C++${CMAKE_CXX_STANDARD}")
77 message(STATUS " Build benchmarks: ${KIWI_BUILD_BENCHMARKS}")
78 message(STATUS " Build tests: ${KIWI_BUILD_TESTS}")
79 message(STATUS "")