-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
69 lines (59 loc) · 2.98 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
62
63
64
65
66
67
68
69
#######################################################
### mdsplit ###
#######################################################
# Project information
cmake_minimum_required(VERSION 3.17)
project(mdsplit VERSION 0.1.1)
set(CMAKE_CXX_STANDARD 17)
# CMake dependencies for installer
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# Cmake scripts
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
option(CPM_USE_LOCAL_PACKAGES "Try `find_package` before downloading dependencies" ON)
include(cmake/CPM.cmake)
# Check if this a master project or a subdirectory of another project
if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
set(MASTER_PROJECT ON)
else ()
set(MASTER_PROJECT OFF)
endif ()
set(MDSPLIT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
#######################################################
### Options ###
#######################################################
option(BUILD_INSTALLER "Build an installation package" ${MASTER_PROJECT})
option(BUILD_PACKAGE "Build an installation package" ${MASTER_PROJECT})
option(BUILD_WITH_PEDANTIC_WARNINGS "Use pedantic warnings. This is useful for developers because many of these warnings will be in continuous integration anyway." ${DEBUG_MODE})
#######################################################
### Libraries ###
#######################################################
add_subdirectory(source)
#######################################################
### Executable ###
#######################################################
add_subdirectory(standalone)
#######################################################
### Packages ###
#######################################################
if (BUILD_INSTALLER AND BUILD_PACKAGE)
# Set the cpack variables
# https://cliutils.gitlab.io/modern-cmake/chapters/install/packaging.html
# The most common cpack variables
set(CPACK_PACKAGE_NAME "mdsplit")
set(CPACK_PACKAGE_VENDOR "https://github.com/alandefreitas")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A Tool to Split Bulky Markdown Files")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
# Set CPACK_SOURCE_IGNORE_FILES with files source packages shouldn't install
# We get these from .gitignore to avoid redundancy
FILE(READ .gitignore GITIGNORE_CONTENTS)
STRING(REGEX REPLACE ";" "\\\\;" GITIGNORE_CONTENTS "${GITIGNORE_CONTENTS}")
STRING(REGEX REPLACE "\n" ";" GITIGNORE_CONTENTS "${GITIGNORE_CONTENTS}")
set(CPACK_SOURCE_IGNORE_FILES ${GITIGNORE_CONTENTS})
# Always include CPack at last
include(CPack)
endif()