From a17204c3c8d71b2aa2de8fb3fea9281a450f5df5 Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Sat, 3 Feb 2024 20:00:26 +0300 Subject: [PATCH 01/12] Support directives --- pub/cppwriter.h | 3 +++ src/cppwriter.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/pub/cppwriter.h b/pub/cppwriter.h index 5b9e3a81..e2541d48 100644 --- a/pub/cppwriter.h +++ b/pub/cppwriter.h @@ -66,6 +66,9 @@ class CppWriter virtual void emitUsingDecl(const CppUsingDecl* usingDecl, std::ostream& stm, CppIndent indentation = CppIndent()) const; + virtual void emitUsingNamespaceDecl(const CppUsingNamespaceDecl* usingDecl, + std::ostream& stm, + CppIndent indentation = CppIndent()) const; virtual void emitTypedefList(const CppTypedefList* typedefList, std::ostream& stm, CppIndent indentation = CppIndent()) const; diff --git a/src/cppwriter.cpp b/src/cppwriter.cpp index 89034bcd..2ed6a738 100644 --- a/src/cppwriter.cpp +++ b/src/cppwriter.cpp @@ -106,6 +106,8 @@ void CppWriter::emit(const CppObj* cppObj, std::ostream& stm, CppIndent indentat return emitDocComment((CppDocComment*) cppObj, stm, indentation); case CppObjType::kUsingDecl: return emitUsingDecl((CppUsingDecl*) cppObj, stm, indentation); + case CppObjType::kUsingNamespaceDecl: + return emitUsingNamespaceDecl((CppUsingNamespaceDecl*) cppObj, stm, indentation); case CppObjType::kTypedefName: return emitTypedef((CppTypedefName*) cppObj, stm, indentation); case CppObjType::kTypedefNameList: @@ -411,6 +413,13 @@ void CppWriter::emitUsingDecl(const CppUsingDecl* usingDecl, stm << ";\n"; } +void CppWriter::emitUsingNamespaceDecl(const CppUsingNamespaceDecl* usingDecl, + std::ostream& stm, + CppIndent indentation /* = CppIndent()*/) const +{ + stm << indentation << "using namespace " << usingDecl->name_ << ";\n"; +} + void CppWriter::emitTypedefList(const CppTypedefList* typedefList, std::ostream& stm, CppIndent indentation /* = CppIndent()*/) const From c636b3a2d8ff087ad7336db5a0cc1042f59d1dfc Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Sun, 4 Feb 2024 01:38:53 +0300 Subject: [PATCH 02/12] Auto find boost in MSCV --- .gitignore | 2 ++ CMakeLists.txt | 44 +++++++++++++++++----------- conf.cmake | 28 ++++++++++++++++++ src/README.mdpp | 20 +++++++++++++ src/parser.l | 2 +- test/app/compare.h | 1 + third_party/btyacc_tp/CMakeLists.txt | 2 +- 7 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 conf.cmake diff --git a/.gitignore b/.gitignore index 1c8ac974..9e72ab9b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ parser.tab.* # Build results +src/catch/ + [Dd]ebug/ [Rr]elease/ x64/ diff --git a/CMakeLists.txt b/CMakeLists.txt index f9c14db5..d6ea944c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(cppparser) enable_testing() -include("../common/cmake/conf.cmake") +include("conf.cmake") set(CMAKE_CXX_STANDARD 17) @@ -17,9 +17,18 @@ add_subdirectory(third_party/btyacc_tp) add_definitions(-DBOOST_AUTO_LINK_NOMANGLE) -add_subdirectory(../common/third_party/boost_tp/cmake ${CMAKE_BINARY_DIR}/boost) +#add_subdirectory(../common/third_party/boost_tp/cmake ${CMAKE_BINARY_DIR}/boost) -include_directories(../common/third_party) +#include_directories(../common/third_party) + +set(Boost_USE_STATIC_LIBS OFF) +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_RUNTIME OFF) +find_package(Boost COMPONENTS filesystem program_options REQUIRED) + +if (NOT EXISTS "${CMAKE_SOURCE_DIR}/src/catch/catch.hpp") + file(DOWNLOAD "https://github.com/catchorg/Catch2/releases/download/v2.13.10/catch.hpp" "${CMAKE_SOURCE_DIR}/src/catch/catch.hpp") +endif() ############################################# ## CppParser @@ -72,18 +81,19 @@ set(CPPPARSER_SOURCES ) add_library(cppparser STATIC ${CPPPARSER_SOURCES}) -add_dependencies(cppparser btyacc boost_filesystem boost_program_options) +#add_dependencies(cppparser btyacc boost_filesystem boost_program_options) target_link_libraries(cppparser PUBLIC - boost_filesystem - boost_program_options - boost_system + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_System} ) target_include_directories( cppparser PUBLIC + ${Boost_INCLUDE_DIR} pub - ../common/third_party/boost_tp + #../common/third_party/boost_tp PRIVATE hack ) @@ -103,9 +113,9 @@ add_executable(cppparsertest target_link_libraries(cppparsertest PRIVATE cppparser - boost_filesystem - boost_program_options - boost_system + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_System} ) set(E2E_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/test/e2e) @@ -145,9 +155,9 @@ target_include_directories(cppparserunittest target_link_libraries(cppparserunittest PRIVATE cppparser - boost_filesystem - boost_program_options - boost_system + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_System} ) set(UNIT_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/test/unit) add_test( @@ -175,9 +185,9 @@ target_compile_definitions(cppparserembeddedsnippetvalidity target_link_libraries(cppparserembeddedsnippetvalidity PRIVATE cppparser - boost_filesystem - boost_program_options - boost_system + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_System} ) if(NOT MSVC) diff --git a/conf.cmake b/conf.cmake new file mode 100644 index 00000000..44883780 --- /dev/null +++ b/conf.cmake @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.4) +cmake_policy(SET CMP0054 NEW) + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fvisibility=hidden") +else() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wall -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fprofile-arcs -ftest-coverage --coverage") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fvisibility=hidden") +endif() + +set(CMAKE_CXX_STANDARD 17) + +# Define DLLEXPORT and DLLIMPORT +if(WIN32 OR CYGWIN ) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(DLLEXPORT "__attribute__((dllexport))") + set(DLLIMPORT "") + else() + set(DLLEXPORT "__declspec(dllexport)") + set(DLLIMPORT "__declspec(dllimport)") + endif() +else() + set(DLLEXPORT "__attribute__((visibility (\"default\")))") + set(DLLIMPORT "") +endif() \ No newline at end of file diff --git a/src/README.mdpp b/src/README.mdpp index 1fa6f051..9eec3dd0 100644 --- a/src/README.mdpp +++ b/src/README.mdpp @@ -45,6 +45,26 @@ git clone https://github.com/satya-das/CppParser.git ## Configure and build +### Windows Visual Studio + +[Install vcpkg](https://vcpkg.io/en/getting-started) to fetch boost + +```powershell +vcpkg install boost-filesystem boost-program-options boost-system +cd cppparser +mkdir build +cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="[path to vcpkg]/scripts/buildsystems/vcpkg.cmake" +cd build +msbuild cppparser.sln +``` + +### Linux and others + +* For Ubuntu to fetch boost: +```sh +sudo apt install libboost-system-dev libboost-filesystem-dev libboost-program-options-dev +``` + ```sh cd cppparser mkdir builds diff --git a/src/parser.l b/src/parser.l index 1171b608..c95d60cd 100644 --- a/src/parser.l +++ b/src/parser.l @@ -32,7 +32,7 @@ For this very reason this file does not use any class that are defined in cppast %{ // C++17 causes problem when register is used and flex uses register in generated code -#define register +//#define register #include "cpptoken.h" #include "cppvarinit.h" diff --git a/test/app/compare.h b/test/app/compare.h index b598ff88..9002a411 100644 --- a/test/app/compare.h +++ b/test/app/compare.h @@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #pragma once #include +#include #include #include diff --git a/third_party/btyacc_tp/CMakeLists.txt b/third_party/btyacc_tp/CMakeLists.txt index a1cfa01d..ad19bf07 100644 --- a/third_party/btyacc_tp/CMakeLists.txt +++ b/third_party/btyacc_tp/CMakeLists.txt @@ -1,4 +1,4 @@ -include("../../../common/cmake/conf.cmake") +include("../../conf.cmake") project(btyacc) From 127b08427f11095ef88694597441b9c26482ac39 Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Sun, 4 Feb 2024 01:42:25 +0300 Subject: [PATCH 03/12] Correct readme --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index c8eea6a7..f748923d 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,27 @@ git clone https://github.com/satya-das/CppParser.git ## Configure and build +### Windows Visual Studio + +[Install vcpkg](https://vcpkg.io/en/getting-started) to fetch boost + +```powershell +vcpkg install boost-filesystem boost-program-options boost-system +cd cppparser +mkdir build +cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="[path to vcpkg]/scripts/buildsystems/vcpkg.cmake" +cd build +msbuild cppparser.sln +``` + +### Linux and others + +*For Ubuntu to fetch boost:* + +```sh +sudo apt install libboost-system-dev libboost-filesystem-dev libboost-program-options-dev +``` + ```sh cd cppparser mkdir builds From 9532e7cf17d795070e2d7091e2c3b66b8e5877bf Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Fri, 8 Mar 2024 21:04:18 +0300 Subject: [PATCH 04/12] fix the tests --- test/e2e/test_master/ObjectArxHeaders/AcTc.h | 1 + test/e2e/test_master/podofo/podofo.h | 1 + test/e2e/test_master/wxWidgets/include/wx/catch_cppunit.h | 1 + test/e2e/test_master/wxWidgets/include/wx/msw/wrapgdip.h | 1 + 4 files changed, 4 insertions(+) diff --git a/test/e2e/test_master/ObjectArxHeaders/AcTc.h b/test/e2e/test_master/ObjectArxHeaders/AcTc.h index 526d8f80..ee3673e7 100644 --- a/test/e2e/test_master/ObjectArxHeaders/AcTc.h +++ b/test/e2e/test_master/ObjectArxHeaders/AcTc.h @@ -167,6 +167,7 @@ namespace AcTc kItemOptionMenuRemoveImage = (0x1 << 4), }; } +using namespace AcTc; struct ACTC_IMAGE_INFO { SIZE mSize; diff --git a/test/e2e/test_master/podofo/podofo.h b/test/e2e/test_master/podofo/podofo.h index 9fc3b24a..da563796 100644 --- a/test/e2e/test_master/podofo/podofo.h +++ b/test/e2e/test_master/podofo/podofo.h @@ -93,5 +93,6 @@ # include "doc/PdfTilingPattern.h" # include "doc/PdfXObject.h" # ifdef _PODOFO_NO_NAMESPACE_ +using namespace PoDoFo; # endif #endif diff --git a/test/e2e/test_master/wxWidgets/include/wx/catch_cppunit.h b/test/e2e/test_master/wxWidgets/include/wx/catch_cppunit.h index 79b0cb58..5ff71d8d 100644 --- a/test/e2e/test_master/wxWidgets/include/wx/catch_cppunit.h +++ b/test/e2e/test_master/wxWidgets/include/wx/catch_cppunit.h @@ -168,6 +168,7 @@ namespace CatchCppUnit }; } } +using namespace CatchCppUnit; // Helpers used in the implementation of the macros below. namespace wxPrivate { diff --git a/test/e2e/test_master/wxWidgets/include/wx/msw/wrapgdip.h b/test/e2e/test_master/wxWidgets/include/wx/msw/wrapgdip.h index f1a0aefd..5e8f9889 100644 --- a/test/e2e/test_master/wxWidgets/include/wx/msw/wrapgdip.h +++ b/test/e2e/test_master/wxWidgets/include/wx/msw/wrapgdip.h @@ -25,6 +25,7 @@ using std::max; # pragma warning(disable:4458) // declaration of 'xxx' hides class member # endif # include +using namespace Gdiplus; # ifdef __VISUALC__ # pragma warning(pop) # endif From f7420486a0662d9db72d19f08f4b362c7cd901be Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Sat, 23 Mar 2024 12:17:22 +0300 Subject: [PATCH 05/12] win build fix --- CMakeLists.txt | 12 +++++++----- conf.cmake | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6ea944c..0b13f2d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.4...3.28) project(cppparser) @@ -46,9 +46,9 @@ else() message(STATUS "Found 'flex' as ${FLEX}") endif() -set_source_files_properties(src/parser.tab.cpp GENERATED) -set_source_files_properties(src/parser.lex.cpp GENERATED) -set_source_files_properties(src/parser.tab.h GENERATED) +set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}src/parser.tab.cpp GENERATED) +set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}src/parser.lex.cpp GENERATED) +set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}src/parser.tab.h GENERATED) add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/parser.tab.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/parser.tab.h @@ -91,7 +91,7 @@ target_link_libraries(cppparser target_include_directories( cppparser PUBLIC - ${Boost_INCLUDE_DIR} + ${Boost_INCLUDE_DIRS} pub #../common/third_party/boost_tp PRIVATE @@ -103,6 +103,8 @@ target_compile_definitions( YY_NO_UNPUT ) +install(TARGETS cppparser PUBLIC_HEADER) + ############################################# ## CppParserTest diff --git a/conf.cmake b/conf.cmake index 44883780..6f3ba3e9 100644 --- a/conf.cmake +++ b/conf.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.4...3.28) cmake_policy(SET CMP0054 NEW) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") From 40fa370764b17dce4dde13648ee9f9b3ec003cc2 Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Mon, 1 Apr 2024 23:13:14 +0300 Subject: [PATCH 06/12] install headers --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b13f2d8..2531756b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,7 +103,9 @@ target_compile_definitions( YY_NO_UNPUT ) -install(TARGETS cppparser PUBLIC_HEADER) +install(TARGETS cppparser) +install(DIRECTORY pub/ DESTINATION include/cppparser) + ############################################# ## CppParserTest From 5b069e810b43ad7c5aef85be923e231a6dbe7a15 Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Thu, 25 Apr 2024 20:32:08 +0300 Subject: [PATCH 07/12] trying with cmake generated config files --- CMakeLists.txt | 83 ++++++++++++++++++++++++++++++++++++++-- conf.cmake | 23 +++++++++-- cppparserConfig.cmake.in | 7 ++++ 3 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 cppparserConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 2531756b..09567729 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.4...3.28) +cmake_policy(SET CMP0054 NEW) +cmake_policy(SET CMP0048 NEW) -project(cppparser) +project(cppparser VERSION 0.1.0) enable_testing() @@ -92,7 +94,8 @@ target_include_directories( cppparser PUBLIC ${Boost_INCLUDE_DIRS} - pub + $ + $ #../common/third_party/boost_tp PRIVATE hack @@ -103,9 +106,81 @@ target_compile_definitions( YY_NO_UNPUT ) -install(TARGETS cppparser) -install(DIRECTORY pub/ DESTINATION include/cppparser) +#install(TARGETS cppparser EXPORT cppparser-config) +#export(TARGETS cppparser NAMESPACE cppparser:: FILE "${CMAKE_CURRENT_BINARY_DIR}/cppparser-config.cmake") +#install(DIRECTORY pub/ DESTINATION include/cppparser) +#install(EXPORT cppparser-config DESTINATION cmake) +# Install rule for headers +install( + DIRECTORY pub/ + DESTINATION ${CPPPARSER_INSTALL_INCLUDE_DIR} + COMPONENT Development +) + +install( + TARGETS cppparser + EXPORT ${export_config_name}Targets + ARCHIVE DESTINATION ${CPPPARSER_INSTALL_LIBRARY_DIR} COMPONENT Development + LIBRARY DESTINATION ${CPPPARSER_INSTALL_LIBRARY_DIR} COMPONENT RuntimeLibraries + RUNTIME DESTINATION ${CPPPARSER_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries +) + +#------------------------------------------------------------------------------ +# Configure ConfigVersion.cmake common to build and install tree +include(CMakePackageConfigHelpers) +set(config_version_file ${PROJECT_BINARY_DIR}/${export_config_name}ConfigVersion.cmake) +write_basic_package_version_file( + ${config_version_file} + VERSION "${CPPPARSER_VERSION}" + COMPATIBILITY ExactVersion +) + +#------------------------------------------------------------------------------ +# Export 'Targets.cmake' for a build tree +export( + EXPORT ${PROJECT_NAME}Targets + FILE "${CMAKE_CURRENT_BINARY_DIR}/${export_config_name}Targets.cmake" +) + +# Configure 'Config.cmake' for a build tree +set(build_config ${CMAKE_BINARY_DIR}/${export_config_name}Config.cmake) +configure_package_config_file( + ${export_config_name}Config.cmake.in + ${build_config} + INSTALL_DESTINATION "${PROJECT_BINARY_DIR}" +) + +#------------------------------------------------------------------------------ +# Export 'Targets.cmake' for an install tree +install( + EXPORT ${export_config_name}Targets + FILE ${export_config_name}Targets.cmake + DESTINATION ${CPPPARSER_INSTALL_CONFIG_DIR} +) + +set(install_config ${PROJECT_BINARY_DIR}/CMakeFiles/${export_config_name}Config.cmake) +configure_package_config_file( + ${export_config_name}Config.cmake.in + ${install_config} + INSTALL_DESTINATION ${CPPPARSER_INSTALL_CONFIG_DIR} +) + +# Install config files +install( + FILES ${config_version_file} ${install_config} + DESTINATION "${CPPPARSER_INSTALL_CONFIG_DIR}" +) + + +#include(CMakePackageConfigHelpers) +#write_basic_package_version_file( +# "cppparserConfigVersion.cmake" +# VERSION ${cppparser_VERSION} +# COMPATIBILITY AnyNewerVersion) + +#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cppparser-config.cmake" DESTINATION lib/cmake/cppparser) +# "${CMAKE_CURRENT_BINARY_DIR}/cppparserConfigVersion.cmake" ############################################# ## CppParserTest diff --git a/conf.cmake b/conf.cmake index 6f3ba3e9..bb84d785 100644 --- a/conf.cmake +++ b/conf.cmake @@ -1,5 +1,4 @@ -cmake_minimum_required(VERSION 3.4...3.28) -cmake_policy(SET CMP0054 NEW) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") @@ -25,4 +24,22 @@ if(WIN32 OR CYGWIN ) else() set(DLLEXPORT "__attribute__((visibility (\"default\")))") set(DLLIMPORT "") -endif() \ No newline at end of file +endif() + +set(export_config_name ${PROJECT_NAME}) + +if(NOT DEFINED CPPPARSER_INSTALL_INCLUDE_DIR) + set(CPPPARSER_INSTALL_INCLUDE_DIR include) +endif() + +if(NOT DEFINED CPPPARSER_INSTALL_BIN_DIR) + set(CPPPARSER_INSTALL_BIN_DIR bin) +endif() + +if(NOT DEFINED CPPPARSER_INSTALL_LIBRARY_DIR) + set(CPPPARSER_INSTALL_LIBRARY_DIR lib) +endif() + +if(NOT DEFINED CPPPARSER_INSTALL_CONFIG_DIR) + set(CPPPARSER_INSTALL_CONFIG_DIR ${CPPPARSER_INSTALL_LIBRARY_DIR}/cmake/${export_config_name}) +endif() diff --git a/cppparserConfig.cmake.in b/cppparserConfig.cmake.in new file mode 100644 index 00000000..dab23b1d --- /dev/null +++ b/cppparserConfig.cmake.in @@ -0,0 +1,7 @@ +@PACKAGE_INIT@ + +set(export_config_name "@export_config_name@") + +set_and_check(${export_config_name}_TARGETS "${CMAKE_CURRENT_LIST_DIR}/${export_config_name}Targets.cmake") + +include(${${export_config_name}_TARGETS}) From 0305b6e93c31c73c4d7c08d3f3fdd1680b8b1ca1 Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Thu, 25 Apr 2024 22:59:24 +0300 Subject: [PATCH 08/12] install headers to include/cppparser dir --- conf.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.cmake b/conf.cmake index bb84d785..aeaebb9a 100644 --- a/conf.cmake +++ b/conf.cmake @@ -29,7 +29,7 @@ endif() set(export_config_name ${PROJECT_NAME}) if(NOT DEFINED CPPPARSER_INSTALL_INCLUDE_DIR) - set(CPPPARSER_INSTALL_INCLUDE_DIR include) + set(CPPPARSER_INSTALL_INCLUDE_DIR include/cppparser) endif() if(NOT DEFINED CPPPARSER_INSTALL_BIN_DIR) From a75f2d5b3d2f4dcbfebd6106921ca8346e99611f Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Wed, 5 Jun 2024 23:11:24 +0300 Subject: [PATCH 09/12] doc improve --- CMakeLists.txt | 2 +- README.md | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09567729..12ecfdc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ add_definitions(-DBOOST_AUTO_LINK_NOMANGLE) set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost COMPONENTS filesystem program_options REQUIRED) +find_package(Boost COMPONENTS filesystem program_options date_time uuid REQUIRED) if (NOT EXISTS "${CMAKE_SOURCE_DIR}/src/catch/catch.hpp") file(DOWNLOAD "https://github.com/catchorg/Catch2/releases/download/v2.13.10/catch.hpp" "${CMAKE_SOURCE_DIR}/src/catch/catch.hpp") diff --git a/README.md b/README.md index f748923d..a14e89c0 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,7 @@ TEST_CASE("Parsing hello world program") ### Get the source ```sh -git clone https://github.com/satya-das/common.git -git clone https://github.com/satya-das/CppParser.git +git clone https://github.com/agladilin/cpppqqarser.git ``` ## Configure and build @@ -102,6 +101,18 @@ mkdir build cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="[path to vcpkg]/scripts/buildsystems/vcpkg.cmake" cd build msbuild cppparser.sln +cmake --build . --config Debug --target install +vcpkg install cppparser --overlay-ports=c:\dev\custom-overlay +``` + +To remove + +```powershell +vcpkg remove cppparser +del $VCPKG_ROOT\buildtrees\cppparser +del $VCPKG_ROOT\packages\cppparser_x64-windows +del $VCPKG_ROOT\downloads\agladilin-cppparser-0.1.0.tar.gz +del C:\Users\\AppData\Local\vcpkg\archives\19 # or whatever corresponding to package ABI hash in install log ``` ### Linux and others From 3f5a0546234c22e68794b662be0affa9b1c73c79 Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Thu, 6 Jun 2024 07:23:23 +0300 Subject: [PATCH 10/12] linux build support --- CMakeLists.txt | 2 +- README.md | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12ecfdc3..88eccdd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ add_definitions(-DBOOST_AUTO_LINK_NOMANGLE) set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) -find_package(Boost COMPONENTS filesystem program_options date_time uuid REQUIRED) +find_package(Boost COMPONENTS filesystem program_options date_time REQUIRED) if (NOT EXISTS "${CMAKE_SOURCE_DIR}/src/catch/catch.hpp") file(DOWNLOAD "https://github.com/catchorg/Catch2/releases/download/v2.13.10/catch.hpp" "${CMAKE_SOURCE_DIR}/src/catch/catch.hpp") diff --git a/README.md b/README.md index a14e89c0..6d760fd7 100644 --- a/README.md +++ b/README.md @@ -95,13 +95,16 @@ git clone https://github.com/agladilin/cpppqqarser.git [Install vcpkg](https://vcpkg.io/en/getting-started) to fetch boost ```powershell -vcpkg install boost-filesystem boost-program-options boost-system +vcpkg install boost-filesystem boost-program-options boost-system boost-date-time cd cppparser mkdir build cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="[path to vcpkg]/scripts/buildsystems/vcpkg.cmake" -cd build -msbuild cppparser.sln -cmake --build . --config Debug --target install +#cd build +#msbuild cppparser.sln +cmake --build . --config Debug +.\build\Debug\cppparsertest.exe +.\build\Debug\cppparserunittest.exe +cmake --build . --config Debug --target install # requires administrator privileges vcpkg install cppparser --overlay-ports=c:\dev\custom-overlay ``` @@ -120,7 +123,7 @@ del C:\Users\\AppData\Local\vcpkg\archives\19 # or whatever corresponding *For Ubuntu to fetch boost:* ```sh -sudo apt install libboost-system-dev libboost-filesystem-dev libboost-program-options-dev +sudo apt install libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev ``` ```sh From ee4a91ee4d07d5f638f093eeaa819d88fbf9eb59 Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Thu, 6 Jun 2024 07:24:30 +0300 Subject: [PATCH 11/12] linux build fix --- conf.cmake | 2 +- src/parser.tab.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf.cmake b/conf.cmake index aeaebb9a..29c2fb9f 100644 --- a/conf.cmake +++ b/conf.cmake @@ -6,7 +6,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fvisibility=hidden") else() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wall -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fprofile-arcs -ftest-coverage --coverage") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Wall -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fvisibility=hidden") endif() diff --git a/src/parser.tab.h b/src/parser.tab.h index fd142e8f..7d62a415 100644 --- a/src/parser.tab.h +++ b/src/parser.tab.h @@ -134,7 +134,7 @@ #define DTORDECL 387 #define YYERRCODE 256 -#line 166 "/home/dassat/github/cppparser/src/parser.y" +#line 166 "/home/user/dev/cppparser/src/parser.y" typedef union { CppToken str; CppNtFuncDeclData funcDeclData; From 205a3bbf29e1955727bee9b6bb9b32fb605aa5de Mon Sep 17 00:00:00 2001 From: Andrey Gladilin Date: Thu, 6 Jun 2024 07:37:46 +0300 Subject: [PATCH 12/12] fix readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d760fd7..2e4f3e96 100644 --- a/README.md +++ b/README.md @@ -101,10 +101,10 @@ mkdir build cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="[path to vcpkg]/scripts/buildsystems/vcpkg.cmake" #cd build #msbuild cppparser.sln -cmake --build . --config Debug +cmake --build build --config Debug .\build\Debug\cppparsertest.exe .\build\Debug\cppparserunittest.exe -cmake --build . --config Debug --target install # requires administrator privileges +cmake --build build --config Debug --target install # requires administrator privileges vcpkg install cppparser --overlay-ports=c:\dev\custom-overlay ```