Skip to content

Commit 17fe796

Browse files
committed
Add the top-level CMakeLists.txt
1 parent 1355d3c commit 17fe796

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

CMakeLists.txt

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#
2+
# Copyright (c) 2025 Gennaro Prota
3+
#
4+
# Distributed under the Boost Software License, Version 1.0.
5+
# (See accompanying file LICENSE_1_0.txt or copy at
6+
# https://www.boost.org/LICENSE_1_0.txt)
7+
#
8+
# Official repository: https://github.com/cppalliance/handlebars
9+
#
10+
11+
cmake_minimum_required(VERSION 3.11)
12+
13+
project(boost_handlebars LANGUAGES CXX)
14+
15+
# Module name
16+
set(BOOST_HANDLEBARS_MODULE_NAME "handlebars")
17+
18+
# Options
19+
option(BOOST_HANDLEBARS_ENABLE_TESTS "Enable tests" ON)
20+
21+
# Default build type
22+
if(NOT CMAKE_BUILD_TYPE)
23+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
24+
endif()
25+
26+
# Collect source files
27+
file(GLOB_RECURSE BOOST_HANDLEBARS_SOURCES CONFIGURE_DEPENDS
28+
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
29+
source_file_names.cpp
30+
)
31+
32+
# Create library target
33+
add_library(boost_handlebars ${BOOST_HANDLEBARS_SOURCES})
34+
35+
# C++ standard
36+
target_compile_features(boost_handlebars PUBLIC cxx_std_23)
37+
38+
# Include directories
39+
target_include_directories(boost_handlebars
40+
PUBLIC
41+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
42+
$<INSTALL_INTERFACE:include>
43+
)
44+
45+
# Shared build macro
46+
target_compile_definitions(boost_handlebars
47+
PRIVATE
48+
-DBOOST_HANDLEBARS_STATIC_LINK
49+
)
50+
51+
if (WIN32)
52+
target_compile_definitions(
53+
boost_handlebars
54+
PUBLIC
55+
-D_WIN32_WINNT=0x0601
56+
-D_CRT_SECURE_NO_WARNINGS
57+
)
58+
59+
if(MSVC)
60+
target_compile_options(
61+
boost_handlebars
62+
PUBLIC
63+
/permissive- # strict C++
64+
/Zc:preprocessor # new preprocessor
65+
/W4 # enable all warnings
66+
/MP # multi-processor compilation
67+
/EHs # C++ exception handling
68+
$<$<CONFIG:Debug>:/Oy-> # disable frame pointer omission
69+
)
70+
endif()
71+
endif()
72+
73+
# Install rules
74+
include(GNUInstallDirs)
75+
76+
install(TARGETS boost_handlebars
77+
EXPORT boost_handlebars_targets
78+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
79+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
80+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
81+
)
82+
83+
install(DIRECTORY boost/handlebars
84+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/boost
85+
)
86+
87+
# Tests
88+
enable_testing()
89+
add_subdirectory(test)

0 commit comments

Comments
 (0)