Update CMake files

This commit is contained in:
ado 2023-02-08 21:54:44 +01:00
parent 0e28a06799
commit db2a72c18b
2 changed files with 44 additions and 39 deletions

View File

@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.14)
project( project(
ssp ssp
VERSION 0.0.1 VERSION 1.3.0
DESCRIPTION "Static split parser" DESCRIPTION "csv parser"
HOMEPAGE_URL "https://github.com/red0124/ssp" HOMEPAGE_URL "https://github.com/red0124/ssp"
LANGUAGES CXX LANGUAGES CXX
) )
@ -11,22 +11,23 @@ project(
# ---- Warning guard ---- # ---- Warning guard ----
# Protect dependents from this project's warnings if the guard isn't disabled # Protect dependents from this project's warnings if the guard isn't disabled
set(ssp_warning_guard SYSTEM) set(SSP_WARNING_GUARD SYSTEM)
if(ssp_INCLUDE_WITHOUT_SYSTEM) if(SSP_INCLUDE_WITHOUT_SYSTEM)
set(ssp_warning_guard "") set(SSP_WARNING_GUARD "")
endif() endif()
# ---- Dependencies ---- # ---- Dependencies ----
include(FetchContent) include(FetchContent)
FetchContent_Declare( fetchcontent_declare(
fast_float fast_float
GIT_REPOSITORY https://github.com/red0124/fast_float.git GIT_REPOSITORY https://github.com/red0124/fast_float.git
GIT_TAG origin/meson GIT_TAG origin/meson
GIT_SHALLOW TRUE) GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(fast_float) fetchcontent_makeavailable(fast_float)
set(fast_float_source_dir "${FETCHCONTENT_BASE_DIR}/fast_float-src") set(FAST_FLOAT_SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/fast_float-src")
# ---- Declare library ---- # ---- Declare library ----
@ -35,7 +36,7 @@ add_library(ssp::ssp ALIAS ssp)
target_include_directories( target_include_directories(
ssp ssp
${ssp_warning_guard} ${SSP_WARNING_GUARD}
INTERFACE INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/fast_float>" "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/fast_float>"
@ -55,19 +56,21 @@ target_link_libraries(
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(GNUInstallDirs) include(GNUInstallDirs)
set(ssp_directory "ssp-${PROJECT_VERSION}") set(SSP_DIRECTORY "ssp-${PROJECT_VERSION}")
set(ssp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}") set(SSP_INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}")
install( install(
DIRECTORY "${PROJECT_SOURCE_DIR}/include/" "${fast_float_source_dir}/include/" DIRECTORY
DESTINATION "${ssp_include_directory}" "${PROJECT_SOURCE_DIR}/include/"
"${FAST_FLOAT_SOURCE_DIR}/include/"
DESTINATION "${SSP_INCLUDE_DIRECTORY}"
COMPONENT ssp_Development COMPONENT ssp_Development
) )
install( install(
TARGETS ssp TARGETS ssp
EXPORT sspTargets EXPORT sspTargets
INCLUDES DESTINATION "${ssp_include_directory}" INCLUDES DESTINATION "${SSP_INCLUDE_DIRECTORY}"
) )
write_basic_package_version_file( write_basic_package_version_file(
@ -76,11 +79,11 @@ write_basic_package_version_file(
ARCH_INDEPENDENT ARCH_INDEPENDENT
) )
set(ssp_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/${ssp_directory}") set(SSP_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${SSP_DIRECTORY}")
install( install(
FILES "${PROJECT_BINARY_DIR}/ssp-config-version.cmake" FILES "${PROJECT_BINARY_DIR}/ssp-config-version.cmake"
DESTINATION "${ssp_install_cmakedir}" DESTINATION "${SSP_INSTALL_CMAKEDIR}"
COMPONENT ssp_Development COMPONENT ssp_Development
) )
@ -88,7 +91,7 @@ install(
EXPORT sspTargets EXPORT sspTargets
FILE ssp-config.cmake FILE ssp-config.cmake
NAMESPACE ssp:: NAMESPACE ssp::
DESTINATION "${ssp_install_cmakedir}" DESTINATION "${SSP_INSTALL_CMAKEDIR}"
COMPONENT ssp_Development COMPONENT ssp_Development
) )

View File

@ -4,17 +4,14 @@ project(ssp_tests CXX)
# ---- Dependencies ---- # ---- Dependencies ----
set( set(SSP_INCLUDE_WITHOUT_SYSTEM YES
ssp_INCLUDE_WITHOUT_SYSTEM CACHE INTERNAL
YES
CACHE
INTERNAL
"Turn the warning guard off to have errors appear in test builds" "Turn the warning guard off to have errors appear in test builds"
) )
include(FetchContent) include(FetchContent)
FetchContent_Declare(ssp SOURCE_DIR "${PROJECT_SOURCE_DIR}/..") fetchcontent_declare(ssp SOURCE_DIR "${PROJECT_SOURCE_DIR}/..")
FetchContent_MakeAvailable(ssp) fetchcontent_makeavailable(ssp)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(ssp INTERFACE -Wall -Wextra) target_compile_options(ssp INTERFACE -Wall -Wextra)
@ -30,8 +27,13 @@ enable_testing()
foreach(name IN ITEMS test_splitter test_parser test_converter test_extractions) foreach(name IN ITEMS test_splitter test_parser test_converter test_extractions)
add_executable("${name}" "${name}.cpp") add_executable("${name}" "${name}.cpp")
target_link_libraries("${name}" PRIVATE ssp::ssp fast_float doctest::doctest) target_link_libraries(
target_compile_definitions("${name}" PRIVATE "${name}"
DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN CMAKE_GITHUB_CI) PRIVATE ssp::ssp fast_float doctest::doctest
)
target_compile_definitions(
"${name}"
PRIVATE DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN CMAKE_GITHUB_CI
)
doctest_discover_tests("${name}") doctest_discover_tests("${name}")
endforeach() endforeach()