-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
123 lines (99 loc) · 2.9 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
cmake_minimum_required(VERSION 3.22)
project(inja_cli
VERSION 0.0.0
DESCRIPTION "Inja CLI"
HOMEPAGE_URL "https://github.com/laurence-myers/inja-cli"
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 20)
################
# Platform config
# Fix DLL not found problem on Windows
# Note: Windows shared libraries do not have RPATH or RUNPATH
# DLLs are searched first at current directories and then in directories
# listed in $PATH variable.
# @see https://caiorss.github.io/C-Cpp-Notes/building-system-cmake.html#orgfdf5850
if (WIN32)
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}")
endif ()
# Statically link the Windows runtime dependencies
if (MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif ()
###################
# Install CPM.cmake
set(CPM_DOWNLOAD_VERSION 0.35.0)
if (CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif (DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else ()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif ()
if (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif ()
include(${CPM_DOWNLOAD_LOCATION})
##############
# Dependencies
CPMAddPackage(
NAME nowide
VERSION 11.1.4
URL "https://github.com/boostorg/nowide/releases/download/v11.1.4/nowide_standalone_v11.1.4.tar.gz"
)
CPMAddPackage("gh:pantor/inja@3.3.0")
CPMAddPackage(
NAME tclap
VERSION 1.4.0-rc1
URL "https://ixpeering.dl.sourceforge.net/project/tclap/tclap-1.4.0-rc1.tar.bz2"
)
if(tclap_ADDED)
add_library(tclap INTERFACE IMPORTED)
target_include_directories(
tclap SYSTEM INTERFACE ${tclap_SOURCE_DIR}/include
)
endif()
##############
# App settings
add_executable(inja_cli main.cpp)
# Set the output exe name
set_target_properties(inja_cli PROPERTIES OUTPUT_NAME "inja")
###################
# Link dependencies
target_link_libraries(inja_cli nowide inja tclap)
################
# Package as zip
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
install(
FILES
${CPACK_RESOURCE_FILE_LICENSE}
${CPACK_RESOURCE_FILE_README}
DESTINATION
.
)
include(CPackComponent)
cpack_add_component(
inja_cli
DISPLAY_NAME "Inja CLI"
REQUIRED
)
install(
TARGETS
inja_cli
RUNTIME
DESTINATION
.
COMPONENT
inja_cli
)
set(CPACK_BINARY_NSIS "OFF")
set(CPACK_BINARY_ZIP "ON")
set(CPACK_PACKAGE_NAME "inja_cli")
set(CPACK_PACKAGE_VENDOR "Laurence Dougal Myers")
include(CPack)