Skip to content

Commit

Permalink
Fix #27: Add basic CMake support.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkem committed Aug 2, 2021
1 parent b81ebf3 commit d689403
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ jobs:
CXX: ${{ matrix.cxx }}
CXXFLAGS: -std=${{ matrix.std }}
run: ./configure && make && make check
msvc:
name: MSVC on windows-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Build and run tests
run: |
cmake -S . -B .
cmake --build .
ctest -C Debug
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.12)

project(
fsmlite
LANGUAGES CXX
HOMEPAGE_URL "https://github.com/tkem/fsmlite"
)

add_library(${PROJECT_NAME} INTERFACE)

target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11)

target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)

list(APPEND PUBLIC_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/src/fsm.h"
)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(tests)
endif()
21 changes: 21 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
macro(fsmlite_add_test TESTNAME)
add_executable(${TESTNAME} ${CMAKE_CURRENT_SOURCE_DIR}/${TESTNAME}.cpp)
target_link_libraries(${TESTNAME} PRIVATE fsmlite)
if (MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.14)
target_compile_options(${TESTNAME}
PRIVATE
/Zc:__cplusplus
)
endif()
add_test(NAME ${PROJECT_NAME}_${TESTNAME} COMMAND ${TESTNAME})
endmacro(fsmlite_add_test)

fsmlite_add_test(test_basic_row)
fsmlite_add_test(test_mem_fn_row)
fsmlite_add_test(test_notrans)
fsmlite_add_test(test_player)
fsmlite_add_test(test_recursive)
fsmlite_add_test(test_row)
fsmlite_add_test(test_scoped)
fsmlite_add_test(test_shared)
fsmlite_add_test(test_traits)

0 comments on commit d689403

Please sign in to comment.