abacus: add cmake-based build system
This commit is contained in:
parent
549c1f0574
commit
331089d101
15
CMakeLists.txt
Normal file
15
CMakeLists.txt
Normal file
|
@ -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)
|
12
src/CMakeLists.txt
Normal file
12
src/CMakeLists.txt
Normal file
|
@ -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)
|
9
src/bignum/CMakeLists.txt
Normal file
9
src/bignum/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
add_library(bignum STATIC
|
||||
bignum.cc
|
||||
bignum.hh
|
||||
)
|
||||
target_link_libraries(bignum PRIVATE common_options)
|
||||
|
||||
target_include_directories(bignum PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
)
|
23
src/parse/CMakeLists.txt
Normal file
23
src/parse/CMakeLists.txt
Normal file
|
@ -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
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||
)
|
1
tests/CMakeLists.txt
Normal file
1
tests/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
add_subdirectory(unit)
|
16
tests/unit/CMakeLists.txt
Normal file
16
tests/unit/CMakeLists.txt
Normal file
|
@ -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})
|
Loading…
Reference in a new issue