diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4ef9a7b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.10) +project(abacus VERSION 0.0.0 LANGUAGES CXX) +enable_testing() + +add_library(common_options INTERFACE) +target_compile_features(common_options INTERFACE + cxx_std_17 +) +target_compile_options(common_options INTERFACE + -Wall + -Wextra +) + +add_subdirectory(src) +add_subdirectory(tests) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..531ca47 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(abacus abacus.cc) +target_link_libraries(abacus PRIVATE common_options) + +add_subdirectory(bignum) +add_subdirectory(parse) + +target_link_libraries(abacus PRIVATE + bignum + parse +) + +install(TARGETS abacus) diff --git a/src/bignum/CMakeLists.txt b/src/bignum/CMakeLists.txt new file mode 100644 index 0000000..b2434b7 --- /dev/null +++ b/src/bignum/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(bignum STATIC + bignum.cc + bignum.hh +) +target_link_libraries(bignum PRIVATE common_options) + +target_include_directories(bignum PUBLIC + $ +) diff --git a/src/parse/CMakeLists.txt b/src/parse/CMakeLists.txt new file mode 100644 index 0000000..3c87a92 --- /dev/null +++ b/src/parse/CMakeLists.txt @@ -0,0 +1,23 @@ +find_package(BISON REQUIRED) +find_package(FLEX REQUIRED) + +bison_target(parser_sources parser.yy ${CMAKE_CURRENT_BINARY_DIR}/parser.cc DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.hh) +flex_target(scanner_sources scanner.ll ${CMAKE_CURRENT_BINARY_DIR}/scanner.cc) +add_flex_bison_dependency(scanner_sources parser_sources) + +add_library(parse STATIC + parser-driver.cc + parser-driver.hh + ${BISON_parser_sources_OUTPUTS} + ${FLEX_scanner_sources_OUTPUTS} +) +target_link_libraries(parse PRIVATE common_options) + +target_link_libraries(parse PRIVATE + bignum +) + +target_include_directories(parse PUBLIC + $ + $ +) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..269aea0 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(unit) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt new file mode 100644 index 0000000..bdf51ae --- /dev/null +++ b/tests/unit/CMakeLists.txt @@ -0,0 +1,16 @@ +find_package(GTest) + +if (${GTest_FOUND}) +include(GoogleTest) + +add_executable(bignum_test bignum.cc) +target_link_libraries(bignum_test PRIVATE common_options) + +target_link_libraries(bignum_test PRIVATE + bignum + GTest::gtest + GTest::gtest_main +) + +gtest_discover_tests(bignum_test) +endif (${GTest_FOUND})