From 5ef7180a12f305ac92fad73efb4d9a7b81e5b980 Mon Sep 17 00:00:00 2001 From: yhirose Date: Mon, 17 Jun 2024 13:03:53 -0400 Subject: [PATCH] Update CMake related files --- CMakeLists.txt | 5 +++++ example/CMakeLists.txt | 12 ++++++++++-- lint/CMakeLists.txt | 3 +-- pl0/CMakeLists.txt | 8 +++++--- test/CMakeLists.txt | 2 +- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4055dc..a37046a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ target_include_directories(peglib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) option(BUILD_TESTS "Build cpp-peglib tests" ON) option(PEGLIB_BUILD_LINT "Build cpp-peglib lint utility" OFF) option(PEGLIB_BUILD_EXAMPLES "Build cpp-peglib examples" OFF) +option(PEGLIB_BUILD_PL0 "Build pl0 interpreter" OFF) if (${BUILD_TESTS}) add_subdirectory(test) @@ -37,4 +38,8 @@ if (${PEGLIB_BUILD_EXAMPLES}) add_subdirectory(example) endif() +if (${PEGLIB_BUILD_PL0}) + add_subdirectory(pl0) +endif() + install(FILES peglib.h DESTINATION include) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 9fb5b12..70dd782 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,34 +1,42 @@ cmake_minimum_required(VERSION 3.14) project(example) -include_directories(..) - add_executable(calc calc.cc) +target_include_directories(calc PRIVATE ..) target_link_libraries(calc ${add_link_deps}) add_executable(calc2 calc2.cc) +target_include_directories(calc2 PRIVATE ..) target_link_libraries(calc2 ${add_link_deps}) add_executable(calc3 calc3.cc) +target_include_directories(calc3 PRIVATE ..) target_link_libraries(calc3 ${add_link_deps}) add_executable(calc4 calc4.cc) +target_include_directories(calc4 PRIVATE ..) target_link_libraries(calc4 ${add_link_deps}) add_executable(calc5 calc5.cc) +target_include_directories(calc5 PRIVATE ..) target_link_libraries(calc5 ${add_link_deps}) add_executable(indent indent.cc) +target_include_directories(indent PRIVATE ..) target_link_libraries(indent ${add_link_deps}) add_executable(docx docx.cc) +target_include_directories(docx PRIVATE ..) target_link_libraries(docx ${add_link_deps}) add_executable(sequence sequence.cc) +target_include_directories(sequence PRIVATE ..) target_link_libraries(sequence ${add_link_deps}) add_executable(enter_leave enter_leave.cc) +target_include_directories(enter_leave PRIVATE ..) target_link_libraries(enter_leave ${add_link_deps}) add_executable(choice choice.cc) +target_include_directories(choice PRIVATE ..) target_link_libraries(choice ${add_link_deps}) diff --git a/lint/CMakeLists.txt b/lint/CMakeLists.txt index c91dcd2..fdf5bf8 100644 --- a/lint/CMakeLists.txt +++ b/lint/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.14) project(peglint) -include_directories(..) - add_executable(peglint peglint.cc) +target_include_directories(peglint PRIVATE ..) target_link_libraries(peglint ${add_link_deps}) diff --git a/pl0/CMakeLists.txt b/pl0/CMakeLists.txt index ed24527..5c5da39 100644 --- a/pl0/CMakeLists.txt +++ b/pl0/CMakeLists.txt @@ -1,10 +1,12 @@ -/Users/yhirose/Projects/cpp-peglib/.travis.yml +cmake_minimum_required(VERSION 3.14) project(pl0) -include_directories(..) +find_package(LLVM REQUIRED CONFIG) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter") add_executable(pl0 pl0.cc) -find_package(LLVM REQUIRED CONFIG) set(add_link_deps ${add_link_deps} LLVM) target_include_directories(pl0 PUBLIC ${LLVM_INCLUDE_DIRS}) +target_include_directories(pl0 PRIVATE ..) target_link_libraries(pl0 ${add_link_deps}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f5f1d69..1088766 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,7 @@ project(test) include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip ) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)