Skip to content

Commit

Permalink
Simplify Test CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
iguessthislldo committed Feb 9, 2024
1 parent db5bf70 commit 0a8d0b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 45 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,13 @@ target_include_directories(monitor PRIVATE

configure_file(opendds.ini . COPYONLY)

add_subdirectory(test EXCLUDE_FROM_ALL)
if(BUILD_TESTING)
set(_OPENDSS_MONITOR_BUILD_TESTS_DEFAULT TRUE)
else()
set(_OPENDSS_MONITOR_BUILD_TESTS_DEFAULT FALSE)
endif()
set(OPENDSS_MONITOR_BUILD_TESTS ${_OPENDSS_MONITOR_BUILD_TESTS_DEFAULT}
CACHE BOOL "Build OpenDDS Monitor Tests")
if(OPENDSS_MONITOR_BUILD_TESTS)
add_subdirectory(test)
endif()
54 changes: 10 additions & 44 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,22 @@ cmake_minimum_required(VERSION 3.20)

project(opendds-monitor-tests VERSION 0.0.1 LANGUAGES CXX)

if ("$ENV{RAPIDJSON_ROOT}" STREQUAL "")
set(RAPIDJSON_ROOT $ENV{DDS_ROOT}/tools/rapidjson)
else()
set(RAPIDJSON_ROOT $ENV{RAPIDJSON_ROOT})
endif()
set(RAPIDJSON_INCLUDE_DIR ${RAPIDJSON_ROOT}/include)

add_executable(managed_testapp
managed.cpp
)

add_library(test_common INTERFACE)
target_compile_options(test_common INTERFACE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -Wall -Wpedantic -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wundef -Werror> $<$<CXX_COMPILER_ID:MSVC>: /W4>)
if (MSVC)
target_compile_definitions(managed_testapp PRIVATE _CRT_SECURE_NO_WARNINGS)
target_compile_definitions(test_common INTERFACE _CRT_SECURE_NO_WARNINGS)
else()
target_compile_features(managed_testapp PRIVATE cxx_std_17)
target_compile_features(test_common INTERFACE cxx_std_17)
endif()

target_compile_options(managed_testapp PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -Wall -Wpedantic -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wundef -Werror> $<$<CXX_COMPILER_ID:MSVC>: /W4>)

OPENDDS_TARGET_SOURCES(managed_testapp test.idl OPENDDS_IDL_OPTIONS "-Gxtypes-complete" SUPPRESS_ANYS OFF)

target_link_libraries(managed_testapp
OpenDDW
OpenDDS::Dcps
)

target_include_directories(managed_testapp PRIVATE
target_include_directories(test_common INTERFACE
../src
${RAPIDJSON_INCLUDE_DIR}
)

add_executable(unmanaged_testapp
unmanaged.cpp
)

if (MSVC)
target_compile_definitions(unmanaged_testapp PRIVATE _CRT_SECURE_NO_WARNINGS)
else ()
target_compile_features(unmanaged_testapp PRIVATE cxx_std_17)
endif()
add_executable(managed_testapp managed.cpp)
OPENDDS_TARGET_SOURCES(managed_testapp test.idl OPENDDS_IDL_OPTIONS "-Gxtypes-complete" SUPPRESS_ANYS OFF)
target_link_libraries(managed_testapp OpenDDW test_common)

add_executable(unmanaged_testapp unmanaged.cpp)
OPENDDS_TARGET_SOURCES(unmanaged_testapp test.idl OPENDDS_IDL_OPTIONS "-Gxtypes-complete" SUPPRESS_ANYS OFF)

target_compile_options(unmanaged_testapp PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -Wall -Wpedantic -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wundef -Werror> $<$<CXX_COMPILER_ID:MSVC>: /W4>)

target_link_libraries(unmanaged_testapp
OpenDDS::Dcps
)

target_include_directories(unmanaged_testapp PRIVATE
../src
${RAPIDJSON_INCLUDE_DIR}
)
target_link_libraries(unmanaged_testapp OpenDDS::Dcps test_common)

0 comments on commit 0a8d0b5

Please sign in to comment.