-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathCMakeLists.txt
61 lines (42 loc) · 1.94 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
51
52
53
54
55
56
57
58
59
60
61
# This project is licensed under the MIT license. For more information see the
# LICENSE file.
cmake_minimum_required(VERSION 3.25)
project(maddy)
# ------------------------------------------------------------------------------
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
# ------------------------------------------------------------------------------
option(MADDY_BUILD_WITH_TESTS "enable building tests - does not work with zip download" OFF)
if(${MADDY_BUILD_WITH_TESTS})
enable_testing()
endif()
option(MADDY_CREATE_PACKAGE "create a package for a version release" OFF)
# ------------------------------------------------------------------------------
set(MADDY_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
# ------------------------------------------------------------------------------
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(${CMAKE_CXX_STANDARD} LESS 14)
message(FATAL_ERROR "maddy requires >=C++14")
endif()
# ------------------------------------------------------------------------------
add_library(maddy INTERFACE)
target_include_directories(maddy INTERFACE
${MADDY_INCLUDE_DIR}
)
# ------------------------------------------------------------------------------
if(${MADDY_BUILD_WITH_TESTS})
add_subdirectory(tests)
endif()
# ------------------------------------------------------------------------------
if(${MADDY_CREATE_PACKAGE})
set(MADDY_PACKAGE_FILES include/ CMakeLists.txt LICENSE)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip
COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip --format=zip -- ${MADDY_PACKAGE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${MADDY_PACKAGE_FILES})
add_custom_target(${PROJECT_NAME}_package DEPENDS ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-src.zip)
endif()