forked from lispparser/sexp-cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
83 lines (71 loc) · 2.7 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
# SExp - A S-Expression Parser for C++
# Copyright (C) 2015 Ingo Ruhnke <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.0)
project(sexp)
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
file(GLOB SEXP_SOURCES src/*.cpp)
file(GLOB SEXP_HEADER_SOURCES include/sexp/*.hpp)
add_library(sexp STATIC ${SEXP_SOURCES})
set_target_properties(sexp PROPERTIES PUBLIC_HEADER "${SEXP_HEADER_SOURCES}")
target_compile_options(sexp PRIVATE ${WARNINGS_CXX_FLAGS})
target_include_directories(sexp SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/sexp.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/sexp.pc"
@ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/sexp.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
if(BUILD_TESTS)
find_package(GTest REQUIRED)
# build sexp tests
file(GLOB TEST_SEXP_SOURCES tests/*.cpp)
add_executable(test_sexp ${TEST_SEXP_SOURCES})
target_compile_options(test_sexp PRIVATE ${WARNINGS_CXX_FLAGS})
target_include_directories(test_sexp PUBLIC src/)
target_link_libraries(test_sexp
GTest::GTest
GTest::Main
sexp)
# add 'make test' target, use 'make test ARGS="-V"' or 'ctest -V' for verbose
enable_testing()
add_test(NAME test_sexp
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND test_sexp)
endif()
if(BUILD_BENCHMARKS)
find_package(benchmark REQUIRED)
find_package(Threads REQUIRED)
# build benchmarks
file(GLOB BENCHMARKSOURCES benchmarks/*.cpp)
foreach(SOURCE ${BENCHMARKSOURCES})
get_filename_component(SOURCE_BASENAME ${SOURCE} NAME_WE)
add_executable(${SOURCE_BASENAME} ${SOURCE})
target_link_libraries(${SOURCE_BASENAME}
sexp
benchmark::benchmark
Threads::Threads
)
set_target_properties(${SOURCE_BASENAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/benchmarks/")
target_compile_options(${SOURCE_BASENAME} PRIVATE -std=c++1y ${WARNINGS_CXX_FLAGS})
endforeach()
endif()
# EOF #