Commit 5beb9f44 authored by Jan Koniarik's avatar Jan Koniarik
Browse files

changed the CMakeLists.txt a bit

parent e3965594
Pipeline #106408 passed with stage
in 55 seconds
......@@ -2,15 +2,16 @@ cmake_minimum_required(VERSION 3.16)
project(emlabcpp)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()
add_library(emlabcpp INTERFACE)
target_include_directories(emlabcpp INTERFACE include/)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
if(BUILD_TESTING)
include(tests/tests.cmake)
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(tests)
add_subdirectory(examples)
endif()
install(TARGETS emlabcpp)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
function(add_emlabcpp_example name)
add_executable(${name}_example ${name}.cpp)
target_link_libraries(${name}_example emlabcpp)
target_compile_options(${name}_example PRIVATE
-DEMLABCPP_USE_STREAMS
-DEMLABCPP_ASSERT_NATIVE
)
add_test(NAME ${name}_example COMMAND ${name}_example)
endfunction()
add_emlabcpp_example(algorithm)
add_emlabcpp_example(protocol)
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)
include(cmake/util.cmake)
include(../cmake/util.cmake)
add_subdirectory(tests/3rd_party/google-test)
add_subdirectory(3rd_party/google-test)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
function(emlabcpp_setup_test target)
target_include_directories(${target} PRIVATE tests/include/)
target_include_directories(${target} PRIVATE include/)
target_link_libraries(${target} emlabcpp)
add_test(NAME ${target} COMMAND ${target})
......@@ -36,7 +36,7 @@ function(emlabcpp_setup_test target)
endfunction()
function(add_emlabcpp_test name)
add_executable(${name} tests/${name}.cpp)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name} GTest::GTest GTest::Main)
emlabcpp_setup_test(${name})
endfunction()
......@@ -53,8 +53,6 @@ add_emlabcpp_test(pid_test)
add_emlabcpp_test(protocol_def_test)
add_emlabcpp_test(protocol_sophisticated_test)
add_emlabcpp_test(protocol_register_map_test)
include(examples/examples.cmake)
#file(GLOB_RECURSE HEADER_FILES
# "${PROJECT_SOURCE_DIR}/include/*.h"
......
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