Skip to content

Commit e59c860

Browse files
committed
Modernize
1 parent 4243553 commit e59c860

File tree

2 files changed

+48
-19
lines changed

2 files changed

+48
-19
lines changed

CMakeLists.txt

+39-7
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,53 @@ cmake_minimum_required (VERSION 3.2.0 FATAL_ERROR)
33
# set project and version
44
project (taocpp-json VERSION 1.0.0 LANGUAGES CXX)
55

6-
# set C++ language standard
7-
set (CMAKE_CXX_STANDARD 11)
8-
set (CMAKE_CXX_STANDARD_REQUIRED ON)
9-
106
# define a header-only library
117
add_library (taocpp-json INTERFACE)
8+
add_library (taocpp::json ALIAS taocpp-json)
129
target_include_directories (taocpp-json INTERFACE
1310
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
1411
$<INSTALL_INTERFACE:include>
1512
)
1613

14+
# features used by taocpp/json
15+
target_compile_features (taocpp-json INTERFACE
16+
cxx_alias_templates
17+
cxx_auto_type
18+
cxx_constexpr
19+
cxx_decltype
20+
cxx_default_function_template_args
21+
cxx_defaulted_functions
22+
cxx_delegating_constructors
23+
cxx_deleted_functions
24+
cxx_explicit_conversions
25+
cxx_generalized_initializers
26+
cxx_inheriting_constructors
27+
cxx_inline_namespaces
28+
cxx_noexcept
29+
cxx_nonstatic_member_init
30+
cxx_nullptr
31+
cxx_range_for
32+
cxx_rvalue_references
33+
cxx_static_assert
34+
cxx_strong_enums
35+
cxx_template_template_parameters
36+
cxx_trailing_return_types
37+
cxx_uniform_initialization
38+
cxx_variadic_macros
39+
cxx_variadic_templates
40+
)
41+
1742
# testing
1843
enable_testing ()
19-
add_subdirectory (src/test/json)
44+
option (TAOCPP_JSON_BUILD_TESTS "Build test programs" ON)
45+
if (TAOCPP_JSON_BUILD_TESTS)
46+
add_subdirectory (src/test/json)
47+
endif ()
48+
49+
# installation directories
50+
set (TAOCPP_JSON_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory")
51+
set (TAOCPP_JSON_INSTALL_DOC_DIR "share/doc/tao/json" CACHE STRING "The installation doc directory")
2052

2153
# install
22-
install (DIRECTORY include/ DESTINATION include)
23-
install (FILES LICENSE DESTINATION include/tao/json)
54+
install (DIRECTORY include/ DESTINATION ${TAOCPP_JSON_INSTALL_INCLUDE_DIR})
55+
install (FILES LICENSE DESTINATION ${TAOCPP_JSON_INSTALL_DOC_DIR})

src/test/json/CMakeLists.txt

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
# set C++ language standard
2-
set (CMAKE_CXX_EXTENSIONS OFF)
3-
4-
# add warnings
5-
if (MSVC)
6-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /utf-8")
7-
else ()
8-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wshadow -Werror")
9-
endif ()
10-
11-
# add tests
121
file (GLOB testsources *.cpp)
132
foreach (testsourcefile ${testsources})
143
get_filename_component (exename ${testsourcefile} NAME_WE)
154
add_executable (${exename} ${testsourcefile})
16-
target_link_libraries (${exename} taocpp-json)
5+
set_property (TARGET ${exename} PROPERTY CXX_STANDARD 11)
6+
set_property (TARGET ${exename} PROPERTY CXX_STANDARD_REQUIRED ON)
7+
set_property (TARGET ${exename} PROPERTY CXX_EXTENSIONS OFF)
8+
target_link_libraries (${exename} taocpp::json)
9+
if (MSVC)
10+
target_compile_options (${exename} PRIVATE /W4 /WX /utf-8)
11+
else ()
12+
target_compile_options (${exename} PRIVATE -pedantic -Wall -Wextra -Wshadow -Werror)
13+
endif ()
1714
add_test (NAME ${exename} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${exename})
1815
endforeach (testsourcefile)

0 commit comments

Comments
 (0)