mirror of
https://github.com/tkem/fsmlite.git
synced 2025-05-09 00:02:52 +08:00
Fix #27: Add basic CMake support.
This commit is contained in:
parent
b81ebf33b8
commit
d689403d3a
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -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
CMakeLists.txt
Normal file
28
CMakeLists.txt
Normal file
@ -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
tests/CMakeLists.txt
Normal file
21
tests/CMakeLists.txt
Normal file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user