2018-08-22 12:11:19 +02:00
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
|
|
|
# Copyright (c) 2018 Mateusz Pusz
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
|
2024-07-16 20:35:05 +02:00
|
|
|
cmake_minimum_required(VERSION 3.25)
|
2022-04-02 18:58:23 +02:00
|
|
|
project(mp-units-dev LANGUAGES CXX)
|
2018-08-22 12:11:19 +02:00
|
|
|
|
2021-03-13 19:53:09 +01:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
2024-11-17 13:35:12 +01:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/src/cmake")
|
|
|
|
include(CheckCacheVarValues)
|
2018-08-22 12:11:19 +02:00
|
|
|
|
2023-06-21 10:55:18 +02:00
|
|
|
set(projectPrefix MP_UNITS_)
|
2021-11-05 23:25:20 +01:00
|
|
|
|
2024-07-11 19:18:28 +02:00
|
|
|
option(${projectPrefix}DEV_BUILD_LA "Build code depending on the linear algebra library" OFF)
|
2024-05-08 11:12:38 +02:00
|
|
|
option(${projectPrefix}DEV_IWYU "Enables include-what-you-use" OFF)
|
|
|
|
option(${projectPrefix}DEV_CLANG_TIDY "Enables clang-tidy" OFF)
|
2024-11-17 13:35:12 +01:00
|
|
|
set(${projectPrefix}DEV_TIME_TRACE
|
|
|
|
NONE
|
|
|
|
CACHE STRING
|
|
|
|
"Enables `-ftime-trace` for a selected scope: NONE, ALL, MODULES, HEADERS. MODULES and HEADERS do not affect unit tests."
|
|
|
|
)
|
|
|
|
check_cache_var_values(DEV_TIME_TRACE NONE ALL MODULES HEADERS)
|
2024-05-08 11:12:38 +02:00
|
|
|
|
2024-04-12 09:43:02 +02:00
|
|
|
message(STATUS "${projectPrefix}DEV_BUILD_LA: ${${projectPrefix}DEV_BUILD_LA}")
|
2024-05-08 11:12:38 +02:00
|
|
|
message(STATUS "${projectPrefix}DEV_IWYU: ${${projectPrefix}DEV_IWYU}")
|
|
|
|
message(STATUS "${projectPrefix}DEV_CLANG_TIDY: ${${projectPrefix}DEV_CLANG_TIDY}")
|
2024-11-17 13:35:12 +01:00
|
|
|
message(STATUS "${projectPrefix}DEV_TIME_TRACE: ${${projectPrefix}DEV_TIME_TRACE}")
|
2023-05-26 15:28:54 +02:00
|
|
|
|
2021-05-07 20:45:24 +02:00
|
|
|
# make sure that the file is being used as an entry point
|
|
|
|
include(modern_project_structure)
|
|
|
|
ensure_entry_point()
|
|
|
|
|
2021-05-08 18:28:49 +02:00
|
|
|
# use ccache if available
|
|
|
|
include(ccache)
|
2021-06-08 18:00:53 +02:00
|
|
|
enable_ccache(BASE_DIR ${PROJECT_SOURCE_DIR})
|
2021-05-08 18:28:49 +02:00
|
|
|
|
2024-04-12 09:43:02 +02:00
|
|
|
if(${projectPrefix}DEV_IWYU)
|
2024-04-24 20:17:39 +02:00
|
|
|
set(${projectPrefix}BUILD_AS_SYSTEM_HEADERS ON)
|
|
|
|
|
2021-03-30 13:15:47 +02:00
|
|
|
include(include-what-you-use)
|
2021-05-07 20:46:40 +02:00
|
|
|
enable_iwyu(
|
2024-05-08 21:53:01 +02:00
|
|
|
REQUIRED
|
2021-03-30 13:15:47 +02:00
|
|
|
MAPPING_FILE "${PROJECT_SOURCE_DIR}/.mp-units.imp"
|
2022-04-02 18:58:23 +02:00
|
|
|
NO_FORWARD_DECLARATIONS QUOTED_INCLUDES_FIRST
|
2021-03-30 13:15:47 +02:00
|
|
|
MAX_LINE_LENGTH 120
|
|
|
|
NO_COMMENTS
|
|
|
|
)
|
2024-05-08 11:12:38 +02:00
|
|
|
elseif(${projectPrefix}DEV_CLANG_TIDY)
|
|
|
|
include(static_analysis)
|
2024-05-08 21:53:01 +02:00
|
|
|
enable_clang_tidy(PROGRAM clang-tidy-18 REQUIRED)
|
2024-04-24 20:10:44 +02:00
|
|
|
else()
|
|
|
|
# set restrictive compilation warnings
|
|
|
|
# (some gcc warnings are not recognized by IWYU which is based on clang)
|
|
|
|
include(warnings)
|
|
|
|
set_warnings()
|
2021-03-30 13:15:47 +02:00
|
|
|
endif()
|
|
|
|
|
2018-08-22 12:11:19 +02:00
|
|
|
# add project code
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
2024-05-31 09:27:05 +02:00
|
|
|
if(NOT ${projectPrefix}API_FREESTANDING)
|
2024-05-30 19:50:02 +02:00
|
|
|
# add usage example
|
|
|
|
add_subdirectory(example)
|
|
|
|
endif()
|
2020-03-09 18:55:41 +01:00
|
|
|
|
2020-12-09 18:54:36 +01:00
|
|
|
# add unit tests
|
|
|
|
enable_testing()
|
2022-10-06 23:43:01 +01:00
|
|
|
add_subdirectory(test)
|