From d14a639143755a55373c50c81b841d3f38eee3bb Mon Sep 17 00:00:00 2001 From: Pagwin Date: Wed, 24 Dec 2025 18:48:59 -0500 Subject: [PATCH] tweaks to compile --- CMakeLists.txt | 6 +----- apps/CMakeLists.txt | 8 -------- apps/exe_entry.cpp | 4 ---- include/visiting.h | 18 ++++++++++++++++++ src/CMakeLists.txt | 9 ++++----- 5 files changed, 23 insertions(+), 22 deletions(-) delete mode 100644 apps/CMakeLists.txt delete mode 100644 apps/exe_entry.cpp create mode 100644 include/visiting.h diff --git a/CMakeLists.txt b/CMakeLists.txt index da44ec1..9448711 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 4.1.2) -project(project_name_here +project(psl VERSION 0.1 LANGUAGES CXX) @@ -25,7 +25,3 @@ set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Wfloat-equal -Wundef -Wpointer-ari # lib src code add_subdirectory(src) - -# app source code -add_subdirectory(apps) - diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt deleted file mode 100644 index db89bb3..0000000 --- a/apps/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# based heavily on https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/apps/CMakeLists.txt - -add_executable(exe_name exe_entry.cpp) - -# example library link -#target_link_libraries(exe_name fmt::fmt) - -target_compile_features(exe_name PRIVATE cxx_std_20) diff --git a/apps/exe_entry.cpp b/apps/exe_entry.cpp deleted file mode 100644 index fe5388f..0000000 --- a/apps/exe_entry.cpp +++ /dev/null @@ -1,4 +0,0 @@ -int main(void){ - - return 0; -} diff --git a/include/visiting.h b/include/visiting.h new file mode 100644 index 0000000..f6eacd1 --- /dev/null +++ b/include/visiting.h @@ -0,0 +1,18 @@ + +namespace psl { + +/// usage: +/// const auto visitor = overloads { +/// [](type_1 v){...}, +/// [](type_2 v){...}, +/// ... +/// }; +/// visitor will then be an object with an overloaded function call op +/// which accepts type_1, type_2, etc +/// got this code from https://en.cppreference.com/w/cpp/utility/variant/visit +/// seems to need C++20 to work but haven't researched to double check +template struct overloads : Ts... { + using Ts::operator()...; +}; + +} // namespace psl diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 62a6c2f..e7ef3c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,17 +1,16 @@ # based heavily on https://gitlab.com/CLIUtils/modern-cmake/-/blob/master/examples/extended-project/src/CMakeLists.txt -# example from when I was doing raft cpp impl -#set(HEADER_LIST "${raft_cpp_impl_SOURCE_DIR}/include/raft/lib.hpp") +set(HEADER_LIST "${psl_SOURCE_DIR}/include/visiting.h") -add_library(example_lib lib.cpp ${HEADER_LIST}) +add_library(psl lib.cpp ${HEADER_LIST}) # We need this directory, and users of our library will need it too -target_include_directories(example_lib PUBLIC ../include) +target_include_directories(psl PUBLIC ../include) #target_link_libraries(example_lib PRIVATE Boost::boost) -target_compile_features(example_lib PUBLIC cxx_std_17) +target_compile_features(psl PUBLIC cxx_std_20) # IDEs should put the headers in a nice place source_group(