-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·69 lines (42 loc) · 1.76 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 3.16)
set(PROJECT_STD_VERSION 14)
set(CMAKE_VERBOSE_MAKEFILE OFF)
project(Svd2cppObjects VERSION 1.0.0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(BUILD_TESTS "Build tests" OFF)
option(BUILD_DRIVER "Build driver files" ON)
if(BUILD_DRIVER)
if(NOT DEFINED SVD_FILE)
message(FATAL_ERROR "The parameter SVD_FILE is not defined. (${SVD_FILE})")
endif()
find_file(SVD_PATH ${SVD_FILE} HINTS ${CMAKE_CURRENT_LIST_DIR} REQUIRED)
# This will install python to the project
execute_process(COMMAND /bin/bash -c ${CMAKE_CURRENT_LIST_DIR}/install.sh)
# This will run the
execute_process(COMMAND /bin/bash -c "${CMAKE_CURRENT_LIST_DIR}/run.sh ${SVD_PATH} ${CMAKE_CURRENT_BINARY_DIR}/generated/")
add_library(Svd2cppObjects INTERFACE)
target_include_directories(Svd2cppObjects INTERFACE inc/ "${CMAKE_CURRENT_BINARY_DIR}/generated/")
add_library(Svd2cppObjects ALIAS Svd2cppObjects)
endif()
if(BUILD_TESTS)
# Ctest / catch2
add_subdirectory(Catch2)
add_executable(tests)
set_property(TARGET tests PROPERTY CXX_STANDARD ${PROJECT_STD_VERSION})
target_compile_options(tests PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Werror)
target_sources(tests PRIVATE
tests/BitfieldTests.cpp
tests/main.cpp
tests/PeripheralFactoryTests.cpp
tests/PeripheralTests.cpp
tests/PropertyTests.cpp
tests/RegisterTests.cpp
)
target_include_directories(tests PRIVATE inc)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/Catch2/contrib/")
target_compile_definitions(tests PRIVATE TEST_CODE=1 DEV_DEBUG=1)
include(CTest)
include(Catch)
catch_discover_tests(tests)
endif()