Commit 544764f7 authored by Jan Koniarik's avatar Jan Koniarik
Browse files

reworked how examples are compiled

parent e1d4ea0e
cmake_minimum_required(VERSION 3.10.2)
project(emlabcpp_examples)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(
-g
-Werror
-Wextra
-Wpedantic
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wnull-dereference
-Wformat=2
#-Wduplicated-cond
#-Wlogical-op
#-Wuseless-cast
-Wunreachable-code
-Wsign-conversion
-Wconversion
-Wdouble-promotion
-fmax-errors=5)
include_directories(../include/)
add_executable(algorithm algorithm.cpp)
function(add_emlabcpp_example name)
add_executable(${name}_example examples/${name}.cpp)
emlabcpp_setup_test(${name}_example)
endfunction()
add_emlabcpp_example(algorithm)
add_emlabcpp_example(protocol)
...@@ -6,7 +6,12 @@ set(CMAKE_CXX_STANDARD 20) ...@@ -6,7 +6,12 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options( function(emlabcpp_setup_test target)
target_include_directories(${target} PRIVATE tests/include/)
target_link_libraries(${target} emlabcpp)
add_test(NAME ${target} COMMAND ${target})
target_compile_options( ${target} PRIVATE
-gdwarf -gdwarf
-Werror -Werror
-Wextra -Wextra
...@@ -28,11 +33,12 @@ add_compile_options( ...@@ -28,11 +33,12 @@ add_compile_options(
-DEMLABCPP_ASSERT_NATIVE -DEMLABCPP_ASSERT_NATIVE
) )
endfunction()
function(add_emlabcpp_test name) function(add_emlabcpp_test name)
add_executable(${name} tests/${name}.cpp) add_executable(${name} tests/${name}.cpp)
target_link_libraries(${name} GTest::GTest GTest::Main emlabcpp) target_link_libraries(${name} GTest::GTest GTest::Main)
target_include_directories(${name} PRIVATE tests/include/) emlabcpp_setup_test(${name})
add_test(NAME ${name} COMMAND ${name})
endfunction() endfunction()
add_emlabcpp_test(static_circular_buffer_test) add_emlabcpp_test(static_circular_buffer_test)
...@@ -48,9 +54,11 @@ add_emlabcpp_test(protocol_def_test) ...@@ -48,9 +54,11 @@ add_emlabcpp_test(protocol_def_test)
add_emlabcpp_test(protocol_sophisticated_test) add_emlabcpp_test(protocol_sophisticated_test)
add_emlabcpp_test(protocol_register_map_test) add_emlabcpp_test(protocol_register_map_test)
file(GLOB_RECURSE HEADER_FILES include(examples/examples.cmake)
"${PROJECT_SOURCE_DIR}/include/*.h"
) #file(GLOB_RECURSE HEADER_FILES
# "${PROJECT_SOURCE_DIR}/include/*.h"
#)
#add_format_test( #add_format_test(
# TARGET emlabcpp_format # TARGET emlabcpp_format
# WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} # WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment