-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
44 lines (35 loc) · 1.54 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
cmake_minimum_required(VERSION 3.1)
cmake_policy(SET CMP0091 NEW)
message(STATUS "Read contents from vcpkg.json")
file(READ "${CMAKE_SOURCE_DIR}/vcpkg.json" VCPKG_JSON_CONTENT)
message(STATUS "Extract version from vcpkg.json")
string(REGEX MATCH "\"version-string\"[ \t]*:[ \t]*\"([^\"]+)\"" VERSION_MATCH "${VCPKG_JSON_CONTENT}")
if (VERSION_MATCH)
string(REGEX REPLACE "\"version-string\"[ \t]*:[ \t]*\"([^\"]+)\"" "\\1" TEMP_DIR_VERSION "${VERSION_MATCH}")
message(STATUS "Extracted version from vcpkg.json: ${TEMP_DIR_VERSION}")
else()
message(FATAL_ERROR "Could not extract version from vcpkg.json")
endif()
project(TempDir VERSION ${TEMP_DIR_VERSION} DESCRIPTION "TempDir is a lightweight C++17 library designed to provide an easy-to-use solution for managing temporary directories and files," LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
if(WIN32)
add_definitions(-DNOMINMAX)
endif(WIN32)
option(TD_BUILD_EXAMPLES "build examples" ON)
message("TD_BUILD_EXAMPLES: ${TD_BUILD_EXAMPLES}")
if(TD_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
option(TD_BUILD_TESTS "build tests" ON)
message("TD_BUILD_TESTS: ${TD_BUILD_TESTS}")
if(TD_BUILD_TESTS)
add_subdirectory(test)
endif()
option(TD_ENABLE_COVERAGE "Enable coverage reporting" OFF)
message("TD_ENABLE_COVERAGE: ${TD_ENABLE_COVERAGE}")
add_library(tempdir INTERFACE)
target_include_directories(tempdir INTERFACE
$<BUILD_INTERFACE:"${CMAKE_CURRENT_SOURCE_DIR}/include}">
$<INSTALL_INTERFACE:include>
)
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_PREFIX}/include")