Skip to content

Commit

Permalink
GHI #13 Update target and executable created by create_test
Browse files Browse the repository at this point in the history
create_test(BT example SOURCE example.cpp):
- target created -> patomic_bt_example
- executable created -> example(.exe)
- executable installed as -> <prefix>/patomic/bt/example(.exe)

Signed-off-by: doodspav <[email protected]>
  • Loading branch information
doodspav committed Mar 21, 2023
1 parent 38390fd commit 8a7dd2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions test/bt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ include(../cmake/WindowsDependenciesPath.cmake)
add_custom_target(patomic_bt)
add_dependencies(patomic_test patomic_bt)

create_test(BT bt_example_add SOURCE example_add.cpp)
create_test(BT bt_example_sub SOURCE example_sub.cpp)
create_test(BT example_add SOURCE example_add.cpp)
create_test(BT example_sub SOURCE example_sub.cpp)


# ---- Windows Path Issues ----
Expand Down
10 changes: 8 additions & 2 deletions test/cmake/CreateTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Creates a target to build a test executable and registers it with CTest.
# Expects a target named patomic_${kind} to exist.
# E.g. if you call it as create_test(BT ...) then patomic_bt must exist.
# The target is named patomic_${kind}_${name} but the name of the executable
# produced is just ${name}.
# When the executable is installed, it's installed as patomic/${kind}/${name}.
#
# create_test(
# BT|UT <name>
Expand Down Expand Up @@ -74,8 +77,9 @@ function(create_test)
# setup target

set(parent_target patomic_${kind})
set(target ${name})
set(target ${parent_target}_${name})
set(target_deps patomic::patomic GTest::gtest_main ${ARG_LINK})
set(output_name ${name})

add_executable(
${target}
Expand All @@ -91,8 +95,10 @@ function(create_test)

target_compile_features(${target} PRIVATE cxx_std_14)

set_target_properties(${target} PROPERTIES OUTPUT_NAME ${output_name})

# setup tests with CTest

# register tests with CTest

# must be run in same directory scope as target
gtest_add_tests(
Expand Down
4 changes: 2 additions & 2 deletions test/ut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ include(../cmake/WindowsDependenciesPath.cmake)
add_custom_target(patomic_ut)
add_dependencies(patomic_test patomic_ut)

create_test(UT ut_example_add SOURCE example_add.cpp)
create_test(UT ut_example_sub SOURCE example_sub.cpp)
create_test(UT example_add SOURCE example_add.cpp)
create_test(UT example_sub SOURCE example_sub.cpp)


# ---- Windows Path Issues ----
Expand Down

0 comments on commit 8a7dd2b

Please sign in to comment.