Skip to content

Commit

Permalink
Modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed May 19, 2017
1 parent 4243553 commit e59c860
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 19 deletions.
46 changes: 39 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,53 @@ cmake_minimum_required (VERSION 3.2.0 FATAL_ERROR)
# set project and version
project (taocpp-json VERSION 1.0.0 LANGUAGES CXX)

# set C++ language standard
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)

# define a header-only library
add_library (taocpp-json INTERFACE)
add_library (taocpp::json ALIAS taocpp-json)
target_include_directories (taocpp-json INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

# features used by taocpp/json
target_compile_features (taocpp-json INTERFACE
cxx_alias_templates
cxx_auto_type
cxx_constexpr
cxx_decltype
cxx_default_function_template_args
cxx_defaulted_functions
cxx_delegating_constructors
cxx_deleted_functions
cxx_explicit_conversions
cxx_generalized_initializers
cxx_inheriting_constructors
cxx_inline_namespaces
cxx_noexcept
cxx_nonstatic_member_init
cxx_nullptr
cxx_range_for
cxx_rvalue_references
cxx_static_assert
cxx_strong_enums
cxx_template_template_parameters
cxx_trailing_return_types
cxx_uniform_initialization
cxx_variadic_macros
cxx_variadic_templates
)

# testing
enable_testing ()
add_subdirectory (src/test/json)
option (TAOCPP_JSON_BUILD_TESTS "Build test programs" ON)
if (TAOCPP_JSON_BUILD_TESTS)
add_subdirectory (src/test/json)
endif ()

# installation directories
set (TAOCPP_JSON_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory")
set (TAOCPP_JSON_INSTALL_DOC_DIR "share/doc/tao/json" CACHE STRING "The installation doc directory")

# install
install (DIRECTORY include/ DESTINATION include)
install (FILES LICENSE DESTINATION include/tao/json)
install (DIRECTORY include/ DESTINATION ${TAOCPP_JSON_INSTALL_INCLUDE_DIR})
install (FILES LICENSE DESTINATION ${TAOCPP_JSON_INSTALL_DOC_DIR})
21 changes: 9 additions & 12 deletions src/test/json/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# set C++ language standard
set (CMAKE_CXX_EXTENSIONS OFF)

# add warnings
if (MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /utf-8")
else ()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wshadow -Werror")
endif ()

# add tests
file (GLOB testsources *.cpp)
foreach (testsourcefile ${testsources})
get_filename_component (exename ${testsourcefile} NAME_WE)
add_executable (${exename} ${testsourcefile})
target_link_libraries (${exename} taocpp-json)
set_property (TARGET ${exename} PROPERTY CXX_STANDARD 11)
set_property (TARGET ${exename} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property (TARGET ${exename} PROPERTY CXX_EXTENSIONS OFF)
target_link_libraries (${exename} taocpp::json)
if (MSVC)
target_compile_options (${exename} PRIVATE /W4 /WX /utf-8)
else ()
target_compile_options (${exename} PRIVATE -pedantic -Wall -Wextra -Wshadow -Werror)
endif ()
add_test (NAME ${exename} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${exename})
endforeach (testsourcefile)

0 comments on commit e59c860

Please sign in to comment.