-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
50 lines (41 loc) · 1.37 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.10)
set(PROJECT_REVISION 1 CACHE INTERNAL "Project revision (CI)")
project(cmake_template
VERSION 0.0.${PROJECT_REVISION}
DESCRIPTION "General CMake template for C++ projects by N.Mikhailovskiy"
HOMEPAGE_URL "https://github.com/CityAplons/cmake-multiplatform-template"
LANGUAGES CXX
)
set_property(GLOBAL PROPERTY G_CXX_STANDARD 14)
set_property(GLOBAL PROPERTY G_CXX_STANDARD_REQUIRED ON)
# Include utility functions
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(compiler)
include(test)
# Transparent versioning
include_directories(cmake/version)
configure_file(cmake/version/version.h.in version.h)
configure_file(cmake/version/VERSION.in VERSION)
add_library(version cmake/version/project.cpp)
target_include_directories(version
PRIVATE "${CMAKE_BINARY_DIR}"
)
# Describe build targets
add_executable(helloworld_cli src/hello.cpp)
target_link_libraries(helloworld_cli PRIVATE
version
)
set_compile_options(helloworld_cli)
set_compile_options(version)
install(TARGETS helloworld_cli
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Describe unit tests
enable_testing()
add_unit_test(test/test_version.cpp version)
# Packaging
option(MAKE_PACKAGE "Add 'package' and 'package_source' build targets for packages" ON)
if (MAKE_PACKAGE)
add_subdirectory(cmake/packaging)
endif()