Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on Linux with local Boost #23

Open
agladilin opened this issue Jun 20, 2023 · 0 comments
Open

Build on Linux with local Boost #23

agladilin opened this issue Jun 20, 2023 · 0 comments

Comments

@agladilin
Copy link

Ubuntu 22.04 supplies Boost 1.74. I would like to link the cppparser with it. Can we have this supported?
The code below does this.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f9c14db5..1c5c275a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@ project(cppparser)
 
 enable_testing()
 
-include("../common/cmake/conf.cmake")
+#include("../common/cmake/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,18 @@ 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_FILESYSTEM_LIBRARY}
+		${Boost_PROGRAM_OPTIONS_LIBRARY}
 		boost_system
 )
 target_include_directories(
 	cppparser
 	PUBLIC
 		pub
-		../common/third_party/boost_tp
+		#../common/third_party/boost_tp
 	PRIVATE
 		hack
 )
diff --git a/third_party/btyacc_tp/CMakeLists.txt b/third_party/btyacc_tp/CMakeLists.txt
index a1cfa01d..c675f138 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("../../../common/cmake/conf.cmake")
 
 project(btyacc)
 

Also please note that the file(DOWNLOAD ...) directive is used in order to download catch.hpp. Thus I got rid of https://github.com/satya-das/common.git repo usage.

salehjg added a commit to salehjg/cppparser that referenced this issue Jun 26, 2023
…satya-das#23).

Excluded `src/catch` from git (an old version is downloaded by the main CMakeLists.txt). Note that `Catch2 v3` is out, and we are going to have to refactor the codes and use the new release soon.
salehjg added a commit to salehjg/cppparser that referenced this issue Jun 26, 2023
…satya-das#23).

Excluded `src/catch` from git (an old version is downloaded by the main CMakeLists.txt). Note that `Catch2 v3` is out, and we are going to have to refactor the codes and use the new release soon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant