-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
50 lines (39 loc) · 1.43 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/include/scalr/version.hpp" version)
STRING(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ ${version})
SET(SCALR_VERSION_MAJOR ${CMAKE_MATCH_1})
STRING(REGEX MATCH "VERSION_MINOR ([0-9]*)" _ ${version})
SET(SCALR_VERSION_MINOR ${CMAKE_MATCH_1})
STRING(REGEX MATCH "VERSION_PATCH ([0-9]*)" _ ${version})
SET(SCALR_VERSION_PATCH ${CMAKE_MATCH_1})
PROJECT(scalr
LANGUAGES CXX
VERSION "${SCALR_VERSION_MAJOR}.${SCALR_VERSION_MINOR}.${SCALR_VERSION_PATCH}"
DESCRIPTION "Physical quantity/unit library for Modern C++"
HOMEPAGE_URL "https://github.com/doganulus/scalr"
)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
INCLUDE(CTest)
INCLUDE(GNUInstallDirs)
SET(SCALR_TARGET_NAME "${PROJECT_NAME}")
# Library Setup
ADD_LIBRARY(${SCALR_TARGET_NAME} INTERFACE "include/scalr/version.hpp")
ADD_LIBRARY(${PROJECT_NAME}::${SCALR_TARGET_NAME} ALIAS ${SCALR_TARGET_NAME})
TARGET_INCLUDE_DIRECTORIES(
${SCALR_TARGET_NAME}
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
SET_TARGET_PROPERTIES(
${SCALR_TARGET_NAME} PROPERTIES VERSION ${PROJECT_VERSION}
)
# Library Install
INSTALL(DIRECTORY include/scalr TYPE INCLUDE)
# Testing
IF(BUILD_TESTING)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
ENDIF()