Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make test target name unique. #28

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
andistorm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ find_package(everest-cmake 0.1 REQUIRED
)

# options
option(${PROJECT_NAME}_BUILD_TESTING "Build unit tests, used if included as dependency" OFF)
option(BUILD_TESTING "Build unit tests, used if standalone project" OFF)
option(EVSE_SECURITY_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT})

# dependencies
Expand Down Expand Up @@ -53,7 +55,8 @@ if (EVSE_SECURITY_INSTALL)
)
endif()

if(BUILD_TESTING_EVSE_SECURITY)
if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} OR ${PROJECT_NAME}_BUILD_TESTING) AND BUILD_TESTING)
include(CTest)
add_subdirectory(tests)
set(CMAKE_BUILD_TYPE Debug)
endif()
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ GTest is required for building the test cases target. To build the target and ru

```bash
mkdir build && cd build
cmake -DBUILD_TESTING_EVSE_SECURITY=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=./dist ..
cmake -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=./dist ..
make -j$(nproc) install
cd tests
./tests
make test
```
15 changes: 11 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
add_executable(tests tests.cpp)

target_include_directories(tests PUBLIC ${GTEST_INCLUDE_DIRS})

set(TEST_TARGET_NAME ${PROJECT_NAME}_tests)
add_executable(${TEST_TARGET_NAME})

target_include_directories(${TEST_TARGET_NAME} PUBLIC ${GTEST_INCLUDE_DIRS})

target_sources(${TEST_TARGET_NAME} PRIVATE
tests.cpp
)

find_package(GTest REQUIRED)

target_link_libraries(tests PRIVATE
target_link_libraries(${TEST_TARGET_NAME} PRIVATE
evse_security
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
Expand All @@ -14,7 +21,7 @@ if(LIBEVSE_CRYPTO_SUPPLIER_OPENSSL)
add_compile_definitions(LIBEVSE_CRYPTO_SUPPLIER_OPENSSL)
endif()

add_test(tests tests)
add_test(${TEST_TARGET_NAME} ${TEST_TARGET_NAME})

install(
PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/generate_test_certs.sh"
Expand Down
Loading