Skip to content

Updated filesystem and JSON dependencies #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ option(skyr_BUILD_EXAMPLES "Build the URL examples." OFF)
option(skyr_FULL_WARNINGS "Build the library with all warnings turned on." ON)
option(skyr_WARNINGS_AS_ERRORS "Treat warnings as errors." ON)
option(skyr_BUILD_WITHOUT_EXCEPTIONS "Build without exceptions." OFF)
option(skyr_BUILD_WITHOUT_RTTI "Build without RTTI." OFF)
option(skyr_USE_STATIC_CRT "Use static C Runtime library (/MT or MTd)." ON)
option(skyr_BUILD_WITH_LLVM_LIBCXX "Instruct Clang to use LLVM's implementation of C++ standard library" OFF)

Expand All @@ -45,12 +46,20 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU OR
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
endif()

if (skyr_BUILD_WITHOUT_RTTI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-declarations")
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES MSVC)
if(DEFINED MSVC_VERSION AND MSVC_VERSION LESS 1900)
message(FATAL_ERROR "Requires VS 2017 or later")
endif()

if (skyr_BUILD_WITHOUT_RTTI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
endif()

if (skyr_USE_STATIC_CRT)
# Replace dynamic MSVCRT linker flags with static version.
foreach(flag_var
Expand Down Expand Up @@ -95,6 +104,7 @@ endif()
# Add an alias for projects that use skyr-url as a dependency
if (NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
add_library(skyr::skyr-url ALIAS skyr-url)
add_library(skyr::skyr-filesystem ALIAS skyr-filesystem)
add_library(skyr::skyr-json ALIAS skyr-json)
endif()

Expand Down
29 changes: 25 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ configure_file(
${PROJECT_SOURCE_DIR}/include/skyr/version.hpp
)

#################################################
# skyr-url
#################################################

add_library(
skyr-url
)
Expand Down Expand Up @@ -69,16 +73,12 @@ target_sources(skyr-url
${PROJECT_SOURCE_DIR}/include/skyr/path/path_element_range.hpp
${PROJECT_SOURCE_DIR}/include/skyr/platform/endianness.hpp
${PROJECT_SOURCE_DIR}/include/skyr/url_search_parameters.hpp
${PROJECT_SOURCE_DIR}/include/skyr/filesystem/path.hpp
${PROJECT_SOURCE_DIR}/include/skyr/url.hpp)

target_link_libraries(skyr-url PUBLIC tl::expected)
if(${CMAKE_CXX_COMPILER_ID} MATCHES Clang AND ${skyr_BUILD_WITH_LLVM_LIBCXX})
target_link_libraries(skyr-url PUBLIC "c++")
endif()
if(${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
target_link_libraries(skyr-url PUBLIC "stdc++fs")
endif()

set_target_properties(skyr-url PROPERTIES
VERSION ${PROJECT_VERSION}
Expand All @@ -92,6 +92,27 @@ target_include_directories(skyr-url
PRIVATE
${PROJECT_SOURCE_DIR}/src)

#################################################
# skyr-filesystem
#################################################

add_library(skyr-filesystem INTERFACE)

target_link_libraries(skyr-filesystem INTERFACE tl::expected)
if(${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
target_link_libraries(skyr-filesystem INTERFACE "stdc++fs")
endif()

target_include_directories(skyr-filesystem
INTERFACE
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)

#################################################
# skyr-json
#################################################

add_library(skyr-json INTERFACE)

target_link_libraries(skyr-json INTERFACE tl::expected nlohmann_json::nlohmann_json)
Expand Down
5 changes: 2 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (MSVC)
endif(MSVC)


function(skyr_create_test file_name output_dir)
function(skyr_create_test file_name output_dir test_name)
skyr_remove_extension(${file_name} test)
add_executable(${test})
target_sources(${test} PRIVATE ${test}.cpp)
Expand All @@ -23,9 +23,7 @@ function(skyr_create_test file_name output_dir)
${test}
PRIVATE
skyr-url
skyr-json
Catch2::Catch2
nlohmann_json::nlohmann_json
fmt::fmt
)
set_target_properties(
Expand All @@ -34,6 +32,7 @@ function(skyr_create_test file_name output_dir)
RUNTIME_OUTPUT_DIRECTORY ${output_dir}
)
add_test(${test} ${output_dir}/${test})
set(test_name ${test} PARENT_SCOPE)
endfunction()

add_subdirectory(unicode)
Expand Down
2 changes: 1 addition & 1 deletion tests/domain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ foreach (
idna_table_tests.cpp
punycode_tests.cpp
domain_tests.cpp)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/domain)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/domain test_name)
endforeach ()
7 changes: 5 additions & 2 deletions tests/filesystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

include(${PROJECT_SOURCE_DIR}/cmake/skyr-url-functions.cmake)

foreach (file_name filesystem_path_tests.cpp)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/filesystem test)
endforeach ()
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/filesystem test_name)
target_link_libraries(${test_name} PRIVATE skyr-filesystem)
endforeach()
3 changes: 2 additions & 1 deletion tests/json/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
# http://www.boost.org/LICENSE_1_0.txt)

foreach (file_name json_query_tests.cpp)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/json)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/json test_name)
target_link_libraries(${test_name} PRIVATE skyr-json)
endforeach ()
2 changes: 1 addition & 1 deletion tests/network/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ foreach (file_name
ipv4_address_tests.cpp
ipv6_address_tests.cpp
)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/network)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/network test_name)
endforeach ()
2 changes: 1 addition & 1 deletion tests/percent_encoding/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ foreach (file_name
percent_decoding_tests.cpp
percent_encoding_tests.cpp
)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/percent_encoding)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/percent_encoding test_name)
endforeach ()
2 changes: 1 addition & 1 deletion tests/unicode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ foreach (
unicode_code_point_tests.cpp
unicode_range_tests.cpp
byte_conversion_tests.cpp)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/unicode)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/unicode test_name)
endforeach ()
4 changes: 2 additions & 2 deletions tests/url/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ foreach (file_name
query_parameter_range_tests.cpp
url_search_parameters_tests.cpp
)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/url)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/url test_name)
endforeach ()

if (NOT skyr_BUILD_WITHOUT_EXCEPTIONS)
foreach (file_name
url_tests_with_exceptions.cpp
url_literal_tests.cpp
)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/url)
skyr_create_test(${file_name} ${PROJECT_BINARY_DIR}/tests/url test_name)
endforeach()
endif()