johnhany / leetcode Goto Github PK
View Code? Open in Web Editor NEWleetcode.com solutions with unit testing (VSCode+CMake+Boost.Test)
License: Apache License 2.0
leetcode.com solutions with unit testing (VSCode+CMake+Boost.Test)
License: Apache License 2.0
boost should be updated to latest version 1.83.0 so that on macOS in Xcode 15.0 the replacement of std::__unary_function over std::unary_function would not produce error.
Otherwise, we have error such as
CMake: Configure
[main] Configuring project: leetcode
[proc] Executing command: /usr/local/bin/cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ -S/Users/congliu/johnhany/leetcode -B/Users/congliu/johnhany/leetcode/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Detected MacOS platform
[cmake] -- Found Boost: /usr/local/Cellar/boost/[email protected]/lib/cmake/Boost-1.76.0/BoostConfig.cmake (found version "1.76.0") found components: unit_test_framework
[cmake] -- Configuring done (0.1s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: /Users/congliu/johnhany/leetcode/build
CMake: Build
[main] Building folder: leetcode
[build] Starting build
[proc] Executing command: /usr/local/bin/cmake --build /Users/congliu/johnhany/leetcode/build --config Debug --target all -j 10 --
[build] [ 25%] Building CXX object CMakeFiles/solution.dir/028-Find-the-Index-of-the-First-Occurrence-in-a-String/solution.cpp.o
[build] [ 50%] Linking CXX static library libsolution.a
[build] [ 50%] Built target solution
[build] [ 75%] Building CXX object CMakeFiles/test_main.dir/028-Find-the-Index-of-the-First-Occurrence-in-a-String/solution_test.cpp.o
[build] In file included from /Users/congliu/johnhany/leetcode/028-Find-the-Index-of-the-First-Occurrence-in-a-String/solution_test.cpp:6:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/test/unit_test.hpp:18:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/test/test_tools.hpp:54:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/test/tools/fpc_op.hpp:19:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/test/tools/fpc_tolerance.hpp:19:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/test/tree/decorator.hpp:22:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/test/tree/fixture.hpp:21:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/function/function0.hpp:11:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/function/detail/maybe_include.hpp:15:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/function/function_template.hpp:13:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/function/detail/prologue.hpp:17:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/function/function_base.hpp:21:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/type_index.hpp:29:
[build] In file included from /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/type_index/stl_type_index.hpp:47:
[build] /usr/local/Cellar/[email protected]/1.76.0_4/include/boost/container_hash/hash.hpp:131:33: error: no template named 'unary_function' in namespace 'std'; did you mean '__unary_function'?
[build] struct hash_base : std::unary_function<T, std::size_t> {};
[build] ~~~~~^
[build] /Applications/Xcode_15_1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__functional/unary_function.h:46:1: note: '__unary_function' declared here
[build] using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;
[build] ^
[build] 1 error generated.
[build] make[2]: *** [CMakeFiles/test_main.dir/028-Find-the-Index-of-the-First-Occurrence-in-a-String/solution_test.cpp.o] Error 1
[build] make[1]: *** [CMakeFiles/test_main.dir/all] Error 2
[build] make: *** [all] Error 2
[proc] The command: /usr/local/bin/cmake --build /Users/congliu/johnhany/leetcode/build --config Debug --target all -j 10 -- exited with code: 2
[driver] Build completed: 00:00:04.971
[build] Build finished with exit code 2
diff --git a/.gitignore b/.gitignore
index 97581c8..bc2c7ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,4 @@
build/*
.vscode/settings.json
.vscode/ipch/*
+.DS_Store
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index db42427..e2b1639 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -4,7 +4,7 @@
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
- "/usr/local/Cellar/boost/1.72.0_3/include"
+ "/usr/local/Cellar/boost/1.83.0/include"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d08cfe..a8fdea5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,8 +25,8 @@ if(WIN32)
target_link_libraries(test_main PRIVATE ${TEST_LIBS} Boost::boost Boost::unit_test_framework)
elseif(APPLE)
message(STATUS "Detected MacOS platform")
- set(BOOST_ROOT "/usr/local/Cellar/boost/1.72.0_3")
- set(BOOST_LIBRARYDIR "/usr/local/Cellar/boost/1.72.0_3/lib")
+ set(BOOST_ROOT "/usr/local/Cellar/boost/1.83.0")
+ set(BOOST_LIBRARYDIR "/usr/local/Cellar/boost/1.83.0/lib")
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED COMPONENTS unit_test_framework)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.