From 4376c84969bd9943f54b6ccd5f3a7e159cff703e Mon Sep 17 00:00:00 2001 From: ado Date: Sun, 7 Feb 2021 14:02:51 +0100 Subject: [PATCH 1/7] undo install removal from cmake --- CMakeLists.txt | 46 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 3 +++ 2 files changed, 49 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1f27d7..323c897 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,3 +47,49 @@ target_link_libraries( "$<$,$,9.0>>:c++fs>" "$<$,$,9.1>>:stdc++fs>" ) + +# ---- Install ---- + +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + +set(ssp_directory "ssp-${PROJECT_VERSION}") +set(ssp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}") + +install( + DIRECTORY "${PROJECT_SOURCE_DIR}/include/" + DESTINATION "${ssp_include_directory}" + COMPONENT ssp_Development +) + +install( + TARGETS ssp + EXPORT sspTargets + INCLUDES DESTINATION "${ssp_include_directory}" +) + +write_basic_package_version_file( + ssp-config-version.cmake + COMPATIBILITY SameMajorVersion + ARCH_INDEPENDENT +) + +set(ssp_install_cmakedir "${CMAKE_INSTALL_LIBDIR}/cmake/${ssp_directory}") + +install( + FILES "${PROJECT_BINARY_DIR}/ssp-config-version.cmake" + DESTINATION "${ssp_install_cmakedir}" + COMPONENT ssp_Development +) + +install( + EXPORT sspTargets + FILE ssp-config.cmake + NAMESPACE ssp:: + DESTINATION "${ssp_install_cmakedir}" + COMPONENT ssp_Development +) + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + include(CPack) +endif() diff --git a/README.md b/README.md index 41968cb..96e7cf3 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,9 @@ Bill (Heath) Gates 65 3.3 * Conversions can be chained if invalid * Fast +# Installation +TODO + # Usage ## Conversions From 1bad4fc3c06b38f8407b1e7c18af7cc16cf39dd0 Mon Sep 17 00:00:00 2001 From: ado Date: Sun, 7 Feb 2021 15:07:35 +0100 Subject: [PATCH 2/7] make cmake install also install fast_float, update README --- CMakeLists.txt | 6 ++++-- README.md | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 323c897..b29af69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ endif() # ---- Dependencies ---- +include(FetchContent) FetchContent_Declare( fast_float GIT_REPOSITORY https://github.com/red0124/fast_float.git @@ -25,6 +26,7 @@ FetchContent_Declare( GIT_SHALLOW TRUE) FetchContent_MakeAvailable(fast_float) +set(fast_float_source_dir "${FETCHCONTENT_BASE_DIR}/fast_float-src") # ---- Declare library ---- @@ -36,7 +38,7 @@ target_include_directories( ${ssp_warning_guard} INTERFACE "$" - fast_float + "$" ) target_compile_features(ssp INTERFACE cxx_std_17) @@ -57,7 +59,7 @@ set(ssp_directory "ssp-${PROJECT_VERSION}") set(ssp_include_directory "${CMAKE_INSTALL_INCLUDEDIR}") install( - DIRECTORY "${PROJECT_SOURCE_DIR}/include/" + DIRECTORY "${PROJECT_SOURCE_DIR}/include/" "${fast_float_source_dir}/include/" DESTINATION "${ssp_include_directory}" COMPONENT ssp_Development ) diff --git a/README.md b/README.md index 96e7cf3..97142a0 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,14 @@ Bill (Heath) Gates 65 3.3 * Fast # Installation -TODO +$ git clone https://github.com/red0124/ssp +$ cd ssp +$ cmake --configure . +$ sudo make install + +*Note, this will also install the fast_float library* +``` # Usage ## Conversions From 8684114ad125df05bc2ec45c405216265cd5a834 Mon Sep 17 00:00:00 2001 From: ado Date: Sun, 7 Feb 2021 15:41:00 +0100 Subject: [PATCH 3/7] update README --- README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 97142a0..7d3a273 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ $ cmake --configure . $ sudo make install *Note, this will also install the fast_float library* -``` +The library supports [CMake](#Cmake) and [meson](#Meson) build systems + # Usage ## Conversions @@ -384,3 +385,27 @@ std::string s; std::cin >> s; int num = c.convert(s.c_str()); ``` + +# CMake + +If you have the repository cloned in your CMake project, simply add it: +``` +add_subdirectory(ssp) +``` +Othervise, you can fetch it from the repository: +``` +include(FetchContent) +FetchContent_Declare( + ssp + GIT_REPOSITORY https://github.com/red0124/ssp.git + GIT_TAG origin/master + GIT_SHALLOW TRUE) + +FetchContent_MakeAvailable(ssp) +``` +Either way, after you prepare the target, you just have to invoke it in your project: +``` +target_link_libraries(project PUBLIC ssp) +``` +# Meson + From cf3469361c76e801bdbf72f4ed4ffebbc14e379e Mon Sep 17 00:00:00 2001 From: ado Date: Sun, 7 Feb 2021 15:46:03 +0100 Subject: [PATCH 4/7] fix README --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7d3a273..939eb7d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Function traits taken from [qt-creator](https://code.woboq.org/qt5/qt-creator/sr # Example Lets say we have a csv file containing students in a given format (NAME,AGE,GRADE) and we want to parse and print all the valid values: -``` +```shell $ cat students.csv James Bailey,65,2.5 Brian S. Wolfe,40,1.9 @@ -38,7 +38,7 @@ int main() { } ``` And if we compile and execute the program we get the following output: -``` +```shell $ ./a.out James Bailey 65 2.5 Brian S. Wolfe 40 1.9 @@ -61,13 +61,15 @@ Bill (Heath) Gates 65 3.3 # Installation +```shell $ git clone https://github.com/red0124/ssp $ cd ssp $ cmake --configure . $ sudo make install +``` -*Note, this will also install the fast_float library* -The library supports [CMake](#Cmake) and [meson](#Meson) build systems +*Note, this will also install the fast_float library* +The library supports [CMake](#Cmake) and [meson](#Meson) build systems # Usage @@ -389,11 +391,11 @@ int num = c.convert(s.c_str()); # CMake If you have the repository cloned in your CMake project, simply add it: -``` +```cmake add_subdirectory(ssp) ``` -Othervise, you can fetch it from the repository: -``` +Othervise, you can fetch just it from the repository: +```cmake include(FetchContent) FetchContent_Declare( ssp @@ -404,7 +406,7 @@ FetchContent_Declare( FetchContent_MakeAvailable(ssp) ``` Either way, after you prepare the target, you just have to invoke it in your project: -``` +```cmake target_link_libraries(project PUBLIC ssp) ``` # Meson From 2fa4f8e863918be390eafc87d6e0f0dded4a9738 Mon Sep 17 00:00:00 2001 From: ado Date: Sun, 7 Feb 2021 15:53:43 +0100 Subject: [PATCH 5/7] add meson setup to README --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 939eb7d..b653a67 100644 --- a/README.md +++ b/README.md @@ -388,13 +388,13 @@ std::cin >> s; int num = c.convert(s.c_str()); ``` -# CMake +## CMake -If you have the repository cloned in your CMake project, simply add it: +If the repository is cloned in the CMake project, it can simply be added: ```cmake add_subdirectory(ssp) ``` -Othervise, you can fetch just it from the repository: +Othervise, it can just be fetched from the repository: ```cmake include(FetchContent) FetchContent_Declare( @@ -409,5 +409,10 @@ Either way, after you prepare the target, you just have to invoke it in your pro ```cmake target_link_libraries(project PUBLIC ssp) ``` -# Meson +## Meson +Simply fetch the dependency and it is ready to be invoked: +```meson +ssp_sub = subproject('ssp') +ssp_dep = ssp_sub.get_variable('ssp_dep') +``` From 8455f37465737ddab8058a5b2330016d2b08093e Mon Sep 17 00:00:00 2001 From: ado Date: Sun, 7 Feb 2021 15:59:17 +0100 Subject: [PATCH 6/7] update README --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b653a67..2e38200 100644 --- a/README.md +++ b/README.md @@ -390,11 +390,11 @@ int num = c.convert(s.c_str()); ## CMake -If the repository is cloned in the CMake project, it can simply be added: +If the repository is cloned within the CMake project, it can be added in the following way: ```cmake add_subdirectory(ssp) ``` -Othervise, it can just be fetched from the repository: +Alternatively, it can be fetched from the repository: ```cmake include(FetchContent) FetchContent_Declare( @@ -411,7 +411,13 @@ target_link_libraries(project PUBLIC ssp) ``` ## Meson -Simply fetch the dependency and it is ready to be invoked: +Create an *ssp.wrap* file in your *subprojects* directory with the following content: +```wrap +[wrap-git] +url = https://github.com/red0124/ssp +revision = origin/master +``` +Then simply fetch the dependency and it is ready to be used: ```meson ssp_sub = subproject('ssp') ssp_dep = ssp_sub.get_variable('ssp_dep') From feb993f4c26cba5c4d49cb8be9268289b548f8ce Mon Sep 17 00:00:00 2001 From: ado Date: Sun, 7 Feb 2021 16:02:10 +0100 Subject: [PATCH 7/7] update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2e38200..f27e771 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,7 @@ std::string s; std::cin >> s; int num = c.convert(s.c_str()); ``` +# Using as a project dependency ## CMake